Code cleaning.
This commit is contained in:
parent
a40e2e27a0
commit
7be1319845
342
functions.php
342
functions.php
@ -12,7 +12,9 @@ require_once 'config.php';
|
||||
*/
|
||||
if (isset($_SESSION['uid'])) {
|
||||
$user = (new users_row($_SESSION['uid']))->result();
|
||||
} else {echo "Не могу проинициализировать игрока!";}
|
||||
} else {
|
||||
echo "Не могу проинициализировать игрока!";
|
||||
}
|
||||
|
||||
if (isset($user['id']) && $user['block'] == 1) {
|
||||
die('user blocked!');
|
||||
@ -102,7 +104,9 @@ function takeshopitem($item, $table = "shop", $present = '', $onlyonetrip = '',
|
||||
|
||||
if ($rec1['koll']) {
|
||||
db::c()->query('UPDATE inventory SET koll = (koll + ?i), massa = (massa + ?i), cost = (cost + ?i) WHERE owner = ?i AND prototype = ?i', $koll, $rec1['massa'] * $koll, $rec1['cost'], $uid, $item);
|
||||
if (db::c()->getAffectedRows() > 0) return ["img" => $rec1['img'], "name" => $rec1['name']];
|
||||
if (db::c()->getAffectedRows() > 0) {
|
||||
return ["img" => $rec1['img'], "name" => $rec1['name']];
|
||||
}
|
||||
$rec1['koll'] = $koll;
|
||||
$rec1['massa'] *= $koll;
|
||||
}
|
||||
@ -122,14 +126,18 @@ function takeshopitem($item, $table = "shop", $present = '', $onlyonetrip = '',
|
||||
|
||||
$sql = "";
|
||||
while ($rec = $r->fetch_assoc()) {
|
||||
if (!$flds[$rec['Field']]) continue;
|
||||
if (!$flds[$rec['Field']]) {
|
||||
continue;
|
||||
}
|
||||
if ($rec['Field'] == "dategoden") {
|
||||
$goden = $rec1[$rec['Field']];
|
||||
}
|
||||
if ($rec['Field'] == "goden") {
|
||||
$goden = $rec1[$rec['Field']];
|
||||
}
|
||||
if ($rec['Field'] == "id" || $rec['Field'] == "prototype" || $rec['Field'] == "dategoden") continue;
|
||||
if ($rec['Field'] == "id" || $rec['Field'] == "prototype" || $rec['Field'] == "dategoden") {
|
||||
continue;
|
||||
}
|
||||
$sql .= ", `$rec[Field]` = '" . $rec1[$rec['Field']] . "' ";
|
||||
}
|
||||
|
||||
@ -153,22 +161,20 @@ function level_up($uid)
|
||||
{
|
||||
global $exptable;
|
||||
$us = db::c()->query('SELECT `id`, `login`, `level`, `money`, `exp`, `vinos`, `nextup`, `stats`, `master`, `maxhp`, `ip`, `in_tower` FROM `users` WHERE `id` =?i', $uid)->fetch_assoc();
|
||||
if (isset($us['id'])) {
|
||||
if ($us['exp'] >= $us['nextup'] && !$us['in_tower']) {
|
||||
if ($exptable[$us['nextup']][4] == 1) {
|
||||
addch("Персонаж <b>{$us['login']}</b> перешел на " . ($us['level'] + 1) . " уровень.");
|
||||
addchp('<span class=\'success\'>Внимание!</span> Вы перешли на новый уровень. За это Вы получаете: ' . $exptable[$us['nextup']][3] . ' кр.', '{[]}' . $us['login'] . '{[]}');
|
||||
} elseif ($exptable[$us['nextup']][4] == 0) {
|
||||
addchp('<span class=\'success\'>Внимание!</span> Вы перешли на новый АП. За это Вы получаете: ' . $exptable[$us['nextup']][3] . ' кр.', '{[]}' . $us['login'] . '{[]}');
|
||||
}
|
||||
$us['nextup'] = $exptable[$us['nextup']][5];
|
||||
$us['stats'] += $exptable[$us['nextup']][0];
|
||||
$us['master'] += $exptable[$us['nextup']][1];
|
||||
$us['vinos'] += $exptable[$us['nextup']][2];
|
||||
$us['maxhp'] += ($exptable[$us['nextup']][2] * 6);
|
||||
$us['money'] += $exptable[$us['nextup']][3];
|
||||
db::c()->query('UPDATE `users` SET `nextup` = ?i, `stats` = ?i, `master` = ?i, `vinos` = ?i, `maxhp` = ?i, `money` = ?i, `level` = ?i WHERE `id` = ?i', $us['nextup'], $us['stats'], $us['master'], $us['vinos'], $us['maxhp'], $us['money'], $us['level'], $us['id']);
|
||||
if (isset($us['id']) && $us['exp'] >= $us['nextup'] && !$us['in_tower']) {
|
||||
if ($exptable[$us['nextup']][4] == 1) {
|
||||
addch("Персонаж <b>{$us['login']}</b> перешел на " . ($us['level'] + 1) . " уровень.");
|
||||
addchp('<span class=\'success\'>Внимание!</span> Вы перешли на новый уровень. За это Вы получаете: ' . $exptable[$us['nextup']][3] . ' кр.', '{[]}' . $us['login'] . '{[]}');
|
||||
} elseif ($exptable[$us['nextup']][4] == 0) {
|
||||
addchp('<span class=\'success\'>Внимание!</span> Вы перешли на новый АП. За это Вы получаете: ' . $exptable[$us['nextup']][3] . ' кр.', '{[]}' . $us['login'] . '{[]}');
|
||||
}
|
||||
$us['nextup'] = $exptable[$us['nextup']][5];
|
||||
$us['stats'] += $exptable[$us['nextup']][0];
|
||||
$us['master'] += $exptable[$us['nextup']][1];
|
||||
$us['vinos'] += $exptable[$us['nextup']][2];
|
||||
$us['maxhp'] += ($exptable[$us['nextup']][2] * 6);
|
||||
$us['money'] += $exptable[$us['nextup']][3];
|
||||
db::c()->query('UPDATE `users` SET `nextup` = ?i, `stats` = ?i, `master` = ?i, `vinos` = ?i, `maxhp` = ?i, `money` = ?i, `level` = ?i WHERE `id` = ?i', $us['nextup'], $us['stats'], $us['master'], $us['vinos'], $us['maxhp'], $us['money'], $us['level'], $us['id']);
|
||||
}
|
||||
}
|
||||
|
||||
@ -204,7 +210,6 @@ function topsethp()
|
||||
|
||||
function nick($user)
|
||||
{
|
||||
$r = '';
|
||||
if ($user['align'] > 0) {
|
||||
$al = $user['align'];
|
||||
} else {
|
||||
@ -215,11 +220,7 @@ function nick($user)
|
||||
} else {
|
||||
$cl = '';
|
||||
}
|
||||
$r .= '<div id="HP"><img src="i/align_' . $al . '.gif" />' . $cl . '';
|
||||
$r .= '<b>' . $user['login'] . '</b> [' . $user['level'] . '] <a href="inf.php?' . $user['id'] . '" target="_blank"><img src="i/inf.gif" width="12" height="11" /></a>';
|
||||
$r .= ' <img src="i/herz.gif" width="10" height="10" /> <img src="i/1green.gif" width="' . (150 * ($user['hp'] / $user['maxhp'])) . '" height="10" name="HP1" /><img src="i/1silver.gif" width="' . (150 - 150 * ($user['hp'] / $user['maxhp'])) . '" height="10" name="HP2" />: <span id=\'hp_value\'>' . $user['hp'] . '</span>/' . $user['maxhp'] . '</div>';
|
||||
$r .= '';
|
||||
return $r;
|
||||
return '<div id="HP"><img src="i/align_' . $al . '.gif" />' . $cl . '<b>' . $user['login'] . '</b> [' . $user['level'] . '] <a href="inf.php?' . $user['id'] . '" target="_blank"><img src="i/inf.gif" alt="Inf"></a> <img src="i/herz.gif" alt="HP"> <img src="i/1green.gif" width="' . (150 * ($user['hp'] / $user['maxhp'])) . '" height="10"><img src="i/1silver.gif" width="' . (150 - 150 * ($user['hp'] / $user['maxhp'])) . '" height="10">: <span id="hp_value">' . $user['hp'] . ' / ' . $user['maxhp'] . '</span></div>';
|
||||
}
|
||||
|
||||
function nick4($id, $st)
|
||||
@ -273,11 +274,13 @@ function ClanImage($clan_id)
|
||||
}
|
||||
}
|
||||
|
||||
function GiveExp($id, $exp){
|
||||
function GiveExp($id, $exp)
|
||||
{
|
||||
db::c()->query('UPDATE users SET exp = exp + ?i WHERE id = ?i', $exp, $id);
|
||||
}
|
||||
|
||||
function GiveRep($id, $rep){
|
||||
function GiveRep($id, $rep)
|
||||
{
|
||||
db::c()->query('UPDATE users SET doblest = (doblest + ?i), rep_laba = (rep_laba + ?i) WHERE `id` = ?i', $rep, $rep, $id);
|
||||
}
|
||||
|
||||
@ -285,7 +288,6 @@ function GiveRep($id, $rep){
|
||||
// полоска НР
|
||||
function setHP($hp, $maxhp)
|
||||
{
|
||||
$rr = '';
|
||||
if ($hp < $maxhp * 0.33) {
|
||||
$polosa = 'i/1red.gif';
|
||||
} elseif ($hp < $maxhp * 0.66) {
|
||||
@ -293,14 +295,14 @@ function setHP($hp, $maxhp)
|
||||
} else {
|
||||
$polosa = 'i/1green.gif';
|
||||
}
|
||||
|
||||
$rr .= "<IMG SRC=i/herz.gif WIDTH=10 HEIGHT=10 ALT=\"Уровень жизни\"><IMG SRC='{$polosa}' WIDTH=";
|
||||
$rr .= (122 * ($hp / $maxhp));
|
||||
$rr .= ' HEIGHT=10 ALT="Уровень жизни" name=HP1 id=HP1><IMG SRC=i/1silver.gif WIDTH=';
|
||||
$rr .= (122 - 122 * ($hp / $maxhp));
|
||||
$rr .= ' HEIGHT=10 ALT="Уровень жизни" name=HP2 id=HP2>';
|
||||
$rr .= '<span id=\'hp_value\'>' . $hp . '/' . $maxhp . '</span>';
|
||||
return $rr;
|
||||
$polosa_width = (122 * ($hp / $maxhp));
|
||||
$silver_polosa_width = (122 - 122 * ($hp / $maxhp));
|
||||
return <<<HTML
|
||||
<IMG SRC=i/herz.gif WIDTH=10 HEIGHT=10 ALT="Уровень жизни">
|
||||
<IMG SRC=$polosa WIDTH=$polosa_width HEIGHT=10 ALT="Уровень жизни" id=HP1>
|
||||
<IMG SRC=i/1silver.gif WIDTH=$silver_polosa_width HEIGHT=10 ALT="Уровень жизни" id=HP2>
|
||||
<span id='hp_value'>$hp / $maxhp</span>
|
||||
HTML;
|
||||
}
|
||||
|
||||
|
||||
@ -311,7 +313,7 @@ function setHP($hp, $maxhp)
|
||||
function showProgressBar($current, $maximum, $line_color = 'limegreen', $bg_color = 'silver')
|
||||
{
|
||||
$bar = round($current / $maximum * 100);
|
||||
$output = <<<HTML
|
||||
return <<<HTML
|
||||
<div style="width: 100%; height: 16px; background: $bg_color; overflow: hidden; border-radius: 3px;">
|
||||
<div style="height: 16px; background: $line_color; border-radius: 3px; width: $bar%;"></div>
|
||||
</div>
|
||||
@ -319,7 +321,6 @@ function showProgressBar($current, $maximum, $line_color = 'limegreen', $bg_colo
|
||||
$current / $maximum
|
||||
</div>
|
||||
HTML;
|
||||
return $output;
|
||||
}
|
||||
|
||||
function echoscroll($slot)
|
||||
@ -372,7 +373,9 @@ function showhrefmagic($dress)
|
||||
|
||||
$r = '';
|
||||
$script = 'main';
|
||||
if ($user['battle']) $script = 'fbattle';
|
||||
if ($user['battle']) {
|
||||
$script = 'fbattle';
|
||||
}
|
||||
|
||||
$r .= "<a onclick=\"";
|
||||
if ($magic['targeted'] == 1) {
|
||||
@ -545,7 +548,7 @@ function showinf_pers($id, $battle = 0, $me = 0) //FIXME 37 запросов! Т
|
||||
$invis = $user['invis'];
|
||||
}
|
||||
|
||||
if ($invis and $user['id'] != $_SESSION['uid']) {
|
||||
if ($invis && $user['id'] != $_SESSION['uid']) {
|
||||
$r = <<<HTML
|
||||
<div style="text-align: center;">
|
||||
<b><i>невидимка</i></b><br><br><img src="i/shadow/0.gif">
|
||||
@ -554,10 +557,17 @@ function showinf_pers($id, $battle = 0, $me = 0) //FIXME 37 запросов! Т
|
||||
HTML;
|
||||
} else {
|
||||
$r .= '<div style="text-align: center">';
|
||||
if (!empty($user['align'])) $r .= "<img src='/i/align_{$user['align']}.gif' > ";
|
||||
if ($user['block']) $r .= "<span class='private'><s>{$user['login']}</s></span>";
|
||||
else $r .= "<b>$user[login]</b> ";
|
||||
if (!empty($user['klan'])) $r .= "<img src='/i/klan/" . ClanImage($user['klan']) . ".gif' > ";
|
||||
if (!empty($user['align'])) {
|
||||
$r .= "<img src='/i/align_{$user['align']}.gif' > ";
|
||||
}
|
||||
if ($user['block']) {
|
||||
$r .= "<span class='private'><s>{$user['login']}</s></span>";
|
||||
} else {
|
||||
$r .= "<b>$user[login]</b> ";
|
||||
}
|
||||
if (!empty($user['klan'])) {
|
||||
$r .= "<img src='/i/klan/" . ClanImage($user['klan']) . ".gif' > ";
|
||||
}
|
||||
$r .= '</div>';
|
||||
|
||||
$r .= showProgressBar($user['hp'], $user['maxhp']);
|
||||
@ -608,8 +618,8 @@ HTML;
|
||||
|
||||
|
||||
if ($user['bron'] > 0 || $user['rybax'] > 0 || $user['plaw'] > 0) {
|
||||
$title = '';
|
||||
$d = '';
|
||||
$title = '';
|
||||
if ($user['plaw']) {
|
||||
$d = $user['plaw'];
|
||||
if ($user['bron']) {
|
||||
@ -792,8 +802,11 @@ HTML;
|
||||
if ($user['klan']) {
|
||||
$clann = db::c()->query('SELECT `name`, `glava` FROM `clans` WHERE `id` = ?i', $user['klan'])->fetch_assoc();
|
||||
$r .= $clann['name'];
|
||||
if ($clann['glava'] == $user['id']) $r .= " - <span style='color:teal;'>Глава клана</span><br>";
|
||||
elseif (!empty($user['status'])) $r .= " - " . $user['status'] . "<br>";
|
||||
if ($clann['glava'] == $user['id']) {
|
||||
$r .= " - <span style='color:teal;'>Глава клана</span><br>";
|
||||
} elseif (!empty($user['status'])) {
|
||||
$r .= " - " . $user['status'] . "<br>";
|
||||
}
|
||||
}
|
||||
|
||||
if ($user['borntime']) {
|
||||
@ -803,7 +816,9 @@ HTML;
|
||||
$r .= 'День рождения персонажа: ' . $date3 . '<br>';
|
||||
}
|
||||
|
||||
if ($user['palcom']) $r .= "<br><span class=private>{$user['palcom']}</span>";
|
||||
if ($user['palcom']) {
|
||||
$r .= "<br><span class=private>{$user['palcom']}</span>";
|
||||
}
|
||||
$r .= '<hr />';
|
||||
|
||||
} else {
|
||||
@ -1092,16 +1107,24 @@ function showpersout($pas = 0) //FIXME Сделать по человеческ
|
||||
<TD valign=top style='width:450px;'></TD>
|
||||
|
||||
Сила: <?= $user['sila'] ?>
|
||||
<?php if (isset($param_bonus['sila'])) echo " <span class='success'>(+" . $param_bonus['sila'] . ")</span>"; ?>
|
||||
<?php if (isset($param_bonus['sila'])) {
|
||||
echo " <span class='success'>(+" . $param_bonus['sila'] . ")</span>";
|
||||
} ?>
|
||||
<BR>
|
||||
Ловкость: <?= $user['lovk'] ?>
|
||||
<?php if (isset($param_bonus['lovk'])) echo " <span class='success'>(+" . $param_bonus['lovk'] . ")</span>"; ?>
|
||||
<?php if (isset($param_bonus['lovk'])) {
|
||||
echo " <span class='success'>(+" . $param_bonus['lovk'] . ")</span>";
|
||||
} ?>
|
||||
<BR>
|
||||
Интуиция: <?= $user['inta'] ?>
|
||||
<?php if (isset($param_bonus['inta'])) echo " <span class='success'>(+" . $param_bonus['inta'] . ")</span>"; ?>
|
||||
<?php if (isset($param_bonus['inta'])) {
|
||||
echo " <span class='success'>(+" . $param_bonus['inta'] . ")</span>";
|
||||
} ?>
|
||||
<BR>
|
||||
Выносливость:<?= $user['vinos'] ?>
|
||||
<?php if (isset($param_bonus['vinos'])) echo " <span class='success'>(+" . $param_bonus['vinos'] . ")</span>"; ?>
|
||||
<?php if (isset($param_bonus['vinos'])) {
|
||||
echo " <span class='success'>(+" . $param_bonus['vinos'] . ")</span>";
|
||||
} ?>
|
||||
<BR>
|
||||
Интеллект: <?= $user['intel'] ?><BR>
|
||||
Мудрость: <?= $user['mudra'] ?><BR>
|
||||
@ -1158,20 +1181,22 @@ function addActions($time, $vars, $vls, $uid)
|
||||
db::c()->query('LOCK TABLES `actions` WRITE');
|
||||
$ins = db::c()->query('INSERT INTO `actions` (`uid`,`time`,`city`,`room`,`vars`,`ip`,`vals`) VALUES (?i, ?i, "?s", ?i, "?s", "?s", "?s")', $uid, $time, "capitalcity", 0, $vars, $_SERVER['HTTP_X_REAL_IP'], $vls);
|
||||
db::c()->query('UNLOCK TABLES');
|
||||
if ($ins) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return $ins;
|
||||
}
|
||||
|
||||
|
||||
function plusorminus($n, $shownum = 1)
|
||||
{
|
||||
if (empty($shownum)) {
|
||||
if ($n >= 2) return "++";
|
||||
if ($n > 0) return "+";
|
||||
if ($n < 0) return "-";
|
||||
if ($n >= 2) {
|
||||
return "++";
|
||||
}
|
||||
if ($n > 0) {
|
||||
return "+";
|
||||
}
|
||||
if ($n < 0) {
|
||||
return "-";
|
||||
}
|
||||
}
|
||||
if ($n >= 0) {
|
||||
return "+$n";
|
||||
@ -1270,7 +1295,9 @@ function dropitemid($slot, $id)
|
||||
$user[$slot1] = 0;
|
||||
}
|
||||
return true;
|
||||
} else return false;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// снять предмет
|
||||
@ -1380,8 +1407,9 @@ function dropitem($slot)
|
||||
`u`.`fauvorot` = `u`.`fauvorot` - `i`.`mfauvorot`,
|
||||
`u`.`uminu` = `u`.`uminu` - `i`.`minu`,
|
||||
`u`.`umaxu` = `u`.`umaxu` - `i`.`maxu`
|
||||
WHERE `i`.`id` = `u`.?f AND `i`.`dressed` = 1 AND `i`.`owner` = ?i AND u.id = ?i', $slot1, $slot1, $user['id'], $user['id']))
|
||||
WHERE `i`.`id` = `u`.?f AND `i`.`dressed` = 1 AND `i`.`owner` = ?i AND u.id = ?i', $slot1, $slot1, $user['id'], $user['id'])) {
|
||||
db::c()->query('UPDATE `users` SET `hp` = `maxhp`, `fullhptime` = ?i WHERE `hp` > `maxhp` AND `id` = ?i', time(), $user['id']);
|
||||
}
|
||||
|
||||
$wear_raw = db::c()->query('SELECT * FROM `inventory` where `owner` = ?i AND `dressed` = 1', $user['id']);
|
||||
while ($wear_list = $wear_raw->fetch_assoc()) {
|
||||
@ -1403,17 +1431,13 @@ function dropitem($slot)
|
||||
//если прото в комплекте и не одет
|
||||
if (in_array($get_pro['prototype'], $temp_is) && (!in_array($get_pro['prototype'], $wear_arr))) {
|
||||
$checker = 1;
|
||||
// echo("<BR>ITEM SETS<BR>");
|
||||
//foreach($temp_is as $tis) echo($tis."<BR>");
|
||||
|
||||
//для каждого одетого предмета
|
||||
foreach ($temp_is as $check_proto)
|
||||
if ($check_proto != $get_pro['prototype']) {
|
||||
if (!in_array($check_proto, $wear_arr)) {
|
||||
$checker = 0;
|
||||
}
|
||||
// echo("Checker=".$checker." at set #".$set_id." item #".$check_proto." Compare=".$get_pro['prototype']."<BR>");
|
||||
foreach ($temp_is as $check_proto) {
|
||||
if ($check_proto != $get_pro['prototype'] && !in_array($check_proto, $wear_arr)) {
|
||||
$checker = 0;
|
||||
}
|
||||
//echo("Checker=".$checker." at set #".$set_id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1466,7 +1490,9 @@ function ref_drop()
|
||||
$user = db::c()->query('SELECT `id`, `align` FROM `users` WHERE `id` = ?i', $_SESSION['uid'])->fetch_assoc();
|
||||
$ts = db::c()->query('SELECT `id`, `nalign` FROM `inventory` WHERE `id` = ?i', $id)->fetch_assoc();
|
||||
$al = '(1 = 1)';
|
||||
if ($ts['nalign'] == 1.1) $al = '(1 = 2)';
|
||||
if ($ts['nalign'] == 1.1) {
|
||||
$al = '(1 = 2)';
|
||||
}
|
||||
$dd = db::c()->query('SELECT `i`.`id` FROM `users` AS `u`, `inventory` AS `i`
|
||||
WHERE
|
||||
`i`.`needident` = 0 AND
|
||||
@ -1494,11 +1520,7 @@ function ref_drop()
|
||||
`u`.`mdark` >= `i`.`ndark` AND
|
||||
`i`.`setsale` = 0 AND
|
||||
`u`.`id` = ?i', $id, $user['id'], $al, $user['align'], $user['id']);
|
||||
if ($dd->getNumRows() > 0) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return $dd->getNumRows() > 0;
|
||||
}
|
||||
|
||||
$slot = ['sergi', 'kulon', 'weap', 'bron', 'r1', 'r2', 'r3', 'helm', 'perchi', 'shit', 'boots', 'm1', 'm2', 'm3', 'm4', 'm5', 'm6', 'm7', 'm8', 'm9', 'm10'];
|
||||
@ -1560,6 +1582,9 @@ function destructitem($id)
|
||||
case 23:
|
||||
$slot1 = 'plaw';
|
||||
break;
|
||||
default:
|
||||
$slot1 = 'weap';
|
||||
break;
|
||||
}
|
||||
if ($dress['type'] == 5) {
|
||||
if ($user['r1'] == $dress['id']) {
|
||||
@ -1592,8 +1617,10 @@ function destructitem($id)
|
||||
$slot1 = 'm10';
|
||||
}
|
||||
}
|
||||
if (($dress['owner'] == $user['id'])) {
|
||||
if ($dress['dressed'] == 1) db::c()->query('UPDATE `users` SET ?f = 0 WHERE `id` = ?i', $slot1, $user['id']);
|
||||
if ($dress['owner'] == $user['id']) {
|
||||
if ($dress['dressed'] == 1) {
|
||||
db::c()->query('UPDATE `users` SET ?f = 0 WHERE `id` = ?i', $slot1, $user['id']);
|
||||
}
|
||||
db::c()->query('DELETE FROM `inventory` WHERE `id` = ?i', $id);
|
||||
}
|
||||
}
|
||||
@ -1617,68 +1644,72 @@ function usemagic($id)
|
||||
$charge = $incmagic['needcharge'];
|
||||
}
|
||||
|
||||
if (($all_magic[$user['id']] < 1) || ($charge == '0')) {
|
||||
if ((($user['sila'] >= $row['nsila']) &&
|
||||
($user['lovk'] >= $row['nlovk']) &&
|
||||
($user['inta'] >= $row['ninta']) &&
|
||||
($user['vinos'] >= $row['nvinos']) &&
|
||||
($user['intel'] >= $row['nintel']) &&
|
||||
($user['level'] >= $row['nlevel']) &&
|
||||
(($user['align'] > 7 && $user['align'] < 8) || ((int)$user['align'] == (int)$row['nalign']) || ($row['nalign'] == 0)) &&
|
||||
($user['noj'] >= $row['nnoj']) &&
|
||||
($user['topor'] >= $row['ntopor']) &&
|
||||
($user['dubina'] >= $row['ndubina']) &&
|
||||
($user['mec'] >= $row['nmech']) &&
|
||||
($row['type'] < 13 || $row['type'] == 50) && ($user['mfire'] >= $row['nfire']) &&
|
||||
($user['mwater'] >= $row['nwater']) &&
|
||||
($user['mair'] >= $row['nair']) &&
|
||||
($user['mearth'] >= $row['nearth']) &&
|
||||
($user['mlight'] >= $row['nlight']) &&
|
||||
($user['mgray'] >= $row['ngray']) &&
|
||||
($user['mdark'] >= $row['ndark']) &&
|
||||
($row['needident'] == 0)
|
||||
) || $row['magic'] == 48 || $row['magic'] == 50) {
|
||||
if ((($all_magic[$user['id']] < 1) || ($charge == '0')) &&
|
||||
(($user['sila'] >= $row['nsila']) &&
|
||||
($user['lovk'] >= $row['nlovk']) &&
|
||||
($user['inta'] >= $row['ninta']) &&
|
||||
($user['vinos'] >= $row['nvinos']) &&
|
||||
($user['intel'] >= $row['nintel']) &&
|
||||
($user['level'] >= $row['nlevel']) &&
|
||||
(($user['align'] > 7 && $user['align'] < 8) || ((int)$user['align'] == (int)$row['nalign']) || ($row['nalign'] == 0)) &&
|
||||
($user['noj'] >= $row['nnoj']) &&
|
||||
($user['topor'] >= $row['ntopor']) &&
|
||||
($user['dubina'] >= $row['ndubina']) &&
|
||||
($user['mec'] >= $row['nmech']) &&
|
||||
($row['type'] < 13 || $row['type'] == 50) && ($user['mfire'] >= $row['nfire']) &&
|
||||
($user['mwater'] >= $row['nwater']) &&
|
||||
($user['mair'] >= $row['nair']) &&
|
||||
($user['mearth'] >= $row['nearth']) &&
|
||||
($user['mlight'] >= $row['nlight']) &&
|
||||
($user['mgray'] >= $row['ngray']) &&
|
||||
($user['mdark'] >= $row['ndark']) &&
|
||||
($row['needident'] == 0)
|
||||
) || $row['magic'] == 48 || $row['magic'] == 50) {
|
||||
|
||||
|
||||
if (!$row['magic']) {
|
||||
$incmagic['name'] = $row['includemagicname'];
|
||||
$incmagic['cur'] = $row['includemagicdex'];
|
||||
$incmagic['max'] = $row['includemagicmax'];
|
||||
if ($incmagic['cur'] <= 0) {
|
||||
return false;
|
||||
}
|
||||
$magic['targeted'] = $incmagic['targeted'];
|
||||
echo "<span class='error'>";
|
||||
include("magic/" . $incmagic['file']);
|
||||
echo "</span>";
|
||||
if (!$row['magic']) {
|
||||
$incmagic['name'] = $row['includemagicname'];
|
||||
$incmagic['cur'] = $row['includemagicdex'];
|
||||
$incmagic['max'] = $row['includemagicmax'];
|
||||
if ($incmagic['cur'] <= 0) {
|
||||
return false;
|
||||
}
|
||||
$magic['targeted'] = $incmagic['targeted'];
|
||||
echo "<span class='error'>";
|
||||
include("magic/" . $incmagic['file']);
|
||||
echo "</span>";
|
||||
} else {
|
||||
echo "<span class='error'>";
|
||||
include("magic/" . $magic['file']);
|
||||
echo "</span>";
|
||||
}
|
||||
if ($bat) {
|
||||
if ($row['maxdur'] <= ($row['duration'] + 1)) {
|
||||
destructitem($row['id']);
|
||||
} else {
|
||||
echo "<span class='error'>";
|
||||
include("magic/" . $magic['file']);
|
||||
echo "</span>";
|
||||
}
|
||||
if ($bat) {
|
||||
if ($row['maxdur'] <= ($row['duration'] + 1)) {
|
||||
destructitem($row['id']);
|
||||
if (!$row['magic']) {
|
||||
db::c()->query('UPDATE `inventory` SET `includemagicdex` =`includemagicdex` - ?i WHERE id = ?i', $bat, $row['id']);
|
||||
} else {
|
||||
if (!$row['magic']) {
|
||||
db::c()->query('UPDATE `inventory` SET `includemagicdex` =`includemagicdex` - ?i WHERE id = ?i', $bat, $row['id']);
|
||||
} else {
|
||||
db::c()->query('UPDATE `inventory` SET duration = duration + ?i WHERE id = ?i', $bat, $row['id']);
|
||||
}
|
||||
db::c()->query('UPDATE `inventory` SET duration = duration + ?i WHERE id = ?i', $bat, $row['id']);
|
||||
}
|
||||
if (!$charge) $charge = 0;
|
||||
//ограничение по кол-ву за ход
|
||||
if ($user['battle'] > 0)
|
||||
$bat = db::c()->query('SELECT * FROM `battle` WHERE `id` = ?i', $user['battle'])->fetch_assoc_array();
|
||||
if ($bat['magic'] == '')
|
||||
$all_magic = [];
|
||||
else
|
||||
$all_magic = unserialize($bat['magic']);
|
||||
$all_magic[$user['id']] += $charge;
|
||||
db::c()->query('UPDATE `battle` SET `magic`= "?s" WHERE id = ?i', serialize($all_magic), $user['battle']);
|
||||
}
|
||||
if (!$charge) {
|
||||
$charge = 0;
|
||||
}
|
||||
//ограничение по кол-ву за ход
|
||||
if ($user['battle'] > 0) {
|
||||
$bat = db::c()->query('SELECT * FROM `battle` WHERE `id` = ?i', $user['battle'])->fetch_assoc_array();
|
||||
}
|
||||
if ($bat['magic'] == '') {
|
||||
$all_magic = [];
|
||||
} else {
|
||||
$all_magic = unserialize($bat['magic']);
|
||||
}
|
||||
$all_magic[$user['id']] += $charge;
|
||||
db::c()->query('UPDATE `battle` SET `magic`= "?s" WHERE id = ?i', serialize($all_magic), $user['battle']);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function addch($text, $room = 0)
|
||||
@ -1719,7 +1750,9 @@ function addchp($text, $who, $room = 0)
|
||||
*/
|
||||
function AddChatSystem($msg)
|
||||
{
|
||||
if ($msg) {db::c()->query('INSERT INTO `chat` (`cid`,`msg`,`type`) VALUES (?i,"?s","?s")', 1, $msg, 'sys');}
|
||||
if ($msg) {
|
||||
db::c()->query('INSERT INTO `chat` (`cid`,`msg`,`type`) VALUES (?i,"?s","?s")', 1, $msg, 'sys');
|
||||
}
|
||||
}
|
||||
|
||||
function err($t)
|
||||
@ -1906,7 +1939,9 @@ function err($t)
|
||||
function telegraph($userId, $text)
|
||||
{
|
||||
db::c()->query('SELECT 1 FROM `users` WHERE `id` = ?i', $userId)->fetch_assoc();
|
||||
if (db::c()->getAffectedRows()) db::c()->query('INSERT INTO `telegraph` (receiver, text) VALUES (?i,"?s")', $userId, $text);
|
||||
if (db::c()->getAffectedRows()) {
|
||||
db::c()->query('INSERT INTO `telegraph` (receiver, text) VALUES (?i,"?s")', $userId, $text);
|
||||
}
|
||||
}
|
||||
|
||||
function get_meshok()
|
||||
@ -1924,9 +1959,11 @@ function getItemsMassaInfo()
|
||||
{
|
||||
$i_row = db::c()->query('SELECT SUM(`massa`) AS `massa`, SUM(`gmeshok`) AS `massa_bonus` FROM `inventory` WHERE `setsale` = 0 AND `owner` = ?i', $_SESSION['uid'])->fetch_assoc();
|
||||
$u_row = db::c()->query('SELECT `sila` FROM `users` WHERE `id` = ?i', $_SESSION['uid'])->fetch_assoc();
|
||||
if ($i_row['massa'] > $u_row['sila'] * 4 + $i_row['massa_bonus'])
|
||||
if ($i_row['massa'] > $u_row['sila'] * 4 + $i_row['massa_bonus']) {
|
||||
return "<span style='color:maroon;'>" . $i_row['massa'] . "</span>/" . ($u_row['sila'] * 4 + $i_row['massa_bonus']);
|
||||
else return $i_row['massa'] . "/" . ($u_row['sila'] * 4 + $i_row['massa_bonus']);
|
||||
} else {
|
||||
return $i_row['massa'] . "/" . ($u_row['sila'] * 4 + $i_row['massa_bonus']);
|
||||
}
|
||||
}
|
||||
|
||||
function addlog($id, $log)
|
||||
@ -1942,7 +1979,7 @@ function addlog($id, $log)
|
||||
|
||||
function star_sign($month, $day)
|
||||
{
|
||||
if (empty($month) or empty($day)) {
|
||||
if (empty($month) || empty($day)) {
|
||||
$month = (int)sprintf("%02d", mt_rand(1, 12));
|
||||
$day = (int)sprintf("%02d", mt_rand(1, 29));
|
||||
}
|
||||
@ -2033,8 +2070,8 @@ function SolveExp($at_id, $def_id, $damage)
|
||||
|
||||
$pls = count(explode(";", $bt['t1'])) + count(explode(";", $bt['t2']));
|
||||
if ($pls > 2) {
|
||||
$mfbot = $bot_active == true ? 0.3 : 1;
|
||||
$mfbot2 = $bot_def == true ? 0.7 : 1;
|
||||
$mfbot = $bot_active ? 0.3 : 1;
|
||||
$mfbot2 = $bot_def ? 0.7 : 1;
|
||||
} else {
|
||||
$mfbot = 1;
|
||||
$mfbot2 = 1;
|
||||
@ -2042,10 +2079,8 @@ function SolveExp($at_id, $def_id, $damage)
|
||||
if ($expmf == 0) {
|
||||
$expmf = 1;
|
||||
}
|
||||
$result = ($baseexp[$def['level']]) * ($def_cost[0] / (($at_cost[0] + $def_cost[0]) / 2)) * ($damage / $def['maxhp']) * $expmf * $mfit * $mfbot * $mfbot2;
|
||||
$result = $result / 3;
|
||||
$result = round($result, 0);
|
||||
return $result;
|
||||
|
||||
return round((($baseexp[$def['level']]) * ($def_cost[0] / (($at_cost[0] + $def_cost[0]) / 2)) * ($damage / $def['maxhp']) * $expmf * $mfit * $mfbot * $mfbot2) / 3, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2059,7 +2094,9 @@ function SolveExp($at_id, $def_id, $damage)
|
||||
*/
|
||||
function addToDelo($message, $user_id = 0, $type = 1)
|
||||
{
|
||||
if (empty($user_id)) $user_id = $_SESSION['uid'];
|
||||
if (empty($user_id)) {
|
||||
$user_id = $_SESSION['uid'];
|
||||
}
|
||||
db::c()->query('INSERT INTO `delo` (pers, text, type, date) VALUES (?i,"?s",?i,?i)', $user_id, $message, $type, time());
|
||||
return true;
|
||||
}
|
||||
@ -2096,18 +2133,23 @@ function addOnePoint($name, $param = null)
|
||||
'mgray' => 'Магия серости',
|
||||
'mdark' => 'Магия тьмы',
|
||||
];
|
||||
if ($param == 'stat' and in_array($name, $allowed_stats)) {
|
||||
if ($param == 'stat' && in_array($name, $allowed_stats)) {
|
||||
db::c()->query('UPDATE `users` SET ?f = ?f + 1, `stats` = `stats` - 1 WHERE `id` = ?i', $name, $name, $_SESSION['uid']);
|
||||
echo "<span style='color:darkgreen'>Параметр {$naming[$name]} увеличен на 1 ед.</span>";
|
||||
} elseif ($param == 'mastery' and in_array($name, $allowed_mastery)) {
|
||||
} elseif ($param == 'mastery' && in_array($name, $allowed_mastery)) {
|
||||
$mastery_level = db::c()->query('SELECT ?f FROM `users` WHERE `id` = ?i', $name, $_SESSION['uid'])->fetch_assoc();
|
||||
if ($mastery_level[$name] < 10) {
|
||||
db::c()->query('UPDATE `users` SET ?f = ?f + 1, `master` = `master` - 1 WHERE `id` = ?i', $name, $name, $_SESSION['uid']);
|
||||
echo "<span style='color:darkgreen'>Параметр {$naming[$name]} увеличен на 1 ед.</span>";
|
||||
} else echo "<span style='color: maroon;'>Ошибка: параметр достиг максимального значения!</span>";
|
||||
} else return null;
|
||||
} else {
|
||||
echo "<span style='color: maroon;'>Ошибка: параметр достиг максимального значения!</span>";
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
function checkIntInRange($int, $min = 1, $max = PHP_INT_MAX) {
|
||||
function checkIntInRange($int, $min = 1, $max = PHP_INT_MAX)
|
||||
{
|
||||
return (int)filter_var($int, FILTER_VALIDATE_INT, ['options' => ['min_range' => $min, 'max_range' => $max]]);
|
||||
}
|
Loading…
Reference in New Issue
Block a user