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 '
"' . $pl['name'] . '" Использовать сейчас? |
"' . $pl['name'] . '" Использовать сейчас? |
"' . $pl['name'] . '" Использовать сейчас? |
"' . $pl['name'] . '" Использовать сейчас? |
@@ -4343,8 +4318,7 @@ class User
if ($d[1] == 1) { //можно выкинуть
if (!isset($po['nodelete'])) {
- $is1 .= ' Предмет ' . $pl['name'] . ' будет утерян, вы уверены ? | |