battles/magic/incmagic.php

75 lines
4.5 KiB
PHP
Raw Normal View History

2018-01-28 16:40:49 +00:00
<?php
if ($_SESSION['uid'] == null) header("Location: index.php");
//запрещенная для встройки магия
$forbidden=array("1","2","3","7","6","8","18","19","20","21","22","43","46","47","48","55","56","58","74","75", "76", "77", "78", "79", "80", "81", "82", "83", "84", "85", "86", "87", "88", "89", "90",
"91", "92", "93", "94", "95", "96", "97", "98", "99", "100", "101", "102", "103", "104", "105", "106",
"107", "108", "109", "110", "111", "112", "113", "114", "115", "116", "117", "118", "119", "120", "121",
"122", "123", "124", "125", "126", "127", "128", "129", "130", "131", "132", "133", "134", "135", "136", "137", "138","139",);
// magic
// встраивание магии
if ($user['battle'] > 0) {
echo "Не в бою...";
} else {
if ($user['intel'] >= 17) {
$int=80 + $user['intel'] - 17;
if ($int>100){$int=100;}
}
else {$int=0;}
if (rand(1,100) <= $int OR !$_SESSION['scroll']) {
if(!$_SESSION['scroll']) {
$_SESSION['scroll'] = $_POST['target'];
?><body onload="okno('Название предмета, в который встраивается свиток', 'main.php?edit=1&use=<?=$_GET['use']?>','target')"><?
} else {
$svitok = mysql_fetch_array(mysql_query("SELECT * FROM `inventory` WHERE `name` = '".$_SESSION['scroll']."' AND `owner` = '{$user['id']}' AND `dressed`=0 LIMIT 1;"));
$dress = mysql_fetch_array(mysql_query("SELECT * FROM `inventory` WHERE `owner` = '{$user['id']}' AND `name` LIKE '{$_POST['target']}' AND `includemagic` = 0 AND `dressed`=0 LIMIT 1;"));
//echo "SELECT * FROM `inventory` WHERE `owner` = '{$user['id']}' AND `name` LIKE '{$_REQUEST['target']}' AND `includemagic` = 0 LIMIT 1;";
$_SESSION['scroll'] = null;
if(!$svitok){
echo "<font color=red><b>У вас нет такого свитка!<b></font>";
}elseif(!$dress OR $dress['type'] >= 12){
echo "<font color=red><b>У вас нет такого предмета!<b></font>";
}else {
$incmagic = mysql_fetch_array(mysql_query("SELECT * FROM `magic` WHERE `id` = '{$svitok['magic']}' LIMIT 1;"));
if((!$incmagic['img'])||in_array($svitok['magic'],$forbidden)) {
echo "<font color=red><b>Этот свиток нельзя встраивать в предметы!<b></font>";
} else {
// встраиваем
destructitem($svitok['id']);
echo "<font color=red><b>Свиток \"".$svitok['name']."\" удачно встроен в \"".$dress['name']."\"<b></font>";
mysql_query("UPDATE `inventory` SET
".($dress['nintel']<$svitok['nintel']?"`nintel`='".$svitok['nintel']."',":"")."
".($dress['nlevel']<$svitok['nlevel']?"`nlevel`='".$svitok['nlevel']."',":"")."
".($dress['nmudra']<$svitok['nmudra']?"`nmudra`='".$svitok['nmudra']."',":"")."
".($dress['ngray']<$svitok['ngray']?"`ngray`='".$svitok['ngray']."',":"")."
".($dress['ndark']<$svitok['ndark']?"`ndark`='".$svitok['ndark']."',":"")."
".($dress['nlight']<$svitok['nlight']?"`nlevel`='".$svitok['nlight']."',":"")."
`massa`=`massa`+1,`cost`=`cost`+'".$svitok['cost']."', `includemagic` = '".$svitok['magic']."', `includemagicdex` = '".$svitok['maxdur']."', `includemagicmax` = '".$svitok['maxdur']."', `includemagicname` = '".$svitok['name']."', `includemagicuses` = '100+".$user['intel']."', `includemagiccost` = '".($svitok['cost']/2)."' WHERE `id` = '{$dress['id']}' LIMIT 1;");
$bet=1;
}
}
}
//$dress = mysql_fetch_array(mysql_query("SELECT * FROM `inventory` WHERE `name` LIKE '%Топор%' AND `owner` = '{$user['id']}' AND `name` = '{$_POST['target']}' AND `sharped` = 0 LIMIT 1;"));
//$svitok = mysql_fetch_array(mysql_query("SELECT * FROM `inventory` WHERE `name` = 'Заточка на топоры +1' AND `owner` = '{$user['id']}' LIMIT 1;"));
/*if ($dress && $svitok) {
if (mysql_query("UPDATE `inventory` SET `sharped` = 1, `name` = CONCAT(`name`,'+1'), `minu` = `minu`+1, `maxu`=`maxu`+1, `cost` = `cost`+6, `ntopor` = `ntopor`+1, `nsila` = `nsila`+1 WHERE `id` = {$dress['id']} LIMIT 1;")) {
echo "<font color=red><b>Предмет \"{$_POST['target']}\" удачно заточен +1.<b></font> ";
$bet=1;
}
else {
echo "<font color=red><b>Произошла ошибка!<b></font>";
}
} else {
echo "<font color=red><b>Неправильное имя предмета или неправильный свиток<b></font>";
}*/
} else
{
echo "<font color=red><b>Cвиток рассыпался в ваших руках...<b></font>";
$bet=1;
$_SESSION['scroll'] = null;
}
}
?>