From 5842b39b248b23a0ffcabbb9efb4d0336d7d8f10 Mon Sep 17 00:00:00 2001 From: "Igor Barkov (iwork)" Date: Mon, 17 Feb 2020 17:03:21 +0200 Subject: [PATCH 1/5] =?UTF-8?q?=D0=9A=D0=B0=D0=BA=D0=B8=D0=B5-=D1=82=D0=BE?= =?UTF-8?q?=20=D0=BC=D0=B5=D0=BB=D0=BE=D1=87=D0=B8.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- magic/attackk.php | 275 ++++++++++++++++++++++------------------------ 1 file changed, 130 insertions(+), 145 deletions(-) diff --git a/magic/attackk.php b/magic/attackk.php index 3100947..b8226a9 100644 --- a/magic/attackk.php +++ b/magic/attackk.php @@ -1,181 +1,166 @@ = ".(time()-60)." AND `id` = users.`id`) as `online` FROM `users` WHERE `login` = '{$_POST['target']}' LIMIT 1;")); -$owntravma = mysql_fetch_array(mysql_query("SELECT * FROM `effects` WHERE `owner` = ".$us['id']." AND (type=13 OR ND type=12 OR type=14);")); +$us = mysql_fetch_array(mysql_query("SELECT *,(select `id` from `online` WHERE `real_time` >= " . (time() - 60) . " AND `id` = users.`id`) as `online` FROM `users` WHERE `login` = '{$_POST['target']}' LIMIT 1;")); +$owntravma = mysql_fetch_array(mysql_query("SELECT * FROM `effects` WHERE `owner` = " . $us['id'] . " AND (type=13 OR ND type=12 OR type=14);")); $magic = mysql_fetch_array(mysql_query("SELECT `chanse` FROM `magic` WHERE `id` = '23' ;")); -$effect = mysql_fetch_array(mysql_query("SELECT `id` FROM `effects` WHERE `owner` = '{$us['id']}' AND `time` > '".time()."' AND `type` = '227' LIMIT 1")); +$effect = mysql_fetch_array(mysql_query("SELECT `id` FROM `effects` WHERE `owner` = '{$us['id']}' AND `time` > '" . time() . "' AND `type` = '227' LIMIT 1")); if ($user['intel'] >= 4) { - $int=$magic['chanse'] + ($user['intel'] - 4)*3; - if ($int>=100){$int=100;} - } -else {$int=0;} + $int = $magic['chanse'] + ($user['intel'] - 4) * 3; + if ($int >= 100) { + $int = 100; + } +} else { + $int = 0; +} if ($user['battle'] > 0) { - echo "Не в бою..."; -} -elseif (!$us['online']) { - echo "Персонаж не в игре!"; -} elseif ($us_b['type']==3 || $us_b['type']==5) { - echo "Запрещено входить в хаотический бой!"; -} elseif ($us['battle']>0 && $us_b['open']==0) { - echo "Бой закрыт для вмешательства!"; -} elseif ($us['align']==2.99) { - echo "Не атакуйте Администратора!"; + echo "Не в бою..."; +} elseif (!$us['online']) { + echo "Персонаж не в игре!"; +} elseif ($us_b['type'] == 3 || $us_b['type'] == 5) { + echo "Запрещено входить в хаотический бой!"; +} elseif ($us['battle'] > 0 && $us_b['open'] == 0) { + echo "Бой закрыт для вмешательства!"; } elseif ($user['zayavka'] > 0) { - echo "Вы ожидаете поединка..."; -} elseif(in_array($us['room'], $unkilable['rooms'])) { - echo "В данной комнате запрещены нападения ..."; -} elseif(in_array($us['id'], $unkilable['users'])) { - echo "Персонаж под защитой от нападений ..."; -} elseif(isset($effect['id'])) { - echo "Персонаж под защитой от нападений ..."; + echo "Вы ожидаете поединка..."; +} elseif (in_array($us['room'], $unkilable['rooms'])) { + echo "В данной комнате запрещены нападения ..."; +} elseif (in_array($us['id'], $unkilable['users'])) { + echo "Персонаж под защитой от нападений ..."; +} elseif (isset($effect['id'])) { + echo "Персонаж под защитой от нападений ..."; } elseif ($owntravma['id'] && !$us['battle']) { - echo "Персонаж тяжело травмирован..."; + echo "Персонаж тяжело травмирован..."; } elseif ($user['room'] != $us['room']) { - echo "Персонаж в другой комнате!"; -} elseif ($us['room'] == 31 || $us['room'] == 46 || $us['room'] == 47 || $us['room'] == 48 || $us['room'] == 49 ||$us['room'] == 600 || $us['room'] == 601 || $us['room'] == 45 || $us['room'] == 602 || $us['room'] == 43 || $us['room'] ==45) { - echo "Нападения в этой локации запрещены!"; -} elseif ($us['align'] == 2.9) { - echo "Нападения на Ангела строго запрещено!"; -} elseif ($us['align'] == 8.11) { - echo "Нападение на Гвардейца Света запрещено!"; -} elseif ($us['align'] == 8.21) { - echo "Нападение на Гвардейца Тьмы запрещено!"; -} elseif ($us['align'] == 8.31) { - echo "Нападение на Гвардейца Нейтралитета запрещено!"; -} elseif ($us['align'] >1 && $us['align'] <2) { - echo "Нападение на Паладинов запрещено!"; -} elseif ($us['align'] == 4.99) { - echo "Нападение на Комментатора запрещено!"; + echo "Персонаж в другой комнате!"; } elseif ($us['level'] < 1) { - echo "Новички находятся под защитой Мироздателя!"; -} elseif ($us['hp'] < $us['maxhp']*0.33 && !$us['battle']) { - echo "Жертва слишком слаба!"; -} elseif ($user['hp'] < $user['maxhp']*0.33) { - echo "Вы слишком ослаблены для нападения!"; -} elseif ($us['hp'] < 1 && $us['battle']) { - echo "Вы не можете напасть на погибшего!"; -} elseif (mt_rand(1,100) < $int) { + echo "Новички находятся под защитой Мироздателя!"; +} elseif ($us['hp'] < $us['maxhp'] * 0.33 && !$us['battle']) { + echo "Жертва слишком слаба!"; +} elseif ($user['hp'] < $user['maxhp'] * 0.33) { + echo "Вы слишком ослаблены для нападения!"; +} elseif ($us['hp'] < 1 && $us['battle']) { + echo "Вы не можете напасть на погибшего!"; +} elseif (mt_rand(1, 100) < $int) { - if ($user['sex'] == 1) {$action="напал";} else {$action="напала";} - if ($user['align'] > '2' && $user['align'] < '3') { - $angel="Ангел"; - } elseif ($user['align'] > '1' && $user['align'] < '2') { - $angel="Персонаж"; - } + if ($user['sex'] == 1) { + $action = "напал"; + } else { + $action = "напала"; + } + $jert = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `login` = '{$_POST['target']}' LIMIT 1;")); + if ($jert['id'] != $user['id']) { + addch(" {$user['login']}, применив магию нападения, внезапно " . $action . " на "{$_POST['target']}""); + addchp('Внимание! На вас ' . $action . ' ' . $user['login'] . '.
\'; top.frames[\'main\'].location=\'fbattle.php\'; var z = \' ', '{[]}' . nick::id($jert['id'])->short() . '{[]}'); + //destructitem($row['id']); + $bet = 1; + //арх + if ($jert['id'] > _BOTSEPARATOR_) { + $arha = mysql_fetch_array(mysql_query('SELECT * FROM `bots` WHERE `prototype` = ' . $jert['id'] . ' LIMIT 1;')); + $jert['battle'] = $arha['battle']; + $jert['id'] = $arha['id']; + $bot = 1; + } + if ($jert['battle'] > 0) { - $jert = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `login` = '{$_POST['target']}' LIMIT 1;")); - if($jert['id']!=$user['id']) { - addch(" {$user['login']}, применив магию нападения, внезапно ".$action." на "{$_POST['target']}""); - addchp ('Внимание! На вас '.$action.' '.$user['login'].'.
\'; top.frames[\'main\'].location=\'fbattle.php\'; var z = \' ','{[]}'.nick::id($jert['id'])->short().'{[]}'); - //destructitem($row['id']); - $bet=1; - //арх - if($jert['id'] > _BOTSEPARATOR_) { - $arha = mysql_fetch_array(mysql_query ('SELECT * FROM `bots` WHERE `prototype` = '.$jert['id'].' LIMIT 1;')); - $jert['battle'] = $arha['battle']; - $jert['id'] = $arha['id']; - $bot=1; - } - if($jert['battle'] > 0) { - - //вмешиваемся - $bd = mysql_fetch_array(mysql_query ('SELECT * FROM `battle` WHERE `id` = '.$jert['battle'].' LIMIT 1;')); - $battle = unserialize($bd['teams']); - $ak = array_keys($battle[$jert['id']]); - $battle[$user['id']] = $battle[$ak[0]]; - foreach($battle[$user['id']] as $k => $v) { - $battle[$user['id']][$k] =array(0,0,time()); - $battle[$k][$user['id']] = array(0,0,time()); - } - $t1 = explode(";",$bd['t1']); - // проставляем кто-где - if (in_array ($jert['id'],$t1)) { - $ttt = 2; - } else { - $ttt = 1; - } - addch ("".nick::id($user['id'])->short()." вмешался в поединок »». ",$user['room']); + //вмешиваемся + $bd = mysql_fetch_array(mysql_query('SELECT * FROM `battle` WHERE `id` = ' . $jert['battle'] . ' LIMIT 1;')); + $battle = unserialize($bd['teams']); + $ak = array_keys($battle[$jert['id']]); + $battle[$user['id']] = $battle[$ak[0]]; + foreach ($battle[$user['id']] as $k => $v) { + $battle[$user['id']][$k] = [0, 0, time()]; + $battle[$k][$user['id']] = [0, 0, time()]; + } + $t1 = explode(";", $bd['t1']); + // проставляем кто-где + if (in_array($jert['id'], $t1)) { + $ttt = 2; + } else { + $ttt = 1; + } + addch("" . nick::id($user['id'])->short() . " вмешался в поединок »». ", $user['room']); - //mysql_query('UPDATE `logs` SET `log` = CONCAT(`log`,\''.date("H:i").' '.nick::id($user['id'])->short().' вмешался в поединок!
\') WHERE `id` = '.$jert['battle'].''); + //mysql_query('UPDATE `logs` SET `log` = CONCAT(`log`,\''.date("H:i").' '.nick::id($user['id'])->short().' вмешался в поединок!
\') WHERE `id` = '.$jert['battle'].''); - addlog($jert['battle'],''.date("H:i").' '.nick::id($user['id'])->short().' вмешался в поединок!
'); + addlog($jert['battle'], '' . date("H:i") . ' ' . nick::id($user['id'])->short() . ' вмешался в поединок!
'); - mysql_query('UPDATE `battle` SET `teams` = \''.serialize($battle).'\', `t'.$ttt.'`=CONCAT(`t'.$ttt.'`,\';'.$user['id'].'\') WHERE `id` = '.$jert['battle'].' ;'); - mysql_query("UPDATE users SET `battle` =".$jert['battle'].",`zayavka`=0 WHERE `id`= ".$user['id']); + mysql_query('UPDATE `battle` SET `teams` = \'' . serialize($battle) . '\', `t' . $ttt . '`=CONCAT(`t' . $ttt . '`,\';' . $user['id'] . '\') WHERE `id` = ' . $jert['battle'] . ' ;'); + mysql_query("UPDATE users SET `battle` =" . $jert['battle'] . ",`zayavka`=0 WHERE `id`= " . $user['id']); - header("Location:fbattle.php"); - //die(""); - } - else - { - // начинаем бой - //$bet=1; - // если чел в заявке, выбиваем его - if($jert['zayavka']) { - $fict1 = mysql_fetch_array(mysql_query("SELECT * FROM `zayavka` WHERE `team1` LIKE '{$jert['id']};%' OR `team1` LIKE '%;{$jert['id']};%' LIMIT 1;")); - $fict2 = mysql_fetch_array(mysql_query("SELECT * FROM `zayavka` WHERE `team2` LIKE '{$jert['id']};%' OR `team2` LIKE '%;{$jert['id']};%' LIMIT 1;")); - if($fict1) { $team=1; } - elseif($fict2) { $team=2; } + header("Location:fbattle.php"); + //die(""); + } else { + // начинаем бой + //$bet=1; + // если чел в заявке, выбиваем его + if ($jert['zayavka']) { + $fict1 = mysql_fetch_array(mysql_query("SELECT * FROM `zayavka` WHERE `team1` LIKE '{$jert['id']};%' OR `team1` LIKE '%;{$jert['id']};%' LIMIT 1;")); + $fict2 = mysql_fetch_array(mysql_query("SELECT * FROM `zayavka` WHERE `team2` LIKE '{$jert['id']};%' OR `team2` LIKE '%;{$jert['id']};%' LIMIT 1;")); + if ($fict1) { + $team = 1; + } elseif ($fict2) { + $team = 2; + } - mysql_query("UPDATE `users` SET `zayavka` = '' WHERE `id` = {$jert['id']} LIMIT 1;"); - $z = mysql_fetch_array(mysql_query("SELECT `team{$team}` FROM `zayavka` WHERE `id`=".$jert['zayavka'].";")); + mysql_query("UPDATE `users` SET `zayavka` = '' WHERE `id` = {$jert['id']} LIMIT 1;"); + $z = mysql_fetch_array(mysql_query("SELECT `team{$team}` FROM `zayavka` WHERE `id`=" . $jert['zayavka'] . ";")); - $teams = str_replace($jert['id'].";","",$z[0]); - mysql_query("UPDATE `zayavka` SET team{$team} = '{$teams}' WHERE id = {$jert['zayavka']};"); - } + $teams = str_replace($jert['id'] . ";", "", $z[0]); + mysql_query("UPDATE `zayavka` SET team{$team} = '{$teams}' WHERE id = {$jert['zayavka']};"); + } - //arch - if($bot) { - mysql_query("INSERT INTO `bots` (`name`,`prototype`,`battle`,`hp`) values ('Архивариус','83','','".$jert['hp']."');"); - $jert['id'] = mysql_insert_id(); - } - undressall($jert['id']); - undressall($user['id']); - $teams = array(); - $teams[$user['id']][$jert['id']] = array(0,0,time()); - $teams[$jert['id']][$user['id']] = array(0,0,time()); - $sv = array(3,4,5); - //$tou = array_rand($sv,1); - mysql_query("INSERT INTO `battle` + //arch + if ($bot) { + mysql_query("INSERT INTO `bots` (`name`,`prototype`,`battle`,`hp`) values ('Архивариус','83','','" . $jert['hp'] . "');"); + $jert['id'] = mysql_insert_id(); + } + undressall($jert['id']); + undressall($user['id']); + $teams = []; + $teams[$user['id']][$jert['id']] = [0, 0, time()]; + $teams[$jert['id']][$user['id']] = [0, 0, time()]; + $sv = [3, 4, 5]; + //$tou = array_rand($sv,1); + mysql_query("INSERT INTO `battle` ( `id`,`coment`,`teams`,`timeout`,`type`,`status`,`t1`,`t2`,`to1`,`to2`,`blood` ) VALUES ( - NULL,'','".serialize($teams)."','".$sv[rand(0,2)]."','1','0','".$user['id']."','".$jert['id']."','".time()."','".time()."','0' + NULL,'','" . serialize($teams) . "','" . $sv[rand(0, 2)] . "','1','0','" . $user['id'] . "','" . $jert['id'] . "','" . time() . "','" . time() . "','0' )"); - $id = mysql_insert_id(); + $id = mysql_insert_id(); - // апдейтим врага - if($bot) { - mysql_query("UPDATE `bots` SET `battle` = {$id} WHERE `id` = {$jert['id']} LIMIT 1;"); - } else { - mysql_query("UPDATE `users` SET `battle` = {$id} WHERE `id` = {$jert['id']} LIMIT 1;"); - } + // апдейтим врага + if ($bot) { + mysql_query("UPDATE `bots` SET `battle` = {$id} WHERE `id` = {$jert['id']} LIMIT 1;"); + } else { + mysql_query("UPDATE `users` SET `battle` = {$id} WHERE `id` = {$jert['id']} LIMIT 1;"); + } - // создаем лог + // создаем лог - $rr = "".nick::id($user['id'])->full(1)." и ".nick::id($jert['id'])->full(1).""; - addch ("Бой между ".nick::id($user['id'])->short()." и ".nick::id($jert['id'])->short()." начался. ",$user['room']); + $rr = "" . nick::id($user['id'])->full(1) . " и " . nick::id($jert['id'])->full(1) . ""; + addch("Бой между " . nick::id($user['id'])->short() . " и " . nick::id($jert['id'])->short() . " начался. ", $user['room']); - //mysql_query("INSERT INTO `logs` (`id`,`log`) VALUES('{$id}',"Часы показывали ".date("Y.m.d H.i").", когда ".$rr." бросили вызов друг другу.
"); + //mysql_query("INSERT INTO `logs` (`id`,`log`) VALUES('{$id}',"Часы показывали ".date("Y.m.d H.i").", когда ".$rr." бросили вызов друг другу.
"); - addlog($id,"Часы показывали ".date("Y.m.d H.i").", когда ".$rr." бросили вызов друг другу.
"); + addlog($id, "Часы показывали " . date("Y.m.d H.i") . ", когда " . $rr . " бросили вызов друг другу.
"); - mysql_query("UPDATE users SET `battle` ={$id},`zayavka`=0 WHERE `id`= {$user['id']} OR `id` = {$jert['id']}"); - header("Location:fbattle.php"); - //die(""); - } - } else { - echo 'Мазохист?...'; - } - //$bet=1; + mysql_query("UPDATE users SET `battle` ={$id},`zayavka`=0 WHERE `id`= {$user['id']} OR `id` = {$jert['id']}"); + header("Location:fbattle.php"); + //die(""); + } + } else { + echo 'Мазохист?...'; + } + //$bet=1; } else { - echo "Свиток рассыпался в ваших руках..."; - $bet=1; - } + echo "Свиток рассыпался в ваших руках..."; + $bet = 1; +} From 6a119b8e4d0b514e3add6ef79a4dc1a96e2a873b Mon Sep 17 00:00:00 2001 From: "Igor Barkov (iwork)" Date: Mon, 17 Feb 2020 17:36:41 +0200 Subject: [PATCH 2/5] =?UTF-8?q?=D0=A4=D0=B8=D0=BA=D1=81=D1=8B=20=D0=B7?= =?UTF-8?q?=D0=B0=D0=BF=D1=80=D0=BE=D1=81=D0=BE=D0=B2=20=D0=B2=20=D0=B1?= =?UTF-8?q?=D0=B0=D0=B7=D1=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fbattle.php | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/fbattle.php b/fbattle.php index c2f3827..cefd172 100644 --- a/fbattle.php +++ b/fbattle.php @@ -39,6 +39,7 @@ $fbattle = new fbattle($user['battle']); const timerID = setTimeout("refreshPeriodic()", 20000); } + timerID = setTimeout("refreshPeriodic()", 20000); - - + forest + + +
-
- - -
- - Уровень жизни - Уровень жизни - уровень жизни: 300/300 - +
+ + +
+ + Уровень жизни + Уровень жизни + уровень жизни: 300/300 + +
+
+
+ + ' . $error . ' + +
+
+
-
-
-
- - - - - - - - - - - - -
- '.$error.''; } ?>
\ No newline at end of file From 98407e76b20cf62fe12e1a072c02f41a0e699327 Mon Sep 17 00:00:00 2001 From: "Igor Barkov (iwork)" Date: Mon, 22 Jun 2020 18:17:34 +0300 Subject: [PATCH 5/5] Code cleaning. --- cronjobs/cron_bots_battle.php | 57 ++++++----------------------------- 1 file changed, 9 insertions(+), 48 deletions(-) diff --git a/cronjobs/cron_bots_battle.php b/cronjobs/cron_bots_battle.php index 38b8454..67cef02 100644 --- a/cronjobs/cron_bots_battle.php +++ b/cronjobs/cron_bots_battle.php @@ -208,11 +208,7 @@ class fbattle function chanse($p) { - if ($p > mt_rand(1, 100)) { - return true; - } else { - return false; - } + return $p > mt_rand(1, 100); } function get_info_by_id($id) @@ -253,21 +249,13 @@ class fbattle function get_chanse($persent) { $mm = 1000000; - if (mt_rand($mm, 100 * $mm) <= $persent * $mm) { - return true; - } else { - return false; - } + return mt_rand($mm, 100 * $mm) <= $persent * $mm; } - function get_block($who, $where_atack, $whom, $where_defend) + function get_block($where_atack, $where_defend) { $blocks = array('1' => array(1, 2), '2' => array(2, 3), '3' => array(3, 4), '4' => array(4, 1)); - if (!in_array($where_atack, $blocks[$where_defend])) { - return true; - } else { - return false; - } + return !in_array($where_atack, $blocks[$where_defend]); } function add_log($text) @@ -502,7 +490,6 @@ class fbattle } if ($lomka) { - $haos_flag = 0; foreach ($lomka as $k => $v) { if (mt_rand(1, 6) == 1) { $us = mysql_query('UPDATE `inventory` SET `duration` = (`duration`+1) WHERE `type` != 12 AND `dressed` = 1 AND `owner` = \'' . $v . '\''); @@ -635,11 +622,6 @@ class fbattle function end_gora() { if ($this->GetTimeout()) { - foreach ($this->team_mine as $v) { - if (in_array($v, array_keys($this->battle))) { - $vvv = $v; - } - } $this->AddToLog("" . date("H:i") . " Бой закончен по таймауту.
"); foreach ($this->team_enemy as $v => $k) { @@ -1093,11 +1075,7 @@ class fbattle $uid = $this->user['id']; } $ins = mysql_query('INSERT INTO `actions` (`uid`, `time`, `city`, `room`, `vars`, `ip`, `vals`) VALUES ("' . $uid . '", "' . $time . '", "capitalcity", "0", "' . mysql_real_escape_string($vars) . '", "' . mysql_real_escape_string($_SERVER['HTTP_X_REAL_IP']) . '", "' . mysql_real_escape_string($vls) . '")'); - if ($ins) { - return true; - } else { - return false; - } + return $ins; } function GetWeaponType($idwep) @@ -1124,7 +1102,6 @@ class fbattle function razmen_log($type, $kuda, $chem, $uron, $kto, $c1, $pokomy, $c2, $hp, $maxhp) { - $color = $this->gen_color($kto, $pokomy); if ($this->enemyhar['sex'] && $kto == $this->enemyhar['id']) { $sex1 = false; } @@ -1257,11 +1234,7 @@ class fbattle function get_blocks($where_atack, $where_defend) { $blocks = array('1' => array(1, 2), '2' => array(2, 3), '3' => array(3, 4), '4' => array(4, 1)); - if (!in_array($where_atack, $blocks[$where_defend])) { - return true; - } else { - return false; - } + return !in_array($where_atack, $blocks[$where_defend]); } function GetBlock($komy, $att, $def, $enemy) @@ -1270,19 +1243,11 @@ class fbattle switch ($komy) { case "me" : - if (in_array($this->battle[$enemy][$this->user['id']][0], $blocks[$def])) { - return true; - } else { - return false; - } + return in_array($this->battle[$enemy][$this->user['id']][0], $blocks[$def]); break; case "he" : - if (in_array($this->battle[$enemy][$this->user['id']][1], $blocks[$att])) { - return true; - } else { - return false; - } + return in_array($this->battle[$enemy][$this->user['id']][1], $blocks[$att]); break; } } @@ -1290,11 +1255,7 @@ class fbattle function GetChance($percent) { $mm = 1; - if (rand($mm, 100 * $mm) <= $percent * $mm) { - return true; - } else { - return false; - } + return rand($mm, 100 * $mm) <= $percent * $mm; } function SelectEnemy()