diff --git a/_incl_data/class/Battle.php b/_incl_data/class/Battle.php index 12135245..b1fd3c76 100644 --- a/_incl_data/class/Battle.php +++ b/_incl_data/class/Battle.php @@ -45,31 +45,18 @@ class Battle 'тьма' => 6, 'серая' => 7, ]; - - /** - * Параметры приёмов, которые, наверное, надо бы занести в БД. - * @var array|BattlePriem[] - */ - private array $prm; - /**Кэширование данных (?!)*/ public bool $cached = false; - /**Отображаем главное окно (1 - можно бить, 2 - ожидаем ход противника, 3 - Проиграли. Ожидаем завершения поединка)*/ public int $mainStatus = 1; - /** Информация о поединке.*/ public Info $i; - /**Информация о пользователях в этом бою*/ public array $users = []; - /**Информация о статах пользователей в этом бою. Фактичесчки $user->stats для каждого участинка поединко.*/ public array $stats = []; - /**Массив объектов бойцов*/ public array $fighters = []; - /**Список пользователей и их id в stats или users. * * Все id пользователей записываются в этот массив по очереди, где id выступает ключом, а значение @@ -78,43 +65,40 @@ class Battle * Например id пользователя = 555 , то $uids[555] выдаст его порядковый номер в массиве users \ stats */ public array $uids = []; - /**Список ударов в этом бою (действующих)*/ public array $atacks = []; - /**Список uid кто нанес удар и по кому $ga[ {id кто ударил} ][ {id кого ударил} ]*/ public array $ga = []; - + public int $hodID = 0; + public array $bots = []; + /** Ошибка (текст) */ + public string $e = ''; + public array $rehodeff = []; + /** Для номерных приёмов */ + public array $um_priem = []; // ID ботов + public array $pr_not_use = []; // i бота + public array $del_val = []; + /** + * Параметры приёмов, которые, наверное, надо бы занести в БД. + * @var array|BattlePriem[] + */ + private array $prm; //Если игрок нанес удар /**Список uid кто нанес удар и по кому $ga[ {id кого ударили} ][ {id кто ударил} ]*/ private array $ag = []; - public int $hodID = 0; + //Очистка кэша для ... private int|array $stnZbVs = 0; - public array $bots = []; // ID ботов - private array $iBots = []; // i бота + private array $iBots = []; private array $stnZb = []; - /** Выбранные зоны атаки и блока */ private array $uAtc = [ 'id' => 0, 'a' => [1 => 0, 2 => 0, 3 => 0, 4 => 0, 5 => 0], 'b' => 0, - ]; //Если игрок нанес удар - - /** Ошибка (текст) */ - public string $e = ''; - //Очистка кэша для ... + ]; private array $uclearc = []; private array $ucleari = []; - public array $rehodeff = []; private array $poglast = []; - - /** Для номерных приёмов */ - public array $um_priem = []; - private int $importUser = 0; - public array $pr_not_use = []; - public array $del_val = []; - private Finish $finish; public function __construct(private readonly Stat $statnames = new Stat()) @@ -123,37 +107,80 @@ class Battle $this->statnames->getBonus(); $this->finish = new Finish($this); - $this->prm = [1 => new BattlePriem(act: 1, typeOf: 5), + $this->prm = [ + 1 => new BattlePriem(act: 1, typeOf: 5), 2 => new BattlePriem(act: 2, typeOf: 3), 4 => new BattlePriem(act: 2, typeOf: 3), 7 => new BattlePriem(act: 1, typeOf: 4), - 290 => new BattlePriem(act: 1, typeOf: 4), - 294 => new BattlePriem(act: 2, typeOf: 0, moment: 0, momentEnd: 3), - 295 => new BattlePriem(act: 2, typeOf: 0, moment: 0, momentEnd: 3), - 296 => new BattlePriem(act: 2, typeOf: 0, moment: 0, momentEnd: 3), - 297 => new BattlePriem(act: 2, typeOf: 0, moment: 3), - 298 => new BattlePriem(act: 2, typeOf: 3), - 141 => new BattlePriem(act: 2, typeOf: 4), - 147 => new BattlePriem(act: 2, typeOf: 4), - 148 => new BattlePriem(act: 2, typeOf: 4), - 149 => new BattlePriem(act: 2, typeOf: 4), - 150 => new BattlePriem(act: 2, typeOf: 4), - 142 => new BattlePriem(act: 2, typeOf: 4), - 144 => new BattlePriem(act: 2, typeOf: 4), - 146 => new BattlePriem(act: 2, typeOf: 4), - 145 => new BattlePriem(act: 2, typeOf: 4), 8 => new BattlePriem(act: 1, typeOf: 1), 9 => new BattlePriem(act: 2, typeOf: 3), 10 => new BattlePriem(act: 1, typeOf: 1), 11 => new BattlePriem(act: 2, typeOf: 3), + 21 => new BattlePriem(act: 2, typeOf: 0, moment: 0, momentEnd: 3), + 22 => new BattlePriem(act: 2, typeOf: 0, moment: 0, momentEnd: 3), + 23 => new BattlePriem(act: 2, typeOf: 0, moment: 0, momentEnd: 3), + 24 => new BattlePriem(act: 2, typeOf: 0, moment: 3), + 33 => new BattlePriem(act: 2, typeOf: 0, moment: 0, momentEnd: 3), + 36 => new BattlePriem(act: 2, typeOf: 0, moment: 0, momentEnd: 3), + 42 => new BattlePriem(act: 2, typeOf: 0, moment: 0, momentEnd: 3), 45 => new BattlePriem(act: 1, typeOf: 4), 47 => new BattlePriem(act: 2, typeOf: 2), 48 => new BattlePriem(act: 1, typeOf: 1), 49 => new BattlePriem(act: 1, typeOf: 1), + 56 => new BattlePriem(act: 2, typeOf: 0, moment: 0, momentEnd: 3), + 57 => new BattlePriem(act: 2, typeOf: 0, moment: 0, momentEnd: 3), + 58 => new BattlePriem(act: 2, typeOf: 0, moment: 0, momentEnd: 3), + 59 => new BattlePriem(act: 2, typeOf: 0, moment: 0, momentEnd: 3), + 60 => new BattlePriem(act: 2, typeOf: 0, moment: 0, momentEnd: 3), + 70 => new BattlePriem(act: 2, typeOf: 0, moment: 0, momentEnd: 3), + 71 => new BattlePriem(act: 2, typeOf: 0, moment: 0, momentEnd: 3), + 72 => new BattlePriem(act: 2, typeOf: 0, moment: 0, momentEnd: 3), + 73 => new BattlePriem(act: 2, typeOf: 0, moment: 0, momentEnd: 3), + 74 => new BattlePriem(act: 2, typeOf: 0, moment: 0, momentEnd: 3), + 75 => new BattlePriem(act: 2, typeOf: 0, moment: 0, momentEnd: 3), + 76 => new BattlePriem(act: 2, typeOf: 0, moment: 0, momentEnd: 3), + 77 => new BattlePriem(act: 2, typeOf: 0, moment: 0, momentEnd: 3), + 78 => new BattlePriem(act: 2, typeOf: 0, moment: 0, momentEnd: 3), + 79 => new BattlePriem(act: 2, typeOf: 0, moment: 0, momentEnd: 3), + 80 => new BattlePriem(act: 2, typeOf: 0, moment: 0, momentEnd: 3), + 81 => new BattlePriem(act: 2, typeOf: 0, moment: 0, momentEnd: 3), + 82 => new BattlePriem(act: 2, typeOf: 0, moment: 0, momentEnd: 3), + 83 => new BattlePriem(act: 2, typeOf: 0, moment: 0, momentEnd: 3), + 84 => new BattlePriem(act: 2, typeOf: 0, moment: 0, momentEnd: 3), + 85 => new BattlePriem(act: 2, typeOf: 0, moment: 0, momentEnd: 3), + 86 => new BattlePriem(act: 2, typeOf: 0, moment: 0, momentEnd: 3), + 87 => new BattlePriem(act: 2, typeOf: 0, moment: 0, momentEnd: 3), + 88 => new BattlePriem(act: 2, typeOf: 0, moment: 0, momentEnd: 3), + 89 => new BattlePriem(act: 2, typeOf: 0, moment: 0, momentEnd: 3), + 90 => new BattlePriem(act: 2, typeOf: 0, moment: 0, momentEnd: 3), + 121 => new BattlePriem(act: 2, typeOf: 0, moment: 0, momentEnd: 3), + 122 => new BattlePriem(act: 2, typeOf: 0, moment: 0, momentEnd: 3), + 123 => new BattlePriem(act: 2, typeOf: 0, moment: 0, momentEnd: 3), + 124 => new BattlePriem(act: 2, typeOf: 0, moment: 0, momentEnd: 3), + 125 => new BattlePriem(act: 2, typeOf: 0, moment: 0, momentEnd: 3), 138 => new BattlePriem(act: 2, typeOf: 3), 140 => new BattlePriem(act: 1, typeOf: 4), + 141 => new BattlePriem(act: 2, typeOf: 4), + 142 => new BattlePriem(act: 2, typeOf: 4), + 144 => new BattlePriem(act: 2, typeOf: 4), + 145 => new BattlePriem(act: 2, typeOf: 4), + 146 => new BattlePriem(act: 2, typeOf: 4), + 147 => new BattlePriem(act: 2, typeOf: 4), + 148 => new BattlePriem(act: 2, typeOf: 4), + 149 => new BattlePriem(act: 2, typeOf: 4), + 150 => new BattlePriem(act: 2, typeOf: 4), + 175 => new BattlePriem(act: 2, typeOf: 8), + 176 => new BattlePriem(act: 2, typeOf: 8), + 177 => new BattlePriem(act: 2, typeOf: 8), + 178 => new BattlePriem(act: 2, typeOf: 8), + 179 => new BattlePriem(act: 2, typeOf: 8), 193 => new BattlePriem(act: 2, typeOf: 3), 204 => new BattlePriem(act: 2, typeOf: 0, moment: 3), + 206 => new BattlePriem(act: 2, typeOf: 8), + 207 => new BattlePriem(act: 2, typeOf: 8), + 208 => new BattlePriem(act: 2, typeOf: 8), + 209 => new BattlePriem(act: 2, typeOf: 8), + 210 => new BattlePriem(act: 2, typeOf: 8), 211 => new BattlePriem(act: 1, typeOf: 4), 213 => new BattlePriem(act: 1, typeOf: 4), 215 => new BattlePriem(act: 1, typeOf: 1), @@ -167,78 +194,40 @@ class Battle 231 => new BattlePriem(act: 2, typeOf: 0, moment: 3), 234 => new BattlePriem(act: 2, typeOf: 4), 235 => new BattlePriem(act: 2, typeOf: 3), - 342 => new BattlePriem(act: 0, typeOf: 0), - 343 => new BattlePriem(act: 0, typeOf: 0), 237 => new BattlePriem(act: 2, typeOf: 3), 239 => new BattlePriem(act: 2, typeOf: 3), 240 => new BattlePriem(act: 2, typeOf: 5), - 21 => new BattlePriem(act: 2, typeOf: 0, moment: 0, momentEnd: 3), - 73 => new BattlePriem(act: 2, typeOf: 0, moment: 0, momentEnd: 3), - 74 => new BattlePriem(act: 2, typeOf: 0, moment: 0, momentEnd: 3), - 75 => new BattlePriem(act: 2, typeOf: 0, moment: 0, momentEnd: 3), - 76 => new BattlePriem(act: 2, typeOf: 0, moment: 0, momentEnd: 3), - 77 => new BattlePriem(act: 2, typeOf: 0, moment: 0, momentEnd: 3), - 78 => new BattlePriem(act: 2, typeOf: 0, moment: 0, momentEnd: 3), - 79 => new BattlePriem(act: 2, typeOf: 0, moment: 0, momentEnd: 3), - 22 => new BattlePriem(act: 2, typeOf: 0, moment: 0, momentEnd: 3), - 80 => new BattlePriem(act: 2, typeOf: 0, moment: 0, momentEnd: 3), - 81 => new BattlePriem(act: 2, typeOf: 0, moment: 0, momentEnd: 3), - 82 => new BattlePriem(act: 2, typeOf: 0, moment: 0, momentEnd: 3), - 83 => new BattlePriem(act: 2, typeOf: 0, moment: 0, momentEnd: 3), - 84 => new BattlePriem(act: 2, typeOf: 0, moment: 0, momentEnd: 3), - 36 => new BattlePriem(act: 2, typeOf: 0, moment: 0, momentEnd: 3), - 85 => new BattlePriem(act: 2, typeOf: 0, moment: 0, momentEnd: 3), - 86 => new BattlePriem(act: 2, typeOf: 0, moment: 0, momentEnd: 3), - 87 => new BattlePriem(act: 2, typeOf: 0, moment: 0, momentEnd: 3), - 88 => new BattlePriem(act: 2, typeOf: 0, moment: 0, momentEnd: 3), - 89 => new BattlePriem(act: 2, typeOf: 0, moment: 0, momentEnd: 3), - 90 => new BattlePriem(act: 2, typeOf: 0, moment: 0, momentEnd: 3), - 23 => new BattlePriem(act: 2, typeOf: 0, moment: 0, momentEnd: 3), - 70 => new BattlePriem(act: 2, typeOf: 0, moment: 0, momentEnd: 3), - 71 => new BattlePriem(act: 2, typeOf: 0, moment: 0, momentEnd: 3), - 72 => new BattlePriem(act: 2, typeOf: 0, moment: 0, momentEnd: 3), + 245 => new BattlePriem(act: 2, typeOf: 9), + 248 => new BattlePriem(act: 2, typeOf: 4), + 249 => new BattlePriem(act: 2, typeOf: 4), + 251 => new BattlePriem(act: 2, typeOf: 0, moment: 0, momentEnd: 3), + 252 => new BattlePriem(act: 2, typeOf: 0, moment: 0, momentEnd: 3), + 255 => new BattlePriem(act: 2, typeOf: 8), 269 => new BattlePriem(act: 2, typeOf: 9), + 270 => new BattlePriem(act: 2, typeOf: 5, typeSec: 5), + 273 => new BattlePriem(act: 1, typeOf: 4), 276 => new BattlePriem(act: 2, typeOf: 9), 277 => new BattlePriem(act: 2, typeOf: 9), - 270 => new BattlePriem(act: 2, typeOf: 5, typeSec: 5), 280 => new BattlePriem(act: 2, typeOf: 0, moment: 0, momentEnd: 3), 281 => new BattlePriem(act: 2, typeOf: 5), 282 => new BattlePriem(act: 2, typeOf: 5), - 24 => new BattlePriem(act: 2, typeOf: 0, moment: 3), - 210 => new BattlePriem(act: 2, typeOf: 8), - 209 => new BattlePriem(act: 2, typeOf: 8), - 208 => new BattlePriem(act: 2, typeOf: 8), - 207 => new BattlePriem(act: 2, typeOf: 8), - 206 => new BattlePriem(act: 2, typeOf: 8), 284 => new BattlePriem(act: 2, typeOf: 8), - 175 => new BattlePriem(act: 2, typeOf: 8), - 176 => new BattlePriem(act: 2, typeOf: 8), - 177 => new BattlePriem(act: 2, typeOf: 8), - 178 => new BattlePriem(act: 2, typeOf: 8), - 179 => new BattlePriem(act: 2, typeOf: 8), - 42 => new BattlePriem(act: 2, typeOf: 0, moment: 0, momentEnd: 3), - 121 => new BattlePriem(act: 2, typeOf: 0, moment: 0, momentEnd: 3), - 122 => new BattlePriem(act: 2, typeOf: 0, moment: 0, momentEnd: 3), - 123 => new BattlePriem(act: 2, typeOf: 0, moment: 0, momentEnd: 3), - 124 => new BattlePriem(act: 2, typeOf: 0, moment: 0, momentEnd: 3), - 125 => new BattlePriem(act: 2, typeOf: 0, moment: 0, momentEnd: 3), - 249 => new BattlePriem(act: 2, typeOf: 4), - 248 => new BattlePriem(act: 2, typeOf: 4), - 251 => new BattlePriem(act: 2, typeOf: 0, moment: 0, momentEnd: 3), - 252 => new BattlePriem(act: 2, typeOf: 0, moment: 0, momentEnd: 3), - 273 => new BattlePriem(act: 1, typeOf: 4), 286 => new BattlePriem(act: 1, typeOf: 4), 287 => new BattlePriem(act: 1, typeOf: 4), 288 => new BattlePriem(act: 1, typeOf: 4), - 255 => new BattlePriem(act: 2, typeOf: 8), - 337 => new BattlePriem(act: 2, typeOf: 5), - 33 => new BattlePriem(act: 2, typeOf: 0, moment: 0, momentEnd: 3), - 56 => new BattlePriem(act: 2, typeOf: 0, moment: 0, momentEnd: 3), - 57 => new BattlePriem(act: 2, typeOf: 0, moment: 0, momentEnd: 3), - 58 => new BattlePriem(act: 2, typeOf: 0, moment: 0, momentEnd: 3), - 59 => new BattlePriem(act: 2, typeOf: 0, moment: 0, momentEnd: 3), - 60 => new BattlePriem(act: 2, typeOf: 0, moment: 0, momentEnd: 3), - 245 => new BattlePriem(act: 2, typeOf: 9), + 290 => new BattlePriem(act: 1, typeOf: 4), + 294 => new BattlePriem(act: 2, typeOf: 0, moment: 0, momentEnd: 3), + 295 => new BattlePriem(act: 2, typeOf: 0, moment: 0, momentEnd: 3), + 296 => new BattlePriem(act: 2, typeOf: 0, moment: 0, momentEnd: 3), + 297 => new BattlePriem(act: 2, typeOf: 0, moment: 3), + 298 => new BattlePriem(act: 2, typeOf: 3), + 299 => new BattlePriem(act: 2, typeOf: 0, moment: 0, momentEnd: 3), + 300 => new BattlePriem(act: 2, typeOf: 0, moment: 0, momentEnd: 3), + 301 => new BattlePriem(act: 2, typeOf: 0, moment: 0, momentEnd: 3), + 302 => new BattlePriem(act: 2, typeOf: 0, moment: 0, momentEnd: 3), + 303 => new BattlePriem(act: 2, typeOf: 4), + 304 => new BattlePriem(act: 2, typeOf: 0, moment: 0, momentEnd: 3), + 305 => new BattlePriem(act: 2, typeOf: 0, moment: 0, momentEnd: 3), 327 => new BattlePriem(act: 2, typeOf: 0, moment: 3), 328 => new BattlePriem(act: 2, typeOf: 0, moment: 0, momentEnd: 3), 329 => new BattlePriem(act: 2, typeOf: 0, moment: 0, momentEnd: 3), @@ -248,17 +237,33 @@ class Battle 333 => new BattlePriem(act: 2, typeOf: 0, moment: 3), 334 => new BattlePriem(act: 2, typeOf: 0, moment: 0, momentEnd: 3), 335 => new BattlePriem(act: 2, typeOf: 0, moment: 0, momentEnd: 3), - 299 => new BattlePriem(act: 2, typeOf: 0, moment: 0, momentEnd: 3), - 300 => new BattlePriem(act: 2, typeOf: 0, moment: 0, momentEnd: 3), - 301 => new BattlePriem(act: 2, typeOf: 0, moment: 0, momentEnd: 3), - 302 => new BattlePriem(act: 2, typeOf: 0, moment: 0, momentEnd: 3), - 303 => new BattlePriem(act: 2, typeOf: 4), - 304 => new BattlePriem(act: 2, typeOf: 0, moment: 0, momentEnd: 3), - 305 => new BattlePriem(act: 2, typeOf: 0, moment: 0, momentEnd: 3), + 337 => new BattlePriem(act: 2, typeOf: 5), + 342 => new BattlePriem(act: 0, typeOf: 0), + 343 => new BattlePriem(act: 0, typeOf: 0), ]; } + /** + * @param int|null $experience + * @param bool $hardcore поединок с гарантированной травмой + * @return array|int[] + */ + public static function getType(?int $experience, bool $hardcore = false): array + { + return match (true) { + $experience >= 5000000 => [150, 150, 'Судный День', 'Судный День'], + $experience >= 2500000 => [100, 125, 'Эпохальная Битва', 'Кровавое Побоище'], + $experience >= 1000000 => [75, 100, 'Историческая Битва', 'Кровавая Сеча'], + $experience >= 500000 => [50, 75, 'Величайшая Битва', 'Кровавая Резня'], + $experience >= 100000 => [25, 50, 'Великая Битва', 'Кровавая Битва'], + $hardcore => [150, 150, 'Жесточайшее Сражение', 'Жесточайшее Сражение'], + default => [0, 0, 'Поединок', 'Кровавый Поединок'], + }; + } + + //JS информация о игроке + public function initRefresh(User $user): bool { $this->i = new Info($user->info['battle']); @@ -272,8 +277,6 @@ class Battle return !empty($this->i->id); } - //JS информация о игроке - public function maginfoattack($u1, $u2, $type): int { /* @@ -296,78 +299,81 @@ class Battle return ' magelogin=' . $v_l . ' onMouseOver=top.hi(this,maginfo(' . $v_z . ',' . $v_p . ',' . $v_m . ',this),event,3,1,1,1,null); onMouseOut=top.hic(); onMouseDown=top.hic(); '; } - public function hphe($uid, $hp, $false_t7 = false): float + + //Мини лог + + public function hphe($uid, $hp, $false_t7 = false): int { if (!isset($this->stats[$this->uids[$uid]])) { echo 'WARNING! ОШИБКА! ПОТЕРЯНА ПЕРЕМЕННАЯ ЗДОРОВЬЯ ПЕРСОНАЖА!'; - } else { - $hpnow = floor($this->stats[$this->uids[$uid]]['hpNow']); - $hpall = $this->stats[$this->uids[$uid]]['hpAll']; - if ($hp > 0) { - //Хиляем - if ($hpnow + $hp > $hpall) { - $hpli = $hpnow + $hp - $hpall; - $hp -= $hpli; - } - if (isset($this->stats[$this->uids[$uid]]['min_heal_proc']) && $this->stats[$this->uids[$uid]]['min_heal_proc'] < -99) { - $hp = 0; - } else { - $hp = $hp / 100 * (100 + $this->stats[$this->uids[$uid]]['min_heal_proc']); - } - //Отнимаем тактику - if (!$false_t7) { - if ($this->users[$this->uids[$uid]]['tactic7'] <= 0) { - $hp = 0; - $this->users[$this->uids[$uid]]['tactic7'] = 0; - $this->stats[$this->uids[$uid]]['tactic7'] = $this->users[$this->uids[$uid]]['tactic7']; - } else { - $gdhh = round($hp / $this->stats[$this->uids[$uid]]['hpAll'] * 10, 2); - if ($gdhh == 0) { - $gdhh = 0.01; - } - - $gdhd = round($this->users[$this->uids[$uid]]['tactic7'] / $gdhh * 100); - - $this->users[$this->uids[$uid]]['tactic7'] = round( - ($this->users[$this->uids[$uid]]['tactic7'] - $gdhh), - 2 - ); - if ($this->users[$this->uids[$uid]]['tactic7'] < 0) { - $this->users[$this->uids[$uid]]['tactic7'] = 0; - } - $this->stats[$this->uids[$uid]]['tactic7'] = $this->users[$this->uids[$uid]]['tactic7']; - if ($gdhd < 100) { - $hp = floor($hp / 100 * $gdhd); - } - } - } - } elseif ($hp < 0) { - //Отнимаемф - if ($hpnow + $hp < 0) { - $hpli = $hpnow + $hp; - $hp += -($hpli); - } - } - - if ($this->stats[$this->uids[$uid]]['hpNow'] < 1) { - $hp = 0; - } - - $this->stats[$this->uids[$uid]]['last_hp'] = -$hp; - Db::sql( - 'update stats set last_hp = ?, tactic7 = ? where id = ?', [ - $this->users[$this->uids[$uid]]['last_hp'], - $this->users[$this->uids[$uid]]['tactic7'], - $uid, - ] - ); + return (int)$hp; } - return (int)floor($hp); + $hpnow = floor($this->stats[$this->uids[$uid]]['hpNow']); + $hpall = $this->stats[$this->uids[$uid]]['hpAll']; + if ($hp > 0) { + //Хиляем + if ($hpnow + $hp > $hpall) { + $hpli = $hpnow + $hp - $hpall; + $hp -= $hpli; + } + if (isset($this->stats[$this->uids[$uid]]['min_heal_proc']) && $this->stats[$this->uids[$uid]]['min_heal_proc'] < -99) { + $hp = 0; + } else { + $hp = $hp / 100 * (100 + $this->stats[$this->uids[$uid]]['min_heal_proc']); + } + //Отнимаем тактику + if (!$false_t7) { + if ($this->users[$this->uids[$uid]]['tactic7'] <= 0) { + $hp = 0; + $this->users[$this->uids[$uid]]['tactic7'] = 0; + $this->stats[$this->uids[$uid]]['tactic7'] = $this->users[$this->uids[$uid]]['tactic7']; + } else { + $gdhh = round($hp / $this->stats[$this->uids[$uid]]['hpAll'] * 10, 2); + if ($gdhh == 0) { + $gdhh = 0.01; + } + + $gdhd = round($this->users[$this->uids[$uid]]['tactic7'] / $gdhh * 100); + + $this->users[$this->uids[$uid]]['tactic7'] = round( + ($this->users[$this->uids[$uid]]['tactic7'] - $gdhh), + 2 + ); + if ($this->users[$this->uids[$uid]]['tactic7'] < 0) { + $this->users[$this->uids[$uid]]['tactic7'] = 0; + } + $this->stats[$this->uids[$uid]]['tactic7'] = $this->users[$this->uids[$uid]]['tactic7']; + if ($gdhd < 100) { + $hp = floor($hp / 100 * $gdhd); + } + } + } + } elseif ($hp < 0) { + //Отнимаемф + if ($hpnow + $hp < 0) { + $hpli = $hpnow + $hp; + $hp += -($hpli); + } + } + + if ($this->stats[$this->uids[$uid]]['hpNow'] < 1) { + $hp = 0; + } + $this->stats[$this->uids[$uid]]['last_hp'] = -$hp; + + Db::sql( + 'update stats set last_hp = ?, tactic7 = ? where id = ?', [ + $this->users[$this->uids[$uid]]['last_hp'], + $this->users[$this->uids[$uid]]['tactic7'], + $uid, + ] + ); + + return (int)$hp; } - - //Мини лог + //Проверяем завершение боя /** * Какая-то хуедрыга для номерных файлов-приёмов @@ -378,14 +384,10 @@ class Battle */ public function deleffm(int $pid, int $uid, int $id): void { - if ($id > 0) { - Db::sql('delete from eff_users where id = ? and v1 = ? and v2 != 0', [$id, 'priem']); - } else { - Db::sql('delete from eff_users where uid = ? and v1 = ? and v2 = ?', [$uid, 'priem', $pid]); - } + Db::sql("delete from eff_users where v1 = 'priem' and (id = ? and v2 != 0 or uid = ? and v2 = ?)", [$id, $uid, $pid]); } - //Проверяем завершение боя + //завершение поединка public function clear_cache_start(): void { @@ -393,8 +395,6 @@ class Battle Db::sql('delete from battle_cache where uid in (?)', [$uids]); } - //завершение поединка - /** * Проверка урон приемов над защитными. * Игрок 1 бьет по Игроку 2 при помощи приема на hp ед. здоровья. @@ -437,6 +437,8 @@ class Battle Db::sql('update stats set battle_yron = battle_yron + ? where id = ?', [$hpDamageValue, $uid]); } + //Проводим удар + public function myInfo($id, $t): string { global $u; @@ -708,7 +710,6 @@ JS; info_reflesh(`$t`,`{$ur['id']}`,`$upinfo`,`{$ur['obraz']}`,`$hpmp[0]`,`$hpmp[1]`,`$hpmp[2]`,`$hpmp[3]`,0,`{$ur['sex']}`,`$ef`,`$stsua`,`{$ur['align']}`,`{$ur['zag']}`);shpb(); JS; - $i = 0; if (is_array($itm)) { while ($i < count($itm)) { @@ -797,7 +798,7 @@ JS; return $info; } - //Проводим удар + //Запускаем магические предметы, если в них что-то встроено /** * Проверка на выживших. @@ -823,8 +824,6 @@ JS; return $tl > 1; } - //Запускаем магические предметы, если в них что-то встроено - public function testFinish(): void { global $u; @@ -1031,14 +1030,12 @@ JS; //конец излома $this->finish->finishBattle($tml, $tmv); mysql_query( - 'INSERT INTO `izlom_rating` (`uid`,`time`,`voln`,`level`,`bots`,`rep`,`obr`,`btl`) VALUES ("' . $u->info['id'] . '","' . time( - ) . '","' . $this->i->izlomroundsee . '","' . $this->i->izlomlvl . '","0","0","' . ($this->i->izlomobr - $this->i->izlomobrnow) . '","' . $this->i->id . '")' + 'INSERT INTO `izlom_rating` (`uid`,`time`,`voln`,`level`,`bots`,`rep`,`obr`,`btl`) VALUES ("' . $u->info['id'] . '","' . time() . '","' . $this->i->izlomroundsee . '","' . $this->i->izlomlvl . '","0","0","' . ($this->i->izlomobr - $this->i->izlomobrnow) . '","' . $this->i->id . '")' ); } else { $this->i->setIzlomround($iz['round']); mysql_query( - 'UPDATE `battle` SET `izlomObrNow` = ' . $obr . ',`izlomObr` = `izlomObr` + ' . $obr . ',`timeout` = (`timeout`+5),`izlomRound` = "' . ($this->i->getIzlomround( - ) + 1) . '",`izlomRoundSee` = `izlomRoundSee`+1 WHERE `id` = "' . $this->i->id . '" LIMIT 1' + 'UPDATE `battle` SET `izlomObrNow` = ' . $obr . ',`izlomObr` = `izlomObr` + ' . $obr . ',`timeout` = (`timeout`+5),`izlomRound` = "' . ($this->i->getIzlomround() + 1) . '",`izlomRoundSee` = `izlomRoundSee`+1 WHERE `id` = "' . $this->i->id . '" LIMIT 1' ); $this->stats[$this->uids[$u->info['id']]]['hpNow'] += $this->stats[$this->uids[$u->info['id']]]['hpAll'] * 0.25; $this->stats[$this->uids[$u->info['id']]]['mpNow'] += $this->stats[$this->uids[$u->info['id']]]['mpAll'] * 0.25; @@ -1139,11 +1136,13 @@ JS; ); } + //Поглощение урона + /** * @param array $botLogins - * @param int $counter - * @param int $obr - * @param int $unique для совместимости с непонятным вызовом User->addAction + * @param int $counter + * @param int $obr + * @param int $unique для совместимости с непонятным вызовом User->addAction * при вызове уникального монстра. * @return void */ @@ -1228,19 +1227,19 @@ JS; Log::add($arr); } - //Расчет контрудара игроков + //Добавляем статистику /** Осторожно! Подключаются файлы!!! * Трогать очень осторожно. Этот шайтан как-то проверяет приёмы на враге * и рассчитывает урон учитывая и эти приёмы тоже. - * @param int $uid1 - * @param int $uid2 - * @param int $priem + * @param int $uid1 + * @param int $uid2 + * @param int $priem * @param $yron - * @param int $profil + * @param int $profil * @param bool $stabil * @param bool $test - * @param int $inlog + * @param int $inlog * @return float|int|mixed */ public function testYronPriem( @@ -1252,7 +1251,8 @@ JS; bool $stabil, bool $test = false, int $inlog = 0 - ): mixed { + ): mixed + { /** * profil = { @@ -1341,8 +1341,6 @@ JS; return $yron; } - //Добавляем статистику - public function priemYronSave($u1, $u2, $yron, $type = 0): void { //$type 0 - урон , 1 - хил @@ -1418,6 +1416,8 @@ JS; ); } + //Добавляем статистику ударов + public function testUserInfoBattle($uid): void { global $u; @@ -1445,7 +1445,7 @@ JS; //fixme много чего повторно берется } - //Добавляем статистику ударов + //Добавляем размены в лог /** * Расчет опыта @@ -1479,7 +1479,7 @@ JS; return (int)round($addExp); } - //Добавляем размены в лог + //Добавляем в лог действия приема public function addNewStat($stat): void { @@ -1529,7 +1529,7 @@ JS; } } - //Добавляем в лог действия приема + //Считаем контру public function lookLog(): string { @@ -1610,7 +1610,8 @@ JS; return $js; } - //Считаем контру + + //Расчитываем статы для конкретной зоны атаки public function lookmLog(): string { @@ -1690,8 +1691,7 @@ JS; return $js; } - - //Расчитываем статы для конкретной зоны атаки + //Считаем урон public function weaponAt22($item, $st): array { @@ -1708,7 +1708,8 @@ JS; ]; } - //Считаем урон + + //Добавляем новую статистику игрока public function autoSmena(): void { @@ -1771,8 +1772,7 @@ JS; } } - - //Добавляем новую статистику игрока + //Проверяем приемы public function smena($uid, $auto = false, $lastdie = false): int|string { @@ -1806,7 +1806,7 @@ JS; return 1; } - //Проверяем приемы + //Приемы которые используются моментально public function testActions(): void { @@ -2022,7 +2022,7 @@ JS; } } - //Приемы которые используются моментально + //Приемы которые используются моментально (в конце хода) private function botAtack($uid, $pl, $tp): void { @@ -2085,7 +2085,7 @@ JS; } } - //Приемы которые используются моментально (в конце хода) + //Используем приемы public function startAtack($id): void { @@ -2278,40 +2278,22 @@ JS; $i++; } //Обновляем задержки предметов - mysql_query( - 'UPDATE `items_users` SET `btl_zd` = `btl_zd` - 1 WHERE (`uid` = "' . $this->atacks[$id]['uid1'] . '" OR `uid` = "' . $this->atacks[$id]['uid2'] . '") AND `btl_zd` > 0 AND `inOdet` > 0 LIMIT 100' - ); - mysql_query( - 'UPDATE `users` SET `notrhod` = "-1" WHERE `id` = "' . $this->atacks[$id]['uid1'] . '" OR `id` = "' . $this->atacks[$id]['uid2'] . '" LIMIT 2' - ); + Db::sql('update items_users set btl_zd = btl_zd - 1 where (uid = ? or uid = ?) and btl_zd > 0 and inOdet > 0', [$this->atacks[$id]['uid1'], $this->atacks[$id]['uid2']]); + Db::sql('update users set notrhod = -1 where id = ? or id = ?', [$this->atacks[$id]['uid1'], $this->atacks[$id]['uid2']]); - //Обновляем задержки пирожков - mysql_query( - 'UPDATE `pirogi` SET `hod` = `hod` - 1 WHERE `btl` = "' . $this->i->id . '" AND (`uid` = "' . $this->atacks[$id]['uid1'] . '" OR `uid` = "' . $this->atacks[$id]['uid2'] . '")' - ); - mysql_query( - 'UPDATE `tactic` SET `hod` = `hod` - 1 WHERE `btl` = "' . $this->i->id . '" AND (`uid` = "' . $this->atacks[$id]['uid1'] . '" OR `uid` = "' . $this->atacks[$id]['uid2'] . '")' - ); + //Обновляем задержки заклинаний, пирогов, тактик + Db::sql('update pirogi set hod = hod - 1 where btl = ? and (uid = ? or uid = ?)', [$this->i->id, $this->atacks[$id]['uid1'], $this->atacks[$id]['uid2']]); + Db::sql('update tactic set hod = hod - 1 where btl = ? and (uid = ? or uid = ?)', [$this->i->id, $this->atacks[$id]['uid1'], $this->atacks[$id]['uid2']]); + Db::sql('update spells set hod = hod - 1 where btl = ? and (uid = ? or uid = ?)', [$this->i->id, $this->atacks[$id]['uid1'], $this->atacks[$id]['uid2']]); - //Тактики - mysql_query('DELETE FROM `pirogi` WHERE `btl` = "' . $this->i->id . '" AND `hod` < 1'); - mysql_query('DELETE FROM `tactic` WHERE `btl` = "' . $this->i->id . '" AND `hod` < 1'); - - //Обновляем задержки пирожков - mysql_query( - 'UPDATE `spells` SET `hod` = `hod` - 1 WHERE `btl` = "' . $this->i->id . '" AND (`uid` = "' . $this->atacks[$id]['uid1'] . '" OR `uid` = "' . $this->atacks[$id]['uid2'] . '")' - ); - mysql_query('DELETE FROM `spells` WHERE `btl` = "' . $this->i->id . '" AND `hod` < 1'); + Db::sql('delete from pirogi where btl = ? and hod < 1', [$this->i->id]); + Db::sql('delete from tactic where btl = ? and hod < 1', [$this->i->id]); + Db::sql('delete from spells where btl = ? and hod < 1', [$this->i->id]); //Обновляем данные в battle_users - mysql_query( - 'UPDATE `battle_users` SET `hp` = "' . $this->stats[$this->uids[$this->atacks[$id]['uid1']]]['hpNow'] . '" - WHERE `battle` = "' . $this->i->id . '" AND `uid` = "' . $this->atacks[$id]['uid1'] . '" LIMIT 1' - ); - mysql_query( - 'UPDATE `battle_users` SET `hp` = "' . $this->stats[$this->uids[$this->atacks[$id]['uid2']]]['hpNow'] . '" - WHERE `battle` = "' . $this->i->id . '" AND `uid` = "' . $this->atacks[$id]['uid2'] . '" LIMIT 1' - ); + Db::sql('update battle_users set hp = ? where battle = ? and uid = ?', [$this->stats[$this->uids[$this->atacks[$id]['uid1']]]['hpNow'], $this->i->id, $this->atacks[$id]['uid1']]); + Db::sql('update battle_users set hp = ? where battle = ? and uid = ?', [$this->stats[$this->uids[$this->atacks[$id]['uid2']]]['hpNow'], $this->i->id, $this->atacks[$id]['uid2']]); + //Восстановление манны 25% от мудрости за ход if ($this->stats[$this->uids[$this->atacks[$id]['uid1']]]['yhod'] > 0) { @@ -2451,10 +2433,10 @@ JS; $pvr['mpSee'] = '--'; } - $btl->stats[$btl->uids[$pvr['uid']]]['mpNow'] = $pvr['mpNow']; - $btl->users[$btl->uids[$pvr['uid']]]['mpNow'] = $pvr['mpNow']; + $this->stats[$this->uids[$pvr['uid']]]['mpNow'] = $pvr['mpNow']; + $this->users[$this->uids[$pvr['uid']]]['mpNow'] = $pvr['mpNow']; mysql_query( - 'UPDATE `stats` SET `mpNow` = "' . $btl->stats[$btl->uids[$pvr['uid']]]['mpNow'] . '" WHERE `id` = "' . $pvr['uid'] . '" LIMIT 1' + 'UPDATE `stats` SET `mpNow` = "' . $this->stats[$this->uids[$pvr['uid']]]['mpNow'] . '" WHERE `id` = "' . $pvr['uid'] . '" LIMIT 1' ); $pvr['text'] = $this->addlt(1, 21, $this->users[$this->uids[$pvr['uid']]]['sex']); @@ -2557,44 +2539,9 @@ JS; } $j++; } - //Проверяем - if (Config::get('propsk_die') > 0 && $this->i->razdel == 0 && $this->i->dnId == 0 && $this->i->izlom == 0) { - $cn1 = mysql_fetch_array( - mysql_query( - 'SELECT COUNT(*) FROM `battle_out` WHERE `battle` = "' . $this->i->id . '" AND `uid1` = "' . $this->atacks[$id]['uid1'] . '" LIMIT 1' - ) - ); - $cn2 = mysql_fetch_array( - mysql_query( - 'SELECT COUNT(*) FROM `battle_out` WHERE `battle` = "' . $this->i->id . '" AND `uid1` = "' . $this->atacks[$id]['uid2'] . '" LIMIT 1' - ) - ); - if ($cn1[0] > 3) { - $pvr['text2'] = '{tm1} Персонаж {u1} был убит из-за большого количества пропусков хода.'; - $this->priemAddLog( - $id, 1, 2, $this->atacks[$id]['uid1'], 0, '', - $pvr['text2'], - $this->hodID - ); - unset($pvr); - mysql_query( - 'UPDATE `stats` SET `hpNow` = 0 WHERE `id` = "' . $this->atacks[$id]['uid1'] . '" LIMIT 1' - ); - } - if ($cn2[0] > Config::get('propsk_die')) { - $pvr['text2'] = '{tm1} Персонаж {u1} был убит из-за большого количества пропусков хода.'; - $this->priemAddLog( - $id, 1, 2, $this->atacks[$id]['uid2'], 0, '', - $pvr['text2'], - $this->hodID - ); - unset($pvr); - mysql_query( - 'UPDATE `stats` SET `hpNow` = 0 WHERE `id` = "' . $this->atacks[$id]['uid2'] . '" LIMIT 1' - ); - } - } - // + + $this->deathByTimeout($id); + //Обновляем текущего противника if ($u->info['id'] == $this->atacks[$id]['uid1']) { $u->info['enemy'] = $this->users[$this->uids[$this->atacks[$id]['uid1']]]['enemy']; @@ -2614,14 +2561,12 @@ JS; mysql_query('DELETE FROM `battle_act` WHERE `id` = "' . $id . '" LIMIT 1'); } - //Используем приемы - /** Осторожно! Подключаются файлы!!! * @param $pl * @param $u1 - * @param int $t + * @param int $t * @param int|array $u2 - * @param string $rznm + * @param string $rznm * @return void */ public function delPriem( @@ -2630,7 +2575,8 @@ JS; int $t = 1, int|array $u2 = 0, string $rznm = 'Очиститься Кровью' - ): void { + ): void + { global $u, $priem; if (!isset($pl['priem']['id']) || isset($this->del_val['eff'][$pl['priem']['id']])) { return; @@ -2689,6 +2635,12 @@ JS; //Повторная проверка приемов + /** + * Расчет количества блоков и противников? + * @param $uid + * @param $uid2 + * @return void + */ private function testZonb($uid, $uid2): void { $zba = []; @@ -2763,8 +2715,8 @@ JS; //Проверка действия приема - /** + * Магия предметов? * Осторожно! Подключаются файлы!!! * @param int $uid1 * @param int $uid2 НЕ УДАЛЯТЬ!!! @@ -2786,19 +2738,100 @@ JS; continue; } if ($end > 0) { - if (file_exists('priems/' . $e['bm_a1'] . '.end.php')) { - require_once 'priems/' . $e['bm_a1'] . '.end.php'; - } - } else { - if (file_exists('priems/' . $e['bm_a1'] . '.php')) { - require_once 'priems/' . $e['bm_a1'] . '.php'; - } + $e['bm_a1'] .= '.end'; + } + if (file_exists('priems/' . $e['bm_a1'] . '.php')) { + require_once 'priems/' . $e['bm_a1'] . '.php'; } } } //Проверка урона приемов + private function newRazmen($id): array + { + $uid1 = $this->atacks[$id]['uid1']; + $uid2 = $this->atacks[$id]['uid2']; + + if ($this->atacks[$id]['out1'] == 0) { + $at[1] = $this->usersTestAtack($id, $uid1, $uid2); + } else { + $at[1] = [0]; + } + if ($this->atacks[$id]['out2'] == 0) { + $at[2] = $this->usersTestAtack($id, $uid2, $uid1); + } else { + $at[2] = [0]; + } + + return $at; + } + + private function usersTestAtack($id, $uid1, $uid2): array + { + $r = []; + $block = [0, 0, 0, 0, 0, 0,]; + + //Проверка блоков + $i = 1; + if ($uid1 == $this->atacks[$id]['uid1']) { + $a = 2; + $j = $this->atacks[$id]['b2']; + $atack = [ + 0, + $this->atacks[$id]['a1'][0], + $this->atacks[$id]['a1'][1], + $this->atacks[$id]['a1'][2], + $this->atacks[$id]['a1'][3], + $this->atacks[$id]['a1'][4], + ]; + } elseif ($uid2 == $this->atacks[$id]['uid1']) { + $a = 1; + $j = $this->atacks[$id]['b1']; + $atack = [ + 0, + $this->atacks[$id]['a2'][0], + $this->atacks[$id]['a2'][1], + $this->atacks[$id]['a2'][2], + $this->atacks[$id]['a2'][3], + $this->atacks[$id]['a2'][4], + ]; + } + + if (isset($a, $j) && $this->atacks[$id]['out' . $a] == 0) { + while ($i <= $this->stats[$this->uids[$uid2]]['zonb']) { + $block[$j] = 1; + $j++; + if ($j > 5 || $j < 1) { + $j = 1; + } + $i++; + } + } + + //Проверка ударов + for ($i = 1; $i <= $this->stats[$this->uids[$uid1]]['zona']; $i++) { + if (!isset($atack[$i]) || $atack[$i] == 0) { + $atack[$i] = rand(1, 5); + } + if ($atack[$i] > 0) { + if ($block[$atack[$i]] == 1) { + //удар был заблокирован + // КУДА БИЛ , ТИП УДАРА + $r['atack'][] = [$atack[$i], 3, 0]; + } else { + //Удар прошел + // КУДА БИЛ , ТИП УДАРА + $r['atack'][] = [$atack[$i], 1, 0]; + } + } + } + + return $r; + } + + //Наносим удар между игроками + public function priemsRazmen(array|int $id, array|string $at): void { if ($at == 'fast') { @@ -2913,625 +2946,6 @@ JS; } } - //Наносим удар между игроками - - private function newRazmen($id): array - { - $uid1 = $this->atacks[$id]['uid1']; - $uid2 = $this->atacks[$id]['uid2']; - - if ($this->atacks[$id]['out1'] == 0) { - $at[1] = $this->usersTestAtack($id, $uid1, $uid2); - } else { - $at[1] = [0]; - } - if ($this->atacks[$id]['out2'] == 0) { - $at[2] = $this->usersTestAtack($id, $uid2, $uid1); - } else { - $at[2] = [0]; - } - - return $at; - } - - private function usersTestAtack($id, $uid1, $uid2): array - { - $r = []; - $block = [0, 0, 0, 0, 0, 0,]; - - //Проверка блоков - $i = 1; - if ($uid1 == $this->atacks[$id]['uid1']) { - $a = 2; - $j = $this->atacks[$id]['b2']; - $atack = [ - 0, - $this->atacks[$id]['a1'][0], - $this->atacks[$id]['a1'][1], - $this->atacks[$id]['a1'][2], - $this->atacks[$id]['a1'][3], - $this->atacks[$id]['a1'][4], - ]; - } elseif ($uid2 == $this->atacks[$id]['uid1']) { - $a = 1; - $j = $this->atacks[$id]['b1']; - $atack = [ - 0, - $this->atacks[$id]['a2'][0], - $this->atacks[$id]['a2'][1], - $this->atacks[$id]['a2'][2], - $this->atacks[$id]['a2'][3], - $this->atacks[$id]['a2'][4], - ]; - } - - if (isset($a, $j) && $this->atacks[$id]['out' . $a] == 0) { - while ($i <= $this->stats[$this->uids[$uid2]]['zonb']) { - $block[$j] = 1; - $j++; - if ($j > 5 || $j < 1) { - $j = 1; - } - $i++; - } - } - - //Проверка ударов - for ($i = 1; $i <= $this->stats[$this->uids[$uid1]]['zona']; $i++) { - if (!isset($atack[$i]) || $atack[$i] == 0) { - $atack[$i] = rand(1, 5); - } - if ($atack[$i] > 0) { - if ($block[$atack[$i]] == 1) { - //удар был заблокирован - // КУДА БИЛ , ТИП УДАРА - $r['atack'][] = [$atack[$i], 3, 0]; - } else { - //Удар прошел - // КУДА БИЛ , ТИП УДАРА - $r['atack'][] = [$atack[$i], 1, 0]; - } - } - } - - return $r; - } - - public function yhod_user($uid1, $uid2, $type) - { - // 1 - кто бьет . 2 - в кого бьют . тип - //Удал летит прямо в противника - if ($this->importUser == 0) { - $r = $uid1; - $rand_user = false; - if ($type == 2) { - //Случайный персонаж из своей команды (в том числе игрок) - $i = 0; - while ($i < count($this->users)) { - if ($this->users[$i]['team'] == $this->users[$this->uids[$uid2]]['team']) { - $rand_user[] = $this->users[$i]['id']; - } - $i++; - } - } elseif ($type == 4) { - //Случайный персонаж, любой - $i = 0; - while ($i < count($this->users)) { - $rand_user[] = $this->users[$i]['id']; - $i++; - } - } elseif ($type == 5) { - //Случайный персонаж, любой (кроме игрока) - $i = 0; - while ($i < count($this->users)) { - if ($this->users[$i]['team'] == $this->users[$this->uids[$uid2]]['team'] && $uid2 != $this->users[$i]['id']) { - $rand_user[] = $this->users[$i]['id']; - } - $i++; - } - } elseif ($type == 6) { - //Случайный персонаж из команды противника - $i = 0; - while ($i < count($this->users)) { - if ($this->users[$i]['team'] != $this->users[$this->uids[$uid2]]['team']) { - $rand_user[] = $this->users[$i]['id']; - } - $i++; - } - } elseif ($type > 100) { - //Удар идет в конкретного игрока - if (!isset($this->users[$this->uids[$type]]) || $this->users[$this->uids[$type]]['id'] != $type) { - $r = $uid2; - } else { - $r = $type; - } - } - if (!empty($rand_user)) { - $r = $rand_user[rand(0, (count($rand_user) - 1))]; - } - $this->importUser = $r; - } else { - $r = $this->importUser; - } - return $r; - } - - - public function testRazmenblock1($id, $uid1, $uid2): bool - { - //перенести в Battle/Razmen. - - $block = []; - $j = 0; - - //Проверка блоков - $i = 1; - - if ($uid1 == $this->atacks[$id]['uid1']) { - $j = $this->atacks[$id]['b2']; - } elseif ($uid2 == $this->atacks[$id]['uid1']) { - $j = $this->atacks[$id]['b1']; - } - - if ($this->atacks[$id]['out2'] == 0) { - while ($i <= $this->stats[$this->uids[$uid2]]['zonb']) { - $block[$j] = 1; - $j++; - if ($j > 5 || $j < 1) { - $j = 1; - } - $i++; - } - } - - return !empty($block); - } - - - //Расчет типа удара от оружия - //Расчет урона от оружия - - public function yronGetrazmen($uid1, $uid2, $witm): array - { - // перенести в Battle/Razmen - - - /** - * Определяем тип урона - * Колющий - * Рубящий - * Режущий - * Дробящий - */ - - $witm_data = Conversion::dataStringToArray($witm['data']); - $witm_type = $this->weaponTx($witm_data); - - if ($witm_type == 0 || $witm_type == 12) { - $witm_type2 = ''; - } else { - $witm_type2 = $witm_type; - } - $r['t'] = $witm_type2; - - //Увеличиваем параметры от текущего оружия которым бьем - $iii = 1; - while ($iii <= 7) { - if (isset($witm_data['sv_a' . $iii]) && $witm_data['sv_a' . $iii] != 0) { - $this->stats[$this->uids[$uid1]]['a' . $iii] += $witm_data['sv_a' . $iii]; - } - if (isset($witm_data['sv_mg' . $iii]) && $witm_data['sv_mg' . $iii] != 0) { - $this->stats[$this->uids[$uid1]]['mg' . $iii] += $witm_data['sv_mg' . $iii]; - } - $iii++; - } - $iii = 1; - while ($iii <= 4) { - if (isset($witm_data['sv_aall']) && $witm_data['sv_aall'] != 0) { - $this->stats[$this->uids[$uid1]]['a' . $iii] += $witm_data['sv_aall']; - } - $iii++; - } - $iii = 1; - while ($iii <= 4) { - if (isset($witm_data['sv_mall']) && $witm_data['sv_mall'] != 0) { - $this->stats[$this->uids[$uid1]]['mg' . $iii] += $witm_data['sv_mall']; - } - $iii++; - } - $iii = 1; - while ($iii <= 7) { - if (isset($witm_data['sv_m2all']) && $witm_data['sv_m2all'] != 0) { - $this->stats[$this->uids[$uid1]]['mg' . $iii] += $witm_data['sv_m2all']; - } - $iii++; - } - - if (isset($witm_data['sv_m3']) && $witm_data['sv_m3'] != 0) { - $this->stats[$this->uids[$uid1]]['m3'] += $witm_data['sv_m3']; - } - - $iii = 1; - while ($iii <= 7) { - if (isset($witm_data['sv_pa' . $iii]) && $witm_data['sv_pa' . $iii] != 0) { - $this->stats[$this->uids[$uid1]]['pa' . $iii] += $witm_data['sv_pa' . $iii] + $witm_data['sv_m10']; - } - if (isset($witm_data['sv_pm' . $iii]) && $witm_data['sv_pm' . $iii] != 0) { - $this->stats[$this->uids[$uid1]]['pm' . $iii] += $witm_data['sv_pm' . $iii] + $witm_data['sv_m11a']; - if ($iii < 5) { - $this->stats[$this->uids[$uid1]]['pm' . $iii] += $witm_data['sv_m11']; - } - } - $iii++; - } - - //мощность + подавление мощности противником - $wAp = 0; - - if ($witm_type == 12) { - //удар кулаком - $wAp += $this->stats[$this->uids[$uid1]]['m10']; - } elseif ($witm_type < 5) { - $wAp += $this->stats[$this->uids[$uid1]]['pa' . $witm_type]; - $wAp -= $this->stats[$this->uids[$uid2]]['antpa' . $witm_type]; - } else { - $wAp += - $this->stats[$this->uids[$uid1]]['m10'] + - $this->stats[$this->uids[$uid1]]['pm' . ($witm_type - 4)] + - $this->stats[$this->uids[$uid1]]['m11a'] + - $witm_data['sv_pm' . ($witm_type - 4)]; - - $wAp -= $this->stats[$this->uids[$uid2]]['antpm' . ($witm_type - 4)]; - } - - //Пробой брони - $proboi = 0; - $witm_data['m9'] = $this->stats[$this->uids[$uid1]]['m9']; - if (rand(1, 100) < floor($witm_data['m9'] / 2)) { - $proboi = floor($witm_data['m9'] / 2); - $r['pb'] = 1; - } - - $y = $this->yrn( - $this->stats[$this->uids[$uid1]], - $this->stats[$this->uids[$uid2]], - $this->users[$this->uids[$uid1]], - $this->users[$this->uids[$uid2]], - $witm_type, - $wAp, //мощность урона - $proboi, //пробой брони - ($witm_data['sv_yron_min'] + $this->stats[$this->uids[$uid1]]['yron_min']), - ($witm_data['sv_yron_max'] + $this->stats[$this->uids[$uid1]]['yron_max']), - $witm['type'], - ); - - $r['y'] = round(rand($y['min'] + $proboi, $y['max'] + round($proboi / 2))); - $r['k'] = round(rand($y['Kmin'] + round($proboi / 4), $y['Kmax'] + round($proboi / 8))); - - $r['m_y'] = $y['max']; - $r['m_k'] = $y['Kmax']; - - $r['bRND'] = $y['bRND']; - - $r['w_type'] = $witm_type; - - //тип от оружия - $tp = match ($witm['type']) { - 18 => 1, - 19 => 2, - 20 => 3, - 21 => 4, - default => 0 - }; - - if ($tp != $witm_type) // ТУТ - { - (int)$r['y'] = round((int)$r['y'] / 3); - $r['k'] = round($r['k'] / 3); - $r['m_k'] = round($r['m_k'] / 3); - $r['m_y'] = round($r['m_y'] / 3); - } - - if (isset($this->stats[$this->uids[$uid2]]['zaproc'])) { - $r['y'] = round($r['y'] - $r['y'] * $this->stats[$this->uids[$uid2]]['zaproc'] / 100); - $r['k'] = round($r['k'] - $r['k'] * $this->stats[$this->uids[$uid2]]['zaproc'] / 100); - $r['m_k'] = round($r['m_k'] - $r['m_k'] * $this->stats[$this->uids[$uid2]]['zaproc'] / 100); - $r['m_y'] = round($r['m_y'] - $r['m_y'] * $this->stats[$this->uids[$uid2]]['zaproc'] / 100); - if ($r['k'] < 1) { - $r['k'] = 2; - } - } - - $r['y'] = max($r['y'], 1); - $r['k'] = max($r['k'], 1); - $r['m_y'] = max($r['m_y'], 1); - $r['m_k'] = max($r['m_k'], 1); - - return $r; - } - - //Расчет урона от оружия - - public function weaponTx($itemdata) - { - $itm = is_array($itemdata) ? $itemdata : Conversion::dataStringToArray($itemdata); - - $t[0]['z'] = 0; - $t[0]['t'] = 0; - //колящий урон - $t[1]['z'] = (int)$itm['tya1']; - $t[1]['t'] = 1; - //рубящий урон - $t[2]['z'] = (int)$itm['tya2']; - $t[2]['t'] = 2; - //дробящий урон - $t[3]['z'] = (int)$itm['tya3']; - $t[3]['t'] = 3; - //режущий урон - $t[4]['z'] = (int)$itm['tya4']; - $t[4]['t'] = 4; - //урон огня - $t[5]['z'] = (int)$itm['tym1']; - $t[5]['t'] = 5; - //урон воздуха - $t[6]['z'] = (int)$itm['tym2']; - $t[6]['t'] = 6; - //урон воды - $t[7]['z'] = (int)$itm['tym3']; - $t[7]['t'] = 7; - //урон земли - $t[8]['z'] = (int)$itm['tym4']; - $t[8]['t'] = 8; - //урон серой магией - $t[11]['z'] = (int)$itm['tym7']; - $t[11]['t'] = 11; - - $tpt = $t[0]['z']; - $tpmin = $t[0]; - $tpmax = $t[0]; - $i = 1; - $ii = 0; - - while ($i <= 11) { - if ($t[$i]['z'] > $tpt) { - $tpt = $t[$i]['z']; - $tpmax = $t[$i]; - $ii = $i; - } - $i++; - } - $t[$ii]['z'] = 0; - - $tpt = $t[0]['z']; - $i = 1; - while ($i <= 11) { - if ($t[$i]['z'] > $tpt) { - $tpt = $t[$i]['z']; - $tpmin = $t[$i]; - } - $i++; - } - - $setclass = rand(1, 100); - - if ($setclass > $tpmax['z']) { - $tp = $tpmin['t']; - } else { - $tp = $tpmax['t']; - } - - return $tp; - } - - - //Расчет защиты - - public function yrn( - array $st1, - array $st2, - array $u1, - array $u2, - int $type, - int $power_yron = 0, - float $proboi = 0, - int $weapom_min = 0, - int $weapom_max = 0, - int $wp_type = 0, - ): array { - - $level = $st1['lvl']; - $power_krit = round($st1['m3']); - - if (!isset($type) || $type == '') { - $type = 12; - } - - //Параметры для возврвата - $r = ['type' => $type]; - $p = [ - 'B' => [0 => 0, 1 => 0, 'rnd' => false], - 'M' => $power_yron, //мощность урона - 'K' => $power_krit, //мощность крита - 'T' => 1, //Кф. оружия - ]; - - //Расчет типа урона - - if ($wp_type == 18) { - $r['type'] = 1; - } elseif ($wp_type == 19) { - $r['type'] = 2; - } elseif ($wp_type == 20) { - $r['type'] = 3; - } elseif ($wp_type == 21) { - $r['type'] = 4; - } - - /** - * (S) - влияние наших статов на профильный урон - * 1 Колющий: S = Сила * 0,3 + Ловкость * 0,7 - * 2 Рубящий: S = Сила * 0,5 + Ловкость * 0,25 + Интуиция * 0,25 - * 3 Дробящий: S = Сила * 1 - * 4 Режущий: S = Сила * 0,3 + Интуиция * 0,7 - * else кулак/магия - */ - if ($r['type'] == 1) { - $p['S'] = $st1['s1'] * 0.25 + $st1['s2'] * 0.75; - $p['U'] = $st1['a1'] * 1.00; //кинжалы - } elseif ($r['type'] == 2) { - $p['S'] = $st1['s1'] * 1.20; - $p['U'] = $st1['a2'] * 1.00; //топоры - } elseif ($r['type'] == 3) { - $p['S'] = $st1['s1'] * 0.5 + $st1['s4'] * 1.00; - $p['U'] = $st1['a3'] * 1.00; //дубины - } elseif ($r['type'] == 4) { - $p['S'] = $st1['s3'] * 1.00; - $p['U'] = $st1['a4'] * 1.00; //мечи - } else { - $p['S'] = 0; - $p['U'] = 0; - } - - $r['bron']['rnd'] = rand($r['bron'][0], $r['bron'][1]); - - //Остальные расчеты (коэфицент) - $p['B'][0] = 2 + $level + $st1['s1'] - round($st1['s1'] / 5); - $p['B'][1] = $p['B'][0] + 3; - $p['B']['rnd'] = rand($p['B'][0], $p['B'][1]); - - //Обычный урон - if ($r['type'] == 12) { - $r['min'] = ($p['B'][0] + $weapom_min) * $p['T'] * (1 + $p['M'] / 100); - $r['max'] = ($p['B'][1] + $weapom_max) * $p['T'] * (1 + $p['M'] / 100); - } else { - $r['min'] = (($p['B'][0] + $p['S'] * 2 + $weapom_min * 2 + $p['U'] * 2) * $p['T']) * (1 + $p['M'] / 100); - $r['max'] = (($p['B'][1] + $p['S'] * 2 + $weapom_max * 2 + $p['U'] * 2) * $p['T']) * (1 + $p['M'] / 100); - } - - $r['bRND'] = $p['B']['rnd']; - $r['Kmin'] = ceil((2 + ($p['K'] / 100)) * $r['min']); - $r['Kmax'] = ceil((2 + ($p['K'] / 100)) * $r['max']); - - //Расчет брони - //для обычного - if ($r['type'] < 5 || $r['type'] == 12) { - $r['min_abron'] = round($r['min'] * 0.05); - $r['max_abron'] = round($r['max'] * 0.05); - if ($proboi != 0) { - $r['bron']['rndold'] = $r['bron']['rnd']; - $r['bron']['rnd'] = 0; - } - $r['Kmin'] -= $r['bron']['rnd'] * 2; //было умножить на 2 - $r['Kmax'] -= $r['bron']['rnd'] * 2; //было умножить на 2 - $r['min'] -= $r['bron']['rnd']; //не было деления ни на чо. - $r['max'] -= $r['bron']['rnd']; //не было деления ни на чо. - } - - //Расчет защиты (не более 80%) - if ($r['type'] < 5 || $r['type'] == 12) { - $r['min'] = round($r['min'] / 100 * (100 - $this->zago($st2['za']))); - $r['max'] = round($r['max'] / 100 * (100 - $this->zago($st2['za']))); - $r['Kmin'] = round($r['Kmin'] / 100 * (100 - $this->zago($st2['za']))); - $r['Kmax'] = round($r['Kmax'] / 100 * (100 - $this->zago($st2['za']))); - } else { - $r['min'] = round($r['min'] / 100 * (100 - $this->zmgo($st2['zm']))); - $r['max'] = round($r['max'] / 100 * (100 - $this->zmgo($st2['zm']))); - $r['Kmin'] = round($r['Kmin'] / 100 * (100 - $this->zmgo($st2['zm']))); - $r['Kmax'] = round($r['Kmax'] / 100 * (100 - $this->zmgo($st2['zm']))); - } - - $r['min'] = round($r['min']); - $r['max'] = round($r['max']); - $r['Kmin'] = round($r['Kmin']); - $r['Kmax'] = round($r['Kmax']); - - $min_yrn = 0; //% - - if ($u1['clone'] > 0) { - $min_yrn = 75; - } - - $r['min'] -= floor($r['min'] / 100 * $min_yrn); - $r['max'] -= floor($r['max'] / 100 * $min_yrn); - $r['Kmin'] -= floor($r['Kmin'] / 100 * ($min_yrn)); - $r['Kmax'] -= floor($r['Kmax'] / 100 * ($min_yrn)); - $r['min_'] -= floor($r['min_'] / 100 * $min_yrn); - $r['max_'] -= floor($r['max_'] / 100 * $min_yrn); - $r['Kmin_'] -= floor($r['Kmin_'] / 100 * ($min_yrn)); - $r['Kmax_'] -= floor($r['Kmax_'] / 100 * ($min_yrn)); - - $defd = mysql_fetch_array( - mysql_query( - 'SELECT SUM(`vals`) FROM `battle_actions` WHERE `btl` = "' . $this->i->id . '" AND `vars` = "use_defteam' . $u2['team'] . '" LIMIT 1' - ) - ); - if ($defd[0] > 100) { - $defd[0] = 100; - } - $defd = 0 + $defd[0]; - $powd = mysql_fetch_array( - mysql_query( - 'SELECT SUM(`vals`) FROM `battle_actions` WHERE `btl` = "' . $this->i->id . '" AND `vars` = "use_powteam' . $u1['team'] . '" LIMIT 1' - ) - ); - if ($powd[0] > 100) { - $powd[0] = 100; - } - $powd = 0 + $powd[0]; - $defd = $defd - $powd; - - $r['min'] -= floor($defd); - $r['max'] -= floor($defd); - $r['Kmin'] -= floor($defd * 2); - $r['Kmax'] -= floor($defd * 2); - $r['min_'] -= floor($defd); - $r['max_'] -= floor($defd); - $r['Kmin_'] -= floor($defd * 2); - $r['Kmax_'] -= floor($defd * 2); - $r['min'] += $st1['maxAtack']; - $r['max'] += $st1['maxAtack']; - $r['Kmin'] += $st1['maxAtack'] * 2; - $r['Kmin'] += $st1['maxAtack'] * 2; - - if ($r['min'] < 1) { - $r['min'] = 1; - } - if ($r['max'] < 1) { - $r['max'] = 1; - } - if ($r['Kmin'] < 2) { - $r['Kmin'] = 2; - } - if ($r['Kmax'] < 2) { - $r['Kmax'] = 2; - } - if ($r['Kmin_'] < 2) { - $r['Kmin_'] = 2; - } - if ($r['Kmin_'] < 2) { - $r['Kmax_'] = 2; - } - - $r['m_k'] = $r['Kmax']; - - return $r; - } - - //Расчет защиты (магия) - - private function zago($v): float - { - if ($v > 1700) { - $v = 1700; - } - return round((1 - (pow(0.5, ($v / 399.51)))) * 100, 2); - } - - public function zmgo($v): float|int - { - return (1 - (pow(0.5, ($v / 250)))) * 100; - } - /** Осторожно! Подключаются файлы!!! * @param $id * @param $at @@ -3690,6 +3104,10 @@ JS; return $at; } + + //Расчет типа удара от оружия + //Расчет урона от оружия + public function testPogB($uid, $yr, $pliid, $test = 0) { $yr2 = $yr; @@ -3788,6 +3206,14 @@ JS; return $yr2; } + //Расчет урона от оружия + + /** + * Обновляем НР и добавляем тактики? + * @param $id + * @param $at + * @return array + */ private function updateHealth($id, $at): array { @@ -3943,7 +3369,69 @@ JS; return $at; } - //Расчет МФ + + //Расчет защиты + + public function yhod_user($uid1, $uid2, $type) + { + // 1 - кто бьет . 2 - в кого бьют . тип + //Удал летит прямо в противника + if ($this->importUser == 0) { + $r = $uid1; + $rand_user = false; + if ($type == 2) { + //Случайный персонаж из своей команды (в том числе игрок) + $i = 0; + while ($i < count($this->users)) { + if ($this->users[$i]['team'] == $this->users[$this->uids[$uid2]]['team']) { + $rand_user[] = $this->users[$i]['id']; + } + $i++; + } + } elseif ($type == 4) { + //Случайный персонаж, любой + $i = 0; + while ($i < count($this->users)) { + $rand_user[] = $this->users[$i]['id']; + $i++; + } + } elseif ($type == 5) { + //Случайный персонаж, любой (кроме игрока) + $i = 0; + while ($i < count($this->users)) { + if ($this->users[$i]['team'] == $this->users[$this->uids[$uid2]]['team'] && $uid2 != $this->users[$i]['id']) { + $rand_user[] = $this->users[$i]['id']; + } + $i++; + } + } elseif ($type == 6) { + //Случайный персонаж из команды противника + $i = 0; + while ($i < count($this->users)) { + if ($this->users[$i]['team'] != $this->users[$this->uids[$uid2]]['team']) { + $rand_user[] = $this->users[$i]['id']; + } + $i++; + } + } elseif ($type > 100) { + //Удар идет в конкретного игрока + if (!isset($this->users[$this->uids[$type]]) || $this->users[$this->uids[$type]]['id'] != $type) { + $r = $uid2; + } else { + $r = $type; + } + } + if (!empty($rand_user)) { + $r = $rand_user[rand(0, (count($rand_user) - 1))]; + } + $this->importUser = $r; + } else { + $r = $this->importUser; + } + return $r; + } + + //Расчет защиты (магия) /** * Добавляем опыт \ нанесенный урон. @@ -4517,7 +4005,6 @@ JS; } } - public function addlt($a, int $id, int $s, $rnd = null): string { if ($rnd === null) { @@ -4643,8 +4130,6 @@ JS; } } - //Проверяем удары, приемы, свитки, зверей - public function priemAddLog( $id, $a, @@ -4656,7 +4141,8 @@ JS; $hodID, $tm1 = 0, $tm2 = 0 - ): void { + ): void + { $time = time(); if ($tm1 == 0) { $tm1 = isset($this->atacks[$id]) ? $this->atacks[$id]['time'] : $time; @@ -4690,8 +4176,14 @@ JS; Log::add($mas); } - //Действия бота + //Расчет МФ + /** + * Возращаем зоны блока? + * @param $uid1 + * @param $uid2 + * @return void + */ private function restZonb($uid1, $uid2): void { if ($this->stnZbVs[$uid1] > 0) { @@ -4702,15 +4194,11 @@ JS; } } - //получаем данные о поединке - private function saveStats($uid): void { Stats::saveBattleStats($this->stats[$this->uids[$uid]], $uid); } - //наносим удар противнику - /** Осторожно! Подключаются файлы!!! * @param $id * @param $at @@ -4770,7 +4258,47 @@ JS; } } - //выделяем пользователей + public static function get(int $id): array + { + $result = Db::getRow('select * from battle where id = ?', [$id]); + return $result ?: []; + } + + //Действия бота (атака) + + /** + * Смерть от пропуска ходов. Включается в конфиге. + * @param int $id + * @return void + */ + private function deathByTimeout(int $id): void + { + if (Config::get('propsk_die') <= 0 || $this->i->razdel != 0 || $this->i->dnId != 0 || $this->i->izlom != 0) { + return; + } + + $cn1 = Db::getValue('select count(*) from battle_out where battle = ? and uid1 = ?', [$this->i->id, $this->atacks[$id]['uid1']]); + $cn2 = Db::getValue('select count(*) from battle_out where battle = ? and uid1 = ?', [$this->i->id, $this->atacks[$id]['uid2']]); + + if ($cn1 > 3) { + $this->priemAddLog( + $id, 1, 2, $this->atacks[$id]['uid1'], 0, '', + '{tm1} Персонаж {u1} был убит из-за большого количества пропусков хода.', + $this->hodID + ); + Db::sql('update stats set hpNow = 0 where id = ?', [$this->atacks[$id]['uid1']]); + } + if ($cn2 > Config::get('propsk_die')) { + $this->priemAddLog( + $id, 1, 2, $this->atacks[$id]['uid2'], 0, '', + '{tm1} Персонаж {u1} был убит из-за большого количества пропусков хода.', + $this->hodID + ); + Db::sql('update stats set hpNow = 0 where id = ?', [$this->atacks[$id]['uid2']]); + } + } + + //Проверяем удары, приемы, свитки, зверей private function addNewAtack(User $u): void { @@ -4856,7 +4384,7 @@ JS; } - //Возращаем зоны блока по умолчанию + //Действия бота private function botAct($uid): bool { @@ -4915,8 +4443,6 @@ JS; $js .= 'testClearZone();'; } - //генерируем команды - public function teamsTake(User $u): void { if ($this->i->id < 1) { @@ -5059,152 +4585,6 @@ JS; $this->i->setStart1(); } - private function addstatuser($uid): void - { - if ($uid <= 0) { - return; - } - - $id = $this->uids[$uid]; - - if (empty($this->stats[$id]['hp'])) { - $this->stats[$id]['hp'] = $this->stats[$id]['hpNow']; - } - Db::sql( - 'insert into battle_users (battle,uid,time_enter,login,level,align,clan,hpall,hp,hpstart,team) values (?,?,unix_timestamp(),?,?,?,?,?,?,?,?)', - [ - $this->i->id, - $uid, - $this->users[$id]['login'], - $this->users[$id]['level'], - $this->users[$id]['align'], - $this->users[$id]['clan'], - $this->stats[$id]['hpAll'], - $this->stats[$id]['hp'], - $this->stats[$id]['hpNow'], - $this->users[$id]['team'], - ] - ); - } - - public function testZonbVis() - { - global $u; - if ($this->stnZbVs == 0) { - $zb = $this->stats[$this->uids[$u->info['id']]]['zonb']; - $this->stnZbVs = $zb; - } else { - $zb = $this->stnZb; - } - $eu = $this->users[$this->uids[$u->info['id']]]['enemy']; - if ($zb > 3) { - $zb = 3; - } - if ( - $eu != 0 && - ( - $this->stats[$this->uids[$eu]]['weapon1'] == 1 || - $this->stats[$this->uids[$eu]]['weapon2'] == 1 - ) && - $this->stats[$this->uids[$u->info['id']]]['weapon1'] != 1 && - $this->stats[$this->uids[$u->info['id']]]['weapon2'] != 1 - ) { - $zb -= 1; - } - if ($zb < 1) { - $zb = 1; - } - return $zb; - } - - ///----Спасение функция - - public function genTeams($you): string - { - $ret = ''; - $teams = []; - //выделяем пользователей - $i = 0; - $j = 1; - $tms = []; - $teams[$this->users[$this->uids[$you]]['team']] = ''; - $tms[0] = $this->users[$this->uids[$you]]['team']; - while ($i < count($this->uids)) { - if ($this->stats[$i]['hpNow'] > 0) { - if (!isset($teams[$this->users[$i]['team']])) { - $tms[$j] = $this->users[$i]['team']; - $j++; - } - if ($this->stats[$i]['hpNow'] < 0) { - $this->stats[$i]['hpNow'] = 0; - } - if ($this->stats[$i]['hpAll'] < $this->stats[$i]['hpNow']) { - $this->stats[$i]['hpNow'] = $this->stats[$i]['hpAll']; - } - - // Цветная метка тем, кто вылетел за таймаут в 15 минут? - $a1ms = ''; - $actcolor = ''; - $actstyle = ''; - $actid = 0; - - if (!empty($this->ga[$this->users[$i]['id']][$you])) { - $actid = $this->ga[$this->users[$i]['id']][$you]; - $actcolor = 'red'; - $actstyle = 'underline'; - } elseif (!empty($this->ag[$this->users[$i]['id']][$you])) { - $actid = $this->ag[$this->users[$i]['id']][$you]; - $actcolor = 'green'; - $actstyle = 'overline'; - } - - if (!empty($actid)) { - $ac = Db::getRow('select id, time from battle_act where id = ?', [$actid]); - if ($ac['id'] && $ac['time'] + $this->i->timeout - 15 < time()) { - $a1ms = " color: $actcolor;"; - } - $a1ms = "style='text-decoration: $actstyle';$a1ms"; - } - - if ($this->users[$i]['login2'] == '') { - $this->users[$i]['login2'] = $this->users[$i]['login']; - } - if ($this->users[$i]['align'] == 9) { - $this->stats[$i]['hpNow'] = $this->stats[$i]['hpNow'] / ($this->stats[$i]['hpAll'] / 100); - $this->stats[$i]['hpAll'] = '100%'; - } - $ldr = ''; - if ($this->users[$i]['lider'] == $this->i->id) { - $ldr = 'users[$i]['team'] . '.gif>'; - } - $teams[$this->users[$i]['team']] .= ', ' . $ldr . 'users[$i]['team'] . '\" onClick=\"chat.addto(\'' . $this->users[$i]['login2'] . '\',\'to\'); return false;\" oncontextmenu=\"top.infoMenu(\'' . $this->users[$i]['login2'] . '\',event,\'main\'); return false;\">' . $this->users[$i]['login2'] . ' [' . floor( - $this->stats[$i]['hpNow'] - ) . '/' . $this->stats[$i]['hpAll'] . ']'; - } - $i++; - } - - //генерируем команды - $i = 0; - while ($i < count($tms)) { - $teams[$tms[$i]] = ltrim($teams[$tms[$i]], ', '); - if ($teams[$tms[$i]] != '') { - $teams[$tms[$i]] = ' ' . $teams[$tms[$i]]; - $ret .= $teams[$tms[$i]]; - if (count($tms) > $i + 1) { - $ret .= '   против   '; - } - } - $i++; - } - return 'genteam("' . $ret . '");'; - } - - public function setIBotsValue($key, $value): void - { - $this->iBots[$key] = $value; - } - /** * @param int $i * @return void @@ -5318,29 +4698,147 @@ JS; Db::sql('update users_animal set eda = eda - 1 where id = ?', [$animal['id']]); } - /** - * @param int|null $experience - * @param bool $hardcore поединок с гарантированной травмой - * @return array|int[] - */ - public static function getType(?int $experience, bool $hardcore = false): array + private function addstatuser($uid): void { - return match (true) { - $experience >= 5000000 => [150, 150, 'Судный День', 'Судный День'], - $experience >= 2500000 => [100, 125, 'Эпохальная Битва', 'Кровавое Побоище'], - $experience >= 1000000 => [75, 100, 'Историческая Битва', 'Кровавая Сеча'], - $experience >= 500000 => [50, 75, 'Величайшая Битва', 'Кровавая Резня'], - $experience >= 100000 => [25, 50, 'Великая Битва', 'Кровавая Битва'], - $hardcore => [150, 150, 'Жесточайшее Сражение', 'Жесточайшее Сражение'], - default => [0, 0, 'Поединок', 'Кровавый Поединок'], - }; + if ($uid <= 0) { + return; + } + + $id = $this->uids[$uid]; + + if (empty($this->stats[$id]['hp'])) { + $this->stats[$id]['hp'] = $this->stats[$id]['hpNow']; + } + Db::sql( + 'insert into battle_users (battle,uid,time_enter,login,level,align,clan,hpall,hp,hpstart,team) values (?,?,unix_timestamp(),?,?,?,?,?,?,?,?)', + [ + $this->i->id, + $uid, + $this->users[$id]['login'], + $this->users[$id]['level'], + $this->users[$id]['align'], + $this->users[$id]['clan'], + $this->stats[$id]['hpAll'], + $this->stats[$id]['hp'], + $this->stats[$id]['hpNow'], + $this->users[$id]['team'], + ] + ); } - public static function get(int $id): array + public function testZonbVis() { - $result = Db::getRow('select * from battle where id = ?', [$id]); - return $result ?: []; + global $u; + if ($this->stnZbVs == 0) { + $zb = $this->stats[$this->uids[$u->info['id']]]['zonb']; + $this->stnZbVs = $zb; + } else { + $zb = $this->stnZb; + } + $eu = $this->users[$this->uids[$u->info['id']]]['enemy']; + if ($zb > 3) { + $zb = 3; + } + if ( + $eu != 0 && + ( + $this->stats[$this->uids[$eu]]['weapon1'] == 1 || + $this->stats[$this->uids[$eu]]['weapon2'] == 1 + ) && + $this->stats[$this->uids[$u->info['id']]]['weapon1'] != 1 && + $this->stats[$this->uids[$u->info['id']]]['weapon2'] != 1 + ) { + $zb -= 1; + } + if ($zb < 1) { + $zb = 1; + } + return $zb; } + public function genTeams($you): string + { + $ret = ''; + $teams = []; + //выделяем пользователей + $i = 0; + $j = 1; + $tms = []; + $teams[$this->users[$this->uids[$you]]['team']] = ''; + $tms[0] = $this->users[$this->uids[$you]]['team']; + while ($i < count($this->uids)) { + if ($this->stats[$i]['hpNow'] > 0) { + if (!isset($teams[$this->users[$i]['team']])) { + $tms[$j] = $this->users[$i]['team']; + $j++; + } + if ($this->stats[$i]['hpNow'] < 0) { + $this->stats[$i]['hpNow'] = 0; + } + if ($this->stats[$i]['hpAll'] < $this->stats[$i]['hpNow']) { + $this->stats[$i]['hpNow'] = $this->stats[$i]['hpAll']; + } + // Цветная метка тем, кто вылетел за таймаут в 15 минут? + $a1ms = ''; + $actcolor = ''; + $actstyle = ''; + $actid = 0; + + if (!empty($this->ga[$this->users[$i]['id']][$you])) { + $actid = $this->ga[$this->users[$i]['id']][$you]; + $actcolor = 'red'; + $actstyle = 'underline'; + } elseif (!empty($this->ag[$this->users[$i]['id']][$you])) { + $actid = $this->ag[$this->users[$i]['id']][$you]; + $actcolor = 'green'; + $actstyle = 'overline'; + } + + if (!empty($actid)) { + $ac = Db::getRow('select id, time from battle_act where id = ?', [$actid]); + if ($ac['id'] && $ac['time'] + $this->i->timeout - 15 < time()) { + $a1ms = " color: $actcolor;"; + } + $a1ms = "style='text-decoration: $actstyle';$a1ms"; + } + + if ($this->users[$i]['login2'] == '') { + $this->users[$i]['login2'] = $this->users[$i]['login']; + } + if ($this->users[$i]['align'] == 9) { + $this->stats[$i]['hpNow'] = $this->stats[$i]['hpNow'] / ($this->stats[$i]['hpAll'] / 100); + $this->stats[$i]['hpAll'] = '100%'; + } + $ldr = ''; + if ($this->users[$i]['lider'] == $this->i->id) { + $ldr = 'users[$i]['team'] . '.gif>'; + } + $teams[$this->users[$i]['team']] .= ', ' . $ldr . 'users[$i]['team'] . '\" onClick=\"chat.addto(\'' . $this->users[$i]['login2'] . '\',\'to\'); return false;\" oncontextmenu=\"top.infoMenu(\'' . $this->users[$i]['login2'] . '\',event,\'main\'); return false;\">' . $this->users[$i]['login2'] . ' [' . floor( + $this->stats[$i]['hpNow'] + ) . '/' . $this->stats[$i]['hpAll'] . ']'; + } + $i++; + } + + //генерируем команды + $i = 0; + while ($i < count($tms)) { + $teams[$tms[$i]] = ltrim($teams[$tms[$i]], ', '); + if ($teams[$tms[$i]] != '') { + $teams[$tms[$i]] = ' ' . $teams[$tms[$i]]; + $ret .= $teams[$tms[$i]]; + if (count($tms) > $i + 1) { + $ret .= '   против   '; + } + } + $i++; + } + return 'genteam("' . $ret . '");'; + } + + public function setIBotsValue($key, $value): void + { + $this->iBots[$key] = $value; + } } diff --git a/_incl_data/class/Priems.php b/_incl_data/class/Priems.php index 88e6c85b..859d3d22 100644 --- a/_incl_data/class/Priems.php +++ b/_incl_data/class/Priems.php @@ -1379,9 +1379,9 @@ class Priems return $r; } - public function testpriem($pl, $t = 1, $o = 0) + private function testpriem($pl, $t = 1, $o = 0): int { - global $c, $u, $code, $btl; + global $btl; $tr = Conversion::dataStringToArray($pl['tr']); $d2 = Conversion::dataStringToArray($pl['date2']); $x = 1; @@ -2103,118 +2103,79 @@ class Priems public function getTechniquesInfo(?int $id = null): array { + # SELECT * FROM `priems` WHERE `level`<="' . $this->u->info['level'] . '" AND `activ` > "0" AND `id` = "' . $id . '" LIMIT 1 + if (isset($id)) { - return Db::getRow( - 'select * from techniques_categories left join priems on techniques_categories.technique_id = priems.id - where priems.level <= ? and priems.activ > 0 and priems.id = ? order by priems.img,priems.level', [User::start()->info['level'], $id] - ); + return Db::getRow('select * from priems where level <= ? and activ > 0 and id = ? order by img,level', [$this->u->info['level'], $id]); +// return Db::getRow( +// 'select * from techniques_categories left join priems on techniques_categories.technique_id = priems.id +// where priems.level <= ? and priems.activ > 0 and priems.id = ? order by priems.img,priems.level', [User::start()->info['level'], $id] +// ); } - return Db::getRows( - 'select * from techniques_categories left join priems on techniques_categories.technique_id = priems.id - where priems.level <= ? and priems.activ > 0 order by priems.img,priems.level', [User::start()->info['level']] - ); + return Db::getRows('select * from priems where level <= ? and activ > 0 order by img,level', [$this->u->info['level']]); +// return Db::getRows( +// 'select * from techniques_categories left join priems on techniques_categories.technique_id = priems.id +// where priems.level <= ? and priems.activ > 0 order by priems.img,priems.level', [User::start()->info['level']] +// ); } - public function seeMy($t) + + public function seeMyPriems(): void { - global $btl; $i = 0; $p = explode('|', $this->u->info['priems']); - $lvar = ''; $pr = ''; + $all = (int)$_GET['all']; while ($i < $this->u->info['priemslot']) { if ($p[$i] > 0) { - $pl = mysql_fetch_assoc( - mysql_query( - 'SELECT * FROM `priems` WHERE `level`<="' . $this->u->info['level'] . '" AND `activ` > "0" AND `id` = "' . mysql_real_escape_string( - $p[$i] - ) . '" LIMIT 1' - ) - ); - $lvar = $this->priemInfo($pl, $t, $i); - $pz = $lvar[1]; + $pl = Db::getRow('select * from priems where level <= ? and activ > 0 and id = ?', [$this->u->info['level'], $p[$i]]); + $lvar = $this->priemInfo($pl, $i); $lvar = $lvar[0]; - if ($t == 1) { - if (isset($_GET['inv'])) { - $cl = 'href="javascript:void(0)" onclick="location.href=\'main.php?all=' . ((int)$_GET['all']) . '&skills=1&rz=4&p_raz=all\'"'; - } else { - $cl = 'href="javascript:void(0)" onclick="location.href=\'main.php?all=' . ((int)$_GET['all']) . '&skills=1&unuse_priem=' . $i . '&rz=4&p_raz=\' + p_raz"'; - } - } else { - if ($pl['type'] == 1) { - //моментально - if ($pl['onUser'] == 1) { - $oninuser = ''; - if ($pl['team'] == 1) { - if ($this->u->info['login2'] != '') { - $oninuser = $this->u->info['login2']; - } else { - $oninuser = $this->u->info['login']; - } - } else { - if ($btl->users[$btl->uids[$this->u->info['enemy']]]['login2'] != '') { - $oninuser = $btl->users[$btl->uids[$this->u->info['enemy']]]['login2']; - } else { - $oninuser = $btl->users[$btl->uids[$this->u->info['enemy']]]['login']; - } - } - $cl = 'href="javascript:void(0);" onClick="top.priemOnUser(' . $i . ',1,\'' . $pl['name'] . '\',\'' . $oninuser . '\',\'' . $pl['img'] . '\');"'; - unset($oninuser); - } else { - $cl = 'href="javascript:void(0);" onClick="usepriem(' . $i . ',1,\'' . $pl['img'] . '\');"'; - } - } elseif ($pl['type'] == 2) { - //длительное - $cl = 'href="javascript:void(0);" onClick="usepriem(' . $i . ',1,\'' . $pl['img'] . '\');"'; - } elseif ($pl['type'] == 3) { - $cl = 'href="javascript:void(0);" onClick="alert(\'Возможно используем?\');"'; - } - } - - - $notr = $this->testpriem($pl, $t); - - - $cl2 = ''; - $cli2 = ''; - if ((($pz[$i] > 0 || $notr > 0) && $t == 2) || (isset($this->u->stats['nopriems']) && $pl['nosh'] == 0) || $this->u->stats['notuse_last_pr'] == $pl['id']) { - $cli2 = ' class="nopriemuse" '; - } - - $pr .= ''; - } else { if (isset($_GET['inv'])) { - $pr .= ''; + $cl = "location.href='/main.php?all=$all&skills=1&rz=4&p_raz=all'"; } else { - $pr .= ''; + $cl = "location.href='/main.php?all=$all&skills=1&unuse_priem=$i&rz=4&p_raz=' + p_raz"; } + $cl = 'onclick="' . $cl . '"'; + $cli2 = ''; + if ((isset($this->u->stats['nopriems']) && $pl['nosh'] == 0) || isset($this->u->stats['notuse_last_pr']) && $this->u->stats['notuse_last_pr'] == $pl['id']) { + $cli2 = ' class="nopriemuse" '; + } + /// ТУТ! + $priemName = $pl['name']; + $priemImg = $pl['img']; + $pr .= << + + + HTML; + + } elseif (isset($_GET['inv'])) { + $pr .= << + + + HTML; + + } else { + $pr .= ''; } $i++; } - if ($this->u->info['animal'] > 0 && $t == 2) { - $use_lst = $this->u->testAction( - '`uid` = "' . $this->u->info['id'] . '" AND `vars` = "animal_use' . $btl->i->id . '" LIMIT 1', - 1 - ); - if (!isset($use_lst['id'])) { - $cl2 = ''; - $pr .= ''; - } else { - $cl2 = '" class="nopriemuse'; - $pr .= ''; - } - } - if ($t == 1) { - echo '
' . $pr . '
'; - } elseif ($t == 2) { - return str_replace('"', '\\"', $pr); - } + + echo '
' . $pr . '
'; } - public function priemInfo($pl, $t, $id = false) + /** + * Летит в js, двойные кавычки не использовать. + * @param array $pl + * @param int $id + * @return array + */ + private function priemInfo(array $pl, int $id = -1): array { global $btl; $pz = explode('|', $this->u->info['priems_z']); @@ -2226,7 +2187,7 @@ class Priems $n = $this->statnames->sysRequirementNames[$x]; if (isset($tr['tr_' . $n])) { if ($tr['tr_' . $n] > $this->u->stats[$n]) { - $trs .= ''; + $trs .= ""; } $trs .= '
• '; $trs .= $this->statnames->requirementNames[$n] . ': ' . $tr['tr_' . $n]; @@ -2242,10 +2203,7 @@ class Priems $nm = [1 => 'hit', 2 => 'krit', 3 => 'counter', 4 => 'block', 5 => 'parry', 6 => 'hp', 7 => 'spirit']; while ($j <= 6) { if ($pl['tt' . $j] > 0) { - $lvar .= ' ' . round( - $pl['tt' . $j], - 2 - ) . '   '; + $lvar .= ' ' . round($pl['tt' . $j], 2) . '   '; } $j++; } @@ -2266,7 +2224,7 @@ class Priems if (isset($tr['tr_mpNow']) && $tr['tr_mpNow'] > 0) { $tr['tr_mpNow'] -= round($tr['tr_mpNow'] / 100 * $this->u->stats['min_use_mp']); if ($this->u->info['mpNow'] < $tr['tr_mpNow'] || (isset($btl->stats[$btl->uids[$this->u->info['id']]]) && $btl->stats[$btl->uids[$this->u->info['id']]]['mpNow'] < $tr['tr_mpNow'])) { - $lvar .= '• Расход маны: ' . $tr['tr_mpNow'] . '
'; + $lvar .= '• Расход маны: ' . $tr['tr_mpNow'] . '
'; } else { $lvar .= '• Расход маны: ' . $tr['tr_mpNow'] . '
'; } @@ -2285,6 +2243,90 @@ class Priems return [0 => $lvar, 1 => $pz]; } + public function seeMy(): string + { + global $btl; + $i = 0; + $p = explode('|', $this->u->info['priems']); + $pr = ''; + $all = (int)$_GET['all']; + while ($i < $this->u->info['priemslot']) { + if ($p[$i] > 0) { + $pl = Db::getRow('select * from priems where level <= ? and activ > 0 and id = ?', [$this->u->info['level'], $p[$i]]); + $cl = ''; + $lvar = $this->priemInfo($pl, $i); + $pz = $lvar[1]; + $lvar = $lvar[0]; + + if ($pl['type'] == 1) { + //моментально + if ($pl['onUser'] == 1) { + if ($pl['team'] == 1) { + if ($this->u->info['login2'] != '') { + $oninuser = $this->u->info['login2']; + } else { + $oninuser = $this->u->info['login']; + } + } else { + if ($btl->users[$btl->uids[$this->u->info['enemy']]]['login2'] != '') { + $oninuser = $btl->users[$btl->uids[$this->u->info['enemy']]]['login2']; + } else { + $oninuser = $btl->users[$btl->uids[$this->u->info['enemy']]]['login']; + } + } + $cl = 'href="javascript:void(0);" onClick="top.priemOnUser(' . $i . ',1,\'' . $pl['name'] . '\',\'' . $oninuser . '\',\'' . $pl['img'] . '\');"'; + unset($oninuser); + } else { + $cl = 'href="javascript:void(0);" onClick="usepriem(' . $i . ',1,\'' . $pl['img'] . '\');"'; + } + } elseif ($pl['type'] == 2) { + //длительное + $cl = 'href="javascript:void(0);" onClick="usepriem(' . $i . ',1,\'' . $pl['img'] . '\');"'; + } elseif ($pl['type'] == 3) { + $cl = 'href="javascript:void(0);" onClick="alert(\'Возможно используем?\');"'; + } + + $notr = $this->testpriem($pl, 2); + + $cli2 = ''; + if (($pz[$i] > 0 || $notr > 0) || (isset($this->u->stats['nopriems']) && $pl['nosh'] == 0) || $this->u->stats['notuse_last_pr'] == $pl['id']) { + $cli2 = ' class="nopriemuse" '; + } + /// ТУТ! + $priemName = $pl['name']; + $priemImg = $pl['img']; + $pr .= << + + + HTML; + + } else { + + if (isset($_GET['inv'])) { + $pr .= ''; + } else { + $pr .= ''; + } + + } + $i++; + } + if ($this->u->info['animal'] > 0) { + $use_lst = $this->u->testAction( + '`uid` = "' . $this->u->info['id'] . '" AND `vars` = "animal_use' . $btl->i->id . '" LIMIT 1', + 1 + ); + if (!isset($use_lst['id'])) { + $pr .= ''; + } else { + $pr .= ''; + } + } + + return str_replace('"', '\\"', $pr); + } + //Мощность / подавление / сопротивление и т.д. public function getByCategory(?int $category_id = null) @@ -2303,9 +2345,7 @@ class Priems echo <<< HTML - + HTML; } diff --git a/_incl_data/class/User.php b/_incl_data/class/User.php index 37c9fc8c..3a541255 100644 --- a/_incl_data/class/User.php +++ b/_incl_data/class/User.php @@ -281,8 +281,8 @@ class User ); $this->addAction( time(), 'frg', '[ ' . $this->info['login'] . ' ] ' . date( - 'd.m.Y H:i:s' - ) . ' [true] , balance: ' . $sb . ' / ' . $this->info['catch'] . ' / ' . $this->info['frg'] . ' ' + 'd.m.Y H:i:s' + ) . ' [true] , balance: ' . $sb . ' / ' . $this->info['catch'] . ' / ' . $this->info['frg'] . ' ' ); } else { mysql_query( @@ -293,8 +293,8 @@ class User if ($sb - 10 > $this->info['catch'] - $this->info['frg']) { $this->addAction( time(), 'frgfalse', '[ ' . $this->info['login'] . ' ] ' . date( - 'd.m.Y H:i:s' - ) . ' [false] , [' . ($sb - ($this->info['catch'] - $this->info['frg'])) . '] , balance: ' . $sb . ' | ' . $this->info['catch'] . ' | ' . $this->info['frg'] . ' ' + 'd.m.Y H:i:s' + ) . ' [false] , [' . ($sb - ($this->info['catch'] - $this->info['frg'])) . '] , balance: ' . $sb . ' | ' . $this->info['catch'] . ' | ' . $this->info['frg'] . ' ' ); } } @@ -382,8 +382,7 @@ class User 'UPDATE `items_users` SET `use_text` = "' . $itm['use_text'] . '" WHERE `id` = "' . $itm['id'] . '" LIMIT 1' ); mysql_query( - 'INSERT INTO `items_text` (`item_id`,`time`,`login`,`text`,`city`,`x`) VALUES ("' . $itm['id'] . '","' . time( - ) . '","' . $this->info['login'] . '","' . mysql_real_escape_string( + 'INSERT INTO `items_text` (`item_id`,`time`,`login`,`text`,`city`,`x`) VALUES ("' . $itm['id'] . '","' . time() . '","' . $this->info['login'] . '","' . mysql_real_escape_string( htmlspecialchars($txt, null) ) . '","' . $this->info['city'] . '","' . $sx . '")' ); @@ -429,8 +428,7 @@ class User $this->error = 'Персонаж уже проводит сделку'; } else { $ins = mysql_query( - 'INSERT INTO `transfers` (`uid1`,`uid2`,`city`,`room`,`time`,`text`,`start1`) VALUES ("' . $this->info['id'] . '","' . $t['id'] . '","' . $this->info['city'] . '","' . $this->info['room'] . '","' . time( - ) . '","' . mysql_real_escape_string( + 'INSERT INTO `transfers` (`uid1`,`uid2`,`city`,`room`,`time`,`text`,`start1`) VALUES ("' . $this->info['id'] . '","' . $t['id'] . '","' . $this->info['city'] . '","' . $this->info['room'] . '","' . time() . '","' . mysql_real_escape_string( htmlspecialchars($_POST['textarea'], null) ) . '","' . time() . '")' ); @@ -754,6 +752,12 @@ class User return $result ?: []; } + public function getStats($uid, $i1 = null, $res = 0, $reimg = false, $btl_cache = false, $minimal = false): array + { + $result = new Stats($this); + return $result->getStats($uid, $i1, $reimg, $btl_cache); + } + private function infoTasks() { if (empty($this->info)) { @@ -813,12 +817,6 @@ class User } } - public function getStats($uid, $i1 = null, $res = 0, $reimg = false, $btl_cache = false, $minimal = false): array - { - $result = new Stats($this); - return $result->getStats($uid, $i1, $reimg, $btl_cache); - } - public function getUserInfoById($id) { return Db::getRow('select * from users left join stats on users.id = stats.id where users.id = ?', [$id]); @@ -3228,8 +3226,7 @@ class User if ($po['sudba'] == '0') { $is2 .= ' '; } elseif ($po['sudba'] == '1') { - $is2 .= ' '; + $is2 .= ' '; } else { $is2 .= ' '; } @@ -3400,8 +3397,7 @@ class User $tr .= '
• Броня ' . $bn[$i] . ': ' . $po['add_mib' . $i] . '-' . $po['add_mab' . $i]; if (isset($po['mf_mib']) && $po['mf_mib'] > 0) { - $tr .= ' '; + $tr .= ' '; } } $i++; @@ -3530,11 +3526,7 @@ class User if (isset($po['free_stats']) && $po['free_stats'] > 0) { $is2 .= '
Распределение статов:'; - $is2 .= '
Сила: ' . $po['add_s1'] . '
Ловкость: ' . $po['add_s2'] . '
Интуиция: ' . $po['add_s3'] . '
Интеллект: ' . $po['add_s5'] . '
'; + $is2 .= '
Сила: ' . $po['add_s1'] . '
Ловкость: ' . $po['add_s2'] . '
Интуиция: ' . $po['add_s3'] . '
Интеллект: ' . $po['add_s5'] . '
'; $is2 .= '• Осталось распределений: ' . $po['free_stats'] . ''; } @@ -3586,28 +3578,17 @@ class User } else { $is2 .= '
Мастерство владения мечами: ' . (0 + $po['add_a1']) . '
- Мастерство владения дубинами, булавами: ' . (0 + $po['add_a2']) . '
- Мастерство владения ножами, кастетами: ' . (0 + $po['add_a3']) . '
- Мастерство владения топорами, секирами: ' . (0 + $po['add_a4']) . '
- Мастерство владения магическими посохами: ' . (0 + $po['add_a5']) . '
- Мастерство владения стихией Огня: ' . (0 + $po['add_mg1']) . '
- Мастерство владения стихией Воздуха: ' . (0 + $po['add_mg2']) . '
- Мастерство владения стихией Воды: ' . (0 + $po['add_mg3']) . '
- Мастерство владения стихией Земли: ' . (0 + $po['add_mg4']) . '
- Мастерство владения магией Света: ' . (0 + $po['add_mg5']) . '
- Мастерство владения магией Тьмы: ' . (0 + $po['add_mg6']) . '
- Мастерство владения серой магией: ' . (0 + $po['add_mg7']) . '
+ Мастерство владения дубинами, булавами: ' . (0 + $po['add_a2']) . '
+ Мастерство владения ножами, кастетами: ' . (0 + $po['add_a3']) . '
+ Мастерство владения топорами, секирами: ' . (0 + $po['add_a4']) . '
+ Мастерство владения магическими посохами: ' . (0 + $po['add_a5']) . '
+ Мастерство владения стихией Огня: ' . (0 + $po['add_mg1']) . '
+ Мастерство владения стихией Воздуха: ' . (0 + $po['add_mg2']) . '
+ Мастерство владения стихией Воды: ' . (0 + $po['add_mg3']) . '
+ Мастерство владения стихией Земли: ' . (0 + $po['add_mg4']) . '
+ Мастерство владения магией Света: ' . (0 + $po['add_mg5']) . '
+ Мастерство владения магией Тьмы: ' . (0 + $po['add_mg6']) . '
+ Мастерство владения серой магией: ' . (0 + $po['add_mg7']) . '
'; $is2 .= 'Осталось распределений: ' . $mx1; } @@ -3760,16 +3741,14 @@ class User mysql_query('SELECT * FROM `clan` WHERE `id` = "' . $po['toclan1'][0] . '" LIMIT 1') ); if (isset($clpo['id'])) { - $is2 .= '
Предмет принадлежит клану ' . $clpo['name'] . ''; + $is2 .= '
Предмет принадлежит клану ' . $clpo['name'] . ''; $plpo = mysql_fetch_array( mysql_query( 'SELECT `id`,`login`,`cityreg` FROM `users` WHERE `id` = "' . $po['toclan1'][1] . '" LIMIT 1' ) ); if (isset($plpo['id'])) { - $is2 .= ' (Дар игрока ' . $plpo['login'] . ')'; + $is2 .= ' (Дар игрока ' . $plpo['login'] . ')'; if ($plpo['login'] == $this->info['login']) { if (isset($_GET['backmyitm'])) { $pl['inOdet'] = 0; @@ -3911,8 +3890,7 @@ class User ) . '" LIMIT 1' ) ); - $is1 .= 'Предмет у игрока
' . $yui['login'] . '
'; + $is1 .= 'Предмет у игрока
' . $yui['login'] . '
'; if ($this->info['tt'][14][0] == 1 || ($this->info['id'] == $us_1)) { $is1 .= '
Изъять предмет'; } @@ -4260,15 +4238,13 @@ class User } if ($pl['magic_inc'] && $pl['type'] == 30) { //используем эликсир - $pldate = '
"' . $pl['name'] . '"
Использовать сейчас?
'; + $pldate = '
"' . $pl['name'] . '"
Использовать сейчас?
'; $useUrl = 'top.useiteminv(\'' . (0 + $pl['id']) . '\',\'' . $pl['img'] . '\',\'' . $pl['img'] . '\',1,\'' . $pldate . '\',\'' . (0 + $_GET['otdel']) . '\');'; } elseif ($pl['magic_inc'] && $pl['type'] == 29) { //используем заклятие if (isset($po['useOnLogin']) && !isset($po['zazuby'])) { //на персонажа $useUrl = 'top.useMagic(\'' . $pl['name'] . '\',' . (0 + $pl['id']) . ',\'' . $pl['img'] . '\',1,\'main.php?' . $inv1 . 'otdel=' . ((int)$_GET['otdel']) . '&use_pid=' . $pl['id'] . '&rnd=' . $code . '\');'; } else { //просто использование (на себя, либо без указания предмета\логина) - $pldate = '
"' . $pl['name'] . '"
Использовать сейчас?
'; + $pldate = '
"' . $pl['name'] . '"
Использовать сейчас?
'; $useUrl = 'top.useiteminv(\'' . (0 + $pl['id']) . '\',\'' . $pl['img'] . '\',\'' . $pl['img'] . '\',1,\'' . $pldate . '\',\'' . (0 + $_GET['otdel']) . '\',' . (0 + $_GET['otdel']) . ');'; } //на предмет @@ -4315,8 +4291,7 @@ class User if ($pl['group'] > 0) { $is1 .= '
'; if ($this->itemsX($pl['id']) < $pl['group_max']) { - $is1 .= ''; + $is1 .= ''; } if ($this->itemsX($pl['id']) > 1) { $tbl = '
@@ -4343,8 +4318,7 @@ class User if ($d[1] == 1) { //можно выкинуть if (!isset($po['nodelete'])) { - $is1 .= '
Предмет ' . $pl['name'] . ' будет утерян, вы уверены ?
\',\'' . intval( $_GET['otdel'] ) . Config::img() . ' / i / clear . gif">'; } @@ -4630,8 +4604,7 @@ class User $itm['data'] = Conversion::dataStringToArray($itm['data']); unset($itm['data']['frompisher']); $itm['data'] = Conversion::arrayToDataString($itm['data']); - if ($pl['data'] == $itm['data'] && $pl['name'] == $itm['name'] && $itm['iznosMAX'] == $pl['iznosMAX'] && $pl['iznosNOW'] == 0 && ($pl['timeOver'] == 0 || $pl['timeOver'] > time( - )) && $pl['gift'] == $itm['gift']) { + if ($pl['data'] == $itm['data'] && $pl['name'] == $itm['name'] && $itm['iznosMAX'] == $pl['iznosMAX'] && $pl['iznosNOW'] == 0 && ($pl['timeOver'] == 0 || $pl['timeOver'] > time()) && $pl['gift'] == $itm['gift']) { $upd = mysql_query( 'UPDATE `items_users` SET `lastUPD` = "' . time() . '", `inGroup` = "' . $itm['inGroup'] . '" WHERE `id` = "' . $pl['id'] . '" LIMIT 1' ); @@ -4730,12 +4703,12 @@ class User $notr++; } } - if (isset($itm['iznosNOW'], $itm['iznosMAX'], $itm['iznosMAXi']) && - $itm['iznosNOW'] >= ceil($itm['iznosMAX']) && - $itm['iznosMAXi'] != 999999999) { + if (isset($itm['iznosnow'], $itm['iznosmax'], $itm['iznosmaxi']) && + $itm['iznosnow'] >= ceil($itm['iznosmax']) && + $itm['iznosmaxi'] != 999999999) { $notr++; } - if ($notr > 0 && $itm['inOdet'] != 0) { + if ($notr > 0 && $itm['inodet'] != 0) { //снимаем предмет $this->snatItem($itm['id'], $u['id']); $snIt++; @@ -4793,16 +4766,16 @@ class User ItemsModel::itemDecay($itm['id'], $itm['overType'], $u['id'], (int)$po['musor2'], $itm['type'], $itm['name']); $notr++; } - if ($itm['iznosNOW'] >= ceil($itm['iznosMAX']) && $itm['iznosMAXi'] != 999999999) { + if ($itm['iznosnow'] >= ceil($itm['iznosmax']) && $itm['iznosmaxi'] != 999999999) { $notr++; } - if ($notr > 0 && $itm['inOdet'] != 0) { + if ($notr > 0 && $itm['inodet'] != 0) { //снимаем предмет $this->snatItem($itm['id'], $u['id']); $snIt++; } //проверяем срок годности - if ($itm['iznosNOW'] >= ceil($itm['iznosMAX']) && $itm['iznosMAXi'] != 999999999 && isset($po['musor']) && $po['musor'] > 0) { + if ($itm['iznosnow'] >= ceil($itm['iznosmax']) && $itm['iznosmaxi'] != 999999999 && isset($po['musor']) && $po['musor'] > 0) { //предмет сломался $this->itemDestroy($itm['id'], $u['id'], (int)$po['musor']); } @@ -5232,8 +5205,7 @@ class User ); $this->error = 'Вам нехорошо...'; } elseif (mysql_query( - 'UPDATE `items_users` SET `uid` = "' . $this->info['id'] . '",`lastUPD` = "' . time( - ) . '",`gift` = "' . $itm['gift'] . '",`gtxt1` = "' . $itm['gtxt1'] . '",`gtxt2` = "Предмет из упаковки. Дата запаковки: ' . date( + 'UPDATE `items_users` SET `uid` = "' . $this->info['id'] . '",`lastUPD` = "' . time() . '",`gift` = "' . $itm['gift'] . '",`gtxt1` = "' . $itm['gtxt1'] . '",`gtxt2` = "Предмет из упаковки. Дата запаковки: ' . date( 'd.m.Y H:i:s', $itmin['time_create'] ) . '" WHERE `id` = "' . $itmin['id'] . '" LIMIT 1' )) { @@ -5264,8 +5236,7 @@ class User $pid = ItemsModel::addItem($s['id'], $this->info['id']); if ($pid > 0) { mysql_query( - 'UPDATE `items_users` SET `lastUPD` = "' . time( - ) . '",`gift` = "' . $itm['gift'] . '" WHERE `id` = "' . $pid . '" AND `uid` = "' . $this->info['id'] . '" LIMIT 1' + 'UPDATE `items_users` SET `lastUPD` = "' . time() . '",`gift` = "' . $itm['gift'] . '" WHERE `id` = "' . $pid . '" AND `uid` = "' . $this->info['id'] . '" LIMIT 1' ); } $j++; @@ -5580,16 +5551,14 @@ LIMIT 1' ); $col = $col[0]; mysql_query( - 'UPDATE `items_users` SET `lastUPD`="' . time() . '",`delete`="' . time( - ) . '" WHERE `item_id`="' . $itm['item_id'] . '" AND `inOdet` = 0 AND `delete` < 100000 AND `uid` = "' . $itm['uid'] . '" AND `data` NOT LIKE "%nodelete%"' . $whr + 'UPDATE `items_users` SET `lastUPD`="' . time() . '",`delete`="' . time() . '" WHERE `item_id`="' . $itm['item_id'] . '" AND `inOdet` = 0 AND `delete` < 100000 AND `uid` = "' . $itm['uid'] . '" AND `data` NOT LIKE "%nodelete%"' . $whr ); $this->error = 'Предметы "' . $itm['name'] . ' (x' . ($col + 1) . ')" выброшены'; Delo::add( 1, 'System.inventory', $uid, - '"System.inventory": Предметы "' . $itm['name'] . ' (x' . $col . ')" [itm:' . $itm['id'] . '=' . time( - ) . '] были выброшены.', + '"System.inventory": Предметы "' . $itm['name'] . ' (x' . $col . ')" [itm:' . $itm['id'] . '=' . time() . '] были выброшены.', ); } else { $this->error = 'Предмет "' . $itm['name'] . '" выброшен'; @@ -6061,8 +6030,7 @@ LIMIT 1' $r = 'Вы успешно изъяли предмет "' . $itm_['name'] . '"
'; $col = $this->itemsX(((int)$id)); mysql_query( - 'INSERT INTO `clan_operations` (`clan`, `time`, `type`, `text`, `val`, `uid`) VALUES ("' . $res['id'] . '", "' . time( - ) . '", "6", "' . $user['login'] . '", "' . $itm_['name'] . ' (x' . $col . ') Ид : [' . $id . '] | У персонажа : [' . $itm_['uid'] . ']", "' . $user['id'] . '")' + 'INSERT INTO `clan_operations` (`clan`, `time`, `type`, `text`, `val`, `uid`) VALUES ("' . $res['id'] . '", "' . time() . '", "6", "' . $user['login'] . '", "' . $itm_['name'] . ' (x' . $col . ') Ид : [' . $id . '] | У персонажа : [' . $itm_['uid'] . ']", "' . $user['id'] . '")' ); mysql_query( 'UPDATE `items_users` SET `lastUPD` = "' . time() . '", `uid` = "-21' . $res['id'] . '" ' . $o . ' WHERE `id` = "' . $id . '" LIMIT 1' @@ -6093,8 +6061,7 @@ LIMIT 1' if ($user['inTurnir'] == 0 && $user['inTurnirnew'] == 0) { $col = $this->itemsX(((int)$id)); mysql_query( - 'INSERT INTO `clan_operations` (`clan`, `time`, `type`, `text`, `val`, `uid`) VALUES ("' . $res['id'] . '", "' . time( - ) . '", "5", "' . $user['login'] . '", "' . $itm_['name'] . ' (x' . $col . ') Ид : [' . $id . '] Хозяин : [' . $cls . ']", "' . $user['id'] . '")' + 'INSERT INTO `clan_operations` (`clan`, `time`, `type`, `text`, `val`, `uid`) VALUES ("' . $res['id'] . '", "' . time() . '", "5", "' . $user['login'] . '", "' . $itm_['name'] . ' (x' . $col . ') Ид : [' . $id . '] Хозяин : [' . $cls . ']", "' . $user['id'] . '")' ); mysql_query( 'UPDATE `items_users` SET `lastUPD` = "' . time() . '", `uid` = "' . $user['id'] . '" WHERE `id` = "' . $id . '" LIMIT 1' @@ -6136,8 +6103,7 @@ LIMIT 1' 'UPDATE `items_users` SET `lastUPD` = "' . time() . '", `uid` = "' . $user['id'] . '", `data` = "' . $pl['data'] . '" WHERE `id` = "' . $pl['id'] . '"' ); mysql_query( - 'INSERT INTO `clan_operations` (`clan`, `time`, `type`, `text`, `val`, `uid`) VALUES ("' . $res['id'] . '", "' . time( - ) . '", "' . $type . '", "' . $user['login'] . '", "' . $it_n['name'] . ' (x' . $col . ') Ид : [' . $pl['id'] . ']", "' . $user['id'] . '")' + 'INSERT INTO `clan_operations` (`clan`, `time`, `type`, `text`, `val`, `uid`) VALUES ("' . $res['id'] . '", "' . time() . '", "' . $type . '", "' . $user['login'] . '", "' . $it_n['name'] . ' (x' . $col . ') Ид : [' . $pl['id'] . ']", "' . $user['id'] . '")' ); } elseif ($pl['uid'] == $user['id']) { $col = $this->itemsX(((int)$pl['id'])); @@ -6148,8 +6114,7 @@ LIMIT 1' 'UPDATE `items_users` SET `lastUPD` = "' . time() . '", `uid` = "-21' . $user['clan'] . '" WHERE `id` = "' . $pl['id'] . '"' ); mysql_query( - 'INSERT INTO `clan_operations` (`clan`, `time`, `type`, `text`, `val`, `uid`) VALUES ("' . $res['id'] . '", "' . time( - ) . '", "9", "' . $user['login'] . '", "' . $it_n['name'] . ' (x' . $col . ') Ид : [' . $pl['id'] . ']", "' . $user['id'] . '")' + 'INSERT INTO `clan_operations` (`clan`, `time`, `type`, `text`, `val`, `uid`) VALUES ("' . $res['id'] . '", "' . time() . '", "9", "' . $user['login'] . '", "' . $it_n['name'] . ' (x' . $col . ') Ид : [' . $pl['id'] . ']", "' . $user['id'] . '")' ); } } diff --git a/_incl_data/class/User/Item.php b/_incl_data/class/User/Item.php index 2b40e47e..f0593434 100644 --- a/_incl_data/class/User/Item.php +++ b/_incl_data/class/User/Item.php @@ -87,7 +87,7 @@ class Item 'iznosNOW' => $iNow, 'iznosMAX' => $iMax, ] = $item; - $this->durability = $iMax - $iNow; + $this->durability = (int)$iMax - (int)$iNow; $stat = new Stat(); $stat->getBonus(); $dataArr = Conversion::dataStringToArray(strtolower($this->data)); diff --git a/jx/battle/refresh.php b/jx/battle/refresh.php index 34281d40..995615d9 100644 --- a/jx/battle/refresh.php +++ b/jx/battle/refresh.php @@ -208,7 +208,7 @@ if (!$isBattle) { } - $js .= '$("#priems").html("' . $priem->seeMy(2) . '");'; + $js .= '$("#priems").html("' . $priem->seeMy() . '");'; $jslog = $btl->lookmLog() . $btl->lookLog(); if ($jslog != '') { $js = $jslog . $js; diff --git a/jx/battle/refresh1.php b/jx/battle/refresh1.php index 7fd9144f..368e1c2c 100644 --- a/jx/battle/refresh1.php +++ b/jx/battle/refresh1.php @@ -190,7 +190,7 @@ if (!$isBattle) { $rehtml = ''; if (!isset($CRON_CORE)) { - $js .= '$("#priems").html("' . $priem->seeMy(2) . '");'; + $js .= '$("#priems").html("' . $priem->seeMy() . '");'; $jslog = $btl->lookmLog(); $jslog .= $btl->lookLog(); if ($jslog != '') { diff --git a/jx/battle/refresh2.php b/jx/battle/refresh2.php index 22e873d3..4152a5e6 100644 --- a/jx/battle/refresh2.php +++ b/jx/battle/refresh2.php @@ -193,7 +193,7 @@ if (isset($_POST['atack'], $_POST['block']) || (isset($_POST['id']) && $_POST['i $rehtml = ''; if (!isset($CRON_CORE)) { - $js .= '$("#priems").html("' . $priem->seeMy(2) . '");'; + $js .= '$("#priems").html("' . $priem->seeMy() . '");'; //if(!isset($_POST['usepriem'])) { $jslog = $btl->lookLog(); if ($jslog != '') { diff --git a/modules_data/_inv.php b/modules_data/_inv.php index 215dc6c8..08fe47c0 100644 --- a/modules_data/_inv.php +++ b/modules_data/_inv.php @@ -94,8 +94,7 @@ if (isset($_POST['compname'])) { if (!isset($tcm['id'])) { //добавляем новый комплект $ins = mysql_query( - 'INSERT INTO `save_com` (`uid`,`time`,`name`,`val`,`type`) VALUES ("' . $u->info['id'] . '","' . time( - ) . '","' . mysql_real_escape_string($_POST['compname']) . '","' . $ptst . '","0")' + 'INSERT INTO `save_com` (`uid`,`time`,`name`,`val`,`type`) VALUES ("' . $u->info['id'] . '","' . time() . '","' . mysql_real_escape_string($_POST['compname']) . '","' . $ptst . '","0")' ); if ($ins) { $u->error = 'Комплект "' . $_POST['compname'] . '" был успешно сохранен'; @@ -117,8 +116,7 @@ if (isset($_POST['compname'])) { } } elseif (isset($_GET['delc1'])) { $cmpl = mysql_query( - 'UPDATE `save_com` SET `delete` = "' . time( - ) . '" WHERE `uid` = "' . $u->info['id'] . '" AND `delete` = "0" AND `id` = "' . mysql_real_escape_string( + 'UPDATE `save_com` SET `delete` = "' . time() . '" WHERE `uid` = "' . $u->info['id'] . '" AND `delete` = "0" AND `id` = "' . mysql_real_escape_string( $_GET['delc1'] ) . '" LIMIT 1' ); @@ -433,13 +431,10 @@ if (isset($_GET['mAjax'])) { echo $usee ? $usee[0] : 'information is lost.'; $priem = new Priems(); echo '
'; - $priem->seeMy(1); + $priem->seeMyPriems(); echo '
' . $u->info_remont(); ?>
-
- -
diff --git a/modules_data/_umenie.php b/modules_data/_umenie.php index 91cdefe7..fe40522c 100644 --- a/modules_data/_umenie.php +++ b/modules_data/_umenie.php @@ -9,6 +9,7 @@ use Core\Config; use DarksLight2\Battle\Techniques\TechniqueCategoryEntity; use DarksLight2\Training\TrainingManager; use Helper\Conversion; +use Model\Constant\Stat; if (!defined('GAME')) { die(); @@ -161,7 +162,7 @@ $tma = ''; +