2022-12-19 20:22:19 +00:00
< ? php
2023-12-19 01:58:37 +00:00
use Battle\Finish ;
use Battle\Helper ;
2024-01-06 15:30:34 +00:00
use Battle\Info ;
2023-12-17 02:32:09 +00:00
use Battle\Log ;
2024-01-05 22:14:35 +00:00
use Battle\Razmen ;
2023-12-17 02:32:09 +00:00
use Clan\ClanInfo ;
2023-03-31 16:54:33 +00:00
use Core\Config ;
use Core\Db ;
2024-01-06 15:30:34 +00:00
use DTO\BattlePriem ;
2024-02-10 16:18:11 +00:00
use Helper\Comparsion ;
2023-08-14 15:15:05 +00:00
use Helper\Conversion ;
2024-01-08 01:33:20 +00:00
use Model\Constant\Stat ;
2023-12-17 02:32:09 +00:00
use User\Effects ;
2023-08-14 15:15:05 +00:00
use User\ItemsModel ;
2024-01-05 22:14:35 +00:00
use User\Login ;
2023-12-19 01:58:37 +00:00
use User\Stats ;
2023-03-31 16:54:33 +00:00
2022-12-19 20:22:19 +00:00
class Battle
{
2022-12-30 19:03:37 +00:00
public array $mncolor = [
2022-12-19 20:22:19 +00:00
1 => '006699' ,
2 => '006699' ,
3 => '006699' ,
4 => '006699' ,
5 => '006699' ,
6 => '006699' ,
7 => '006699' ,
2023-01-10 16:29:32 +00:00
]; //не крит
2022-12-30 19:03:37 +00:00
public array $mcolor = [
2022-12-19 20:22:19 +00:00
1 => 'A00000' ,
2 => '008080' ,
3 => '0000FF' ,
4 => 'A52A2A' ,
5 => '006699' ,
6 => '006699' ,
7 => '006699' ,
2023-01-10 16:29:32 +00:00
]; //не крит
2022-12-30 19:03:37 +00:00
public array $mname = [
2023-01-10 16:29:32 +00:00
'огонь' => 1 ,
'воздух' => 2 ,
'вода' => 3 ,
'земля' => 4 ,
'свет' => 5 ,
'тьма' => 6 ,
'серая' => 7 ,
2022-12-19 20:22:19 +00:00
];
2024-01-05 22:14:35 +00:00
/**Кэширование данных (?!)*/
public bool $cached = false ;
/**Отображаем главное окно (1 - можно бить, 2 - ожидаем ход противника, 3 - Проиграли. Ожидаем завершения поединка)*/
public int $mainStatus = 1 ;
2024-01-08 01:33:20 +00:00
/** Информация о поединке.*/
2024-01-06 15:30:34 +00:00
public Info $i ;
2024-01-05 22:14:35 +00:00
/**Информация о пользователях в этом бою*/
public array $users = [];
/**Информация о статах пользователей в этом бою. Фактичесчки $user->stats для каждого участинка поединко.*/
public array $stats = [];
/**Массив объектов бойцов*/
public array $fighters = [];
/** Список пользователей и их id в stats или users .
*
* В с е id пользователей записываются в этот массив по очереди , где id выступает ключом , а значение
* это порядковый номер .
*
* Например id пользователя = 555 , то $uids [ 555 ] выдаст е г о порядковый номер в массиве users \ stats
*/
public array $uids = [];
/**Список ударов в этом бою (действующих)*/
public array $atacks = [];
/**Список uid кто нанес удар и по кому $ga[ {id кто ударил} ][ {id кого ударил} ]*/
public array $ga = [];
2024-02-09 19:41:54 +00:00
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 ; //Если игрок нанес удар
2024-01-05 22:14:35 +00:00
/**Список uid кто нанес удар и по кому $ga[ {id кого ударили} ][ {id кто ударил} ]*/
private array $ag = [];
2024-02-09 19:41:54 +00:00
//Очистка кэша для ...
2023-12-17 02:32:09 +00:00
private int | array $stnZbVs = 0 ;
2024-02-09 19:41:54 +00:00
private array $iBots = [];
2023-12-17 02:32:09 +00:00
private array $stnZb = [];
2024-01-05 22:14:35 +00:00
/** Выбранные зоны атаки и блока */
2023-12-17 02:32:09 +00:00
private array $uAtc = [
2023-03-31 16:54:33 +00:00
'id' => 0 ,
'a' => [ 1 => 0 , 2 => 0 , 3 => 0 , 4 => 0 , 5 => 0 ],
'b' => 0 ,
2024-02-09 19:41:54 +00:00
];
2023-12-17 02:32:09 +00:00
private array $uclearc = [];
private array $ucleari = [];
private array $poglast = [];
private int $importUser = 0 ;
2023-12-19 01:58:37 +00:00
private Finish $finish ;
2023-03-31 16:54:33 +00:00
2024-01-16 07:13:15 +00:00
public function __construct ( private readonly Stat $statnames = new Stat ())
2022-12-19 20:22:19 +00:00
{
2023-03-31 16:54:33 +00:00
ignore_user_abort ( true );
2024-01-16 07:13:15 +00:00
$this -> statnames -> getBonus ();
2023-12-19 01:58:37 +00:00
$this -> finish = new Finish ( $this );
2024-01-06 15:30:34 +00:00
2024-02-09 19:41:54 +00:00
$this -> prm = [
1 => new BattlePriem ( act : 1 , typeOf : 5 ),
2024-02-09 17:49:51 +00:00
2 => new BattlePriem ( act : 2 , typeOf : 3 ),
4 => new BattlePriem ( act : 2 , typeOf : 3 ),
7 => new BattlePriem ( act : 1 , 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 ),
2024-02-09 19:41:54 +00:00
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 ),
2024-02-09 17:49:51 +00:00
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 ),
2024-02-09 19:41:54 +00:00
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 ),
2024-02-09 17:49:51 +00:00
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 ),
2024-02-09 19:41:54 +00:00
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 ),
216 => new BattlePriem ( act : 2 , typeOf : 2 ),
217 => new BattlePriem ( act : 2 , typeOf : 0 , moment : 3 ),
219 => new BattlePriem ( act : 2 , typeOf : 3 ),
220 => new BattlePriem ( act : 2 , typeOf : 0 , moment : 3 ),
222 => new BattlePriem ( act : 2 , typeOf : 3 ),
225 => new BattlePriem ( act : 1 , typeOf : 4 ),
226 => new BattlePriem ( act : 1 , typeOf : 4 ),
231 => new BattlePriem ( act : 2 , typeOf : 0 , moment : 3 ),
234 => new BattlePriem ( act : 2 , typeOf : 4 ),
235 => new BattlePriem ( act : 2 , typeOf : 3 ),
237 => new BattlePriem ( act : 2 , typeOf : 3 ),
239 => new BattlePriem ( act : 2 , typeOf : 3 ),
240 => new BattlePriem ( act : 2 , typeOf : 5 ),
245 => new BattlePriem ( act : 2 , typeOf : 9 ),
2024-02-09 17:49:51 +00:00
248 => new BattlePriem ( act : 2 , typeOf : 4 ),
2024-02-09 19:41:54 +00:00
249 => new BattlePriem ( act : 2 , typeOf : 4 ),
2024-02-09 17:49:51 +00:00
251 => new BattlePriem ( act : 2 , typeOf : 0 , moment : 0 , momentEnd : 3 ),
252 => new BattlePriem ( act : 2 , typeOf : 0 , moment : 0 , momentEnd : 3 ),
2024-02-09 19:41:54 +00:00
255 => new BattlePriem ( act : 2 , typeOf : 8 ),
269 => new BattlePriem ( act : 2 , typeOf : 9 ),
270 => new BattlePriem ( act : 2 , typeOf : 5 , typeSec : 5 ),
2024-02-09 17:49:51 +00:00
273 => new BattlePriem ( act : 1 , typeOf : 4 ),
2024-02-09 19:41:54 +00:00
276 => new BattlePriem ( act : 2 , typeOf : 9 ),
277 => new BattlePriem ( act : 2 , typeOf : 9 ),
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 ),
284 => new BattlePriem ( act : 2 , typeOf : 8 ),
2024-02-09 17:49:51 +00:00
286 => new BattlePriem ( act : 1 , typeOf : 4 ),
287 => new BattlePriem ( act : 1 , typeOf : 4 ),
288 => new BattlePriem ( act : 1 , typeOf : 4 ),
2024-02-09 19:41:54 +00:00
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 ),
2024-02-09 17:49:51 +00:00
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 ),
330 => new BattlePriem ( act : 2 , typeOf : 0 , moment : 0 , momentEnd : 3 ),
331 => new BattlePriem ( act : 2 , typeOf : 0 , moment : 0 , momentEnd : 3 ),
332 => new BattlePriem ( act : 2 , typeOf : 0 , moment : 0 , momentEnd : 3 ),
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 ),
2024-02-09 19:41:54 +00:00
337 => new BattlePriem ( act : 2 , typeOf : 5 ),
342 => new BattlePriem ( act : 0 , typeOf : 0 ),
343 => new BattlePriem ( act : 0 , typeOf : 0 ),
2024-01-06 15:30:34 +00:00
];
2023-03-31 16:54:33 +00:00
}
2024-02-09 19:41:54 +00:00
/**
* @ param int | null $experience
2024-05-10 11:32:06 +00:00
* @ param bool $hardcore поединок с гарантированной травмой
2024-02-09 19:41:54 +00:00
* @ 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 информация о игроке
2024-01-05 22:14:35 +00:00
public function initRefresh ( User $user ) : bool
{
2024-01-06 15:30:34 +00:00
$this -> i = new Info ( $user -> info [ 'battle' ]);
2024-01-08 01:33:20 +00:00
$this -> hodID = Db :: getValue ( 'select id_hod from battle_logs where battle = ? order by id desc limit 1' , [ $this -> i -> id ]);
if ( ! $this -> hodID ) {
$this -> hodID = 0 ;
}
2024-01-06 15:30:34 +00:00
return ! empty ( $this -> i -> id );
2024-01-05 22:14:35 +00:00
}
public function maginfoattack ( $u1 , $u2 , $type ) : int
2023-03-31 16:54:33 +00:00
{
/*
1 - огонь ,
2 - воздух ,
3 - вода ,
4 - земля
*/
$v_l = str_replace ( ' ' , ' ' , $this -> users [ $this -> uids [ $u1 ]][ 'login' ]);
$v_z = ( int ) $this -> stats [ $this -> uids [ $u2 ]][ 'zm' . $type ]; //защита цели
$v_p = ( int ) round (
(
$this -> stats [ $this -> uids [ $u1 ]][ 'pzm' . $type ] +
$this -> stats [ $this -> uids [ $u1 ]][ 'pzm' ]
)
* 0.4
); //подавление защиты от магии
$v_m = ( int ) $this -> stats [ $this -> uids [ $u1 ]][ 'pm' . $type ]; //мощность мага
//
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(); ' ;
}
2024-02-09 19:41:54 +00:00
//Мини лог
public function hphe ( $uid , $hp , $false_t7 = false ) : int
2022-12-19 20:22:19 +00:00
{
if ( ! isset ( $this -> stats [ $this -> uids [ $uid ]])) {
2023-01-10 16:29:32 +00:00
echo 'WARNING! ОШИБКА! ПОТЕРЯНА ПЕРЕМЕННАЯ ЗДОРОВЬЯ ПЕРСОНАЖА!' ;
2024-02-09 19:41:54 +00:00
return ( int ) $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 ) {
2022-12-19 20:22:19 +00:00
$hp = 0 ;
2024-02-09 19:41:54 +00:00
$this -> users [ $this -> uids [ $uid ]][ 'tactic7' ] = 0 ;
$this -> stats [ $this -> uids [ $uid ]][ 'tactic7' ] = $this -> users [ $this -> uids [ $uid ]][ 'tactic7' ];
2022-12-19 20:22:19 +00:00
} else {
2024-02-09 19:41:54 +00:00
$gdhh = round ( $hp / $this -> stats [ $this -> uids [ $uid ]][ 'hpAll' ] * 10 , 2 );
if ( $gdhh == 0 ) {
$gdhh = 0.01 ;
}
2022-12-19 20:22:19 +00:00
2024-02-09 19:41:54 +00:00
$gdhd = round ( $this -> users [ $this -> uids [ $uid ]][ 'tactic7' ] / $gdhh * 100 );
2022-12-19 20:22:19 +00:00
2024-02-09 19:41:54 +00:00
$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 );
2022-12-19 20:22:19 +00:00
}
}
}
2024-02-09 19:41:54 +00:00
} elseif ( $hp < 0 ) {
//Отнимаемф
if ( $hpnow + $hp < 0 ) {
$hpli = $hpnow + $hp ;
$hp += - ( $hpli );
2022-12-19 20:22:19 +00:00
}
2024-02-09 19:41:54 +00:00
}
2022-12-19 20:22:19 +00:00
2024-02-09 19:41:54 +00:00
if ( $this -> stats [ $this -> uids [ $uid ]][ 'hpNow' ] < 1 ) {
$hp = 0 ;
2022-12-19 20:22:19 +00:00
}
2024-02-09 19:41:54 +00:00
$this -> stats [ $this -> uids [ $uid ]][ 'last_hp' ] = - $hp ;
2022-12-19 20:22:19 +00:00
2024-02-09 19:41:54 +00:00
Db :: sql (
'update stats set last_hp = ?, tactic7 = ? where id = ?' , [
2024-05-10 11:32:06 +00:00
$this -> users [ $this -> uids [ $uid ]][ 'last_hp' ],
$this -> users [ $this -> uids [ $uid ]][ 'tactic7' ],
$uid ,
]
2024-02-09 19:41:54 +00:00
);
2022-12-19 20:22:19 +00:00
2024-02-09 19:41:54 +00:00
return ( int ) $hp ;
2022-12-19 20:22:19 +00:00
}
2024-02-09 19:41:54 +00:00
//Проверяем завершение боя
2023-08-10 14:51:16 +00:00
2023-03-31 16:54:33 +00:00
/**
* Какая - то хуедрыга для номерных файлов - приёмов
* @ param int $pid
* @ param int $uid
* @ param int $id
* @ return void
*/
2023-12-17 02:32:09 +00:00
public function deleffm ( int $pid , int $uid , int $id ) : void
2022-12-19 20:22:19 +00:00
{
2024-02-09 19:41:54 +00:00
Db :: sql ( " delete from eff_users where v1 = 'priem' and (id = ? and v2 != 0 or uid = ? and v2 = ?) " , [ $id , $uid , $pid ]);
2022-12-19 20:22:19 +00:00
}
2024-02-09 19:41:54 +00:00
//завершение поединка
2022-12-19 20:22:19 +00:00
2023-12-17 02:32:09 +00:00
public function clear_cache_start () : void
2022-12-19 20:22:19 +00:00
{
2023-03-31 16:54:33 +00:00
$uids = implode ( ',' , $this -> ucleari );
Db :: sql ( 'delete from battle_cache where uid in (?)' , [ $uids ]);
2022-12-19 20:22:19 +00:00
}
2023-03-31 16:54:33 +00:00
/**
* Проверка урон приемов над защитными .
* Игрок 1 бьет по Игроку 2 при помощи приема на hp ед . здоровья .
2023-12-17 02:32:09 +00:00
* @ param $u2
* @ param array $hp
* @ return array
2023-03-31 16:54:33 +00:00
*/
2023-12-17 02:32:09 +00:00
public function testYronPriemAttack ( $u2 , array $hp ) : array
2023-03-31 16:54:33 +00:00
{
2023-01-10 16:29:32 +00:00
//Получаем приемы и смотрим когда какой действует
2023-03-31 16:54:33 +00:00
foreach ( $this -> stats [ $this -> uids [ $u2 ]][ 'effects' ] as $effect ) {
2023-11-02 13:57:39 +00:00
if ( ! isset ( $effect ) ||
$effect [ 'id_eff' ] != 22 ||
$effect [ 'v1' ] != 'priem' ||
$effect [ 'v2' ] != 140 && $effect [ 'v2' ] != 211 && $effect [ 'v2' ] != 45
2023-03-31 16:54:33 +00:00
) {
2023-11-02 13:57:39 +00:00
continue ;
2022-12-19 20:22:19 +00:00
}
2023-11-02 13:57:39 +00:00
//Приемы от которых урон = 1 , то есть выдаем 0
$hp [ 'y' ] = - 1 ;
$hp [ 'r' ] = 1 ;
$hp [ 'k' ] = 2 ;
$hp [ 'm_y' ] = 1 ;
$hp [ 'm_k' ] = 2 ;
2022-12-19 20:22:19 +00:00
}
return $hp ;
}
2023-12-17 02:32:09 +00:00
public function takeYronNow ( int $uid , int | float $hpDamageValue ) : void
2022-12-19 20:22:19 +00:00
{
2023-08-10 14:51:16 +00:00
global $u ;
2023-12-17 02:32:09 +00:00
( int ) $hpDamageValue = floor ( $hpDamageValue );
$this -> users [ $this -> uids [ $uid ]][ 'battle_yron' ] += $hpDamageValue ;
$this -> stats [ $this -> uids [ $uid ]][ 'battle_yron' ] += $hpDamageValue ;
2023-08-10 14:51:16 +00:00
if ( $uid == $u -> info [ 'id' ]) {
2023-12-17 02:32:09 +00:00
$u -> info [ 'battle_yron' ] += $hpDamageValue ;
$u -> stats [ 'battle_yron' ] += $hpDamageValue ;
2022-12-19 20:22:19 +00:00
}
2023-12-17 02:32:09 +00:00
Db :: sql ( 'update stats set battle_yron = battle_yron + ? where id = ?' , [ $hpDamageValue , $uid ]);
2022-12-19 20:22:19 +00:00
}
2024-02-09 19:41:54 +00:00
//Проводим удар
2023-12-17 02:32:09 +00:00
public function myInfo ( $id , $t ) : string
2022-12-19 20:22:19 +00:00
{
2023-09-30 20:17:25 +00:00
global $u ;
2023-08-10 14:51:16 +00:00
if ( ! isset ( $this -> users [ $this -> uids [ $id ]]) && $u -> info [ 'id' ] != $id ) {
2023-12-17 02:32:09 +00:00
return '' ;
2023-08-10 14:51:16 +00:00
}
2024-01-05 22:14:35 +00:00
2023-08-10 14:51:16 +00:00
if ( $u -> info [ 'id' ] == $id || ( $u -> info [ 'enemy' ] == $id && $id > 0 )) {
//Всегда обновляем
2023-09-30 20:17:25 +00:00
$this -> users [ $this -> uids [ $id ]] = Db :: getRow (
' select u . zag , u . id , u . login , u . login2 , u . online , u . admin , u . city , u . cityreg , u . align , u . align_lvl , u . align_exp , u . clan ,
2023-08-10 14:51:16 +00:00
u . level , u . money , u . money3 , u . money2 , u . money4 , u . battle , u . sex , u . obraz , u . win , u . win_t ,
2024-01-06 15:30:34 +00:00
u . lose , u . lose_t , u . nich , u . timemain , u . invis , u . bot_id , u . animal , u . type_pers ,
u . notrhod , u . bot_room , u . inuser , u . inturnir , u . inturnirnew , u . stopexp , u . real , s .* from users as u left join stats as s on ( u . id = s . id ) where u . id = ? ' , [ $id ]
2023-09-30 20:17:25 +00:00
);
2022-12-19 20:22:19 +00:00
2023-08-10 14:51:16 +00:00
$this -> stats [ $this -> uids [ $id ]] = $u -> getStats ( $this -> users [ $this -> uids [ $id ]], 0 , 0 , false , false , true );
2022-12-19 20:22:19 +00:00
2023-08-10 14:51:16 +00:00
}
$ur = $this -> users [ $this -> uids [ $id ]];
$st = $this -> stats [ $this -> uids [ $id ]];
$itm = $this -> stats [ $this -> uids [ $id ]][ 'items' ];
$eff = $this -> stats [ $this -> uids [ $id ]][ 'effects' ];
2024-02-10 01:12:05 +00:00
2023-08-10 14:51:16 +00:00
$i = 0 ;
2023-12-17 02:32:09 +00:00
$img = Config :: img ();
$armor1 = '<br>Броня головы: ' ;
$armor2 = '<br>Броня корпуса: ' ;
$armor3 = '<br>Броня пояса: ' ;
$armor4 = '<br>Броня ног: ' ;
2024-02-10 01:12:05 +00:00
if ( empty ( $eff )) {
$ef = '' ;
} else {
if ( $u -> info [ 'seff' ] < 1 ) {
# Передаётся в js, переносы строк всё ломают!
$ef = <<< HTML
2024-01-05 22:14:35 +00:00
< div class = " pimg " pog = " 0 " col = " 0 " stl = " 0 " stt = " Свернуть " >< img src = " $img /i/eff/effs_hide.gif " alt = " " onclick = " top.useMagicBattle('Свернуть',7777,'effs_show.gif',1,2); " onmouseover = " top.hi(this,'<strong>Свернуть</strong>',event,3,1,1,1); " onmouseout = " top.hic(); " onmousedown = " top.hic(); " ></ div >
2023-12-17 02:32:09 +00:00
HTML ;
2023-08-10 14:51:16 +00:00
2024-02-10 01:12:05 +00:00
while ( $i != - 1 ) {
$nseef = 0 ;
if (
$this -> users [ $this -> uids [ $ur [ 'id' ]]][ 'id' ] != $u -> info [ 'id' ] &&
$ur [ 'id' ] != 0 && $this -> stats [ $this -> uids [ $ur [ 'id' ]]][ 'seeAllEff' ] != 1
) {
$nseef = 1 ;
if ( isset ( $eff [ $i ][ 'v1' ]) && $eff [ $i ][ 'v1' ] == 'priem' ) {
$eff [ $i ][ 'priem' ] = Db :: getRow ( 'select * from priems where id = ?' , [ $eff [ $i ][ 'v2' ]]);
2022-12-19 20:22:19 +00:00
2024-02-10 01:12:05 +00:00
}
if ( isset ( $eff [ $i ][ 'priem' ][ 'id' ]) && $eff [ $i ][ 'priem' ][ 'neg' ] == 1 ) {
$nseef = 0 ;
}
2023-12-17 02:32:09 +00:00
}
2023-03-31 16:54:33 +00:00
2024-02-10 01:12:05 +00:00
if ( isset ( $eff [ $i ]) && $eff [ $i ] != 'delete' ) {
if ( $nseef == 0 ) {
$ei = '<strong><u>' . $eff [ $i ][ 'name' ] . '</u></strong>' ;
if ( $eff [ $i ][ 'x' ] > 1 ) {
$ei .= ' x' . $eff [ $i ][ 'x' ] . ' ' ;
}
2023-12-17 02:32:09 +00:00
2024-02-10 01:12:05 +00:00
$ei .= match ( $eff [ $i ][ 'type1' ]) {
1 , 2 , 3 , 4 , 5 , 6 => ' (Эликсир)' ,
7 , 8 , 9 , 10 , 16 => ' (Заклятие)' ,
14 => ' (Прием)' ,
15 => ' (Изучение)' ,
17 => ' (Проклятие)' ,
18 , 19 => ' (Травма)' ,
20 => ' (Пристрастие)' ,
22 => ' (Ожидание)' ,
default => ' (Эффект)'
};
$ei .= '<br>' ;
$time_still = ( $eff [ $i ][ 'timeUse' ] + ( $eff [ $i ][ 'timeAce' ] - $eff [ $i ][ 'timeUse' ]) + $eff [ $i ][ 'actionTime' ]);
if ( $eff [ $i ][ 'timeAce' ] == 0 ) {
$time_still += $eff [ $i ][ 'timeUse' ];
2022-12-19 20:22:19 +00:00
}
2024-02-10 01:12:05 +00:00
$time_still -= time ();
if ( $eff [ $i ][ 'bp' ] == 0 && $eff [ $i ][ 'timeUse' ] != 77 ) {
if ( $eff [ $i ][ 'type1' ] != 13 ) {
$ei .= 'Осталось: ' . Conversion :: secondsToTimeout ( $time_still );
}
} else {
if ( $eff [ $i ][ 'timeUse' ] != 77 && $eff [ $i ][ 'hod' ] < 1 ) {
$ei .= 'Осталось: ' . Conversion :: secondsToTimeout ( $time_still );
} elseif ( $eff [ $i ][ 'hod' ] >= 0 ) {
$ei .= 'Зарядов: ' . $eff [ $i ][ 'hod' ];
}
2022-12-19 20:22:19 +00:00
}
2024-02-10 01:12:05 +00:00
if ( $eff [ $i ][ 'user_use' ] != '' ) {
$str = '<br>Автор: <strong>%s</strong>' ;
if ( $this -> users [ $this -> uids [ $eff [ $i ][ 'user_use' ]]][ 'login2' ] != '' ) {
$ei .= sprintf ( $str , $this -> users [ $this -> uids [ $eff [ $i ][ 'user_use' ]]][ 'login2' ]);
} elseif ( $this -> users [ $this -> uids [ $eff [ $i ][ 'user_use' ]]][ 'login' ] != '' ) {
$ei .= sprintf ( $str , $this -> users [ $this -> uids [ $eff [ $i ][ 'user_use' ]]][ 'login' ]);
}
unset ( $str );
2022-12-19 20:22:19 +00:00
}
2024-02-10 01:12:05 +00:00
//Действие эффекта
$tr = '' ;
$x = 0 ;
$ed = Conversion :: dataStringToArray ( $eff [ $i ][ 'data' ]);
while ( $x < count ( $this -> statnames -> sysBonusNames )) {
$n = $this -> statnames -> sysBonusNames [ $x ];
if ( isset ( $ed [ 'add_' . $n ]) && $n != 'pog' ) {
$z = '' ;
if ( $ed [ 'add_' . $n ] > 0 ) {
$z = '+' ;
}
$tr .= '<br>' . $this -> statnames -> bonusNames [ $n ] . ': ' . $z . $ed [ 'add_' . $n ];
2022-12-19 20:22:19 +00:00
}
2024-02-10 01:12:05 +00:00
$x ++ ;
2022-12-19 20:22:19 +00:00
}
2024-02-10 01:12:05 +00:00
if ( isset ( $ed [ 'add_mib1' ]) && $ed [ 'add_mib1' ] != 0 ) {
if ( $ed [ 'add_mab1' ] != 0 ) {
$tr .= $armor1 . $ed [ 'add_mib1' ] . '-' . $ed [ 'add_mab1' ];
} else {
$m1l = $ed [ 'add_mib1' ];
if ( $m1l > 0 ) {
$m1l = '+' . $m1l ;
}
$tr .= $armor1 . $m1l ;
2022-12-19 20:22:19 +00:00
}
}
2024-02-10 01:12:05 +00:00
if ( isset ( $ed [ 'add_mib2' ]) && $ed [ 'add_mib2' ] != 0 ) {
if ( $ed [ 'add_mab2' ] != 0 ) {
$tr .= $armor2 . $ed [ 'add_mib2' ] . '-' . $ed [ 'add_mab2' ];
} else {
$m1l = $ed [ 'add_mib2' ];
if ( $m1l > 0 ) {
$m1l = '+' . $m1l ;
}
$tr .= $armor2 . $m1l ;
2022-12-19 20:22:19 +00:00
}
}
2024-02-10 01:12:05 +00:00
if ( isset ( $ed [ 'add_mib3' ]) && $ed [ 'add_mib3' ] != 0 ) {
if ( $ed [ 'add_mab3' ] != 0 ) {
$tr .= $armor3 . $ed [ 'add_mib3' ] . '-' . $ed [ 'add_mab3' ];
} else {
$m1l = $ed [ 'add_mib3' ];
if ( $m1l > 0 ) {
$m1l = '+' . $m1l ;
}
$tr .= $armor3 . $m1l ;
2022-12-19 20:22:19 +00:00
}
}
2024-02-10 01:12:05 +00:00
if ( isset ( $ed [ 'add_mib4' ]) && $ed [ 'add_mib4' ] != 0 ) {
if ( $ed [ 'add_mab4' ] != 0 ) {
$tr .= $armor4 . $ed [ 'add_mib4' ] . '-' . $ed [ 'add_mab4' ];
} else {
$m1l = $ed [ 'add_mib4' ];
if ( $m1l > 0 ) {
$m1l = '+' . $m1l ;
}
$tr .= $armor4 . $m1l ;
2022-12-19 20:22:19 +00:00
}
}
2024-02-10 01:12:05 +00:00
$efix = 0 ;
if ( isset ( $ed [ 'add_pog2' ]) && $ed [ 'add_pog2' ] > 0 ) {
$efix = $ed [ 'add_pog2' ];
}
if ( isset ( $ed [ 'add_pog' ])) {
$tr .= '<br>Магический барьер способен поглотить еще <strong>' . $ed [ 'add_pog' ] . '</strong> ед. урона' ;
}
if ( isset ( $ed [ 'add_pog2' ])) {
$tr .= '<br>Магический барьер способен поглотить еще <strong>' . $ed [ 'add_pog2' ] . '</strong> ед. урона <small>(' . $ed [ 'add_pog2p' ] . '%)</small>' ;
}
2022-12-19 20:22:19 +00:00
2024-02-10 01:12:05 +00:00
if ( $tr != '' ) {
$ei .= $tr ;
}
if ( $eff [ $i ][ 'info' ] != '' ) {
$ei .= '<br><i>Информация:</i><br>' . $eff [ $i ][ 'info' ];
}
2022-12-19 20:22:19 +00:00
2024-02-10 01:12:05 +00:00
$efcol = $eff [ $i ][ 'x' ];
$efimg = $eff [ $i ][ 'img' ];
$ef .= <<< HTML
2024-01-05 22:14:35 +00:00
< div class = " pimg " pog = " $efix " col = " $efcol " stl = " 0 " stt = " $ei " >< img src = " $img /i/eff/ $efimg " alt = " " ></ div >
2023-12-17 02:32:09 +00:00
HTML ;
2024-02-10 01:12:05 +00:00
unset ( $efix , $efcol , $efimg );
}
} elseif ( $eff [ $i ] != 'delete' ) {
$i = - 2 ;
2023-03-31 16:54:33 +00:00
}
2024-02-10 01:12:05 +00:00
$i ++ ;
2022-12-19 20:22:19 +00:00
}
2024-02-10 01:12:05 +00:00
} else {
$ef = <<< HTML
2023-12-17 02:32:09 +00:00
< div class = " pimg " pog = " 0 " col = " 0 " stl = " 0 " stt = " Развернуть " >
< img src = " $img /i/eff/effs_show.gif " alt = " "
onclick = " top.useMagicBattle('Развернуть',5555,'effs_hide.gif',1,2) "
onmouseover = " top.hi(this,'<strong>Развернуть</strong>',event,3,1,1,1,''); "
onmouseout = " top.hic(); " onmousedown = " top.hic(); "
>
</ div >
HTML ;
2024-02-10 01:12:05 +00:00
}
2023-03-31 16:54:33 +00:00
}
$ca = '' ;
2023-12-17 02:32:09 +00:00
2023-03-31 16:54:33 +00:00
if ( $ur [ 'clan' ] > 0 ) {
2023-12-17 02:32:09 +00:00
$clanName = ClanInfo :: getNameById ( $ur [ 'clan' ]);
if ( ! empty ( $clanName )) {
$ca = " <img src=' $img /i/clan/ $clanName .gif' title=' $clanName ' alt=' $clanName '> " ;
2022-12-19 20:22:19 +00:00
}
2023-03-31 16:54:33 +00:00
}
2023-12-17 02:32:09 +00:00
2023-03-31 16:54:33 +00:00
if ( $ur [ 'align' ] > 0 ) {
2023-12-17 02:32:09 +00:00
$ca = " <img src=' $img /i/align/align { $ur [ 'align' ] } .gif' alt='Склонность'> $ca " ;
2023-03-31 16:54:33 +00:00
}
2023-12-17 02:32:09 +00:00
2023-03-31 16:54:33 +00:00
if ( $ur [ 'login2' ] == '' ) {
$ur [ 'login2' ] = $ur [ 'login' ];
}
2023-12-17 02:32:09 +00:00
2023-03-31 16:54:33 +00:00
if ( floor ( $st [ 'hpNow' ]) > $st [ 'hpAll' ]) {
$st [ 'hpNow' ] = $st [ 'hpAll' ];
}
2023-12-17 02:32:09 +00:00
2023-03-31 16:54:33 +00:00
if ( floor ( $st [ 'mpNow' ]) > $st [ 'mpAll' ]) {
$st [ 'mpNow' ] = $st [ 'mpAll' ];
}
2023-12-17 02:32:09 +00:00
2023-03-31 16:54:33 +00:00
$stsua = '<strong>' . $ur [ 'login2' ] . '</strong>' ;
$stsua .= '<br>Сила: ' . $st [ 's1' ];
$stsua .= '<br>Ловкость: ' . $st [ 's2' ];
$stsua .= '<br>Интуиция: ' . $st [ 's3' ];
$stsua .= '<br>Выносливость: ' . $st [ 's4' ];
if ( $st [ 's5' ] != 0 ) {
$stsua .= '<br>Интелект: ' . $st [ 's5' ];
}
if ( $st [ 's6' ] != 0 ) {
$stsua .= '<br>Мудрость: ' . $st [ 's6' ];
}
if ( $st [ 's7' ] != 0 ) {
$stsua .= '<br>Духовность: ' . $st [ 's7' ];
}
2024-01-05 22:14:35 +00:00
2023-12-17 02:32:09 +00:00
$tpImg = [
2023-03-31 16:54:33 +00:00
1 => 4 ,
2 => 5 ,
14 => 6 ,
3 => 7 ,
5 => 8 ,
7 => 9 ,
17 => 10 ,
16 => 11 ,
13 => 12 ,
10 => 13 ,
9 => 14 ,
8 => 15 ,
11 => 17 , //кольцо 2
12 => 18 , //кольцо 3
];
2024-01-05 22:14:35 +00:00
$upinfo = <<< JS
$ca < a href = " javascript:void(0) " onClick = " top.chat.addto(' { $ur [ 'login2' ] } ','to');return false; " > { $ur [ 'login2' ]} </ a > [{ $ur [ 'level' ]}] < a href = " info/ { $ur [ 'id' ] } " target = " _blank " >< img src = " //img.new-combats.tech/i/inf.gif " title = " Инф. о { $ur [ 'login2' ] } " alt = " " ></ a >& nbsp ;
JS ;
2024-01-06 15:30:34 +00:00
$hpmp = [ floor ( $st [ 'hpNow' ]), floor ( $st [ 'hpAll' ]), floor ( $st [ 'mpNow' ]), floor ( $st [ 'mpAll' ]),];
2024-01-05 22:14:35 +00:00
$info = <<< 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 ;
2023-03-31 16:54:33 +00:00
$i = 0 ;
if ( is_array ( $itm )) {
2024-02-10 01:12:05 +00:00
2023-03-31 16:54:33 +00:00
while ( $i < count ( $itm )) {
2024-02-10 01:12:05 +00:00
if ( isset ( $tpImg [ $itm [ $i ][ 'inOdet' ]], $st [ 'items_img' ][ $tpImg [ $itm [ $i ][ 'inOdet' ]]])) {
2023-12-17 02:32:09 +00:00
$itm [ $i ][ 'img' ] = $st [ 'items_img' ][ $tpImg [ $itm [ $i ][ 'inOdet' ]]];
2023-03-31 16:54:33 +00:00
}
//генерируем предметы
$ttl = '<strong>' . $itm [ $i ][ 'name' ] . '</strong>' ;
2023-08-14 15:15:05 +00:00
$td = Conversion :: dataStringToArray ( $itm [ $i ][ 'data' ]);
2024-01-06 15:30:34 +00:00
2023-03-31 16:54:33 +00:00
$lvar = '' ;
2024-01-08 01:33:20 +00:00
if ( isset ( $td [ 'add_hpAll' ]) && $td [ 'add_hpAll' ] > 0 ) {
2023-03-31 16:54:33 +00:00
$td [ 'add_hpAll' ] = '+' . $td [ 'add_hpAll' ];
2023-12-17 02:32:09 +00:00
$lvar .= '<br>Уровень жизни: ' . $td [ 'add_hpAll' ];
2023-03-31 16:54:33 +00:00
}
2024-01-08 01:33:20 +00:00
if ( isset ( $td [ 'sv_yron_max' ]) && $td [ 'sv_yron_max' ] > 0 || isset ( $td [ 'sv_yron_min' ]) && $td [ 'sv_yron_min' ] > 0 ) {
2023-12-17 02:32:09 +00:00
$lvar .= '<br>Урон: ' . ( 0 + $td [ 'sv_yron_min' ]) . '-' . ( 0 + $td [ 'sv_yron_max' ]);
2023-03-31 16:54:33 +00:00
}
2024-01-08 01:33:20 +00:00
if ( isset ( $td [ 'add_mab1' ]) && $td [ 'add_mab1' ] > 0 ) {
2023-12-17 02:32:09 +00:00
if ( $td [ 'add_mib1' ] == $td [ 'add_mab1' ]) {
2023-03-31 16:54:33 +00:00
$m1l = '+' ;
2023-12-17 02:32:09 +00:00
$lvar .= $armor1 . $m1l . ( 0 + $td [ 'add_mab1' ]);
2023-03-31 16:54:33 +00:00
} else {
2023-12-17 02:32:09 +00:00
$lvar .= $armor1 . ( 0 + $td [ 'add_mib1' ]) . '-' . ( 0 + $td [ 'add_mab1' ]);
2022-12-19 20:22:19 +00:00
}
2023-03-31 16:54:33 +00:00
}
2024-01-08 01:33:20 +00:00
if ( isset ( $td [ 'add_mab2' ]) && $td [ 'add_mab2' ] > 0 ) {
2023-12-17 02:32:09 +00:00
if ( $td [ 'add_mib2' ] == $td [ 'add_mab2' ]) {
2023-03-31 16:54:33 +00:00
$m1l = '+' ;
2023-12-17 02:32:09 +00:00
$lvar .= $armor2 . $m1l . ( 0 + $td [ 'add_mab2' ]);
2023-03-31 16:54:33 +00:00
} else {
2023-12-17 02:32:09 +00:00
$lvar .= $armor2 . ( 0 + $td [ 'add_mib2' ]) . '-' . ( 0 + $td [ 'add_mab2' ]);
2022-12-19 20:22:19 +00:00
}
2023-03-31 16:54:33 +00:00
}
2024-01-08 01:33:20 +00:00
if ( isset ( $td [ 'add_mab3' ]) && $td [ 'add_mab3' ] > 0 ) {
2023-12-17 02:32:09 +00:00
if ( $td [ 'add_mib3' ] == $td [ 'add_mab3' ]) {
2023-03-31 16:54:33 +00:00
$m1l = '+' ;
2023-12-17 02:32:09 +00:00
$lvar .= $armor3 . $m1l . ( 0 + $td [ 'add_mab3' ]);
2023-03-31 16:54:33 +00:00
} else {
2023-12-17 02:32:09 +00:00
$lvar .= $armor3 . ( 0 + $td [ 'add_mib3' ]) . '-' . ( 0 + $td [ 'add_mab3' ]);
2022-12-19 20:22:19 +00:00
}
2023-03-31 16:54:33 +00:00
}
2024-01-08 01:33:20 +00:00
if ( isset ( $td [ 'add_mab4' ]) && $td [ 'add_mab4' ] > 0 ) {
2023-12-17 02:32:09 +00:00
if ( $td [ 'add_mib4' ] == $td [ 'add_mab4' ]) {
2023-03-31 16:54:33 +00:00
$m1l = '+' ;
2023-12-17 02:32:09 +00:00
$lvar .= $armor4 . $m1l . ( 0 + $td [ 'add_mab4' ]);
2023-03-31 16:54:33 +00:00
} else {
2023-12-17 02:32:09 +00:00
$lvar .= $armor4 . ( 0 + $td [ 'add_mib4' ]) . '-' . ( 0 + $td [ 'add_mab4' ]);
2022-12-19 20:22:19 +00:00
}
2023-03-31 16:54:33 +00:00
}
2024-01-08 01:33:20 +00:00
if ( isset ( $itm [ $i ][ 'iznosMAX' ]) && $itm [ $i ][ 'iznosMAX' ] > 0 ) {
if ( isset ( $itm [ $i ][ 'iznosMAXi' ]) && $itm [ $i ][ 'iznosMAXi' ] == 999999999 ) {
2023-12-17 02:32:09 +00:00
$lvar .= '<br>Долговечность: <span style="color: brown;">неразрушимо</span>' ;
2023-03-31 16:54:33 +00:00
} else {
2024-01-05 22:14:35 +00:00
$lvar .= '<br>Долговечность: ' . floor ( $itm [ $i ][ 'iznosNOW' ]) . '/' . floor ( $itm [ $i ][ 'iznosMAX' ]);
2022-12-19 20:22:19 +00:00
}
2023-03-31 16:54:33 +00:00
}
$ttl .= $lvar ;
$ccv = '' ;
2022-12-19 20:22:19 +00:00
2024-01-08 01:33:20 +00:00
if ( isset ( $itm [ $i ][ 'magic_inci' ]) && $itm [ $i ][ 'magic_inci' ] != '' || isset ( $itm [ $i ][ 'magic_inc' ]) && $itm [ $i ][ 'magic_inc' ] != '' ) {
2023-03-31 16:54:33 +00:00
if ( $itm [ $i ][ 'magic_inc' ] == '' ) {
$itm [ $i ][ 'magic_inc' ] = $itm [ $i ][ 'magic_inci' ];
}
$mgi = Db :: getRow ( 'select * from eff_main where id2 = ? and type1 = 12345' , [ $itm [ $i ][ 'magic_inc' ]]);
if ( isset ( $mgi [ 'id2' ])) {
2024-01-05 22:14:35 +00:00
$ccv .= " top.useMagicBattle(' { $mgi [ 'mname' ] } ',' { $itm [ $i ][ 'id' ] } ',' { $mgi [ 'img' ] } ',1,2) " ;
2022-12-19 20:22:19 +00:00
}
2022-12-30 19:03:37 +00:00
}
2022-12-19 20:22:19 +00:00
2023-12-17 02:32:09 +00:00
$var1 = ( int ) $t ;
2024-02-10 01:12:05 +00:00
$var2 = ( int ) $id ;
2023-12-17 02:32:09 +00:00
$var3 = ( int ) $itm [ $i ][ 'id' ];
$var4 = ( int ) $itm [ $i ][ 'inOdet' ];
$var5 = $itm [ $i ][ 'name' ];
$var6 = $ttl ;
$var7 = $itm [ $i ][ 'img' ];
$var8 = $ccv ;
2024-01-05 22:14:35 +00:00
$info .= " abitms( $var1 , $var2 , $var3 , $var4 ,` $var5 `,` $var6 `,` $var7 `,` $var8 `); " ;
2023-12-17 02:32:09 +00:00
unset ( $var1 , $var2 , $var3 , $var4 , $var5 , $var6 , $var7 , $var8 );
2023-03-31 16:54:33 +00:00
$i ++ ;
}
2022-12-19 20:22:19 +00:00
}
2023-03-31 16:54:33 +00:00
return $info ;
2022-12-19 20:22:19 +00:00
}
2024-02-09 19:41:54 +00:00
//Запускаем магические предметы, если в них что-то встроено
2023-08-10 14:51:16 +00:00
2023-03-31 16:54:33 +00:00
/**
* Проверка на выживших .
2024-01-05 22:14:35 +00:00
* Дополнительно обнуляет отрицательное здоровье .
2023-03-31 16:54:33 +00:00
* @ return bool
*/
2022-12-30 19:03:37 +00:00
public function testUsersLive () : bool
2022-12-19 20:22:19 +00:00
{
$tl = 0 ;
2024-01-05 22:14:35 +00:00
for ( $i = 0 ; $i < count ( $this -> uids ); $i ++ ) {
if ( empty ( $this -> stats [ $i ][ 'id' ])) {
continue ;
2022-12-19 20:22:19 +00:00
}
2024-01-05 22:14:35 +00:00
$this -> stats [ $i ][ 'hpNow' ] = max ( 0 , ( int ) $this -> stats [ $i ][ 'hpNow' ]);
if ( ! empty ( $tml [ $this -> stats [ $i ][ 'team' ]]) || $this -> stats [ $i ][ 'hpNow' ] == 0 ) {
continue ;
}
$tml [ $this -> stats [ $i ][ 'team' ]] = 1 ;
$tl ++ ;
2022-12-19 20:22:19 +00:00
}
2024-01-05 22:14:35 +00:00
return $tl > 1 ;
2022-12-19 20:22:19 +00:00
}
2023-12-17 02:32:09 +00:00
public function testFinish () : void
2022-12-19 20:22:19 +00:00
{
global $u ;
2023-12-17 02:32:09 +00:00
[
'id' => $check ,
'team_win' => $tw ,
2024-01-06 15:30:34 +00:00
] = Db :: getRow ( 'select id, team_win from battle where id = ?' , [ $this -> i -> id ]);
2023-12-17 02:32:09 +00:00
if ( empty ( $check )) {
return ;
}
2024-01-06 15:30:34 +00:00
if ( $tw !== - 1 ) {
2024-02-09 17:49:51 +00:00
$this -> finish -> finishBattle ( nl : 10 );
2024-01-06 15:30:34 +00:00
return ;
}
$tml = [];
$tmv = [];
$tl = 0 ;
$i = 0 ;
$j = 0 ;
//fixme есть аналогичное во внешней функции, возможно ошибка. testUsersLive()
while ( $i < count ( $this -> uids )) {
if ( $this -> stats [ $i ][ 'id' ] > 0 ) {
if ( floor ( $this -> stats [ $i ][ 'hpNow' ]) < 1 ) {
$this -> stats [ $i ][ 'hpNow' ] = 0 ;
}
if ( ! isset ( $tml [ $this -> users [ $i ][ 'team' ]]) && floor ( $this -> stats [ $i ][ 'hpNow' ]) >= 1 ) {
$tml [ $this -> users [ $i ][ 'team' ]] = 1 ;
$tmv [ $j ] = $this -> users [ $i ][ 'team' ];
$tl ++ ;
2022-12-19 20:22:19 +00:00
}
}
2024-01-06 15:30:34 +00:00
$i ++ ;
}
2022-12-19 20:22:19 +00:00
2024-01-06 15:30:34 +00:00
if ( $tl > 1 ) {
return ;
}
2023-12-17 02:32:09 +00:00
2024-01-06 15:30:34 +00:00
//Доп.проверка
$tmHpNow = [];
$tmNow = [];
2023-12-17 02:32:09 +00:00
2024-01-06 15:30:34 +00:00
foreach (
Db :: getRow ( 'select team, hpnow from users left join stats on users.id = stats.id where battle = ?' , [ $this -> i -> id ])
as $pl
) {
if ( ! isset ( $tmHpNow [ $pl [ 'team' ]])) {
$tmHpNow [ $pl [ 'team' ]] = 0 ;
$tmNow [] = $pl [ 'team' ];
}
$hpTm = floor ( $pl [ 'hpNow' ]);
if ( $hpTm < 0 ) {
$hpTm = 0 ;
}
if ( $hpTm > 0 ) {
$tmHpNow [ $pl [ 'team' ]] += $pl [ 'hpNow' ];
}
}
$gdj = 0 ;
$i = 0 ;
while ( $i < count ( $tmNow )) {
if ( isset ( $tmNow [ $i ])) {
$j = $tmNow [ $i ];
if ( $tmHpNow [ $j ] > 0 ) {
$gdj ++ ;
2022-12-19 20:22:19 +00:00
}
}
2024-01-06 15:30:34 +00:00
$i ++ ;
}
if ( $gdj > 1 ) {
echo 'Поединок может завершиться не корректно... (Сообщите Администрации о б этом)' ;
}
2022-12-19 20:22:19 +00:00
2024-01-06 15:30:34 +00:00
//завершаем поединок, кто-то один победил, либо ничья
2022-12-19 20:22:19 +00:00
2024-01-06 15:30:34 +00:00
$i = 0 ;
$tmwin = 0 ;
while ( $i < count ( $tmv )) {
if ( $tmv [ $i ] >= 1 && $tml [ $tmv [ $i ]] > 0 ) {
$tmwin = $tmv [ $i ];
}
$i ++ ;
}
2022-12-19 20:22:19 +00:00
2024-01-06 15:30:34 +00:00
$ir = 0 ;
$bi = 0 ;
2024-02-10 19:33:10 +00:00
$stats = new Stats ( $u );
2024-01-06 15:30:34 +00:00
if ( $this -> i -> id > 0 ) {
if ( $this -> i -> izlom == 0 ) {
//данные о игроках в бою
2024-02-10 19:33:10 +00:00
$bu = Db :: getRows ( " select *, if(login2 = '', login, login2) as login2 from users left join stats on users.id = stats.id where battle = ? order by bot desc " , [ $this -> i -> id ]);
2023-12-17 02:32:09 +00:00
2024-01-06 15:30:34 +00:00
$this -> users = [];
$this -> stats = [];
$this -> uids = [];
$this -> bots = [];
$this -> iBots = [];
2023-12-17 02:32:09 +00:00
2024-02-10 19:33:10 +00:00
foreach ( $bu as $user ) {
$this -> users [ $ir ] = $user ;
$this -> uids [ $user [ 'id' ]] = $ir ;
if ( $user [ 'bot' ] > 0 ) {
$this -> bots [ $bi ] = $user [ 'id' ];
$this -> iBots [ $user [ 'id' ]] = $bi ;
2024-01-06 15:30:34 +00:00
$bi ++ ;
2022-12-19 20:22:19 +00:00
}
2024-02-10 19:33:10 +00:00
$this -> stats [ $ir ] = $stats -> getStats ( $user [ 'id' ]);
2024-01-06 15:30:34 +00:00
$ir ++ ;
}
2024-02-10 19:33:10 +00:00
2024-01-06 15:30:34 +00:00
} elseif ( ! isset ( $this -> uids [ $u -> info [ 'id' ]])) {
//данные о игроках в бою
2024-02-10 19:33:10 +00:00
$bu = Db :: getRows ( " select *, if(login2 = '', login, login2) as login2 from users left join stats on users.id = stats.id where users.id = ? " , [ $this -> i -> id ]);
foreach ( $bu as $user ) {
$this -> users [] = $user ;
$this -> uids [ $user [ 'id' ]] = $ir ;
if ( $user [ 'bot' ] > 0 ) {
$this -> bots [] = $user [ 'id' ];
$this -> iBots [ $user [ 'id' ]] = $bi ;
}
$this -> stats [] = $stats -> getStats ( $user [ 'id' ]);
2024-01-06 15:30:34 +00:00
}
}
}
2022-12-19 20:22:19 +00:00
2024-01-06 15:30:34 +00:00
if ( $this -> i -> izlom > 0 && $tmwin == 1 ) {
// выкидываем ботов из боя
$i = 0 ;
2023-12-17 02:32:09 +00:00
2024-01-06 15:30:34 +00:00
$botsIds = Db :: getColumn ( 'select users.id from users left join stats on users.id = stats.id where battle = ? and bot = 1 and team != ?' , [ $this -> i -> id , $u -> info [ 'team' ]]);
Db :: sql ( 'delete from users where id in (?)' , [ implode ( ',' , $botsIds )]);
Db :: sql ( 'delete from stats where id in (?)' , [ implode ( ',' , $botsIds )]);
Db :: sql ( 'delete from items_users where uid in (?)' , [ implode ( ',' , $botsIds )]);
Db :: sql ( 'delete from eff_users where uid in (?)' , [ implode ( ',' , $botsIds )]);
2023-12-17 02:32:09 +00:00
2024-01-06 15:30:34 +00:00
$j = 0 ;
$obr = 0 ;
$bots = [];
//Это излом, добавляем еще ботов
if ( Helper :: getChanse ( 20 )) {
//Уникальные монстры
if ( $this -> i -> izlomlvl == 8 ) {
$bots = [
'Валентайский Охотник' ,
'Шипокрыл Х а о с а ' ,
'Шипокрыл' ,
'Лик Х а о с а ' ,
'Фанатик Х а о с а ' ,
];
}
2023-12-17 02:32:09 +00:00
2024-01-06 15:30:34 +00:00
echo '<div style="font-weight: bold; color: crimson; text-align: center">Приближается нечто...</div>' ;
2023-12-17 02:32:09 +00:00
2024-01-06 15:30:34 +00:00
$this -> addIzlomBot ( $bots , $j , $obr , $this -> users [ $i ][ 'id' ]);
2023-12-17 02:32:09 +00:00
2024-01-06 15:30:34 +00:00
} else {
//Обычные монстры
if ( $this -> i -> izlomlvl == 8 ) {
$bots = [
'Литейщик' ,
'Проклятие Глубин' ,
'Пустынник Маньяк' ,
'Пустынник Убийца' ,
'Рабочий Мглы' ,
'Смотритель Мглы' ,
'Сторож Мглы' ,
];
}
2023-12-17 02:32:09 +00:00
2024-01-06 15:30:34 +00:00
$this -> addIzlomBot ( $bots , $j , $obr );
$this -> addIzlomBot ( $bots , $j , $obr );
2023-12-17 02:32:09 +00:00
2024-01-06 15:30:34 +00:00
if ( rand ( 0 , 100 ) < 70 ) {
$this -> addIzlomBot ( $bots , $j , $obr );
}
2022-12-19 20:22:19 +00:00
2024-01-06 15:30:34 +00:00
//Каждые 10 волн = +1 монстр
$irb = floor ( $this -> i -> izlomroundsee / 10 );
while ( $irb > 0 ) {
$this -> addIzlomBot ( $bots , $j , $obr );
$irb -- ;
}
}
2023-12-17 02:32:09 +00:00
2024-01-06 15:30:34 +00:00
if ( $j == 0 ) {
//конец излома
$this -> finish -> finishBattle ( $tml , $tmv );
2024-02-10 19:33:10 +00:00
Db :: sql (
'insert into izlom_rating (uid, time, voln, level, obr, btl) values (?,unix_timestamp(),?,?,?,?)' ,
[ $u -> info [ 'id' ], $this -> i -> izlomroundsee , $this -> i -> izlomlvl , $this -> i -> izlomobr - $this -> i -> izlomobrnow , $this -> i -> id ]
2024-01-06 15:30:34 +00:00
);
2024-02-10 19:33:10 +00:00
2024-01-06 15:30:34 +00:00
} else {
2024-02-10 19:33:10 +00:00
Db :: sql (
'update battle set izlomobrnow = ?, izlomobr = izlomobr + ?, timeout = timeout + 5, izlomround = izlomround + 1, izlomroundsee = izlomroundsee + 1 where id = ?' ,
[ $obr , $obr , $this -> i -> id ]
2024-01-06 15:30:34 +00:00
);
2024-02-10 19:33:10 +00:00
2024-01-06 15:30:34 +00:00
$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 ;
$this -> users [ $this -> uids [ $u -> info [ 'id' ]]][ 'hpNow' ] = $this -> stats [ $this -> uids [ $u -> info [ 'id' ]]][ 'hpAll' ];
$this -> users [ $this -> uids [ $u -> info [ 'id' ]]][ 'mpNow' ] = $this -> stats [ $this -> uids [ $u -> info [ 'id' ]]][ 'mpAll' ];
//где это брать??
2024-02-10 19:33:10 +00:00
$vLog = 'at1=00000||at2=00000||zb1=' . $this -> stats [ $this -> uids [ $u -> info [ 'id' ]]][ 'zonb' ] .
'||zb2=' . $this -> stats [ $this -> uids [ $u -> info [ 'enemy' ]]][ 'zonb' ] .
'||bl1=' . $this -> atacks [ $this -> i -> id ][ 'b1' ] .
'||bl2=' . $this -> atacks [ $this -> i -> id ][ 'b2' ] .
'||time1=' . $this -> atacks [ $this -> i -> id ][ 'time' ] .
'||time2=' . $this -> atacks [ $this -> i -> id ][ 'time2' ] .
'||s2=' . $this -> users [ $this -> uids [ $u -> info [ 'enemy' ]]][ 'sex' ] .
'||s1=' . $this -> users [ $this -> uids [ $u -> info [ 'id' ]]][ 'sex' ] .
'||t2=' . $this -> users [ $this -> uids [ $u -> info [ 'enemy' ]]][ 'team' ] .
'||t1=' . $this -> users [ $this -> uids [ $u -> info [ 'id' ]]][ 'team' ] .
'||login1=' . $this -> users [ $this -> uids [ $u -> info [ 'id' ]]][ 'login2' ] .
'||login2=' . $this -> users [ $this -> uids [ $u -> info [ 'enemy' ]]][ 'login2' ];
2024-01-06 15:30:34 +00:00
$mas = [
'battle' => $this -> i -> id ,
'id_hod' => ( $this -> hodID + 1 ),
'vars' => $vLog ,
'type' => 1 ,
];
$textpart1 = $u -> info [ 'sex' ] == 1 ? 'воспользовалась' : 'воспользовался' ;
2024-01-05 22:14:35 +00:00
2024-01-06 15:30:34 +00:00
$mas [ 'text' ] = '<span class=date>' . date ( 'H:i' ) .
'</span> <strong>' . $u -> info [ 'login' ] .
'</strong> ' . $textpart1 . ' приемом "<strong>Передышка</strong>".' ;
2022-12-19 20:22:19 +00:00
2024-01-06 15:30:34 +00:00
if ( $u -> stats [ 'hpNow' ] < $u -> stats [ 'hpAll' ]) {
$hpSks = floor (( $u -> stats [ 'hpAll' ] * (( rand ( 15 , 25 )) / 100 )));
if ( $hpSks > floor ( $u -> stats [ 'hpAll' ] - $u -> stats [ 'hpNow' ])) {
$hpSks = floor ( $u -> stats [ 'hpAll' ] - $u -> stats [ 'hpNow' ]);
2022-12-19 20:22:19 +00:00
}
2024-01-06 15:30:34 +00:00
$textpart2 = " + $hpSks " ;
2022-12-19 20:22:19 +00:00
} else {
2024-01-06 15:30:34 +00:00
$hpSks = 0 ;
$textpart2 = '--' ;
2022-12-19 20:22:19 +00:00
}
2023-01-28 02:24:37 +00:00
2024-01-06 15:30:34 +00:00
$mas [ 'text' ] .= ' <strong style="color: #06a;">+' . $textpart2 . '</strong>' ;
$mas [ 'text' ] .= ' [' . floor ( $u -> info [ 'hpNow' ] + $hpSks ) . '/' . $u -> stats [ 'hpAll' ] . ']' ;
2023-12-17 02:32:09 +00:00
2024-02-09 17:28:32 +00:00
Log :: add ( $mas );
2023-12-17 02:32:09 +00:00
Db :: sql (
2024-01-06 15:30:34 +00:00
'update stats set hpnow = ?, mpnow = ? where id = ?' ,
[
$u -> info [ 'hpNow' ] + $u -> stats [ 'hpAll' ] * (( rand ( 15 , 25 )) / 100 ),
$u -> info [ 'mpNow' ] + $u -> stats [ 'mpAll' ] * 0.25 ,
$u -> info [ 'id' ],
]
2023-12-17 02:32:09 +00:00
);
2022-12-19 20:22:19 +00:00
}
2024-01-06 15:30:34 +00:00
2022-12-19 20:22:19 +00:00
} else {
2024-01-06 15:30:34 +00:00
//завершаем бой
$this -> finish -> finishBattle ( $tml , $tmv );
if ( $this -> i -> izlom > 0 ) {
Db :: sql (
'insert into izlom_rating (uid, time, voln, level, obr, btl) values (?,unix_timestamp(),?,?,?,?)' ,
[
$u -> info [ 'id' ],
$this -> i -> izlomroundsee ,
$this -> i -> izlomlvl ,
$this -> i -> izlomobr - $this -> i -> izlomobrnow ,
$this -> i -> id ,
]
);
}
}
Effects :: addById ( $u -> info [ 'id' ], 31 );
$cmsg = new ChatMessage ();
$cmsg -> setRoom ( $u -> info [ 'room' ]);
$cmsg -> setTo ( $u -> info [ 'login' ]);
$cmsg -> setType ( 6 );
$cmsg -> setText (
'Вы создали предмет "Образец" x' . (( $this -> i -> izlomobr - $this -> i -> izlomobrnow ) * 7 )
);
( new Chat ()) -> sendMsg ( $cmsg );
$i01 = 1 ;
while ( $i01 <= ( $this -> i -> izlomobr - $this -> i -> izlomobrnow ) * 7 ) {
ItemsModel :: addItem ( 1226 , $u -> info [ 'id' ], '|sudba=' . $u -> info [ 'login' ]);
$i01 ++ ;
2023-12-17 02:32:09 +00:00
}
2024-01-06 15:30:34 +00:00
Db :: sql (
" insert into actions (uid, time, city, room, vars, ip, vals, val) values (?,unix_timestamp(),'capitalcity',?,'izlom','','','') " ,
[ $u -> info [ 'id' ], $u -> info [ 'room' ]]
);
2023-12-17 02:32:09 +00:00
}
2024-02-09 19:41:54 +00:00
//Поглощение урона
2023-12-17 02:32:09 +00:00
/**
* @ param array $botLogins
2024-05-10 11:32:06 +00:00
* @ param int $counter
* @ param int $obr
* @ param int $unique для совместимости с непонятным вызовом User -> addAction
2023-12-17 02:32:09 +00:00
* при вызове уникального монстра .
* @ return void
*/
private function addIzlomBot ( array $botLogins , int & $counter , int & $obr , int $unique = 0 ) : void
{
global $u ;
if ( empty ( $botLogins ) || mt_rand ( 0 , count ( $botLogins ) - 1 ) === 0 ) {
return ;
}
[
'id' => $id ,
'align' => $align ,
'clan' => $clan ,
'level' => $level ,
'sex' => $gender ,
'login' => $login ,
] = Db :: getRow (
" select id, align, clan, level, sex, login from test_bot where login = ? and pishera != '' and active = 1 and level <= ? order by level desc limit 1 " ,
[ $botLogins [ array_rand ( $botLogins )], $u -> info [ 'level' ]]
);
2024-01-06 15:30:34 +00:00
$bot = $u -> addNewbot ( id : $id , round : round ( $this -> i -> izlomroundsee ) * mt_rand ( 1 , 2 ));
2023-12-17 02:32:09 +00:00
if ( empty ( $bot )) {
return ;
}
2024-01-05 22:14:35 +00:00
$btxt = ( new Login ( $align , $clan , $level , $login )) -> fullLogin ;
2023-12-17 02:32:09 +00:00
$btxt .= $gender == 1 ? ' вмешалась в поединок.' : ' вмешался в поединок.' ;
2023-12-19 01:58:37 +00:00
Log :: add (
[
'text' => " { tm1} $btxt " ,
2024-01-06 15:30:34 +00:00
'battle' => $this -> i -> id ,
2023-12-19 01:58:37 +00:00
'id_hod' => ( $this -> hodID + 1 ),
'vars' => 'at1=00000||at2=00000||zb1=0||zb2=0||bl1=0||bl2=0||time1=' . time () .
'||time2=' . time () .
'||s1=' . $gender .
'||t1=0' .
'||login1=' . $login ,
'type' => 1 ,
]
);
2023-08-10 14:51:16 +00:00
2024-01-06 15:30:34 +00:00
Db :: sql ( 'update users left join stats on users.id = stats.id set battle = ?, team = 2 where users.id = ?' , [ $this -> i -> id , $bot [ 'id' ]]);
2023-08-10 14:51:16 +00:00
2023-12-19 01:58:37 +00:00
if ( $unique ) {
$u -> addAction ( time (), 'win_bot_' . $id , '' , $unique );
}
2023-08-10 14:51:16 +00:00
2023-12-19 01:58:37 +00:00
$counter ++ ;
if ( mt_rand ( 0 , 10000 ) < 1500 ) {
$obr ++ ;
2022-12-19 20:22:19 +00:00
}
2023-08-10 14:51:16 +00:00
}
2023-12-19 01:58:37 +00:00
//Иг р о к1 наносит удар Иг р о к2
2023-08-10 14:51:16 +00:00
//Проверка ухода удара в игрока
//Расчет уворота игроков
//Расчет крита игроков
//Расчет блока щитом игроков
2022-12-19 20:22:19 +00:00
2023-12-19 01:58:37 +00:00
public function priemAddLogFast ( $u1 , $u2 , $prm , $text , $hodID , $tm ) : void
2023-08-10 14:51:16 +00:00
{
2023-12-19 01:58:37 +00:00
$vLog =
'prm=' . $prm .
'||time1=' . $tm .
'||time2=' . $tm .
'||s1=' . $this -> users [ $this -> uids [ $u1 ]][ 'sex' ] .
'||s2=' . $this -> users [ $this -> uids [ $u2 ]][ 'sex' ] .
'||t2=' . $this -> users [ $this -> uids [ $u2 ]][ 'team' ] .
'||t1=' . $this -> users [ $this -> uids [ $u1 ]][ 'team' ] .
'||login1=' . $this -> users [ $this -> uids [ $u1 ]][ 'login2' ] .
'||login2=' . $this -> users [ $this -> uids [ $u2 ]][ 'login2' ];
$arr = [
2023-08-10 14:51:16 +00:00
'text' => $text ,
2024-01-06 15:30:34 +00:00
'battle' => $this -> i -> id ,
2023-12-19 01:58:37 +00:00
'id_hod' => $this -> hodID + $hodID ,
2023-08-10 14:51:16 +00:00
'vars' => $vLog ,
'type' => 1 ,
];
2024-02-09 17:28:32 +00:00
Log :: add ( $arr );
2023-08-10 14:51:16 +00:00
}
2022-12-19 20:22:19 +00:00
2024-02-09 19:41:54 +00:00
//Добавляем статистику
2023-11-02 13:57:39 +00:00
2023-09-30 20:17:25 +00:00
/** Осторожно ! Подключаются файлы !!!
2023-08-10 14:51:16 +00:00
* Трогать очень осторожно . Этот шайтан как - то проверяет приёмы на враге
* и рассчитывает урон учитывая и эти приёмы тоже .
2024-05-10 11:32:06 +00:00
* @ param int $uid1
* @ param int $uid2
* @ param int $priem
2024-01-05 22:14:35 +00:00
* @ param $yron
2024-05-10 11:32:06 +00:00
* @ param int $profil
2024-01-05 22:14:35 +00:00
* @ param bool $stabil
* @ param bool $test
2024-05-10 11:32:06 +00:00
* @ param int $inlog
2023-08-10 14:51:16 +00:00
* @ return float | int | mixed
*/
2024-01-05 22:14:35 +00:00
public function testYronPriem (
int $uid1 ,
int $uid2 ,
int $priem ,
$yron ,
int $profil ,
bool $stabil ,
bool $test = false ,
int $inlog = 0
2024-05-10 11:32:06 +00:00
) : mixed
{
2024-01-05 22:14:35 +00:00
/**
* profil = {
* - 1 - урон оружием
* - 2 - урон магией
* 0 - неизвестно
* 1 - 4 - профильный оружия
* 5 - 12 - профильный магия
* }
* stabil - урон не подвержен мощностям и т . д
*/
2023-08-10 14:51:16 +00:00
//Проверка
$a = 1 ;
$b = 2 ;
$u1 = $uid1 ;
$u2 = $uid2 ;
//Проверяем приемы защиты игрока $u1 на урон игрока $u2
//Получаем приемы и смотрим когда какой действует
if ( ! isset ( $this -> stats [ $this -> uids [ $u2 ]][ 'u_priem' ])) {
$j = 0 ;
2024-01-05 22:14:35 +00:00
foreach ( $this -> stats [ $this -> uids [ $u2 ]][ 'effects' ] as $effect ) {
if ( $effect [ 'id_eff' ] != 22 || $effect [ 'v1' ] != 'priem' || $effect [ 'v2' ] < 1 ) {
continue ;
}
$this -> stats [ $this -> uids [ $u2 ]][ 'u_priem' ][] = [
$j ,
$effect [ 'v2' ],
2024-01-06 15:30:34 +00:00
$this -> prm [ $effect [ 'v2' ]] -> act ,
2024-01-05 22:14:35 +00:00
$effect [ 'id' ],
2024-01-06 15:30:34 +00:00
$this -> prm [ $effect [ 'v2' ]] -> typeOf ,
$this -> prm [ $effect [ 'v2' ]] -> moment ,
2024-01-05 22:14:35 +00:00
];
2023-08-10 14:51:16 +00:00
}
2022-12-19 20:22:19 +00:00
}
2024-01-05 22:14:35 +00:00
/** 4: Приемы защиты; 8,9: Прочие приемы; */
2023-08-10 14:51:16 +00:00
$j = 0 ;
2024-01-05 22:14:35 +00:00
foreach ( $this -> stats [ $this -> uids [ $u2 ]][ 'u_priem' ] as $priem ) {
2024-02-08 13:35:42 +00:00
if ( $priem [ 2 ] < 1 || ! in_array ( $priem [ 4 ], [ 4 , 8 , 9 ]) || ! file_exists ( " Priem/ $priem[1] .php " )) {
2024-01-05 22:14:35 +00:00
continue ;
}
$pr_momental_this = $u2 ;
2024-02-08 13:35:42 +00:00
require_once " Priem/ $priem[1] .php " ;
2024-01-05 22:14:35 +00:00
if ( isset ( $fx_moment )) {
$yron = $fx_moment ( $u2 , $u1 , $j , $yron , $profil , $inlog );
unset ( $fx_moment );
2023-08-10 14:51:16 +00:00
}
$j ++ ;
2022-12-19 20:22:19 +00:00
}
2023-08-10 14:51:16 +00:00
$j = 0 ;
2024-01-05 22:14:35 +00:00
foreach ( $this -> stats [ $this -> uids [ $u1 ]][ 'u_priem' ] as $priem ) {
2024-02-08 13:35:42 +00:00
if ( $priem [ 2 ] < 1 || $priem [ 4 ] != 5 && $priem [ 7 ] != 5 || ! file_exists ( " Priem/ $priem[1] .php " )) {
2024-01-05 22:14:35 +00:00
continue ;
}
if ( $priem [ 4 ] == 5 ) {
$pr_momental_this = $u1 ;
} elseif ( $priem [ 7 ] == 5 ) { // влияет на урон от моментальных приемов
$pr_momental_this_seven = $u1 ;
}
2024-02-08 13:35:42 +00:00
require_once " Priem/ $priem[1] .php " ;
2024-01-05 22:14:35 +00:00
if ( isset ( $fx_moment )) {
$yron = $fx_moment ( $u1 , $u2 , $j , $yron , $profil , $inlog );
unset ( $fx_moment );
}
if ( isset ( $fx_moment_seven )) {
$yron = $fx_moment_seven ( $u1 , $u2 , $j , $yron , $profil , $inlog );
unset ( $fx_moment_seven );
2022-12-19 20:22:19 +00:00
}
2024-01-05 22:14:35 +00:00
if ( $priem [ 1 ] == 180 && $priem [ 7 ] == 5 ) { // Переохлаждение (снижает урон на 10%).
2023-08-10 14:51:16 +00:00
$x = Db :: getValue ( 'select x from eff_users where v2 = 180 and uid = ?' , [ $u1 ]);
$yron = 0.1 * $x ;
2022-12-19 20:22:19 +00:00
}
2023-08-10 14:51:16 +00:00
$j ++ ;
}
2022-12-19 20:22:19 +00:00
2023-08-10 14:51:16 +00:00
if ( $this -> stats [ $this -> uids [ $u2 ]][ 'zaproc' ] > 0 ) {
$yron = round ( $yron - $yron * $this -> stats [ $this -> uids [ $uid2 ]][ 'zaproc' ] / 100 );
if ( $yron < 1 ) {
$yron = 1 ;
}
2022-12-19 20:22:19 +00:00
}
2023-08-10 14:51:16 +00:00
return $yron ;
2022-12-19 20:22:19 +00:00
}
2024-01-05 22:14:35 +00:00
public function priemYronSave ( $u1 , $u2 , $yron , $type = 0 ) : void
2022-12-19 20:22:19 +00:00
{
2023-08-10 14:51:16 +00:00
//$type 0 - урон , 1 - хил
2022-12-19 20:22:19 +00:00
2023-08-10 14:51:16 +00:00
$this -> testUserInfoBattle ( $u1 );
$this -> testUserInfoBattle ( $u2 );
2022-12-19 20:22:19 +00:00
2024-01-05 22:14:35 +00:00
if ( ! isset ( $this -> uids [ $u1 ], $this -> uids [ $u2 ])) {
return ;
}
2022-12-19 20:22:19 +00:00
2024-01-05 22:14:35 +00:00
if ( $this -> stats [ $this -> uids [ $u2 ]][ 'hpAll' ] <= 1000 ) {
$adt6 = round ( 0.1 * ( floor ( $yron ) / $this -> stats [ $this -> uids [ $u2 ]][ 'hpAll' ] * 100 ), 10 );
} else {
$adt6 = round ( 0.1 * ( floor ( $yron ) / 1000 * 100 ), 10 );
}
2022-12-19 20:22:19 +00:00
2024-01-05 22:14:35 +00:00
if ( $yron > $this -> stats [ $this -> uids [ $u2 ]][ 'hpNow' ]) {
$yron = $this -> stats [ $this -> uids [ $u2 ]][ 'hpNow' ];
}
if ( $yron > 0 ) {
$this -> users [ $this -> uids [ $u1 ]][ 'battle_yron' ] += $yron ;
$this -> users [ $this -> uids [ $u1 ]][ 'battle_exp' ] += round (
$this -> testExp ( $yron , $this -> stats [ $this -> uids [ $u2 ]])
);
if ( $this -> stats [ $this -> uids [ $u2 ]][ 'this_animal' ] == 0 ) {
$this -> users [ $this -> uids [ $u1 ]][ 'tactic6' ] += $adt6 ;
$this -> stats [ $this -> uids [ $u1 ]][ 'tactic6' ] += $adt6 ;
2023-08-10 14:51:16 +00:00
} else {
2024-01-05 22:14:35 +00:00
$this -> users [ $this -> uids [ $u1 ]][ 'tactic6' ] += $adt6 / 3 ;
$this -> stats [ $this -> uids [ $u1 ]][ 'tactic6' ] += $adt6 / 3 ;
2022-12-19 20:22:19 +00:00
}
2024-01-05 22:14:35 +00:00
} else {
$adt6 = 0 ;
2022-12-19 20:22:19 +00:00
}
2024-01-05 22:14:35 +00:00
$this -> users [ $this -> uids [ $u2 ]][ 'last_hp' ] = - $yron ;
Db :: sql (
'update stats set tactic6 = tactic6 + ?, battle_yron = battle_yron + ?, battle_exp = battle_exp + ? where id = ?' ,
[
$adt6 ,
$yron ,
round ( $this -> testExp ( $yron , $this -> stats [ $this -> uids [ $u2 ]])),
$u1 ,
]
);
Db :: sql ( 'update stats set last_hp = ? where id = ?' , [ - $yron , $u2 ]);
2023-08-10 14:51:16 +00:00
$this -> addNewStat (
[
1 => [
2024-01-06 15:30:34 +00:00
'battle' => $this -> i -> id ,
2023-08-10 14:51:16 +00:00
'uid1' => $this -> users [ $this -> uids [ $u1 ]][ 'id' ],
'uid2' => $this -> users [ $this -> uids [ $u2 ]][ 'id' ],
'time' => time (),
'type' => 0 ,
'a' => '10000' ,
'b' => 0 ,
'type_a' => 1 ,
'type_b' => 0 ,
'ma' => 1 ,
'mb' => 1 ,
'yrn' => $yron ,
'yrn_krit' => 0 ,
'tm1' => $this -> users [ $this -> uids [ $u1 ]][ 'team' ],
'tm2' => $this -> users [ $this -> uids [ $u2 ]][ 'team' ],
],
]
);
}
2022-12-19 20:22:19 +00:00
2024-02-09 19:41:54 +00:00
//Добавляем статистику ударов
2023-12-19 01:58:37 +00:00
public function testUserInfoBattle ( $uid ) : void
2023-08-10 14:51:16 +00:00
{
2023-12-19 01:58:37 +00:00
if ( isset ( $this -> uids [ $uid ])) {
return ;
}
//Заносим данные о б игроке снова (видимо он погиб и е г о стерло с инфо)
2023-08-10 14:51:16 +00:00
if ( ! isset ( $this -> uids [ $uid ])) {
2023-12-19 01:58:37 +00:00
$this -> uids [ $uid ] = count ( $this -> users );
2023-08-10 14:51:16 +00:00
}
2024-02-10 19:33:10 +00:00
$stats = new Stats ( User :: start ());
$this -> users [ $this -> uids [ $uid ]] = User :: getInfo ( $uid );
$this -> stats [ $this -> uids [ $uid ]] = $stats -> getStats ( $uid ); //getStats($this->users[$this->uids[$uid]])
2023-12-19 01:58:37 +00:00
//fixme много чего повторно берется
2022-12-19 20:22:19 +00:00
}
2023-08-14 15:15:05 +00:00
/**
* Расчет опыта
* @ param $y
* @ param $s2
* @ return int
*/
private function testExp ( $y , $s2 ) : int
{
2024-02-10 01:12:05 +00:00
if ( $s2 [ 'levels' ] == 'undefined' || $this -> users [ $this -> uids [ $s2 [ 'id' ]]][ 'bot' ] > 0 ) {
2023-08-14 15:15:05 +00:00
return 0 ;
}
$y = max ( 0 , ( int ) $y );
$expmultiplier = 1 ;
if ( $this -> users [ $this -> uids [ $s2 [ 'id' ]]][ 'level' ] >= 8 ) {
$expmultiplier = $this -> users [ $this -> uids [ $s2 [ 'id' ]]][ 'level' ] - 5 ;
}
if ( $s2 [ 'hpNow' ] < 0 ) {
$y = 0 ;
}
if ( $s2 [ 'hpNow' ] < $y ) {
$y = max ( 0 , $s2 [ 'hpNow' ]);
}
$addExp = $y * $expmultiplier ;
if ( $s2 [ 'hpAll' ] - $y <= 0 ) {
$addExp = 100 ;
}
return ( int ) round ( $addExp );
}
2024-02-10 19:33:10 +00:00
public function addNewStat ( array $stat ) : void
2023-08-14 15:15:05 +00:00
{
2024-02-10 19:33:10 +00:00
$sql = ' insert into battle_stat ( battle , uid1 , uid2 , time , type , a , b , type_a , type_b , ma , mb , yrn , yrn_krit , tm1 , tm2 )
values ( : battle , : uid1 , : uid2 , : time , : type , : a , : b , : type_a , : type_b , : ma , : mb , : yrn , : yrn_krit , : tm1 , : tm2 ) ' ;
2023-08-14 15:15:05 +00:00
if ( isset ( $stat [ 1 ])) {
2024-02-10 19:33:10 +00:00
$stat [ 1 ][ 'battle' ] = $this -> i -> id ;
Db :: sql ( $sql , $stat [ 1 ]);
2023-08-14 15:15:05 +00:00
}
2024-02-10 19:33:10 +00:00
2023-08-14 15:15:05 +00:00
if ( isset ( $stat [ 2 ])) {
2024-02-10 19:33:10 +00:00
$stat [ 2 ][ 'battle' ] = $this -> i -> id ;
Db :: sql ( $sql , $stat [ 2 ]);
2023-08-14 15:15:05 +00:00
}
}
2023-08-10 14:51:16 +00:00
public function lookLog () : string
{
2024-02-10 19:33:10 +00:00
$u = User :: start ();
$js = '' ;
$pll = 0 ;
2024-01-05 22:14:35 +00:00
2024-02-10 19:33:10 +00:00
$hodID = Db :: getValue ( 'select id_hod from battle_logs where battle = ? order by time limit 1' , [ $this -> i -> id ]) ? ? 0 ;
if ( $hodID <= 1 ) {
2023-08-10 14:51:16 +00:00
$u -> info [ 'alog' ] = 0 ;
}
2022-12-19 20:22:19 +00:00
2024-02-10 19:33:10 +00:00
$sp = Db :: getRows ( 'select * from battle_logs where battle = ? and id_hod >= (select alog from stats where id = ?) order by id desc' , [ $this -> i -> id , $u -> info [ 'id' ]]) ? ? [];
2024-01-05 22:14:35 +00:00
2024-02-10 19:33:10 +00:00
if ( ! empty ( $sp ) && $this -> i -> getTeamwin () != - 1 ) {
$sp = Db :: getRows ( 'select * from battle_logs_save where battle = ? and id_hod >= (select alog from stats where id = ?) order by id desc' , [ $this -> i -> id , $u -> info [ 'id' ]]) ? ? [];
2022-12-19 20:22:19 +00:00
}
2024-02-10 19:33:10 +00:00
$search = [ '{tm1}' , '{tm2}' , '{tm3}' , '{tm4}' ];
2023-08-10 14:51:16 +00:00
2024-02-10 19:33:10 +00:00
foreach ( $sp as $log ) {
if ( ! isset ( $firstloop )) {
$u -> info [ 'alog' ] = $log [ 'id_hod' ];
$firstloop = true ;
}
$log [ 'vars' ] = str_replace ( '^^^^' , 'rvnO' , $log [ 'vars' ]);
$replace = [
'<span class=\"date {fru}\">' . date ( 'H:i' , $log [ 'time' ]) . '</span>' ,
'<span class=\"date {fru}\">' . date ( 'H:i' , $log [ 'time' ]) . '</span>' ,
'<span class=\"date {fru}\">' . date ( 'd.m.Y H:i' , $log [ 'time' ]) . '</span>' ,
'<span class=\"date {fru}\">' . date ( 'd.m.Y H:i' , $log [ 'time' ]) . '</span>' ,
];
$log [ 'text' ] = str_replace ( $search , $replace , $log [ 'text' ]);
if ( $pll < $log [ 'id' ]) {
$pll = $log [ 'id' ];
2023-08-10 14:51:16 +00:00
}
2024-02-10 19:33:10 +00:00
$jstext = json_encode ( $log [ 'text' ]);
$jsvars = json_encode ( $log [ 'vars' ]);
2024-12-17 08:40:25 +00:00
//old
//$js = "add_log({$log['id']},0,$jstext,{$log['id_hod']},0,0,$jsvars)" . $js;
//home
//$js = "add_log({$log['id']},0,$jstext,{$log['id_hod']},$jsvars);" . $js;
//work
2024-05-10 12:59:04 +00:00
$js = " add_log( { $log [ 'id' ] } , $jstext , { $log [ 'id_hod' ] } , $jsvars ); " . $js ;
2022-12-19 20:22:19 +00:00
}
2024-02-10 19:33:10 +00:00
Db :: sql ( 'update stats set alog = ? where id = ?' , [ $u -> info [ 'alog' ], $u -> info [ 'id' ]]);
$js .= " id_log= $pll ; " ;
2024-12-03 21:54:41 +00:00
//return htmlspecialchars($js, ENT_QUOTES);
return $js ;
2024-02-10 19:33:10 +00:00
}
2024-02-09 19:41:54 +00:00
2023-08-14 15:15:05 +00:00
2023-08-10 14:51:16 +00:00
public function lookmLog () : string
{
2024-02-10 19:33:10 +00:00
if ( $this -> i -> type == 9 ) {
return '' ;
}
$u = User :: start ();
2023-08-10 14:51:16 +00:00
$js = '' ;
$pll = 0 ;
2022-12-19 20:22:19 +00:00
2024-02-10 19:33:10 +00:00
$hodID = Db :: getValue ( 'select id_hod from battle_logs where battle = ? order by time limit 1' , [ $this -> i -> id ]) ? ? 0 ;
if ( $hodID <= 1 ) {
$u -> info [ 'mlog' ] = 0 ;
}
2023-09-30 20:17:25 +00:00
2024-02-10 19:33:10 +00:00
$sp = Db :: getRows (
" select * from battle_logs where battle = ? and id_hod >= (select mlog from stats where id = ?) and vars like ? order by id desc " ,
[ $this -> i -> id , $u -> info [ 'id' ], " % { $u -> info [ 'login' ] } % " ]
) ? ? [];
2022-12-19 20:22:19 +00:00
2024-02-10 19:33:10 +00:00
if ( ! empty ( $sp ) && $this -> i -> getTeamwin () != - 1 ) {
$sp = Db :: getRows (
'select * from battle_logs_save where battle = ? and id_hod >= (select mlog from stats where id = ?) and vars like ? order by id desc' ,
[ $this -> i -> id , $u -> info [ 'id' ], " % { $u -> info [ 'login' ] } % " ]
) ? ? [];
}
$search = [ '{tm1}' , '{tm2}' , '{tm3}' , '{tm4}' ];
foreach ( $sp as $log ) {
if ( ! isset ( $firstloop )) {
$u -> info [ 'mlog' ] = $log [ 'id_hod' ];
$firstloop = true ;
2022-12-19 20:22:19 +00:00
}
2024-02-10 19:33:10 +00:00
$log [ 'vars' ] = str_replace ( '^^^^' , 'rvnO' , $log [ 'vars' ]);
$replace = [
'<span class=\"date {fru}\">' . date ( 'H:i' , $log [ 'time' ]) . '</span>' ,
'<span class=\"date {fru}\">' . date ( 'H:i' , $log [ 'time' ]) . '</span>' ,
'<span class=\"date {fru}\">' . date ( 'd.m.Y H:i' , $log [ 'time' ]) . '</span>' ,
'<span class=\"date {fru}\">' . date ( 'd.m.Y H:i' , $log [ 'time' ]) . '</span>' ,
];
$log [ 'text' ] = str_replace ( $search , $replace , $log [ 'text' ]);
if ( $pll < $log [ 'id' ]) {
$pll = $log [ 'id' ];
2022-12-19 20:22:19 +00:00
}
2024-02-10 19:33:10 +00:00
$jstext = json_encode ( $log [ 'text' ]);
$jsvars = json_encode ( $log [ 'vars' ]);
2024-12-17 08:40:25 +00:00
$js = " add_mlog( { $log [ 'id' ] } ,0, $jstext , { $log [ 'id_hod' ] } ,0,0, $jsvars ) " . $js ;
//old
//$js = "add_mlog({$log['id']},0,$jstext,{$log['id_hod']},0,0,$jsvars)" . $js;
//home
////$js = "add_mlog({$log['id']},0,$jstext,{$log['id_hod']},$jsvars);" . $js;
//$js = "add_mlog({$log['id']},0,'{$log['text']}',{$log['id_hod']},'{$log['vars']}');" . $js;
//work
2024-05-10 11:32:06 +00:00
$js = " add_mlog( { $log [ 'id' ] } , $jstext , { $log [ 'id_hod' ] } , $jsvars ) " . $js ;
2022-12-19 20:22:19 +00:00
}
2024-02-10 19:33:10 +00:00
Db :: sql ( 'update stats set mlog = ? where id = ?' , [ $u -> info [ 'mlog' ], $u -> info [ 'id' ]]);
$js .= " id_mlog= $pll ; " ;
2024-12-03 21:54:41 +00:00
//return htmlspecialchars($js, ENT_QUOTES);
return $js ;
2022-12-19 20:22:19 +00:00
}
2024-02-09 19:41:54 +00:00
//Считаем урон
2023-11-02 13:57:39 +00:00
2023-08-10 14:51:16 +00:00
public function weaponAt22 ( $item , $st ) : array
2022-12-19 20:22:19 +00:00
{
2023-12-19 01:58:37 +00:00
if ( ! isset ( $item [ 'id' ])) {
return [ 0 , 0 ];
}
$itm = Conversion :: dataStringToArray ( $item [ 'data' ]);
//начинаем расчет урона
return [
$itm [ 'sv_yron_min' ] + $itm [ 'yron_min' ] + $st [ 'minAtack' ],
$itm [ 'sv_yron_max' ] + $itm [ 'yron_max' ] + $st [ 'maxAtack' ],
];
2022-12-19 20:22:19 +00:00
}
2024-02-09 19:41:54 +00:00
//Добавляем новую статистику игрока
2023-08-10 14:51:16 +00:00
2023-12-19 01:58:37 +00:00
public function autoSmena () : void
2022-12-19 20:22:19 +00:00
{
global $u ;
2023-08-10 14:51:16 +00:00
$ms = [];
$ms_ansf = [];
$i = 0 ;
$j = 0 ;
$z = 0 ;
while ( $i < count ( $this -> users )) {
if ( isset ( $this -> users [ $i ]) && $this -> users [ $i ][ 'id' ] != $u -> info [ 'id' ] && $this -> users [ $i ][ 'team' ] != $u -> info [ 'team' ] && $this -> stats [ $i ][ 'hpNow' ] > 0 && - ( $u -> info [ 'enemy' ]) != $this -> users [ $i ][ 'id' ]) {
if ( ! isset ( $this -> ga [ $u -> info [ 'id' ]][ $this -> users [ $i ][ 'id' ]])) {
$ms [ $j ] = $this -> users [ $i ][ 'id' ];
$j ++ ;
}
2023-09-30 20:17:25 +00:00
2023-08-10 14:51:16 +00:00
if ( isset ( $this -> ga [ $this -> users [ $i ][ 'id' ]][ $u -> info [ 'id' ]])) {
$ms_ansf [ $z ] = $this -> users [ $i ][ 'id' ];
$z ++ ;
}
}
$i ++ ;
}
$msh = [];
if ( $j == 0 && $z == 0 ) {
$enemydie = 0 ;
if ( isset ( $this -> stats [ $this -> uids [ $u -> info [ 'enemy' ]]])) {
$u -> info [ 'enemy' ] = 0 ;
$enemydie = 1 ;
}
if (( ! isset ( $this -> uids [( - ( $u -> info [ 'enemy' ]))]) || $this -> stats [ $this -> uids [( - ( $u -> info [ 'enemy' ]))]][ 'hpNow' ] < 1 ) && ( $u -> info [ 'enemy' ] < 0 || $enemydie == 1 )) {
$i = 0 ;
$j = 0 ;
while ( $i < count ( $this -> users )) {
if ( isset ( $this -> users [ $i ]) && $this -> users [ $i ][ 'id' ] != $u -> info [ 'id' ] && $this -> users [ $i ][ 'team' ] != $u -> info [ 'team' ] && $this -> stats [ $i ][ 'hpNow' ] >= 1 && - ( $u -> info [ 'enemy' ]) != $this -> users [ $i ][ 'id' ]) {
$ms [ $j ] = $this -> users [ $i ][ 'id' ];
$msh [ $ms [ $j ]] = true ;
$j ++ ;
}
$i ++ ;
}
}
}
2022-12-19 20:22:19 +00:00
2023-08-10 14:51:16 +00:00
$ms = $ms [ rand ( 0 , $j - 1 )];
$ms_ansf = $ms_ansf [ rand ( 0 , $z - 1 )];
if ( $z > 0 ) {
$this -> smena ( $ms_ansf , true );
} elseif ( $j > 0 ) {
if ( isset ( $msh [ $ms ])) {
$this -> smena ( $ms , true , true );
2022-12-19 20:22:19 +00:00
} else {
2023-08-10 14:51:16 +00:00
$this -> smena ( $ms , true );
2022-12-19 20:22:19 +00:00
}
2023-08-10 14:51:16 +00:00
} else {
if ( $u -> info [ 'enemy' ] < 0 ) {
$smnr5 = $this -> smena ( - ( $u -> info [ 'enemy' ]), true );
unset ( $smnr5 );
2022-12-19 20:22:19 +00:00
}
2023-08-10 14:51:16 +00:00
}
}
2022-12-19 20:22:19 +00:00
2024-02-09 19:41:54 +00:00
//Проверяем приемы
2022-12-19 20:22:19 +00:00
2023-12-19 01:58:37 +00:00
public function smena ( $uid , $auto = false , $lastdie = false ) : int | string
2023-08-10 14:51:16 +00:00
{
global $u ;
2023-12-19 01:58:37 +00:00
if (( $auto || $u -> info [ 'smena' ] <= 0 ) && ! $auto ) {
2023-08-10 14:51:16 +00:00
return 'У вас закончились смены противника' ;
}
2023-12-19 01:58:37 +00:00
if ( $this -> stats [ $this -> uids [ $u -> info [ 'id' ]]][ 'hpNow' ] < 1 ) {
return 'Для вас поединок закончен, ожидайте пока завершат другие...' ;
}
if ( ! isset ( $this -> uids [ $uid ]) || $uid == $u -> info [ 'id' ] || $this -> users [ $this -> uids [ $uid ]][ 'team' ] == $this -> users [ $this -> uids [ $u -> info [ 'id' ]]][ 'team' ]) {
return 'Нельзя сменить на выбранную цель []' ;
}
if ( isset ( $this -> ga [ $u -> info [ 'id' ]][ $uid ]) && ! $lastdie ) {
return 'Нельзя сменить на выбранную цель!' ;
}
if ( ceil ( $this -> stats [ $this -> uids [ $uid ]][ 'hpNow' ]) < 1 ) {
return 'Нельзя сменить, противник уже мертв' ;
}
//меняем противника
if ( ! $auto ) {
$u -> info [ 'smena' ] -- ;
}
Db :: sql ( 'update stats set enemy = ?, smena = ? where id = ?' , [ $uid , $u -> info [ 'smena' ], $u -> info [ 'id' ]]);
$u -> info [ 'enemy' ] = $uid ;
$this -> users [ $this -> uids [ $uid ]][ 'smena' ] = $u -> info [ 'smena' ];
$this -> users [ $this -> uids [ $u -> info [ 'id' ]]][ 'enemy' ] = $uid ;
return 1 ;
2023-08-10 14:51:16 +00:00
}
2022-12-19 20:22:19 +00:00
2024-02-09 19:41:54 +00:00
//Приемы которые используются моментально
2022-12-19 20:22:19 +00:00
2024-01-05 22:14:35 +00:00
public function testActions () : void
2023-08-10 14:51:16 +00:00
{
2024-02-10 19:33:10 +00:00
$u = User :: start ();
2023-08-10 14:51:16 +00:00
//проверяем удары
2024-02-10 19:33:10 +00:00
$ba = Db :: getRows ( 'select * from battle_act where battle = ? order by id' , [ $this -> i -> id ]);
foreach ( $ba as $pl ) {
$testhpnow = Db :: getValue ( 'select hpnow from stats where hpnow <= 0 and id in (?,?) limit 1' , [ $pl [ 'uid1' ], $pl [ 'uid2' ]]);
$testid = ( bool ) Db :: getValue ( 'select count(id) from battle_act where id = ?' , [ $pl [ 'id' ]]);
if ( $testid ) {
if ( $testhpnow ) {
Db :: sql ( 'delete from battle_act where id = ?' , [ $pl [ 'id' ]]);
2024-01-06 15:30:34 +00:00
} elseif ( $pl [ 'time' ] + $this -> i -> timeout > time ()) {
2023-08-10 14:51:16 +00:00
//удар не пропущен по тайму, просто заносим данные
$this -> atacks [ $pl [ 'id' ]] = $pl ;
$this -> ga [ $pl [ 'uid1' ]][ $pl [ 'uid2' ]] = $pl [ 'id' ];
$this -> ag [ $pl [ 'uid2' ]][ $pl [ 'uid1' ]] = $pl [ 'id' ];
2023-09-30 20:17:25 +00:00
//ударили бота и он не ответил
if ( isset ( $this -> iBots [ $pl [ 'uid2' ]]) && $this -> users [ $this -> uids [ $pl [ 'uid2' ]]][ 'timeGo' ] < time ()) {
$this -> botAtack ( $pl [ 'uid1' ], $pl , 2 );
2022-12-19 20:22:19 +00:00
}
2023-08-10 14:51:16 +00:00
} else {
//пропуск по тайму
$pl [ 'time' ] = time ();
if ( $pl [ 'a1' ] == 0 && $pl [ 'a2' ] == 0 ) {
//игрок 1 пропустил по тайму
$pl [ 'out1' ] = time ();
$pl [ 'tout1' ] = 1 ;
//игрок 2 пропустил по тайму
$pl [ 'out2' ] = time ();
$pl [ 'tout2' ] = 1 ;
} elseif ( $pl [ 'a1' ] == 0 ) {
//игрок 1 пропустил по тайму
$pl [ 'out1' ] = time ();
$pl [ 'tout1' ] = 1 ;
} elseif ( $pl [ 'a2' ] == 0 ) {
//игрок 2 пропустил по тайму
$pl [ 'out2' ] = time ();
$pl [ 'tout2' ] = 1 ;
2022-12-19 20:22:19 +00:00
}
2023-08-10 14:51:16 +00:00
//наносим удар по пропуску
$this -> atacks [ $pl [ 'id' ]] = $pl ;
$this -> startAtack ( $pl [ 'id' ]);
2024-02-10 19:33:10 +00:00
Db :: sql ( 'delete from battle_act where id = ?' , [ $pl [ 'id' ]]);
2023-08-10 14:51:16 +00:00
}
}
2024-02-10 01:12:05 +00:00
//тест удара
if ( $this -> uAtc [ 'id' ] > 0 ) {
if ( $pl [ 'out1' ] == 0 && $pl [ 'out2' ] == 0 ) {
//Может разменяться только тот кто бил
if ( $pl [ 'uid1' ] == $u -> info [ 'id' ] || $pl [ 'uid2' ] == $u -> info [ 'id' ]) {
$this -> addNewAtack ( $u );
}
} else {
2023-12-19 01:58:37 +00:00
$this -> addNewAtack ( $u );
2022-12-19 20:22:19 +00:00
}
2023-08-10 14:51:16 +00:00
}
}
2024-01-05 22:14:35 +00:00
2024-02-10 19:33:10 +00:00
$i = 0 ;
2023-08-10 14:51:16 +00:00
//тест, бот делает удары
while ( $i < count ( $this -> bots )) {
$bot = $this -> bots [ $i ];
2024-01-05 22:14:35 +00:00
if (
isset ( $bot ) &&
$this -> stats [ $this -> uids [ $bot ]][ 'hpNow' ] >= 1 &&
2024-02-10 01:12:05 +00:00
$this -> users [ $this -> uids [ $bot ]][ 'bot' ] != 1
2024-01-05 22:14:35 +00:00
) { //Тут проверка на бота saintlucia
2022-12-19 20:22:19 +00:00
$j = 0 ;
2023-08-10 14:51:16 +00:00
while ( $j < count ( $this -> users )) {
2024-01-06 15:30:34 +00:00
if ( $this -> i -> razdel == 0 ) {
2023-08-10 14:51:16 +00:00
$tnbot = time () + rand ( 1 , 1 );
} else {
$tnbot = time () + rand ( 1 , 2 );
2022-12-19 20:22:19 +00:00
}
2024-01-05 22:14:35 +00:00
if (
2024-01-08 01:33:20 +00:00
$this -> users [ $j ][ 'timego' ] < time () &&
$this -> users [ $this -> uids [ $bot ]][ 'timego' ] < time () &&
$this -> users [ $j ][ 'hpnow' ] >= 1 &&
$this -> users [ $this -> uids [ $bot ]][ 'hpnow' ] >= 1 &&
2024-01-05 22:14:35 +00:00
$this -> users [ $this -> uids [ $bot ]][ 'team' ] != $this -> users [ $j ][ 'team' ]
) {
if (
isset ( $this -> users [ $j ]) &&
2024-01-08 01:33:20 +00:00
$this -> stats [ $j ][ 'hpnow' ] >= 1 &&
$this -> stats [ $this -> uids [ $bot ]][ 'hpnow' ] >= 1 &&
2024-01-05 22:14:35 +00:00
! isset ( $this -> ga [ $bot ][ $this -> users [ $j ][ 'id' ]]) &&
! isset ( $this -> ag [ $bot ][ $this -> users [ $j ][ 'id' ]]) &&
$this -> users [ $j ][ 'id' ] != $bot &&
$this -> users [ $j ][ 'team' ] != $this -> users [ $this -> uids [ $bot ]][ 'team' ]
) {
if (
2024-01-08 01:33:20 +00:00
$this -> users [ $j ][ 'timego' ] < time () &&
$this -> users [ $this -> uids [ $bot ]][ 'timego' ] < time ()
2024-01-05 22:14:35 +00:00
) {
2023-12-19 01:58:37 +00:00
$this -> botAtack ( $this -> users [ $j ][ 'id' ], $bot , 1 );
2024-02-10 19:33:10 +00:00
Db :: sql ( 'update stats set timego = ? where id = ?' , [ $tnbot , $this -> users [ $this -> uids [ $bot ]][ 'id' ]]);
2023-12-19 01:58:37 +00:00
}
2024-01-05 22:14:35 +00:00
} elseif (
isset ( $this -> users [ $i ]) &&
$this -> users [ $i ][ 'bot' ] > 0 &&
2024-01-08 01:33:20 +00:00
$this -> stats [ $i ][ 'hpnow' ] >= 1 &&
$this -> stats [ $this -> uids [ $bot ]][ 'hpnow' ] >= 1 &&
2024-01-05 22:14:35 +00:00
$this -> users [ $i ][ 'id' ] != $bot &&
$this -> users [ $i ][ 'team' ] != $this -> users [ $this -> uids [ $bot ]][ 'team' ]
) {
if (
2024-01-08 01:33:20 +00:00
$this -> users [ $j ][ 'timego' ] < time () &&
$this -> users [ $this -> uids [ $bot ]][ 'timego' ] < time () &&
2024-01-05 22:14:35 +00:00
$this -> botAct ( $bot )
) {
if (
! isset ( $this -> ga [ $bot ][ $this -> users [ $i ][ 'id' ]]) &&
2024-01-08 01:33:20 +00:00
$this -> users [ $this -> uids [ $bot ]][ 'timego' ] < time () &&
2024-01-05 22:14:35 +00:00
! isset ( $this -> ag [ $bot ][ $this -> users [ $i ][ 'id' ]])
) {
2023-12-19 01:58:37 +00:00
$this -> botAtack ( $this -> users [ $i ][ 'id' ], $bot , 1 );
2024-02-10 19:33:10 +00:00
Db :: sql ( 'update stats set timego = ? where id = ?' , [ $tnbot , $this -> users [ $this -> uids [ $bot ]][ 'id' ]]);
2024-01-05 22:14:35 +00:00
} elseif (
! isset ( $this -> ag [ $bot ][ $this -> users [ $i ][ 'id' ]]) &&
isset ( $this -> ga [ $bot ][ $this -> users [ $i ][ 'id' ]]) &&
2024-01-08 01:33:20 +00:00
$this -> users [ $this -> uids [ $bot ]][ 'timego' ] < time ()
2024-01-05 22:14:35 +00:00
) {
2023-12-19 01:58:37 +00:00
$this -> botAtack ( $bot , $this -> users [ $i ][ 'id' ], 1 );
2024-02-10 19:33:10 +00:00
Db :: sql ( 'update stats set timego = ? where id = ?' , [ $tnbot , $this -> users [ $this -> uids [ $bot ]][ 'id' ]]);
2023-08-10 14:51:16 +00:00
}
2023-12-19 01:58:37 +00:00
}
} else {
//Удары между ботами
2024-01-05 22:14:35 +00:00
if (
2024-01-08 01:33:20 +00:00
$this -> users [ $j ][ 'timego' ] < time () &&
$this -> users [ $this -> uids [ $bot ]][ 'timego' ] < time () &&
$this -> users [ $j ][ 'hpnow' ] >= 1 &&
$this -> users [ $this -> uids [ $bot ]][ 'hpnow' ] >= 1
2024-01-05 22:14:35 +00:00
) {
2024-02-10 01:12:05 +00:00
if ( isset ( $this -> ga [ $bot ][ $this -> users [ $j ][ 'id' ]])) {
$this -> atacks [ $this -> ga [ $bot ][ $this -> users [ $j ][ 'id' ]]][ 'a1' ] =
rand ( 1 , 5 ) . rand ( 1 , 5 ) . rand ( 1 , 5 ) . rand ( 1 , 5 ) . rand ( 1 , 5 );
2024-01-05 22:14:35 +00:00
2024-02-10 01:12:05 +00:00
$this -> atacks [ $this -> ga [ $bot ][ $this -> users [ $j ][ 'id' ]]][ 'b1' ] = rand ( 1 , 5 );
2024-01-05 22:14:35 +00:00
2024-02-10 01:12:05 +00:00
$this -> atacks [ $this -> ga [ $bot ][ $this -> users [ $j ][ 'id' ]]][ 'a2' ] =
rand ( 1 , 5 ) . rand ( 1 , 5 ) . rand ( 1 , 5 ) . rand ( 1 , 5 ) . rand ( 1 , 5 );
2024-01-05 22:14:35 +00:00
2024-02-10 01:12:05 +00:00
$this -> atacks [ $this -> ga [ $bot ][ $this -> users [ $j ][ 'id' ]]][ 'b2' ] = rand ( 1 , 5 );
}
if ( isset ( $this -> ag [ $bot ][ $this -> users [ $j ][ 'id' ]])) {
$this -> atacks [ $this -> ag [ $bot ][ $this -> users [ $j ][ 'id' ]]][ 'a1' ] =
rand ( 1 , 5 ) . rand ( 1 , 5 ) . rand ( 1 , 5 ) . rand ( 1 , 5 ) . rand ( 1 , 5 );
2024-01-05 22:14:35 +00:00
2024-02-10 01:12:05 +00:00
$this -> atacks [ $this -> ag [ $bot ][ $this -> users [ $j ][ 'id' ]]][ 'b1' ] = rand ( 1 , 5 );
2024-01-05 22:14:35 +00:00
2024-02-10 01:12:05 +00:00
$this -> atacks [ $this -> ag [ $bot ][ $this -> users [ $j ][ 'id' ]]][ 'a2' ] =
rand ( 1 , 5 ) . rand ( 1 , 5 ) . rand ( 1 , 5 ) . rand ( 1 , 5 ) . rand ( 1 , 5 );
2024-01-05 22:14:35 +00:00
2024-02-10 01:12:05 +00:00
$this -> atacks [ $this -> ag [ $bot ][ $this -> users [ $j ][ 'id' ]]][ 'b2' ] = rand ( 1 , 5 );
}
2024-01-05 22:14:35 +00:00
if (
isset ( $this -> ga [ $bot ][ $this -> users [ $j ][ 'id' ]]) &&
$this -> users [ $j ][ 'bot' ] > 0
) {
if (
2024-01-08 01:33:20 +00:00
$this -> users [ $j ][ 'timego' ] < time () &&
$this -> users [ $this -> uids [ $bot ]][ 'timego' ] < time ()
2024-01-05 22:14:35 +00:00
) {
2023-12-19 01:58:37 +00:00
$tnbot = time () + rand ( 3 , 7 );
2024-01-06 15:30:34 +00:00
if ( $this -> i -> type == 329 ) { // тестовый бой
2023-12-19 01:58:37 +00:00
$tnbot = time () - 1 ;
}
$this -> startAtack ( $this -> ga [ $bot ][ $this -> users [ $j ][ 'id' ]]);
2024-01-08 01:33:20 +00:00
$this -> users [ $this -> uids [ $bot ]][ 'timego' ] = $tnbot ;
2024-02-10 19:33:10 +00:00
Db :: sql ( 'update stats set timego = ? where id = ?' , [ $tnbot , $this -> users [ $this -> uids [ $bot ]][ 'id' ]]);
2023-12-19 01:58:37 +00:00
}
2024-01-05 22:14:35 +00:00
} elseif (
isset ( $this -> ag [ $bot ][ $this -> users [ $j ][ 'id' ]]) &&
$this -> users [ $j ][ 'bot' ] > 0
) {
if (
2024-01-08 01:33:20 +00:00
$this -> users [ $this -> uids [ $bot ]][ 'timego' ] < time () &&
$this -> users [ $j ][ 'timego' ] < time ()
2024-01-05 22:14:35 +00:00
) {
2023-12-19 01:58:37 +00:00
$this -> startAtack ( $this -> ag [ $bot ][ $this -> users [ $j ][ 'id' ]]);
$tnbot = time () + rand ( 3 , 7 );
2024-01-06 15:30:34 +00:00
if ( $this -> i -> type == 329 ) { // тестовый бой
2023-12-19 01:58:37 +00:00
$tnbot = time () - 1 ;
}
2024-01-08 01:33:20 +00:00
$this -> users [ $this -> uids [ $bot ]][ 'timego' ] = $tnbot ;
2024-02-10 19:33:10 +00:00
Db :: sql ( 'update stats set timego = ? where id = ?' , [ $tnbot , $this -> users [ $this -> uids [ $bot ]][ 'id' ]]);
2023-08-10 14:51:16 +00:00
}
}
2022-12-19 20:22:19 +00:00
}
}
2023-08-10 14:51:16 +00:00
}
$j ++ ;
}
}
$i ++ ;
}
}
2024-01-05 22:14:35 +00:00
private function botAtack ( $uid , $pl , $tp ) : void
2023-08-10 14:51:16 +00:00
{
2024-02-10 14:35:56 +00:00
$testAttack = Db :: getValue ( 'select count(id) from battle_act where battle = ? and uid1 in (?,?) and uid2 in(?,?) and uid1 != uid2' , [ $this -> i -> id , $pl , $uid , $pl , $uid ]) === 0 ;
$testuid = Db :: getValue ( 'select id from stats where id = ? and hpnow >= 1' , [ $uid ]);
2023-08-10 14:51:16 +00:00
2024-02-10 14:35:56 +00:00
if ( $tp == 1 && $testAttack ) {
$testpl = Db :: getValue ( 'select id from stats where id = ? and hpnow >= 1' , [ $pl ]);
$check = $testuid && $testpl && $testuid !== $testpl ;
if ( $check ) {
$a = rand ( 1 , 5 ) . rand ( 1 , 5 ) . rand ( 1 , 5 ) . rand ( 1 , 5 ) . rand ( 1 , 5 );
2023-08-10 14:51:16 +00:00
$b = rand ( 1 , 5 );
2024-01-05 22:14:35 +00:00
Db :: sql (
" insert into battle_act (battle,time,uid1,uid2,a1,b1,a2,b2,invis1,invis2) values (?,unix_timestamp(),?,?,?,?,'',0,0,0) " ,
2024-01-06 15:30:34 +00:00
[ $this -> i -> id , $pl , $uid , $a , $b ,]
2023-08-10 14:51:16 +00:00
);
}
} elseif ( $tp == 2 ) {
//бот отвечает на удар
2024-02-10 14:35:56 +00:00
$testpl = Db :: getValue ( 'select id from stats where id = ? and hpnow >= 1' , [ $pl [ 'uid2' ]]);
$check = $testuid && $testpl && $testuid !== $testpl ;
2023-08-10 14:51:16 +00:00
2024-02-10 14:35:56 +00:00
if ( $check ) {
//Проводим удар
$this -> atacks [ $pl [ 'id' ]][ 'a2' ] = rand ( 1 , 5 ) . '_' . rand ( 1 , 5 ) . '_' . rand ( 1 , 5 ) . '_' . rand ( 1 , 5 ) . '_' . rand ( 1 , 5 );
$this -> atacks [ $pl [ 'id' ]][ 'b2' ] = rand ( 1 , 5 );
2023-08-10 14:51:16 +00:00
$this -> startAtack ( $pl [ 'id' ]);
}
}
}
2024-01-05 22:14:35 +00:00
public function startAtack ( $id ) : void
2023-08-10 14:51:16 +00:00
{
2023-09-30 20:17:25 +00:00
global $u , $priem ;
2023-08-10 14:51:16 +00:00
2023-11-02 13:57:39 +00:00
if ( ! isset ( $this -> atacks [ $id ]) || $this -> atacks [ $id ][ 'lock' ] != 0 ) {
return ;
}
2024-02-10 16:18:11 +00:00
2023-11-02 13:57:39 +00:00
//Прием разгадать тактику
$i = 1 ;
$j = 2 ;
while ( $i <= 2 ) {
2024-02-10 16:18:11 +00:00
$hasResolveTacticPriem = Db :: getValue ( " select count(id) from eff_users where v1 = 'priem' and v2 = 217 and uid = ? " , [ $this -> atacks [ $id ][ 'uid' . $i ]]) > 0 ;
$hasNoAgressiveShield = Db :: getValue ( " select count(id) from eff_users where v1 = 'priem' and v2 = 211 and uid = ? " , [ $this -> atacks [ $id ][ 'uid' . $j ]]) == 0 ;
if ( $hasResolveTacticPriem && $hasNoAgressiveShield ) {
2024-02-10 16:41:23 +00:00
$activePriems = Db :: getRows (
" select eff_users.* from eff_users inner join priems on eff_users.v2 = priems.id where uid = ? and v1 = 'priem' and
2024-02-10 16:18:11 +00:00
v2 not in ( 29 , 30 , 31 , 32 , 36 , 49 , 85 , 86 , 87 , 88 , 89 , 90 , 139 , 174 , 175 , 176 , 177 , 178 , 179 , 187 , 188 , 191 , 201 , 206 , 207 , 208 , 209 , 210 , 211 , 217 , 220 , 222 , 226 ,
227 , 228 , 229 , 233 , 236 , 238 , 245 , 248 , 249 , 256 , 258 , 261 , 262 , 263 , 269 , 270 , 276 , 277 , 284 , 285 , 324 , 332 , 333 , 334 , 335 ) and
2024-02-10 16:41:23 +00:00
eff_users . name not like '%Иммунитет%' and neg = 0 " , [ $this->atacks [ $id ]['uid' . $j ]]
);
2024-02-10 16:18:11 +00:00
foreach ( $activePriems as $ap ) {
$this -> delPriem ( $ap , $this -> users [ $this -> uids [ $this -> atacks [ $id ][ 'uid' . $j ]]], 100 );
2023-08-10 14:51:16 +00:00
}
}
2023-11-02 13:57:39 +00:00
$j -- ;
$i ++ ;
}
2023-08-10 14:51:16 +00:00
2023-11-02 13:57:39 +00:00
//Восстановление манны 1% за ход
if ( $this -> atacks [ $id ][ 'out1' ] == 0 ) {
if ( $this -> stats [ $this -> uids [ $this -> atacks [ $id ][ 'uid1' ]]][ 's6' ] / 4 < $this -> stats [ $this -> uids [ $this -> atacks [ $id ][ 'uid1' ]]][ 'level' ]) {
$this -> stats [ $this -> uids [ $this -> atacks [ $id ][ 'uid1' ]]][ 'mpNow' ] += floor (
$this -> stats [ $this -> uids [ $this -> atacks [ $id ][ 'uid1' ]]][ 'level' ] + $this -> stats [ $this -> uids [ $this -> atacks [ $id ][ 'uid1' ]]][ 'hod_minmana' ]
);
} else {
$this -> stats [ $this -> uids [ $this -> atacks [ $id ][ 'uid1' ]]][ 'mpNow' ] += floor (
$this -> stats [ $this -> uids [ $this -> atacks [ $id ][ 'uid1' ]]][ 's6' ] / 4 + $this -> stats [ $this -> uids [ $this -> atacks [ $id ][ 'uid1' ]]][ 'hod_minmana' ]
2023-08-10 14:51:16 +00:00
);
}
2023-11-02 13:57:39 +00:00
$this -> users [ $this -> uids [ $this -> atacks [ $id ][ 'uid1' ]]][ 'mpNow' ] = $this -> stats [ $this -> uids [ $this -> atacks [ $id ][ 'uid1' ]]][ 'mpNow' ];
}
//
if ( $this -> atacks [ $id ][ 'out2' ] == 0 ) {
if ( $this -> stats [ $this -> uids [ $this -> atacks [ $id ][ 'uid2' ]]][ 's6' ] / 4 < $this -> stats [ $this -> uids [ $this -> atacks [ $id ][ 'uid2' ]]][ 'level' ]) {
$this -> stats [ $this -> uids [ $this -> atacks [ $id ][ 'uid2' ]]][ 'mpNow' ] += floor (
$this -> stats [ $this -> uids [ $this -> atacks [ $id ][ 'uid2' ]]][ 'level' ] + $this -> stats [ $this -> uids [ $this -> atacks [ $id ][ 'uid2' ]]][ 'hod_minmana' ]
);
} else {
$this -> stats [ $this -> uids [ $this -> atacks [ $id ][ 'uid2' ]]][ 'mpNow' ] += floor (
$this -> stats [ $this -> uids [ $this -> atacks [ $id ][ 'uid2' ]]][ 's6' ] / 4 + $this -> stats [ $this -> uids [ $this -> atacks [ $id ][ 'uid2' ]]][ 'hod_minmana' ]
2023-08-10 14:51:16 +00:00
);
}
2023-11-02 13:57:39 +00:00
$this -> users [ $this -> uids [ $this -> atacks [ $id ][ 'uid2' ]]][ 'mpNow' ] = $this -> stats [ $this -> uids [ $this -> atacks [ $id ][ 'uid2' ]]][ 'mpNow' ];
}
2023-08-10 14:51:16 +00:00
2023-11-02 13:57:39 +00:00
//Антистаты
if ( $this -> stats [ $this -> uids [ $this -> atacks [ $id ][ 'uid1' ]]][ 'antm3' ] != 0 ) {
$this -> stats [ $this -> uids [ $this -> atacks [ $id ][ 'uid2' ]]][ 'm3' ] -= round (
$this -> stats [ $this -> uids [ $this -> atacks [ $id ][ 'uid1' ]]][ 'antm3' ]
);
}
if ( $this -> stats [ $this -> uids [ $this -> atacks [ $id ][ 'uid2' ]]][ 'antm3' ] != 0 ) {
$this -> stats [ $this -> uids [ $this -> atacks [ $id ][ 'uid1' ]]][ 'm3' ] -= round (
$this -> stats [ $this -> uids [ $this -> atacks [ $id ][ 'uid2' ]]][ 'antm3' ]
);
}
2023-08-10 14:51:16 +00:00
2023-11-02 13:57:39 +00:00
//Расчет количества блоков и противников
$this -> testZonb ( $this -> atacks [ $id ][ 'uid1' ], $this -> atacks [ $id ][ 'uid2' ]);
2023-08-10 14:51:16 +00:00
2023-11-02 13:57:39 +00:00
//Запускаем магию предметов
$this -> magicItems ( $this -> atacks [ $id ][ 'uid1' ], $this -> atacks [ $id ][ 'uid2' ], $id );
$this -> magicItems ( $this -> atacks [ $id ][ 'uid2' ], $this -> atacks [ $id ][ 'uid1' ], $id );
2023-08-10 14:51:16 +00:00
2024-01-05 22:14:35 +00:00
$at = $this -> newRazmen ( $id );
2023-11-02 13:57:39 +00:00
// Получаем приемы игроков
$this -> priemsRazmen ( $id , $at );
$this -> priemsRazmenMoment ( $id , $at );
$this -> priemsRazmen ( $id , $at );
2023-08-10 14:51:16 +00:00
2023-11-02 13:57:39 +00:00
// Тестируем какие еще могут быть варианты при ударе
// Уворот, парирование, крит, пробить блок, блок щитом
// Блок щитом (если есть щит, конечно)
2024-01-05 22:14:35 +00:00
$rzm = new Razmen ( $this , $id , $at );
$rzm -> criticalDamage ();
$rzm -> parry ();
$rzm -> blockByShield ();
$rzm -> evasion ();
$rzm -> counterstrike ();
$rzm -> damage ();
$at = $rzm -> getAt ();
2022-12-19 20:22:19 +00:00
2023-11-02 13:57:39 +00:00
// Проверяем приемы
// Получаем приемы игроков
$at = $this -> priemsTestRazmen ( $id , $at );
2024-02-10 16:18:11 +00:00
2023-11-02 13:57:39 +00:00
// Собираем размен (пересчитываем и расчитываем урон и т.д)
$at = $this -> priemsRestartRazmen ( $id , $at ); //Повторная проверка приемов (если требуется)
2022-12-19 20:22:19 +00:00
2023-11-02 13:57:39 +00:00
//Минусуем поглощенный урон
if ( count ( $this -> stats [ $this -> uids [ $this -> atacks [ $id ][ 'uid1' ]]][ 'set_pog' ]) > 0 ) {
$this -> testPogB ( $this -> atacks [ $id ][ 'uid1' ], 1 , $id , 1 );
}
if ( count ( $this -> stats [ $this -> uids [ $this -> atacks [ $id ][ 'uid2' ]]][ 'set_pog' ]) > 0 ) {
$this -> testPogB ( $this -> atacks [ $id ][ 'uid2' ], 1 , $id , 1 );
}
2022-12-19 20:22:19 +00:00
2023-11-02 13:57:39 +00:00
// Обновляем Н Р и добавляем тактики
$at = $this -> updateHealth ( $id , $at );
2022-12-19 20:22:19 +00:00
2024-02-09 17:30:22 +00:00
$this -> hodID ++ ;
2023-11-02 13:57:39 +00:00
// Заносим в логи + записываем статистику боя
$this -> addlogRazmen ( $id , $at );
2024-02-10 01:12:05 +00:00
2023-11-02 13:57:39 +00:00
//Запускаем магию предметов
$this -> magicItems ( $this -> atacks [ $id ][ 'uid1' ], $this -> atacks [ $id ][ 'uid2' ], $id );
$this -> magicItems ( $this -> atacks [ $id ][ 'uid2' ], $this -> atacks [ $id ][ 'uid1' ], $id );
2023-08-10 14:51:16 +00:00
2023-11-02 13:57:39 +00:00
//Возращаем зоны блока
$this -> restZonb ( $this -> atacks [ $id ][ 'uid1' ], $this -> atacks [ $id ][ 'uid2' ]);
2024-02-10 16:18:11 +00:00
2023-11-02 13:57:39 +00:00
//обновляем задержки приемов
$zd1 = explode ( '|' , $this -> users [ $this -> uids [ $this -> atacks [ $id ][ 'uid1' ]]][ 'priems_z' ]);
$zd2 = explode ( '|' , $this -> users [ $this -> uids [ $this -> atacks [ $id ][ 'uid2' ]]][ 'priems_z' ]);
2022-12-19 20:22:19 +00:00
2024-02-10 16:18:11 +00:00
$i5 = 0 ;
2023-11-02 13:57:39 +00:00
while ( $i5 < 51 ) {
if ( isset ( $zd1 [ $i5 ]) && $zd1 [ $i5 ] > 0 ) {
//Если приемы не требуют ход
$zd1 [ $i5 ] -= 1 ;
} else {
$zd1 [ $i5 ] = 0 ;
2022-12-19 20:22:19 +00:00
}
2023-11-02 13:57:39 +00:00
if ( isset ( $zd2 [ $i5 ]) && $zd2 [ $i5 ] > 0 ) {
//Если приемы не требуют ход
$zd2 [ $i5 ] -= 1 ;
} else {
$zd2 [ $i5 ] = 0 ;
2022-12-19 20:22:19 +00:00
}
2023-11-02 13:57:39 +00:00
$i5 ++ ;
}
2024-02-10 16:18:11 +00:00
2023-11-02 13:57:39 +00:00
if ( $this -> users [ $this -> uids [ $this -> atacks [ $id ][ 'uid1' ]]][ 'enemy' ] == $this -> users [ $this -> uids [ $this -> atacks [ $id ][ 'uid2' ]]][ 'id' ]) {
$this -> users [ $this -> uids [ $this -> atacks [ $id ][ 'uid1' ]]][ 'enemy' ] = - $this -> users [ $this -> uids [ $this -> atacks [ $id ][ 'uid1' ]]][ 'enemy' ];
}
2023-08-10 14:51:16 +00:00
2023-11-02 13:57:39 +00:00
if ( $this -> users [ $this -> uids [ $this -> atacks [ $id ][ 'uid2' ]]][ 'enemy' ] == $this -> users [ $this -> uids [ $this -> atacks [ $id ][ 'uid1' ]]][ 'id' ]) {
$this -> users [ $this -> uids [ $this -> atacks [ $id ][ 'uid2' ]]][ 'enemy' ] = - $this -> users [ $this -> uids [ $this -> atacks [ $id ][ 'uid2' ]]][ 'enemy' ];
}
$this -> users [ $this -> uids [ $this -> atacks [ $id ][ 'uid1' ]]][ 'priems_z' ] = implode ( '|' , $zd1 );
$this -> users [ $this -> uids [ $this -> atacks [ $id ][ 'uid2' ]]][ 'priems_z' ] = implode ( '|' , $zd2 );
if ( $this -> atacks [ $id ][ 'uid1' ] == $u -> info [ 'id' ]) {
$u -> info [ 'priems_z' ] = implode ( '|' , $zd1 );
} elseif ( $this -> atacks [ $id ][ 'uid2' ] == $u -> info [ 'id' ]) {
$u -> info [ 'priems_z' ] = implode ( '|' , $zd2 );
}
2024-02-10 16:18:11 +00:00
2023-11-02 13:57:39 +00:00
//Проверяем тактики
2024-02-10 16:18:11 +00:00
2023-11-02 13:57:39 +00:00
$i = 1 ;
while ( $i <= 6 ) {
2024-02-10 16:18:11 +00:00
$this -> users [ $this -> uids [ $this -> atacks [ $id ][ 'uid1' ]]][ 'tactic' . $i ] = Comparsion :: minimax ( $this -> users [ $this -> uids [ $this -> atacks [ $id ][ 'uid1' ]]][ 'tactic' . $i ], 0 , 25 );
$this -> users [ $this -> uids [ $this -> atacks [ $id ][ 'uid2' ]]][ 'tactic' . $i ] = Comparsion :: minimax ( $this -> users [ $this -> uids [ $this -> atacks [ $id ][ 'uid2' ]]][ 'tactic' . $i ], 0 , 25 );
2023-11-02 13:57:39 +00:00
$i ++ ;
}
2024-02-10 16:18:11 +00:00
2023-11-02 13:57:39 +00:00
//Обновляем задержки предметов
2024-02-10 16:18:11 +00:00
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' ]]);
2024-02-09 19:41:54 +00:00
Db :: sql ( 'update users set notrhod = -1 where id = ? or id = ?' , [ $this -> atacks [ $id ][ 'uid1' ], $this -> atacks [ $id ][ 'uid2' ]]);
2022-12-19 20:22:19 +00:00
2024-02-09 19:41:54 +00:00
//Обновляем задержки заклинаний, пирогов, тактик
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' ]]);
2023-08-10 14:51:16 +00:00
2024-02-09 19:41:54 +00:00
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 ]);
2022-12-19 20:22:19 +00:00
2023-11-02 13:57:39 +00:00
//Обновляем данные в battle_users
2024-02-09 19:41:54 +00:00
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' ]]);
2023-11-02 13:57:39 +00:00
//Восстановление манны 25% от мудрости за ход
if ( $this -> stats [ $this -> uids [ $this -> atacks [ $id ][ 'uid1' ]]][ 'yhod' ] > 0 ) {
2024-02-09 18:26:44 +00:00
$this -> saveStats (
2023-11-02 13:57:39 +00:00
$this -> yhod_user (
$this -> atacks [ $id ][ 'uid2' ], $this -> atacks [ $id ][ 'uid1' ],
$this -> stats [ $this -> uids [ $this -> atacks [ $id ][ 'uid1' ]]][ 'yhod' ]
)
2023-08-10 14:51:16 +00:00
);
2023-11-02 13:57:39 +00:00
} elseif ( $this -> stats [ $this -> uids [ $this -> atacks [ $id ][ 'uid2' ]]][ 'yhod' ] > 0 ) {
2024-02-09 18:26:44 +00:00
$this -> saveStats (
2023-11-02 13:57:39 +00:00
$this -> yhod_user (
$this -> atacks [ $id ][ 'uid1' ], $this -> atacks [ $id ][ 'uid2' ],
$this -> stats [ $this -> uids [ $this -> atacks [ $id ][ 'uid2' ]]][ 'yhod' ]
)
2023-08-10 14:51:16 +00:00
);
2023-11-02 13:57:39 +00:00
}
2024-01-05 22:14:35 +00:00
2024-01-06 15:30:34 +00:00
$sql = ' update stats set hpnow = : hpnow , mpnow = : mpnow ,
2024-01-05 22:14:35 +00:00
tactic1 = : t1 , tactic2 = : t2 , tactic3 = : t3 , tactic4 = : t4 ,
tactic5 = : t5 , tactic6 = : t6 , tactic7 = : t7 , enemy = : enemy ,
battle_yron = : by , last_hp = : lasthp , battle_exp = : be ,
priems_z = : pz where id = : uid ' ;
$arg1 = [
'hpnow' => $this -> stats [ $this -> uids [ $this -> atacks [ $id ][ 'uid1' ]]][ 'hpNow' ],
'mpnow' => $this -> stats [ $this -> uids [ $this -> atacks [ $id ][ 'uid1' ]]][ 'mpNow' ],
't1' => $this -> users [ $this -> uids [ $this -> atacks [ $id ][ 'uid1' ]]][ 'tactic1' ],
't2' => $this -> users [ $this -> uids [ $this -> atacks [ $id ][ 'uid1' ]]][ 'tactic2' ],
't3' => $this -> users [ $this -> uids [ $this -> atacks [ $id ][ 'uid1' ]]][ 'tactic3' ],
't4' => $this -> users [ $this -> uids [ $this -> atacks [ $id ][ 'uid1' ]]][ 'tactic4' ],
't5' => $this -> users [ $this -> uids [ $this -> atacks [ $id ][ 'uid1' ]]][ 'tactic5' ],
't6' => $this -> users [ $this -> uids [ $this -> atacks [ $id ][ 'uid1' ]]][ 'tactic6' ],
't7' => $this -> users [ $this -> uids [ $this -> atacks [ $id ][ 'uid1' ]]][ 'tactic7' ],
'enemy' => $this -> users [ $this -> uids [ $this -> atacks [ $id ][ 'uid1' ]]][ 'enemy' ],
'by' => $this -> users [ $this -> uids [ $this -> atacks [ $id ][ 'uid1' ]]][ 'battle_yron' ],
'lasthp' => $this -> users [ $this -> uids [ $this -> atacks [ $id ][ 'uid1' ]]][ 'last_hp' ],
'be' => $this -> users [ $this -> uids [ $this -> atacks [ $id ][ 'uid1' ]]][ 'battle_exp' ],
'pz' => $this -> users [ $this -> uids [ $this -> atacks [ $id ][ 'uid1' ]]][ 'priems_z' ],
'uid' => $this -> atacks [ $id ][ 'uid1' ],
];
$arg2 = [
'hpnow' => $this -> stats [ $this -> uids [ $this -> atacks [ $id ][ 'uid2' ]]][ 'hpNow' ],
'mpnow' => $this -> stats [ $this -> uids [ $this -> atacks [ $id ][ 'uid2' ]]][ 'mpNow' ],
't1' => $this -> users [ $this -> uids [ $this -> atacks [ $id ][ 'uid2' ]]][ 'tactic1' ],
't2' => $this -> users [ $this -> uids [ $this -> atacks [ $id ][ 'uid2' ]]][ 'tactic2' ],
't3' => $this -> users [ $this -> uids [ $this -> atacks [ $id ][ 'uid2' ]]][ 'tactic3' ],
't4' => $this -> users [ $this -> uids [ $this -> atacks [ $id ][ 'uid2' ]]][ 'tactic4' ],
't5' => $this -> users [ $this -> uids [ $this -> atacks [ $id ][ 'uid2' ]]][ 'tactic5' ],
't6' => $this -> users [ $this -> uids [ $this -> atacks [ $id ][ 'uid2' ]]][ 'tactic6' ],
't7' => $this -> users [ $this -> uids [ $this -> atacks [ $id ][ 'uid2' ]]][ 'tactic7' ],
'enemy' => $this -> users [ $this -> uids [ $this -> atacks [ $id ][ 'uid2' ]]][ 'enemy' ],
'by' => $this -> users [ $this -> uids [ $this -> atacks [ $id ][ 'uid2' ]]][ 'battle_yron' ],
'lasthp' => $this -> users [ $this -> uids [ $this -> atacks [ $id ][ 'uid2' ]]][ 'last_hp' ],
'be' => $this -> users [ $this -> uids [ $this -> atacks [ $id ][ 'uid2' ]]][ 'battle_exp' ],
'pz' => $this -> users [ $this -> uids [ $this -> atacks [ $id ][ 'uid2' ]]][ 'priems_z' ],
'uid' => $this -> atacks [ $id ][ 'uid2' ],
];
Db :: sql ( $sql , $arg1 );
Db :: sql ( $sql , $arg2 );
unset ( $sql , $arg1 , $arg2 );
2023-11-02 13:57:39 +00:00
$this -> priemsRazmenMomentEnd ( $id , $at );
2024-01-05 22:14:35 +00:00
2023-11-02 13:57:39 +00:00
//Минусуем заряд приема \ эффекта
$j = 1 ;
while ( $j <= 2 ) {
$eff = $this -> stats [ $this -> uids [ $this -> atacks [ $id ][ 'uid' . $j ]]][ 'effects' ];
$i = 0 ;
while ( $i < count ( $eff )) {
if ( isset ( $eff [ $i ])) {
if ( $eff [ $i ][ 'timeUse' ] == 77 && $eff [ $i ][ 'hod' ] > - 1 ) {
$eff [ $i ][ 'hod' ] -- ;
2024-02-10 16:18:11 +00:00
$eff [ $i ][ 'priem' ] = Db :: getValue ( 'select * from priems where id = ?' , [ $eff [ $i ][ 'v2' ]]) ? ? 0 ;
2023-11-02 13:57:39 +00:00
if ( round ( $eff [ $i ][ 'priem' ][ 'minmana' ] * $eff [ $i ][ 'x' ]) != 0 ) {
//Отнимаем ману у того кто кастовал
$priem -> minMana (
$eff [ $i ][ 'user_use' ],
round ( $eff [ $i ][ 'priem' ][ 'minmana' ] * $eff [ $i ][ 'x' ])
2023-08-10 14:51:16 +00:00
);
2023-11-02 13:57:39 +00:00
if ( $this -> stats [ $this -> uids [ $eff [ $i ][ 'user_use' ]]][ 'mpNow' ] <= 0 ) {
$eff [ $i ][ 'hod' ] = 0 ;
2023-08-10 14:51:16 +00:00
}
2023-11-02 13:57:39 +00:00
}
if ( strripos ( $eff [ $i ][ 'data' ], 'minprocmanahod' )) {
$pvr = [
'x1' => 0 ,
'x2' => 0 ,
'i' => 0 ,
'uid' => $eff [ $i ][ 'uid' ],
'color' => '' ,
'color2' => '' ,
'effx' => '' ,
'x' => $eff [ $i ][ 'name' ],
];
$pvr [ 'd' ] = explode ( '|' , $eff [ $i ][ 'data' ]);
while ( $pvr [ 'i' ] < count ( $pvr [ 'd' ])) {
if ( isset ( $pvr [ 'd' ][ $pvr [ 'i' ]])) {
$pvr [ 'd1' ] = explode ( '=' , $pvr [ 'd' ][ $pvr [ 'i' ]]);
if ( $pvr [ 'd1' ][ 0 ] == 'minprocmanahod' ) {
$pvr [ 'd1' ] = explode ( 'x' , $pvr [ 'd1' ][ 1 ]);
$pvr [ 'x1' ] = $pvr [ 'd1' ][ 0 ];
$pvr [ 'x2' ] = $pvr [ 'd1' ][ 1 ];
2023-08-10 14:51:16 +00:00
}
}
2023-11-02 13:57:39 +00:00
$pvr [ 'i' ] ++ ;
}
2022-12-19 20:22:19 +00:00
2023-11-02 13:57:39 +00:00
$pvr [ 'mp' ] = round (
$this -> stats [ $this -> uids [ $pvr [ 'uid' ]]][ 'mpAll' ] / 100 * rand (
$pvr [ 'x1' ],
$pvr [ 'x2' ]
)
);
$pvr [ 'mpSee' ] = 0 ;
$pvr [ 'mpNow' ] = floor ( $this -> stats [ $this -> uids [ $pvr [ 'uid' ]]][ 'mpNow' ]);
$pvr [ 'mpAll' ] = $this -> stats [ $this -> uids [ $pvr [ 'uid' ]]][ 'mpAll' ];
$pvr [ 'mpTr' ] = $pvr [ 'mpAll' ] - $pvr [ 'mpNow' ];
if ( $pvr [ 'mpTr' ] > 0 ) {
//Требуется хилл
if ( $pvr [ 'mpTr' ] < $pvr [ 'mp' ]) {
$pvr [ 'mp' ] = $pvr [ 'mpTr' ];
2023-08-10 14:51:16 +00:00
}
2023-11-02 13:57:39 +00:00
$pvr [ 'mpSee' ] = '+' . $pvr [ 'mp' ];
$pvr [ 'mpNow' ] += $pvr [ 'mp' ];
}
2024-02-10 16:18:11 +00:00
$pvr [ 'mpNow' ] = Comparsion :: minimax ( $pvr [ 'mpNow' ], 0 , $pvr [ 'mpAll' ]);
2023-11-02 13:57:39 +00:00
if ( $pvr [ 'mpSee' ] == 0 ) {
$pvr [ 'mpSee' ] = '--' ;
}
2023-08-10 14:51:16 +00:00
2024-02-09 19:41:54 +00:00
$this -> stats [ $this -> uids [ $pvr [ 'uid' ]]][ 'mpNow' ] = $pvr [ 'mpNow' ];
$this -> users [ $this -> uids [ $pvr [ 'uid' ]]][ 'mpNow' ] = $pvr [ 'mpNow' ];
2024-02-10 16:18:11 +00:00
Db :: sql ( 'update stats set mpnow = ? where id = ?' , [ $this -> stats [ $this -> uids [ $pvr [ 'uid' ]]][ 'mpNow' ], $pvr [ 'uid' ]]);
2023-08-10 14:51:16 +00:00
2024-01-05 22:14:35 +00:00
$pvr [ 'text' ] = $this -> addlt ( 1 , 21 , $this -> users [ $this -> uids [ $pvr [ 'uid' ]]][ 'sex' ]);
$pvr [ 'text2' ] = '{tm1} ' . $pvr [ 'text' ] . ' на <strong style="color: #006699;">' . $pvr [ 'mpSee' ] . '</strong> [' . $pvr [ 'mpNow' ] . '/' . $pvr [ 'mpAll' ] . '] (Мана)' ;
2023-11-02 13:57:39 +00:00
$this -> priemAddLog (
$id , 1 , 2 , $pvr [ 'uid' ], 0 ,
'<font color^^^^#' . $pvr [ 'color2' ] . '>' . $pvr [ 'x' ] . '</font>' ,
$pvr [ 'text2' ],
2024-01-05 22:14:35 +00:00
$this -> hodID
2023-11-02 13:57:39 +00:00
);
unset ( $pvr );
}
if ( isset ( $this -> rehodeff [ $eff [ $i ][ 'id' ]])) {
$eff [ $i ][ 'hod' ] = $this -> rehodeff [ $eff [ $i ][ 'id' ]];
}
if ( $eff [ $i ][ 'hod' ] > 0 ) {
$this -> stats [ $this -> uids [ $this -> atacks [ $id ][ 'uid' . $j ]]][ 'effects' ][ 'hod' ] = $eff [ $i ][ 'hod' ];
2024-02-10 16:18:11 +00:00
Effects :: setHod ( $eff [ $i ][ 'id' ], $eff [ $i ][ 'hod' ]);
2023-11-02 13:57:39 +00:00
} else {
//удаляем прием
if ( $eff [ $i ][ 'v2' ] > 0 ) {
if ( $j == 1 ) {
$jn = 2 ;
} else {
$jn = 1 ;
}
$this -> delPriem (
$eff [ $i ], $this -> users [ $this -> uids [ $this -> atacks [ $id ][ 'uid' . $j ]]],
3 , $this -> atacks [ $id ][ 'uid' . $jn ]
2023-08-10 14:51:16 +00:00
);
}
2023-11-02 13:57:39 +00:00
}
} elseif ( $eff [ $i ][ 'timeUse' ] == 77 && $eff [ $i ][ 'hod' ] == - 2 ) {
2024-02-10 16:18:11 +00:00
$eff [ $i ][ 'priem' ] = Db :: getRow ( 'select * from priems where id = ?' , [ $eff [ $i ][ 'v2' ]]);
$priem -> hodUsePriem ( $this , $eff [ $i ]);
2023-11-02 13:57:39 +00:00
} else {
2024-02-10 16:18:11 +00:00
$eff [ $i ][ 'priem' ] = Db :: getRow ( 'select * from priems where id = ?' , [ $eff [ $i ][ 'v2' ]]);
2023-11-02 13:57:39 +00:00
if ( isset ( $eff [ $i ][ 'priem' ][ 'minmana' ]) && round (
$eff [ $i ][ 'priem' ][ 'minmana' ] * $eff [ $i ][ 'x' ]
) != 0 ) {
//Отнимаем ману у того кто кастовал
$priem -> minMana (
$eff [ $i ][ 'user_use' ],
round ( $eff [ $i ][ 'priem' ][ 'minmana' ] * $eff [ $i ][ 'x' ])
);
if ( $this -> stats [ $this -> uids [ $eff [ $i ][ 'user_use' ]]][ 'mpNow' ] <= 0 ) {
$eff [ $i ][ 'hod' ] = 0 ;
if ( isset ( $this -> rehodeff [ $eff [ $i ][ 'id' ]])) {
$eff [ $i ][ 'hod' ] = $this -> rehodeff [ $eff [ $i ][ 'id' ]];
}
if ( $eff [ $i ][ 'v2' ] > 0 ) {
if ( $j == 1 ) {
$jn = 2 ;
} else {
$jn = 1 ;
}
$this -> delPriem (
$eff [ $i ],
$this -> users [ $this -> uids [ $this -> atacks [ $id ][ 'uid' . $j ]]], 3 ,
$this -> atacks [ $id ][ 'uid' . $jn ]
);
}
}
} elseif ( $eff [ $i ][ 'timeUse' ] > 100 && $eff [ $i ][ 'hod' ] > - 1 && Config :: get ( 'effz' ) > 0 ) {
$eff [ $i ][ 'hod' ] -- ;
2023-08-10 14:51:16 +00:00
if ( isset ( $this -> rehodeff [ $eff [ $i ][ 'id' ]])) {
$eff [ $i ][ 'hod' ] = $this -> rehodeff [ $eff [ $i ][ 'id' ]];
}
if ( $eff [ $i ][ 'hod' ] > 0 ) {
$this -> stats [ $this -> uids [ $this -> atacks [ $id ][ 'uid' . $j ]]][ 'effects' ][ 'hod' ] = $eff [ $i ][ 'hod' ];
2024-02-10 16:18:11 +00:00
Effects :: setHod ( $eff [ $i ][ 'id' ], $eff [ $i ][ 'hod' ]);
2023-08-10 14:51:16 +00:00
} else {
//удаляем прием
if ( $eff [ $i ][ 'v2' ] > 0 ) {
if ( $j == 1 ) {
$jn = 2 ;
} else {
$jn = 1 ;
}
$this -> delPriem (
2023-11-02 13:57:39 +00:00
$eff [ $i ],
$this -> users [ $this -> uids [ $this -> atacks [ $id ][ 'uid' . $j ]]], 3 ,
$this -> atacks [ $id ][ 'uid' . $jn ]
2023-08-10 14:51:16 +00:00
);
2022-12-19 20:22:19 +00:00
}
}
}
}
}
2023-11-02 13:57:39 +00:00
$i ++ ;
2022-12-19 20:22:19 +00:00
}
2023-11-02 13:57:39 +00:00
$j ++ ;
}
2024-02-09 19:41:54 +00:00
$this -> deathByTimeout ( $id );
2023-11-02 13:57:39 +00:00
//Обновляем текущего противника
if ( $u -> info [ 'id' ] == $this -> atacks [ $id ][ 'uid1' ]) {
$u -> info [ 'enemy' ] = $this -> users [ $this -> uids [ $this -> atacks [ $id ][ 'uid1' ]]][ 'enemy' ];
}
if ( $u -> info [ 'id' ] == $this -> atacks [ $id ][ 'uid2' ]) {
$u -> info [ 'enemy' ] = $this -> users [ $this -> uids [ $this -> atacks [ $id ][ 'uid2' ]]][ 'enemy' ];
}
//Удаляем размен из базы //Т У Т возможен лаг удаления
2024-02-10 16:41:23 +00:00
Db :: sql (
'delete from battle_act where uid1 != uid2 and uid1 in (?,?) and uid2 in (?,?)' ,
[ $this -> atacks [ $id ][ 'uid1' ], $this -> atacks [ $id ][ 'uid2' ], $this -> atacks [ $id ][ 'uid1' ], $this -> atacks [ $id ][ 'uid2' ]]
2023-11-02 13:57:39 +00:00
);
2024-02-10 16:41:23 +00:00
2023-11-02 13:57:39 +00:00
unset ( $old_s1 , $old_s2 );
unset ( $this -> ga [ $this -> atacks [ $id ][ 'uid1' ]][ $this -> atacks [ $id ][ 'uid2' ]], $this -> ga [ $this -> atacks [ $id ][ 'uid2' ]][ $this -> atacks [ $id ][ 'uid1' ]]);
unset ( $this -> ag [ $this -> atacks [ $id ][ 'uid1' ]][ $this -> atacks [ $id ][ 'uid2' ]], $this -> ag [ $this -> atacks [ $id ][ 'uid2' ]][ $this -> atacks [ $id ][ 'uid1' ]]);
unset ( $this -> atacks [ $id ]);
2024-02-10 16:41:23 +00:00
Db :: sql ( 'delete from battle_act where id = ?' , [ $id ]);
2023-11-02 13:57:39 +00:00
}
2024-05-10 11:32:06 +00:00
//Используем приемы
2023-11-02 13:57:39 +00:00
/** Осторожно ! Подключаются файлы !!!
2024-05-10 11:32:06 +00:00
* @ param array $pl
2024-01-05 22:14:35 +00:00
* @ param $u1
2024-05-10 11:32:06 +00:00
* @ param int $t
2024-01-05 22:14:35 +00:00
* @ param int | array $u2
2024-05-10 11:32:06 +00:00
* @ param string $rznm
2023-11-02 13:57:39 +00:00
* @ return void
*/
public function delPriem (
2024-02-10 16:18:11 +00:00
array $pl ,
$u1 ,
int $t = 1 ,
2024-01-05 22:14:35 +00:00
int | array $u2 = 0 ,
2024-02-10 16:18:11 +00:00
string $rznm = 'Очиститься Кровью'
2024-05-10 11:32:06 +00:00
) : void
{
2023-11-02 13:57:39 +00:00
global $u , $priem ;
if ( ! isset ( $pl [ 'priem' ][ 'id' ]) || isset ( $this -> del_val [ 'eff' ][ $pl [ 'priem' ][ 'id' ]])) {
return ;
}
if ( $pl [ 'x' ] > 1 ) {
2023-12-17 02:32:09 +00:00
$pl [ 'name' ] = $pl [ 'name' ] . ' x' . $pl [ 'x' ];
2023-11-02 13:57:39 +00:00
}
if ( $pl [ 'timeUse' ] == 77 ) {
//завершаем прием
2024-02-10 16:41:23 +00:00
Effects :: removeById ( 0 , $pl [ 'id' ]);
2023-11-02 13:57:39 +00:00
}
2023-12-17 02:32:09 +00:00
$vLog = 'time1=' . time () . '||s1=' . $u1 [ 'sex' ] . '||t1=' . $u1 [ 'team' ] . '||login1=' . $u1 [ 'login' ];
2024-01-05 22:14:35 +00:00
if ( is_array ( $u2 ) && isset ( $u2 [ 'id' ])) {
2023-12-17 02:32:09 +00:00
$vLog .= '||s2=' . $u2 [ 'sex' ] . '||t2=' . $u2 [ 'team' ] . '||login2=' . $u2 [ 'login' ];
2023-11-02 13:57:39 +00:00
}
$mas1 = [
2024-01-06 15:30:34 +00:00
'battle' => $this -> i -> id ,
2023-11-02 13:57:39 +00:00
'id_hod' => $this -> hodID ,
'text' => '' ,
'vars' => $vLog ,
'type' => '1' ,
];
if ( $t == 4 ) {
$mas1 [ 'id_hod' ] ++ ;
$t = 2 ;
}
if ( $t == 1 ) {
$mas1 [ 'id_hod' ] ++ ;
if ( $pl [ 'priem' ][ 'file' ] != '0' ) {
if ( file_exists ( '../../_incl_data/class/priems/' . $pl [ 'priem' ][ 'file' ] . '.php' )) {
2024-01-05 22:14:35 +00:00
require_once 'priems/' . $pl [ 'priem' ][ 'file' ] . '.php' ;
2022-12-19 20:22:19 +00:00
}
2023-11-02 13:57:39 +00:00
} elseif ( $pl [ 'priem' ][ 'file3' ] != '0' ) {
if ( file_exists ( '../../_incl_data/class/priems/' . $pl [ 'priem' ][ 'file3' ] . '.php' )) {
2024-01-05 22:14:35 +00:00
require_once 'priems/' . $pl [ 'priem' ][ 'file3' ] . '.php' ;
2023-08-10 14:51:16 +00:00
}
2023-11-02 13:57:39 +00:00
} else {
$mas1 [ 'text' ] = '{tm1} {u1} {1x16x0} прием "<strong>' . $pl [ 'name' ] . '</strong>".' ;
$this -> del_val [ 'eff' ][ $pl [ 'priem' ][ 'id' ]] = true ;
2023-08-10 14:51:16 +00:00
}
2023-11-02 13:57:39 +00:00
} elseif ( $t == 2 ) {
$mas1 [ 'text' ] = '{tm1} У персонажа {u1} закончилось действие магии "<strong>' . $pl [ 'name' ] . '</strong>".' ;
} elseif ( $t == 99 ) {
$mas1 [ 'text' ] = '{u1} Снял эфект "<strong>' . $pl [ 'name' ] . '</strong>" с помощью <strong>' . $rznm . '</strong> .' ;
} else {
if ( $t == 100 ) {
$mas1 [ 'id_hod' ] ++ ;
2023-08-10 14:51:16 +00:00
}
2023-11-02 13:57:39 +00:00
$mas1 [ 'text' ] = '{tm1} Закончилось действие эффекта "<strong>' . $pl [ 'name' ] . '</strong>" для {u1}.' ;
2022-12-19 20:22:19 +00:00
}
2023-11-02 13:57:39 +00:00
if ( $pl [ 'priem' ][ 'id' ] != 24 ) {
2024-02-09 17:28:32 +00:00
Log :: add ( $mas1 );
2023-11-02 13:57:39 +00:00
}
$this -> stats [ $this -> uids [ $pl [ 'uid' ]]] = $u -> getStats ( $pl [ 'uid' ], 0 , 0 , false , false , true );
2023-08-10 14:51:16 +00:00
}
2022-12-19 20:22:19 +00:00
2024-02-09 19:41:54 +00:00
/**
* Расчет количества блоков и противников ?
* @ param $uid
* @ param $uid2
* @ return void
*/
2024-01-05 22:14:35 +00:00
private function testZonb ( $uid , $uid2 ) : void
2023-08-10 14:51:16 +00:00
{
$zba = [];
2022-12-19 20:22:19 +00:00
2023-08-10 14:51:16 +00:00
if ( $this -> stnZb [ $uid ] == 0 ) {
$zba [ 1 ] = $this -> stats [ $this -> uids [ $uid ]][ 'zonb' ];
$this -> stnZb [ $uid ] = $zba [ 1 ];
} else {
$zba [ 1 ] = $this -> stnZb [ $uid ];
}
2022-12-19 20:22:19 +00:00
2023-08-10 14:51:16 +00:00
if ( $this -> stnZb [ $uid2 ] == 0 ) {
$zba [ 2 ] = $this -> stats [ $this -> uids [ $uid2 ]][ 'zonb' ];
$this -> stnZb [ $uid ] = $zba [ 2 ];
2022-12-19 20:22:19 +00:00
} else {
2023-08-10 14:51:16 +00:00
$zba [ 2 ] = $this -> stnZb [ $uid2 ];
2022-12-19 20:22:19 +00:00
}
2023-08-10 14:51:16 +00:00
if ( $zba [ 1 ] > 3 ) {
$zba [ 1 ] = 3 ;
}
if ( $zba [ 2 ] > 3 ) {
$zba [ 2 ] = 3 ;
2022-12-19 20:22:19 +00:00
}
2023-08-10 14:51:16 +00:00
//Блоки игрока 1
if (
(
$this -> stats [ $this -> uids [ $uid2 ]][ 'weapon1' ] == 1 ||
$this -> stats [ $this -> uids [ $uid2 ]][ 'weapon2' ] == 1
) &&
$this -> stats [ $this -> uids [ $uid ]][ 'weapon1' ] != 1 &&
$this -> stats [ $this -> uids [ $uid ]][ 'weapon2' ] != 1
) {
$zba [ 1 ] -= 1 ;
2022-12-19 20:22:19 +00:00
}
2023-08-10 14:51:16 +00:00
//Блоки игрока 2
if (
(
$this -> stats [ $this -> uids [ $uid ]][ 'weapon1' ] == 1 ||
$this -> stats [ $this -> uids [ $uid ]][ 'weapon2' ] == 1
) &&
$this -> stats [ $this -> uids [ $uid2 ]][ 'weapon1' ] != 1 &&
$this -> stats [ $this -> uids [ $uid2 ]][ 'weapon2' ] != 1
) {
$zba [ 2 ] -= 1 ;
2022-12-19 20:22:19 +00:00
}
2023-08-10 14:51:16 +00:00
if ( $zba [ 1 ] < 1 ) {
$zba [ 1 ] = 1 ;
2022-12-19 20:22:19 +00:00
}
2023-08-10 14:51:16 +00:00
if ( $zba [ 2 ] < 1 ) {
$zba [ 2 ] = 1 ;
2022-12-19 20:22:19 +00:00
}
2023-08-10 14:51:16 +00:00
$this -> stats [ $this -> uids [ $uid ]][ 'zonb' ] = $zba [ 1 ];
$this -> stats [ $this -> uids [ $uid2 ]][ 'zonb' ] = $zba [ 2 ];
if (
$this -> stats [ $this -> uids [ $uid ]][ 'min_zonb' ] > 0 &&
$this -> stats [ $this -> uids [ $uid ]][ 'zonb' ] < $this -> stats [ $this -> uids [ $uid ]][ 'min_zonb' ]
) {
$this -> stats [ $this -> uids [ $uid ]][ 'zonb' ] = $this -> stats [ $this -> uids [ $uid ]][ 'min_zonb' ];
2022-12-19 20:22:19 +00:00
}
2023-08-10 14:51:16 +00:00
if (
$this -> stats [ $this -> uids [ $uid2 ]][ 'min_zonb' ] > 0 &&
$this -> stats [ $this -> uids [ $uid2 ]][ 'zonb' ] < $this -> stats [ $this -> uids [ $uid2 ]][ 'min_zonb' ]
) {
$this -> stats [ $this -> uids [ $uid2 ]][ 'zonb' ] = $this -> stats [ $this -> uids [ $uid2 ]][ 'min_zonb' ];
2022-12-19 20:22:19 +00:00
}
}
2024-05-10 11:32:06 +00:00
//Повторная проверка приемов
2023-08-10 14:51:16 +00:00
2024-01-05 22:14:35 +00:00
/**
2024-02-09 19:41:54 +00:00
* Магия предметов ?
2024-01-05 22:14:35 +00:00
* Осторожно ! Подключаются файлы !!!
* @ param int $uid1
* @ param int $uid2 Н Е УДАЛЯТЬ !!!
* @ param int $end
2023-09-30 20:17:25 +00:00
* @ return void
*/
2024-01-05 22:14:35 +00:00
private function magicItems ( int $uid1 , int $uid2 , int $end ) : void
2022-12-19 20:22:19 +00:00
{
2023-08-10 14:51:16 +00:00
if ( ! isset ( $this -> stats [ $this -> uids [ $uid1 ]])) {
return ;
}
2024-01-05 22:14:35 +00:00
foreach ( $this -> stats [ $this -> uids [ $uid1 ]][ 'items' ] as $item ) {
if ( ! isset ( $item [ 'id' ])) {
continue ;
}
$e = Conversion :: dataStringToArray ( $item [ 'data' ]);
if ( ! isset ( $e [ 'bm_a1' ])) {
continue ;
}
if ( $end > 0 ) {
2024-02-09 19:41:54 +00:00
$e [ 'bm_a1' ] .= '.end' ;
2022-12-19 20:22:19 +00:00
}
2024-02-09 19:41:54 +00:00
if ( file_exists ( 'priems/' . $e [ 'bm_a1' ] . '.php' )) {
require_once 'priems/' . $e [ 'bm_a1' ] . '.php' ;
2023-08-10 14:51:16 +00:00
}
}
}
2024-05-10 11:32:06 +00:00
//Проверка действия приема
2023-08-14 15:15:05 +00:00
2024-01-05 22:14:35 +00:00
private function newRazmen ( $id ) : array
2023-08-10 14:51:16 +00:00
{
$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 ;
}
2024-05-10 11:32:06 +00:00
//Проверка урона приемов
2023-09-30 20:17:25 +00:00
private function usersTestAtack ( $id , $uid1 , $uid2 ) : array
2023-08-10 14:51:16 +00:00
{
$r = [];
2024-01-05 22:14:35 +00:00
$block = [ 0 , 0 , 0 , 0 , 0 , 0 ,];
2023-08-10 14:51:16 +00:00
//Проверка блоков
$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 ],
];
}
2024-01-05 22:14:35 +00:00
if ( isset ( $a , $j ) && $this -> atacks [ $id ][ 'out' . $a ] == 0 ) {
2023-08-10 14:51:16 +00:00
while ( $i <= $this -> stats [ $this -> uids [ $uid2 ]][ 'zonb' ]) {
$block [ $j ] = 1 ;
$j ++ ;
if ( $j > 5 || $j < 1 ) {
$j = 1 ;
}
$i ++ ;
}
}
2024-01-05 22:14:35 +00:00
2023-08-10 14:51:16 +00:00
//Проверка ударов
2024-01-05 22:14:35 +00:00
for ( $i = 1 ; $i <= $this -> stats [ $this -> uids [ $uid1 ]][ 'zona' ]; $i ++ ) {
2023-08-10 14:51:16 +00:00
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 {
//Удар прошел
// КУДА БИЛ , ТИП УДАРА
2024-02-09 19:41:54 +00:00
$r [ 'atack' ][] = [ $atack [ $i ], 1 , 0 ];
}
2023-11-02 13:57:39 +00:00
}
}
2024-02-09 19:41:54 +00:00
return $r ;
2023-11-02 13:57:39 +00:00
}
2024-02-09 19:41:54 +00:00
public function priemsRazmen ( array | int $id , array | string $at ) : void
{
if ( $at == 'fast' ) {
$uid1 = $id [ 0 ];
$uid2 = $id [ 1 ];
2023-08-10 14:51:16 +00:00
} else {
2024-02-09 19:41:54 +00:00
$uid1 = $this -> atacks [ $id ][ 'uid1' ];
$uid2 = $this -> atacks [ $id ][ 'uid2' ];
2023-08-10 14:51:16 +00:00
}
2024-02-09 19:41:54 +00:00
$this -> stats [ $this -> uids [ $uid1 ]][ 'u_priem' ] = [];
$this -> stats [ $this -> uids [ $uid2 ]][ 'u_priem' ] = [];
2022-12-19 20:22:19 +00:00
2024-02-09 19:41:54 +00:00
//Получаем приемы и смотрим когда какой действует
2022-12-19 20:22:19 +00:00
2024-02-09 19:41:54 +00:00
$j = 0 ;
foreach ( $this -> stats [ $this -> uids [ $uid1 ]][ 'effects' ] as $effect ) {
if ( $effect [ 'id_eff' ] != 22 || $effect [ 'v1' ] != 'priem' || $effect [ 'v2' ] < 1 ) {
continue ;
2022-12-19 20:22:19 +00:00
}
2024-02-09 19:41:54 +00:00
$this -> stats [ $this -> uids [ $uid1 ]][ 'u_priem' ] = [
$j ,
$effect [ 'v2' ],
$this -> prm [ $effect [ 'v2' ]] -> act ,
$effect [ 'id' ],
$this -> prm [ $effect [ 'v2' ]] -> typeOf ,
$this -> prm [ $effect [ 'v2' ]] -> moment ,
$this -> prm [ $effect [ 'v2' ]] -> momentEnd ,
$this -> prm [ $effect [ 'v2' ]] -> typeSec ,
];
$j ++ ;
2023-08-10 14:51:16 +00:00
}
2022-12-19 20:22:19 +00:00
2024-02-09 19:41:54 +00:00
$j = 0 ;
foreach ( $this -> stats [ $this -> uids [ $uid2 ]][ 'effects' ] as $effect ) {
if ( empty ( $effect ) || $effect [ 'id_eff' ] != 22 || $effect [ 'v1' ] != 'priem' || $effect [ 'v2' ] < 1 ) {
continue ;
}
$this -> stats [ $this -> uids [ $uid2 ]][ 'u_priem' ] = [
$j ,
$effect [ 'v2' ],
$this -> prm [ $effect [ 'v2' ]] -> act ,
$effect [ 'id' ],
$this -> prm [ $effect [ 'v2' ]] -> typeOf ,
2024-01-06 15:30:34 +00:00
$this -> prm [ $effect [ 'v2' ]] -> moment ,
$this -> prm [ $effect [ 'v2' ]] -> momentEnd ,
$this -> prm [ $effect [ 'v2' ]] -> typeSec ,
2024-01-05 22:14:35 +00:00
];
$j ++ ;
2023-08-10 14:51:16 +00:00
}
}
2022-12-19 20:22:19 +00:00
2024-05-10 11:32:06 +00:00
//Наносим удар между игроками
2023-09-30 20:17:25 +00:00
/** Осторожно ! Подключаются файлы !!!
* @ param $id
* @ param $at
2024-01-05 22:14:35 +00:00
* @ return void
2023-09-30 20:17:25 +00:00
*/
2024-01-05 22:14:35 +00:00
private function priemsRazmenMoment ( $id , $at ) : void
2023-08-10 14:51:16 +00:00
{
2022-12-19 20:22:19 +00:00
$uid1 = $this -> atacks [ $id ][ 'uid1' ];
$uid2 = $this -> atacks [ $id ][ 'uid2' ];
$i = 1 ;
while ( $i <= 2 ) {
if ( $i == 1 ) {
$a = 1 ;
$b = 2 ;
2023-11-02 13:57:39 +00:00
$u1 = $uid1 ;
$u2 = $uid2 ;
2022-12-19 20:22:19 +00:00
} else {
$a = 2 ;
$b = 1 ;
2023-11-02 13:57:39 +00:00
$u1 = $uid2 ;
$u2 = $uid1 ;
2022-12-19 20:22:19 +00:00
}
2023-08-10 14:51:16 +00:00
if ( ! isset ( $at [ 'p' ][ 'p_cast' ])) {
$at [ 'p' ] = $at ;
$at [ 'p' ][ 'p_cast' ] = true ;
2022-12-19 20:22:19 +00:00
}
2023-08-10 14:51:16 +00:00
$j = 0 ;
2024-01-05 22:14:35 +00:00
foreach ( $this -> stats [ $this -> uids [ $u1 ]][ 'u_priem' ] as $priem ) {
/** $priem [ 5 ]
* 1 Приемы ухода от удара
* 2 Приемы крита
* 3 Приемы атаки
* 4 Приемы защиты
* 5 Прочие приемы
*/
if (
empty ( $priem [ 2 ]) ||
! in_array ( $priem [ 5 ], [ 1 , 2 , 3 , 4 , 5 ]) ||
2024-02-08 13:35:42 +00:00
! file_exists ( " Priem/ $priem[1] .php " ) ||
2024-01-05 22:14:35 +00:00
$priem [ 5 ] == 1 && empty ( $this -> stats [ $this -> uids [ $u2 ]][ 'nopryh' ])
) {
continue ;
2023-08-10 14:51:16 +00:00
}
2022-12-19 20:22:19 +00:00
2024-01-05 22:14:35 +00:00
$pr_used_this = $u1 ;
$pr_moment = true ;
2024-02-08 13:35:42 +00:00
require_once " Priem/ $priem[1] .php " ;
2024-01-05 22:14:35 +00:00
if ( isset ( $fx_priem )) {
$fx_priem ( $id , $at , $u1 , $j );
unset ( $fx_priem );
2023-08-10 14:51:16 +00:00
}
$j ++ ;
2024-01-05 22:14:35 +00:00
if ( $priem [ 5 ] == 1 ) {
$this -> stats [ $this -> uids [ $u2 ]][ 'nopryh' ] -- ;
2023-08-10 14:51:16 +00:00
}
}
$i ++ ;
}
2024-01-05 22:14:35 +00:00
}
/** Осторожно ! Подключаются файлы !!!
* @ param $id
* @ param $at
* @ return array | mixed
*/
private function priemsTestRazmen ( $id , $at ) : mixed
{
$uid1 = $this -> atacks [ $id ][ 'uid1' ];
$uid2 = $this -> atacks [ $id ][ 'uid2' ];
2022-12-19 20:22:19 +00:00
2023-08-10 14:51:16 +00:00
$i = 1 ;
while ( $i <= 2 ) {
if ( $i == 1 ) {
$a = 1 ;
$b = 2 ;
2023-11-02 13:57:39 +00:00
$u1 = $uid1 ;
$u2 = $uid2 ;
2023-08-10 14:51:16 +00:00
} else {
$a = 2 ;
$b = 1 ;
2023-11-02 13:57:39 +00:00
$u1 = $uid2 ;
$u2 = $uid1 ;
2022-12-19 20:22:19 +00:00
}
2023-08-10 14:51:16 +00:00
if ( ! isset ( $at [ 'p' ][ 'p_cast' ])) {
$at [ 'p' ] = $at ;
$at [ 'p' ][ 'p_cast' ] = true ;
}
2022-12-19 20:22:19 +00:00
2024-01-05 22:14:35 +00:00
/** $priem [ 4 ]
* 1 Приемы ухода от удара
* 2 Приемы крита
* 3 Приемы атаки
* 4 Приемы защиты
* 5 , 8 , 9 Прочие приемы
*/
2022-12-19 20:22:19 +00:00
2023-08-10 14:51:16 +00:00
$j = 0 ;
2024-01-05 22:14:35 +00:00
foreach ( $this -> stats [ $this -> uids [ $u1 ]][ 'u_priem' ] as $priem ) {
if ((
in_array ( $priem [ 1 ], [ 213 , 220 , 237 , 286 , 287 , 288 ]) ||
in_array ( $priem [ 4 ], [ 2 , 3 , 4 , 5 , 8 , 9 ]) && $priem [ 2 ] > 0 ||
$priem [ 4 ] == 1 && $priem [ 2 ] > 0 && empty ( $this -> stats [ $this -> uids [ $u2 ]][ 'nopryh' ])) &&
2024-02-08 13:35:42 +00:00
file_exists ( " Priem/ $priem[1] .php " )
2024-01-05 22:14:35 +00:00
) {
$pr_used_this = $u1 ;
2024-02-08 13:35:42 +00:00
require_once " Priem/ $priem[1] .php " ;
2024-01-05 22:14:35 +00:00
if ( isset ( $fx_priem )) {
2023-08-10 14:51:16 +00:00
$at = $fx_priem ( $id , $at , $u1 , $j );
2023-11-02 13:57:39 +00:00
unset ( $fx_priem );
2023-08-10 14:51:16 +00:00
}
2024-01-05 22:14:35 +00:00
$j ++ ;
if ( $priem [ 4 ] == 1 ) {
$this -> stats [ $this -> uids [ $u2 ]][ 'nopryh' ] -- ;
}
2023-08-10 14:51:16 +00:00
}
}
2024-01-05 22:14:35 +00:00
2023-08-10 14:51:16 +00:00
$i ++ ;
}
2024-01-05 22:14:35 +00:00
2023-08-10 14:51:16 +00:00
return $at ;
}
2022-12-19 20:22:19 +00:00
2023-09-30 20:17:25 +00:00
/** Осторожно ! Подключаются файлы !!!
* @ param $id
* @ param $at
* @ return mixed
*/
2024-01-05 22:14:35 +00:00
private function priemsRestartRazmen ( $id , $at ) : mixed
2023-08-10 14:51:16 +00:00
{
if ( isset ( $at [ 'p' ])) {
//Проверка
$uid1 = $this -> atacks [ $id ][ 'uid1' ];
$uid2 = $this -> atacks [ $id ][ 'uid2' ];
2024-01-05 22:14:35 +00:00
/**
* Если возникнут проблемы с приемами , придется переписать алгоритм , сейчас он выглядит так :
* Цикл 1. Проверяем пользователя
* Цикл 2 внутри Цикла 1. Проверяем приемы поторые пользователь использовал
*
* Придется сделать :
* Цикл 1. Проверяем пользователя
* Цикл 2 внутри Цикла 1. Проверяем приемы уворота
* Цикл 3. Проверяем пользователя
* Цикл 4 внутри Цикла 3. Проверяем приемы крита
* и т . д .
*/
2023-08-10 14:51:16 +00:00
$i = 1 ;
while ( $i <= 2 ) {
if ( $i == 1 ) {
$a = 1 ;
$b = 2 ;
2023-11-02 13:57:39 +00:00
$u1 = $uid1 ;
$u2 = $uid2 ;
2023-08-10 14:51:16 +00:00
} else {
$a = 2 ;
$b = 1 ;
2023-11-02 13:57:39 +00:00
$u1 = $uid2 ;
$u2 = $uid1 ;
2023-08-10 14:51:16 +00:00
}
2022-12-19 20:22:19 +00:00
2023-08-10 14:51:16 +00:00
if ( ! isset ( $at [ 'p' ][ 'p_cast' ])) {
$at [ 'p' ] = $at ;
$at [ 'p' ][ 'p_cast' ] = true ;
}
2024-01-05 22:14:35 +00:00
/** $priem [ 4 ]
* 1 Приемы ухода от удара
* 2 Приемы крита
* 3 Приемы атаки
* 4 Приемы защиты
* 5 , 8 , 9 Прочие приемы
*/
2023-08-10 14:51:16 +00:00
$j = 0 ;
2024-01-05 22:14:35 +00:00
foreach ( $this -> stats [ $this -> uids [ $u1 ]][ 'u_priem' ] as $priem ) {
if ((
in_array ( $priem [ 4 ], [ 2 , 3 , 4 , 5 ]) && $priem [ 2 ] > 0 ||
$priem [ 4 ] == 1 && $priem [ 2 ] > 0 && empty ( $this -> stats [ $this -> uids [ $u2 ]][ 'nopryh' ])) &&
2024-02-08 13:35:42 +00:00
file_exists ( " Priem/ $priem[1] .php " )
2024-01-05 22:14:35 +00:00
) {
$pr_used_this = $u1 ;
2024-02-08 13:35:42 +00:00
require_once " Priem/ $priem[1] .php " ;
2024-01-05 22:14:35 +00:00
if ( isset ( $fx_priem )) {
2023-08-10 14:51:16 +00:00
$at = $fx_priem ( $id , $at , $u1 , $j );
2023-11-02 13:57:39 +00:00
unset ( $fx_priem );
2023-08-10 14:51:16 +00:00
}
2024-01-05 22:14:35 +00:00
$j ++ ;
if ( $priem [ 4 ] == 1 ) {
$this -> stats [ $this -> uids [ $u2 ]][ 'nopryh' ] -- ;
2023-08-10 14:51:16 +00:00
}
}
}
2024-01-05 22:14:35 +00:00
2023-08-10 14:51:16 +00:00
$j = 0 ;
2024-01-05 22:14:35 +00:00
foreach ( $this -> stats [ $this -> uids [ $u2 ]][ 'u_priem' ] as $priem ) {
2024-02-08 13:35:42 +00:00
if ( in_array ( $priem [ 4 ], [ 8 , 9 ]) && $priem [ 2 ] > 0 && file_exists ( " Priem/ $priem[1] .php " )) {
2024-01-05 22:14:35 +00:00
$pr_used_this = $u2 ;
2024-02-08 13:35:42 +00:00
require_once " Priem/ $priem[1] .php " ;
2024-01-05 22:14:35 +00:00
if ( isset ( $fx_priem )) {
2023-08-10 14:51:16 +00:00
$at = $fx_priem ( $id , $at , $u2 , $j );
2023-11-02 13:57:39 +00:00
unset ( $fx_priem );
2023-08-10 14:51:16 +00:00
}
2024-01-05 22:14:35 +00:00
$j ++ ;
2022-12-19 20:22:19 +00:00
}
}
2023-08-10 14:51:16 +00:00
$i ++ ;
2022-12-19 20:22:19 +00:00
}
2024-01-05 22:14:35 +00:00
2023-08-10 14:51:16 +00:00
$at = $at [ 'p' ];
unset ( $at [ 'p' ]);
}
return $at ;
}
public function testPogB ( $uid , $yr , $pliid , $test = 0 )
{
2024-02-10 19:33:10 +00:00
$checktuman = Db :: getValue ( 'select count(id) from eff_users where uid = ? and v2 in (273,286,287,288)' , [ $uid ]) == 0 ; //проверка на туманный образ
if ( $yr <= 0 || ! $checktuman ) {
return $yr ;
}
global $priem ;
2023-08-10 14:51:16 +00:00
$yr2 = $yr ;
2024-02-10 19:33:10 +00:00
$i = 0 ;
while ( $i < count ( $this -> stats [ $this -> uids [ $uid ]][ 'set_pog2' ])) {
$j = $this -> stats [ $this -> uids [ $uid ]][ 'set_pog2' ][ $i ];
if ( $this -> stats [ $this -> uids [ $uid ]][ 'effects' ][ $j [ 'id' ] - 1 ][ 'id' ] != $pliid && $test != 1 ) {
$i ++ ;
continue ;
}
$this -> stats [ $this -> uids [ $uid ]][ 'effects' ][ $j [ 'id' ] - 1 ][ 'data' ] = str_replace (
'add_pog2=' . $j [ 'y' ],
'add_pog2=$' , $this -> stats [ $this -> uids [ $uid ]][ 'effects' ][ $j [ 'id' ] - 1 ][ 'data' ]
);
$dt3 = Conversion :: dataStringToArray ( $this -> stats [ $this -> uids [ $uid ]][ 'effects' ][ $j [ 'id' ] - 1 ][ 'data' ]);
$dt30 = floor ( $j [ 'y' ] / $yr2 * 100 );
if ( $dt30 < $dt3 [ 'add_pog2p' ]) {
$dt3 [ 'add_pog2p' ] = $dt30 ;
}
unset ( $dt30 );
if ( isset ( $dt3 [ 'add_pog2mp' ])) {
if (( round ( round ( $yr2 / 100 * ( 100 - $dt3 [ 'add_pog2p' ])) * $dt3 [ 'add_pog2mp' ])) > $this -> stats [ $this -> uids [ $uid ]][ 'mpNow' ]) {
//не хватило маны, считаем сколько хватит % от поглощенного урона
$j [ 'yhj' ] = $this -> stats [ $this -> uids [ $uid ]][ 'mpNow' ] / ( round ( round ( $yr2 / 100 * ( 100 - $dt3 [ 'add_pog2p' ])) * $dt3 [ 'add_pog2mp' ])) * 100 ;
$j [ 'yhj' ] = floor ( $j [ 'yhj' ]); //Сколько % мы можем поглотить
$dt3 [ 'add_pog2p' ] = floor ( $dt3 [ 'add_pog2p' ] / 100 * $j [ 'yhj' ]);
}
if ( $test == 1 ) {
$priem -> minMana ( $uid , round ( round ( $yr2 / 100 * $dt3 [ 'add_pog2p' ]) * $dt3 [ 'add_pog2mp' ]));
}
}
if ( ! isset ( $this -> poglast [ $uid ])) {
$this -> poglast [ $uid ] = 0 ;
}
$this -> poglast [ $uid ] += $yr2 ;
if ( $test == 1 ) {
// осталось для поглощения
$j [ 'y' ] -= round ( $this -> poglast [ $uid ] / 100 * $dt3 [ 'add_pog2p' ]);
$priem -> minMana ( $uid , round ( round ( $this -> poglast [ $uid ] / 100 * $dt3 [ 'add_pog2p' ]) * $dt3 [ 'add_pog2mp' ]));
}
if ( isset ( $dt3 [ 'add_pog2p' ])) {
$yr2 = round ( $yr2 / 100 * ( 100 - $dt3 [ 'add_pog2p' ]));
}
if ( $j [ 'y' ] < 0 || ( $this -> stats [ $this -> uids [ $uid ]][ 'mpNow' ] <= 0 && $dt3 [ 'add_pog2mp' ] > 0 )) {
$dt2 = Conversion :: dataStringToArray ( $this -> stats [ $this -> uids [ $uid ]][ 'effects' ][ $j [ 'id' ] - 1 ][ 'data' ]);
if ( isset ( $dt2 [ 'endPog' ]) && $dt2 [ 'endPog' ] == 1 ) {
//удаляем прием
//Добавляем в лог
$this -> stats [ $this -> uids [ $uid ]][ 'effects' ][ $j [ 'id' ] - 1 ][ 'priem' ] =
Db :: getRow ( 'select * from priems where id = ?' , [ $this -> stats [ $this -> uids [ $uid ]][ 'effects' ][ $j [ 'id' ] - 1 ][ 'v2' ]]);
$this -> delPriem (
$this -> stats [ $this -> uids [ $uid ]][ 'effects' ][ $j [ 'id' ] - 1 ],
$this -> users [ $this -> uids [ $uid ]], 4 , $uid
2022-12-30 19:03:37 +00:00
);
2024-02-10 19:33:10 +00:00
$this -> stats [ $this -> uids [ $uid ]][ 'effects' ][ $j [ 'id' ] - 1 ] = 'delete' ;
2022-12-19 20:22:19 +00:00
}
2024-02-10 19:33:10 +00:00
unset ( $dt2 );
$j [ 'y' ] = 0 ;
}
$this -> stats [ $this -> uids [ $uid ]][ 'set_pog' ][ $i ][ 'y' ] = $j [ 'y' ];
if ( isset ( $this -> stats [ $this -> uids [ $uid ]][ 'effects' ][ $j [ 'id' ] - 1 ][ 'data' ])) {
$this -> stats [ $this -> uids [ $uid ]][ 'effects' ][ $j [ 'id' ] - 1 ][ 'data' ] = str_replace (
'add_pog2=$' ,
'add_pog2=' . $j [ 'y' ], $this -> stats [ $this -> uids [ $uid ]][ 'effects' ][ $j [ 'id' ] - 1 ][ 'data' ]
);
Db :: sql (
'update eff_users set data = ? where id = ?' ,
[ $this -> stats [ $this -> uids [ $uid ]][ 'effects' ][ $j [ 'id' ] - 1 ][ 'data' ], $this -> stats [ $this -> uids [ $uid ]][ 'effects' ][ $j [ 'id' ] - 1 ][ 'id' ]]
);
2022-12-19 20:22:19 +00:00
}
2024-02-10 19:33:10 +00:00
if ( $j [ 'y' ] - $this -> poglast [ $uid ] + $yr2 < 0 ) {
$yr -= $yr + ( $j [ 'y' ] - $this -> poglast [ $uid ] + $yr2 );
$yr2 = $yr ;
$i = count ( $this -> stats [ $this -> uids [ $uid ]][ 'set_pog2' ]) + 1 ;
}
$i ++ ;
2022-12-19 20:22:19 +00:00
}
2024-02-10 19:33:10 +00:00
2023-08-10 14:51:16 +00:00
return $yr2 ;
2022-12-19 20:22:19 +00:00
}
2024-05-10 11:32:06 +00:00
//Расчет типа удара от оружия
2024-02-09 19:41:54 +00:00
//Расчет урона от оружия
2023-08-14 15:15:05 +00:00
2024-02-09 19:41:54 +00:00
/**
* Обновляем Н Р и добавляем тактики ?
* @ param $id
* @ param $at
* @ return array
*/
2023-09-30 20:17:25 +00:00
private function updateHealth ( $id , $at ) : array
2022-12-19 20:22:19 +00:00
{
2023-11-02 13:57:39 +00:00
$uid1 = $this -> atacks [ $id ][ 'uid1' ];
$uid2 = $this -> atacks [ $id ][ 'uid2' ];
if ( $this -> stats [ $this -> uids [ $this -> atacks [ $id ][ 'uid1' ]]][ 'yhod' ] > 0 ) {
2023-12-17 02:32:09 +00:00
$uid1 = $this -> yhod_user (
$this -> atacks [ $id ][ 'uid2' ], $this -> atacks [ $id ][ 'uid1' ],
$this -> stats [ $this -> uids [ $this -> atacks [ $id ][ 'uid1' ]]][ 'yhod' ]
);
2023-11-02 13:57:39 +00:00
} elseif ( $this -> stats [ $this -> uids [ $this -> atacks [ $id ][ 'uid2' ]]][ 'yhod' ] > 0 ) {
2023-12-17 02:32:09 +00:00
$uid2 = $this -> yhod_user (
$this -> atacks [ $id ][ 'uid1' ], $this -> atacks [ $id ][ 'uid2' ],
$this -> stats [ $this -> uids [ $this -> atacks [ $id ][ 'uid2' ]]][ 'yhod' ]
);
2023-11-02 13:57:39 +00:00
}
2023-08-10 14:51:16 +00:00
$i = 1 ;
while ( $i <= 2 ) {
if ( $i == 1 ) {
$a = 1 ;
$b = 2 ;
2023-11-02 13:57:39 +00:00
$u1 = $uid1 ;
$u2 = $uid2 ;
2023-08-10 14:51:16 +00:00
} else {
$a = 2 ;
$b = 1 ;
2023-11-02 13:57:39 +00:00
$u1 = $uid2 ;
$u2 = $uid1 ;
2023-08-10 14:51:16 +00:00
}
2022-12-19 20:22:19 +00:00
2023-08-10 14:51:16 +00:00
//Рассчет дополнительных тактик
if ( $this -> atacks [ $id ][ 'out' . $b ] > 0 ) {
//Игрок ${'u'.$a} получает тактики, возможно
2024-01-05 22:14:35 +00:00
//выдаем тактику контрудара
if ( rand ( 0 , 100 ) < min ( floor ( $this -> stats [ $this -> uids [ $u1 ]][ 'm6' ] / 5 ), 20 ) && $this -> stats [ $this -> uids [ $u2 ]][ 'this_animal' ] == 0 ) {
$this -> users [ $this -> uids [ $u1 ]][ 'tactic3' ] ++ ;
2023-08-10 14:51:16 +00:00
}
2024-01-05 22:14:35 +00:00
//выдаем тактику щита
if ( rand ( 0 , 100 ) < min ( floor ( $this -> stats [ $this -> uids [ $u1 ]][ 'm8' ] / 4 ), 20 ) && $this -> stats [ $this -> uids [ $u2 ]][ 'this_animal' ] == 0 ) {
$this -> users [ $this -> uids [ $u1 ]][ 'tactic4' ] ++ ;
2023-08-10 14:51:16 +00:00
}
}
2022-12-19 20:22:19 +00:00
2024-01-05 22:14:35 +00:00
if ( ! isset ( $at [ $a ][ 'atack' ])) {
$at [ $a ][ 'atack' ] = []; // Argument #1 ($value) must be of type Countable|array, null given
}
2023-08-10 14:51:16 +00:00
//Расчет удара Цели (u2) по Атакующему (u1)
$j = 0 ;
while ( $j < count ( $at [ $a ][ 'atack' ]) && $j < 8 ) {
//Добавляем тактики
if ( $at [ $a ][ 'atack' ][ $j ][ 1 ] == 1 ) {
//u1 ударил обычным ударом u2
if ( $this -> stats [ $this -> uids [ $u2 ]][ 'this_animal' ] == 0 ) {
$this -> users [ $this -> uids [ $u1 ]][ 'tactic1' ] ++ ;
}
//Двуручка
if ( $at [ $a ][ 'atack' ][ $j ][ 'yron' ][ '2h' ] == 1 && $this -> stats [ $this -> uids [ $u2 ]][ 'this_animal' ] == 0 ) {
$this -> users [ $this -> uids [ $u1 ]][ 'tactic1' ] += 2 ;
}
} elseif ( $at [ $a ][ 'atack' ][ $j ][ 1 ] != 2 ) {
2024-01-05 22:14:35 +00:00
if ( $at [ $a ][ 'atack' ][ $j ][ 1 ] == 3 || $at [ $a ][ 'atack' ][ $j ][ 1 ] == 7 ) {
//u2 заблокировал удар u1 (3) OR u2 блокировал щитом удар u1 //Т У Т ЩИТ (7)
2023-08-10 14:51:16 +00:00
if ( $this -> stats [ $this -> uids [ $u2 ]][ 'this_animal' ] == 0 ) {
$this -> users [ $this -> uids [ $u2 ]][ 'tactic4' ] ++ ;
}
} elseif ( $at [ $a ][ 'atack' ][ $j ][ 1 ] == 4 ) {
//u1 пробил блок u2 критом
2024-01-05 22:14:35 +00:00
if ( ! isset ( $at [ $a ][ 'atack' ][ $j ][ 'notactic2' ]) && $this -> stats [ $this -> uids [ $u2 ]][ 'this_animal' ] == 0 ) {
$this -> users [ $this -> uids [ $u1 ]][ 'tactic2' ] ++ ;
2023-08-10 14:51:16 +00:00
}
$this -> users [ $this -> uids [ $u2 ]][ 'tactic4' ] ++ ; //тактика за пробив блок
} elseif ( $at [ $a ][ 'atack' ][ $j ][ 1 ] == 5 ) {
//u1 ударил критическим ударом u2
if ( ! isset ( $at [ $a ][ 'atack' ][ $j ][ 'notactic2' ])) {
if ( $this -> stats [ $this -> uids [ $u2 ]][ 'this_animal' ] == 0 ) {
$this -> users [ $this -> uids [ $u1 ]][ 'tactic2' ] += 2 ;
}
//Двуручка
if ( $at [ $a ][ 'atack' ][ $j ][ 'yron' ][ '2h' ] == 1 && $this -> stats [ $this -> uids [ $u2 ]][ 'this_animal' ] == 0 ) {
$this -> users [ $this -> uids [ $u1 ]][ 'tactic2' ] += 1 ;
}
}
} elseif ( $at [ $a ][ 'atack' ][ $j ][ 1 ] == 6 ) {
//u2 парировал удар u1
if ( ! isset ( $at [ $a ][ 'atack' ][ $j ][ 'notactic5' ]) && $this -> stats [ $this -> uids [ $u1 ]][ 'this_animal' ] == 0 ) {
$this -> users [ $this -> uids [ $u2 ]][ 'tactic5' ] ++ ;
}
} elseif ( $at [ $a ][ 'atack' ][ $j ][ 1 ] == 8 ) {
//u2 увернулся от удара u1 и нанес по нему контрудар
if ( $this -> stats [ $this -> uids [ $u1 ]][ 'this_animal' ] == 0 ) {
$this -> users [ $this -> uids [ $u2 ]][ 'tactic3' ] ++ ;
}
}
2022-12-19 20:22:19 +00:00
}
2023-08-10 14:51:16 +00:00
// КУДА БИЛ , ТИП УДАРА
if ( isset ( $at [ $a ][ 'atack' ][ $j ][ 'yron' ]) && (
$at [ $a ][ 'atack' ][ $j ][ 1 ] == 1 ||
$at [ $a ][ 'atack' ][ $j ][ 1 ] == 4 ||
$at [ $a ][ 'atack' ][ $j ][ 1 ] == 5 )) {
//
2022-12-30 19:03:37 +00:00
2023-08-10 14:51:16 +00:00
if ( $this -> stats [ $this -> uids [ $u2 ]][ 'hpNow' ] <= $at [ $a ][ 'atack' ][ $j ][ 'yron' ][ 'y' ]) {
$at [ $a ][ 'atack' ][ $j ][ 'yron' ][ 'y' ] = $this -> stats [ $this -> uids [ $u2 ]][ 'hpNow' ];
}
if ( $this -> stats [ $this -> uids [ $u2 ]][ 'hpNow' ] <= $at [ $a ][ 'atack' ][ $j ][ 'yron' ][ 'k' ]) {
$at [ $a ][ 'atack' ][ $j ][ 'yron' ][ 'k' ] = $this -> stats [ $this -> uids [ $u2 ]][ 'hpNow' ];
}
2022-12-30 19:03:37 +00:00
2023-08-10 14:51:16 +00:00
if ( $at [ $a ][ 'atack' ][ $j ][ 'yron' ][ 'y' ] < 0 ) {
$at [ $a ][ 'atack' ][ $j ][ 'yron' ][ 'y' ] = 1 ;
$at [ $a ][ 'atack' ][ $j ][ 'yron' ][ 'r' ] = - 1 ;
$at [ $a ][ 'atack' ][ $j ][ 'yron' ][ 'k' ] = 1 ;
}
if ( $this -> stats [ $this -> uids [ $u2 ]][ 'hpNow' ] < 1 ) {
$at [ $a ][ 'atack' ][ $j ][ 'yron' ][ 'y' ] = 0 ;
$at [ $a ][ 'atack' ][ $j ][ 'yron' ][ 'r' ] = - 1 ;
$at [ $a ][ 'atack' ][ $j ][ 'yron' ][ 'k' ] = 0 ;
}
//Добавляем нанесенный урон и опыт
$this -> takeExp ( $u1 , $at [ $a ][ 'atack' ][ $j ][ 'yron' ][ 'y' ], $u1 , $u2 );
//Отнимаем Н Р
$this -> stats [ $this -> uids [ $u2 ]][ 'hpNow' ] -= $at [ $a ][ 'atack' ][ $j ][ 'yron' ][ 'y' ];
$this -> users [ $this -> uids [ $u2 ]][ 'last_hp' ] = - $at [ $a ][ 'atack' ][ $j ][ 'yron' ][ 'y' ];
$at [ $a ][ 'atack' ][ $j ][ 'yron' ][ 'hp' ] = $this -> stats [ $this -> uids [ $u2 ]][ 'hpNow' ];
if ( $at [ $a ][ 'atack' ][ $j ][ 'yron' ][ 'hp' ] < 1 ) {
$at [ $a ][ 'atack' ][ $j ][ 'yron' ][ 'hp' ] = 0 ;
}
$at [ $a ][ 'atack' ][ $j ][ 'yron' ][ 'hpAll' ] = $this -> stats [ $this -> uids [ $u2 ]][ 'hpAll' ];
if ( $at [ $a ][ 'atack' ][ $j ][ 'yron' ][ 'hp' ] > $at [ $a ][ 'atack' ][ $j ][ 'yron' ][ 'hpAll' ]) {
$at [ $a ][ 'atack' ][ $j ][ 'yron' ][ 'hp' ] = $at [ $a ][ 'atack' ][ $j ][ 'yron' ][ 'hpAll' ];
}
2024-02-10 19:33:10 +00:00
2023-08-10 14:51:16 +00:00
//Травмирование
2024-02-10 19:33:10 +00:00
if (
rand ( 0 , 100 ) <= 50 &&
( $at [ $a ][ 'atack' ][ $j ][ 1 ] == 4 || $at [ $a ][ 'atack' ][ $j ][ 1 ] == 5 ) &&
! isset ( $at [ $a ][ 'atack' ][ $j ][ 'yron' ][ 'travma' ]) &&
$this -> users [ $this -> uids [ $u2 ]][ 'level' ] > 1 &&
$this -> stats [ $this -> uids [ $u1 ]] > 1
) {
2024-01-05 22:14:35 +00:00
$trvm_chns = floor ( rand ( 0 , 200 ) / 10 );
if ( $trvm_chns > 3 || $trvm_chns < 1 ) {
$trvm_chns = 0 ;
2023-08-10 14:51:16 +00:00
}
2024-01-05 22:14:35 +00:00
$at [ $a ][ 'atack' ][ $j ][ 'yron' ][ 'travma' ] = [ $trvm_chns , 'Обыкновенная травма' ];
unset ( $trvm_chns );
2023-08-10 14:51:16 +00:00
}
2022-12-19 20:22:19 +00:00
}
2023-08-10 14:51:16 +00:00
$j ++ ;
2022-12-19 20:22:19 +00:00
}
2023-08-10 14:51:16 +00:00
$i ++ ;
2022-12-19 20:22:19 +00:00
}
2023-08-10 14:51:16 +00:00
return $at ;
2022-12-19 20:22:19 +00:00
}
2024-05-10 11:32:06 +00:00
//Расчет урона от оружия
2024-01-05 22:14:35 +00:00
2024-02-09 19:41:54 +00:00
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 ;
}
2023-11-02 13:57:39 +00:00
}
2024-02-09 19:41:54 +00:00
if ( ! empty ( $rand_user )) {
$r = $rand_user [ rand ( 0 , ( count ( $rand_user ) - 1 ))];
2023-11-02 13:57:39 +00:00
}
2024-02-09 19:41:54 +00:00
$this -> importUser = $r ;
2023-11-02 13:57:39 +00:00
} else {
2024-02-09 19:41:54 +00:00
$r = $this -> importUser ;
2023-11-02 13:57:39 +00:00
}
2024-02-09 19:41:54 +00:00
return $r ;
2023-11-02 13:57:39 +00:00
}
2024-05-10 11:32:06 +00:00
//Расчет защиты
2023-08-14 15:15:05 +00:00
2023-08-10 14:51:16 +00:00
/**
* Добавляем опыт \ нанесенный урон .
* Кривовсрато , на переделку .
2023-12-19 01:58:37 +00:00
* @ param $id
* @ param $y
* @ param $id1
* @ param $id2
* @ param bool $mgregen
* @ param bool $nobattle_uron
2023-08-10 14:51:16 +00:00
* @ return void
*/
2023-12-19 01:58:37 +00:00
public function takeExp ( $id , $y , $id1 , $id2 , bool $mgregen = false , bool $nobattle_uron = false ) : void
2022-12-19 20:22:19 +00:00
{
2023-08-10 14:51:16 +00:00
global $u ;
if ( isset ( $this -> users [ $this -> uids [ $id ]])) {
$s2 = $this -> stats [ $this -> uids [ $id2 ]];
if ( $id1 != $id2 ) {
$e = $this -> testExp ( $y , $s2 );
} else {
$e = 0 ;
2022-12-19 20:22:19 +00:00
}
2024-01-06 15:30:34 +00:00
if (( int ) $this -> users [ $this -> uids [ $id1 ]][ 'bot_id' ] == 0 && $this -> users [ $this -> uids [ $id1 ]][ 'dnow' ] != 0 && $this -> i -> dungeon != 1 ) {
2023-08-10 14:51:16 +00:00
$dun_limitForLevel = [ // Максимум для каждого уровня.
4 => 750 ,
5 => 1500 ,
6 => 3500 ,
7 => 8000 ,
8 => 25000 ,
9 => 50000 ,
10 => 75000 ,
11 => 125000 ,
12 => 250000 ,
13 => 500000 ,
14 => 750000 ,
];
$dun_expFactor = [ // Максимум для каждого уровня.
4 => 5 ,
5 => 5 ,
6 => 5 ,
7 => 5 ,
8 => 5 ,
9 => 3 ,
10 => 1 ,
11 => 1 ,
12 => 1 ,
13 => 1 ,
14 => 1 ,
];
if ( isset ( $dun_expFactor [( int ) $this -> users [ $this -> uids [ $id1 ]][ 'level' ]])) {
$e = $e * $dun_expFactor [( int ) $this -> users [ $this -> uids [ $id1 ]][ 'level' ]];
}
2024-01-06 15:30:34 +00:00
if ( $this -> i -> dungeon > 1 && $this -> users [ $this -> uids [ $id1 ]][ 'battle' ] > 0 ) { // пещерный лимит
2023-08-10 14:51:16 +00:00
$dun_exp = []; // Текущий лимит опыта игрока в подземельях.
$rep = Db :: getValue (
'select dungeonexp from rep where id = ?' , [ $this -> users [ $this -> uids [ $id1 ]][ 'id' ]]
);
$rep = explode ( ',' , $rep );
2024-01-05 22:14:35 +00:00
foreach ( $rep as $val ) {
2023-08-10 14:51:16 +00:00
$val = explode ( '=' , $val );
if ( isset ( $val [ 0 ]) && isset ( $val [ 1 ]) && $val [ 0 ] != '' && $val [ 1 ] != 0 ) {
$dun_exp [( int ) $val [ 0 ]] = ( int ) $val [ 1 ];
} // текущий лимит опыта в подземке
}
unset ( $rep );
2022-12-19 20:22:19 +00:00
2024-01-06 15:30:34 +00:00
if ( ! isset ( $dun_exp [ $this -> i -> dungeon ])) {
$dun_exp [ $this -> i -> dungeon ] = 0 ;
2022-12-30 19:03:37 +00:00
}
2023-08-10 14:51:16 +00:00
if ( ! isset ( $dun_limitForLevel [( int ) $this -> users [ $this -> uids [ $id1 ]][ 'level' ]])) { // Если лимит не задан, опыт не даем.
$e = 0 ;
} elseif (
2024-01-06 15:30:34 +00:00
isset ( $dun_exp [ $this -> i -> dungeon ]) &&
$dun_exp [ $this -> i -> dungeon ] >= $dun_limitForLevel [( int ) $this -> users [ $this -> uids [ $id1 ]][ 'level' ]]
2023-08-10 14:51:16 +00:00
) { // Если лимит уже достигнут, опыт не даем.
$e = 0 ;
} elseif (
2024-01-06 15:30:34 +00:00
isset ( $dun_exp [ $this -> i -> dungeon ]) &&
$dun_limitForLevel [( int ) $this -> users [ $this -> uids [ $id1 ]][ 'level' ]] > $dun_exp [ $this -> i -> dungeon ]
2023-08-10 14:51:16 +00:00
) { // Если текущая репутация не достигла лимита.
2024-01-06 15:30:34 +00:00
if (( $dun_exp [ $this -> i -> dungeon ] + $e ) > $dun_limitForLevel [( int ) $this -> users [ $this -> uids [ $id1 ]][ 'level' ]]) {
2023-08-10 14:51:16 +00:00
// Если опыта набрано достаточно, для достижения лимита.
$e = abs (
$e - abs (
2024-01-06 15:30:34 +00:00
$dun_limitForLevel [( int ) $this -> users [ $this -> uids [ $id1 ]][ 'level' ]] - ( $e + $dun_exp [ $this -> i -> dungeon ])
2023-08-10 14:51:16 +00:00
)
);
2024-01-06 15:30:34 +00:00
$dun_exp [ $this -> i -> dungeon ] += $e ;
} elseif ( $dun_limitForLevel [( int ) $this -> users [ $this -> uids [ $id1 ]][ 'level' ]] > ( $dun_exp [ $this -> i -> dungeon ] + $e )) {
2023-08-10 14:51:16 +00:00
// Если опыта недостаточно, для достижения лимита.
2024-01-06 15:30:34 +00:00
$dun_exp [ $this -> i -> dungeon ] += $e ;
2023-08-10 14:51:16 +00:00
} else {
$e = 0 ;
}
} else { // В любой непонятной ситуцаии.
$e = 0 ;
2022-12-30 19:03:37 +00:00
}
2023-08-10 14:51:16 +00:00
}
// Опыт в пещерах.
2024-01-06 15:30:34 +00:00
if ( $this -> i -> dungeon == 102 ) {
2023-08-10 14:51:16 +00:00
$e = floor ( $e * 0.002 );
2022-12-19 20:22:19 +00:00
}
}
2024-01-05 22:14:35 +00:00
2023-08-10 14:51:16 +00:00
$this -> users [ $this -> uids [ $id1 ]][ 'battle_exp' ] += floor ( $e );
if ( ! $mgregen && ! $nobattle_uron ) {
$this -> users [ $this -> uids [ $id1 ]][ 'battle_yron' ] += floor ( $y );
if ( $this -> stats [ $this -> uids [ $id1 ]][ 'notactic' ] != 1 ) {
if ( $s2 [ 'hpAll' ] <= 1000 ) {
if ( $this -> stats [ $this -> uids [ $id2 ]][ 'this_animal' ] == 0 ) {
2023-12-19 01:58:37 +00:00
$this -> users [ $this -> uids [ $id1 ]][ 'tactic6' ] +=
round ( 0.1 * ( floor ( $y ) / $s2 [ 'hpAll' ] * 100 ), 10 );
2023-08-10 14:51:16 +00:00
} else {
2023-12-19 01:58:37 +00:00
$this -> users [ $this -> uids [ $id1 ]][ 'tactic6' ] +=
round ( 0.1 * ( floor ( $y ) / $s2 [ 'hpAll' ] * 100 ), 10 ) / 3 ;
2023-08-10 14:51:16 +00:00
}
} else {
if ( $this -> stats [ $this -> uids [ $id2 ]][ 'this_animal' ] == 0 ) {
2023-12-19 01:58:37 +00:00
$this -> users [ $this -> uids [ $id1 ]][ 'tactic6' ] +=
round ( 0.1 * ( floor ( $y ) / 1000 * 100 ), 10 );
2023-08-10 14:51:16 +00:00
} else {
2023-12-19 01:58:37 +00:00
$this -> users [ $this -> uids [ $id1 ]][ 'tactic6' ] +=
round ( 0.1 * ( floor ( $y ) / 1000 * 100 ), 10 ) / 3 ;
2023-08-10 14:51:16 +00:00
}
}
}
}
Db :: sql (
2023-12-19 01:58:37 +00:00
'update stats set last_hp = ?, tactic6 = ?, battle_yron = ?, battle_exp = ? where id = ?' ,
[
$this -> users [ $this -> uids [ $id1 ]][ 'last_hp' ],
$this -> users [ $this -> uids [ $id1 ]][ 'tactic6' ],
$this -> users [ $this -> uids [ $id1 ]][ 'battle_yron' ],
$this -> users [ $this -> uids [ $id1 ]][ 'battle_exp' ],
( int ) $id1 ,
]
2023-08-10 14:51:16 +00:00
);
$this -> stats [ $this -> uids [ $id1 ]][ 'battle_exp' ] = $this -> users [ $this -> uids [ $id1 ]][ 'battle_exp' ];
2023-11-02 13:57:39 +00:00
$this -> clearCache ( $id1 );
2023-08-10 14:51:16 +00:00
$this -> stats [ $this -> uids [ $id1 ]][ 'tactic6' ] = $this -> users [ $this -> uids [ $id1 ]][ 'tactic6' ];
if ( $id1 == $u -> info [ 'id' ]) {
$u -> info [ 'tactic6' ] = $this -> users [ $this -> uids [ $id1 ]][ 'tactic6' ];
$u -> stats [ 'tactic6' ] = $this -> users [ $this -> uids [ $id1 ]][ 'tactic6' ];
$u -> info [ 'battle_exp' ] = $this -> users [ $this -> uids [ $id1 ]][ 'battle_exp' ];
$u -> info [ 'battle_yron' ] = $this -> users [ $this -> uids [ $id1 ]][ 'battle_yron' ];
$u -> info [ 'notactic' ] = $this -> users [ $this -> uids [ $id1 ]][ 'notactic' ];
$u -> stats [ 'notactic' ] = $this -> users [ $this -> uids [ $id1 ]][ 'notactic' ];
}
2022-12-19 20:22:19 +00:00
}
}
2024-05-10 11:32:06 +00:00
//Расчет защиты (магия)
2023-11-02 13:57:39 +00:00
private function clearCache ( $uid ) : void
2023-08-10 14:51:16 +00:00
{
2023-12-19 01:58:37 +00:00
if ( $uid <= 0 || isset ( $this -> uclearc [ $uid ])) {
return ;
2022-12-19 20:22:19 +00:00
}
2023-12-19 01:58:37 +00:00
$this -> uclearc [ $uid ] = true ;
$this -> ucleari [] = $uid ;
2022-12-19 20:22:19 +00:00
}
2024-02-09 17:49:51 +00:00
/**
2024-02-09 17:54:55 +00:00
* Сборная солянка .
*
2024-02-09 17:49:51 +00:00
* Отправка в лог боя результата размена .
2024-02-09 17:54:55 +00:00
* Запись статистики .
* Запись рейтинга .
* Выдача травм .
* Обновление информацими по Н Р игроков .
2024-02-09 17:49:51 +00:00
* @ param $id
* @ param $at
* @ return void
*/
2024-01-05 22:14:35 +00:00
private function addlogRazmen ( $id , $at ) : void
2022-12-19 20:22:19 +00:00
{
2023-08-10 14:51:16 +00:00
$dies = [
1 => 0 ,
2 => 0 ,
];
//массив для статистики
$stat = [
1 => [
'uid1' => 0 ,
'uid2' => 0 ,
'time' => time (),
'type' => 0 ,
'a' => '00000' ,
'b' => '0' ,
'type_a' => '' ,
'type_b' => '0' ,
'yrn' => 0 ,
'yrn_krit' => 0 ,
'ma' => 0 ,
'mb' => 0 ,
'tm1' => 0 ,
'tm2' => 0 ,
],
2 => [
'uid1' => 0 ,
'uid2' => 0 ,
'time' => time (),
'type' => 0 ,
'a' => '00000' ,
'b' => '0' ,
'type_a' => '' ,
'type_b' => '0' ,
'yrn' => 0 ,
'yrn_krit' => 0 ,
'ma' => 0 ,
'mb' => 0 ,
'tm1' => 0 ,
'tm2' => 0 ,
],
];
2022-12-19 20:22:19 +00:00
2023-11-02 13:57:39 +00:00
$uid1 = $this -> atacks [ $id ][ 'uid1' ];
$uid2 = $this -> atacks [ $id ][ 'uid2' ];
2022-12-19 20:22:19 +00:00
2023-08-10 14:51:16 +00:00
$i = 1 ;
while ( $i <= 2 ) {
if ( $i == 1 ) {
$a = 1 ;
$b = 2 ;
2023-11-02 13:57:39 +00:00
$u1 = $uid1 ;
$u2 = $uid2 ;
2023-08-10 14:51:16 +00:00
} else {
$a = 2 ;
$b = 1 ;
2023-11-02 13:57:39 +00:00
$u1 = $uid2 ;
$u2 = $uid1 ;
2022-12-19 20:22:19 +00:00
}
2023-08-10 14:51:16 +00:00
if ( $this -> stats [ $this -> uids [ $u1 ]][ 'yhod' ] <= 0 && $this -> stats [ $this -> uids [ $u2 ]][ 'yhod' ] > 0 ) {
$u2 = $this -> yhod_user ( $u1 , $u2 , $this -> stats [ $this -> uids [ $u2 ]][ 'yhod' ]);
}
2022-12-19 20:22:19 +00:00
2023-08-10 14:51:16 +00:00
$s1 = $this -> users [ $this -> uids [ $u1 ]][ 'sex' ];
$s2 = $this -> users [ $this -> uids [ $u2 ]][ 'sex' ];
2022-12-19 20:22:19 +00:00
2023-08-10 14:51:16 +00:00
$stat [ $a ][ 'uid1' ] = $u1 ;
$stat [ $a ][ 'uid2' ] = $u2 ;
$stat [ $a ][ 'ma' ] = $this -> stats [ $this -> uids [ $u1 ]][ 'zona' ];
$stat [ $a ][ 'mb' ] = $this -> stats [ $this -> uids [ $u1 ]][ 'zonb' ];
$stat [ $a ][ 'tm1' ] = $this -> users [ $this -> uids [ $u1 ]][ 'team' ];
$stat [ $a ][ 'tm2' ] = $this -> users [ $this -> uids [ $u2 ]][ 'team' ];
$stat [ $a ][ 'a' ] = $this -> atacks [ $id ][ 'a' . $a ];
$stat [ $a ][ 'b' ] = $this -> atacks [ $id ][ 'b' . $a ];
2022-12-19 20:22:19 +00:00
2024-01-05 22:14:35 +00:00
$vLog =
'at1=00000||at2=00000||zb1=' .
$this -> stats [ $this -> uids [ $u1 ]][ 'zonb' ] .
'||zb2=' . $this -> stats [ $this -> uids [ $u2 ]][ 'zonb' ] .
'||bl1=' . $this -> atacks [ $id ][ 'b' . $a ] .
'||bl2=' . $this -> atacks [ $id ][ 'b' . $b ] .
'||time1=' . $this -> atacks [ $id ][ 'time' ] .
'||time2=' . $this -> atacks [ $id ][ 'time2' ] .
'||s' . $a . '=' . $s1 .
'||s' . $b . '=' . $s2 .
'||t2=' . $this -> users [ $this -> uids [ $u2 ]][ 'team' ] .
'||t1=' . $this -> users [ $this -> uids [ $u1 ]][ 'team' ] .
'||login1=' . $this -> users [ $this -> uids [ $u1 ]][ 'login2' ] .
'||login2=' . $this -> users [ $this -> uids [ $u2 ]][ 'login2' ];
2022-12-19 20:22:19 +00:00
2023-08-10 14:51:16 +00:00
$mas = [
'text' => '' ,
'time' => time (),
2024-01-06 15:30:34 +00:00
'battle' => $this -> i -> id ,
2023-08-10 14:51:16 +00:00
'id_hod' => $this -> hodID ,
'vars' => $vLog ,
'type' => 1 ,
];
2022-12-19 20:22:19 +00:00
2023-08-10 14:51:16 +00:00
if ( ! isset ( $at [ $a ][ 'atack' ])) { //Т У Т тест пропуска
if ( $this -> atacks [ $id ][ 'tpo' . $a ] == 2 ) {
$mas [ 'text' ] .= '{u1} потратил свой ход на магию.' ;
} else {
2024-01-06 15:30:34 +00:00
if ( $this -> i -> razdel == 0 && $this -> i -> dnId == 0 && $this -> i -> izlom == 0 ) {
2024-02-09 17:49:51 +00:00
Db :: sql ( 'insert into battle_out (time, battle, uid1, uid2, `out`) values (unix_timestamp(),?,?,?,1)' , [ $this -> i -> id , $u1 , $u2 ]);
2023-08-10 14:51:16 +00:00
}
2023-09-30 20:17:25 +00:00
2024-02-09 17:49:51 +00:00
$mas [ 'text' ] .= '{u1} пропустил свой ход.' ;
//Cб р о с туманок
Db :: sql ( " delete from eff_users where uid = ? and v1 = 'priem' and v2 in (273,286,287,288) limit 1 " , [ $u1 ]);
2023-08-10 14:51:16 +00:00
}
$mas [ 'text' ] = '{tm1} ' . $mas [ 'text' ];
2024-02-09 17:28:32 +00:00
Log :: add ( $mas );
2023-08-10 14:51:16 +00:00
} else {
$j = 0 ;
2024-01-05 22:14:35 +00:00
2023-08-10 14:51:16 +00:00
while ( $j < count ( $at [ $a ][ 'atack' ]) && $j < 8 ) {
$mas [ 'text' ] = '' ;
$wt = [
21 => 4 ,
22 => 5 ,
20 => 2 ,
28 => 2 ,
19 => 3 ,
18 => 1 ,
26 => 22 ,
];
2024-01-05 22:14:35 +00:00
[ $attackItem , $attackZone ] = Log :: getAttackTurnText ( $at [ $a ][ 'atack' ][ $j ][ 0 ], $wt [ $at [ $a ][ 'atack' ][ $j ][ 'wt' ]]);
$zone = " { zn2_ { $at [ $a ][ 'atack' ][ $j ][ 0 ] } } " ;
2023-09-30 20:17:25 +00:00
2023-08-10 14:51:16 +00:00
$this -> atacks [ $id ][ 'uid_' . $u1 . '_t' . $at [ $a ][ 'atack' ][ $j ][ 1 ]] ++ ;
2024-01-05 22:14:35 +00:00
//2-3 -> 1-2
2023-09-30 20:17:25 +00:00
2024-01-05 22:14:35 +00:00
if ( $at [ $a ][ 'atack' ][ $j ][ 1 ] == 1 || $at [ $a ][ 'atack' ][ $j ][ 1 ] == 5 ) {
//u1 ударил обычным ударом u2 (1) OR u1 ударил критическим ударом u2 (5)
$mas [ 'text' ] .= $zone .
'{u2} ' . $this -> addlt ( $b , 1 , $s2 ) . $this -> addlt ( $b , 2 , $s2 ) . $this -> addlt ( $a , 3 , $s1 ) .
2023-09-30 20:17:25 +00:00
' {u1} ' . $this -> addlt ( $a , 4 , $s1 ) . $this -> addlt ( $a , 5 , $s1 ) . $this -> addlt ( $a , 6 , $s1 ) .
2024-01-05 22:14:35 +00:00
' ' . $this -> addlt ( 1 , 7 , $s1 , $at [ $a ][ 'atack' ][ $j ][ 'yron' ][ 't' ]) . ' ' . $attackItem . ' ' . $attackZone . '. ' ;
2023-08-10 14:51:16 +00:00
} elseif ( $at [ $a ][ 'atack' ][ $j ][ 1 ] == 2 ) {
//u2 увернулся от u1
2024-01-05 22:14:35 +00:00
$mas [ 'text' ] .= $zone . '{u1} ' . $this -> addlt ( $a , 8 , $s1 ) . $this -> addlt ( $a , 9 , $s1 ) .
' {u2} <strong style="color:#0071a3;">' . $this -> addlt ( $b , 11 , $s2 ) . '</strong> ' . $attackItem . ' ' . $attackZone . '. ' ;
2023-08-10 14:51:16 +00:00
} elseif ( $at [ $a ][ 'atack' ][ $j ][ 1 ] == 3 ) {
//u2 заблокировал удар u1
2024-01-05 22:14:35 +00:00
$mas [ 'text' ] .= $zone . '{u1} ' . $this -> addlt ( $a , 8 , $s1 ) . $this -> addlt ( $a , 9 , $s1 ) .
2023-09-30 20:17:25 +00:00
' {u2} <strong style="color:#356d37;">' . $this -> addlt ( $b , 10 , $s2 ) . '</strong> ' . $this -> addlt ( 1 , 7 , 0 , $s1 ) .
2024-01-05 22:14:35 +00:00
' ' . $attackItem . ' ' . $attackZone . '. ' ;
2023-08-10 14:51:16 +00:00
} elseif ( $at [ $a ][ 'atack' ][ $j ][ 1 ] == 4 ) {
//u1 пробил блок u2 критом
if ( isset ( $at [ $a ][ 'atack' ][ $j ][ 'yron' ][ 't' ])) {
2024-01-05 22:14:35 +00:00
$mas [ 'text' ] .= $zone . '{u2} ' . $this -> addlt ( $b , 1 , $s2 ) . $this -> addlt ( $b , 2 , $s2 ) . $this -> addlt ( $a , 3 , $s1 ) .
2023-09-30 20:17:25 +00:00
' {u1} ' . $this -> addlt ( $a , 4 , $s1 ) . $this -> addlt ( $a , 5 , $s1 ) . ', <u style="color:red;">пробив блок</u>, ' . $this -> addlt ( $a , 6 , $s1 ) .
2024-01-05 22:14:35 +00:00
' ' . $this -> addlt ( 1 , 7 , $s1 , $at [ $a ][ 'atack' ][ $j ][ 'yron' ][ 't' ]) . ' ' . $attackItem . ' ' . $attackZone . '. ' ;
2023-08-10 14:51:16 +00:00
}
} elseif ( $at [ $a ][ 'atack' ][ $j ][ 1 ] == 6 ) {
//u2 парировал удар u1
2024-01-05 22:14:35 +00:00
$mas [ 'text' ] .= $zone . '{u1} ' . $this -> addlt ( $a , 8 , $s1 ) . $this -> addlt ( $a , 9 , $s1 ) .
' {u2} неожиданно <strong style="color:#c59400;">парировал</strong> ' . $this -> addlt ( 1 , 7 , 0 , $s1 ) . ' ' . $attackItem . ' ' . $attackZone . '. ' ;
2023-08-10 14:51:16 +00:00
} elseif ( $at [ $a ][ 'atack' ][ $j ][ 1 ] == 7 ) {
//u2 блокировал щитом удар u1
2024-01-05 22:14:35 +00:00
$mas [ 'text' ] .= $zone . '{u1} ' . $this -> addlt ( $a , 8 , $s1 ) . $this -> addlt ( $a , 9 , $s1 ) .
2023-09-30 20:17:25 +00:00
' {u2}, воспользовавшись <u style="color:#356d37;">своим щитом</u>, ' . $this -> addlt ( $b , 10 , $s2 ) . ' ' . $this -> addlt ( 1 , 7 , 0 , $s1 ) .
2024-01-05 22:14:35 +00:00
' ' . $attackItem . ' ' . $attackZone . '. ' ;
2023-08-10 14:51:16 +00:00
} elseif ( $at [ $a ][ 'atack' ][ $j ][ 1 ] == 8 ) {
//u2 увернулся от удара u1 и нанес по нему контрудар
2024-01-05 22:14:35 +00:00
$mas [ 'text' ] .= $zone . '{u1} ' . $this -> addlt ( $a , 8 , $s1 ) . $this -> addlt ( $a , 9 , $s1 ) .
' {u2} <strong style="color:#0071a3;">' . $this -> addlt ( $b , 11 , $s2 ) . '</strong> ' . $attackItem . ' ' . $attackZone . ' и нанес контрудар. ' ;
2023-08-10 14:51:16 +00:00
}
2022-12-19 20:22:19 +00:00
2023-09-30 20:17:25 +00:00
$stat [ $a ][ 'type_a' ] .= '' . $at [ $a ][ 'atack' ][ $j ][ 1 ];
2023-08-10 14:51:16 +00:00
if (( ! isset ( $this -> stats [ $this -> uids [ $u2 ]][ 'notravma' ]) || $this -> stats [ $this -> uids [ $u2 ]][ 'notravma' ] == 0 ) && isset ( $at [ $a ][ 'atack' ][ $j ][ 'yron' ][ 'travma' ]) && $at [ $a ][ 'atack' ][ $j ][ 'yron' ][ 'travma' ][ 0 ] > 0 && floor (
$at [ $a ][ 'atack' ][ $j ][ 'yron' ][ 'hp' ]
) <= 0 ) {
2024-02-09 17:49:51 +00:00
$tr_pl = Db :: getRow ( 'select id, v1 from eff_users where id_eff = 4 and uid = ? order by v1 desc limit 1' , [ $u2 ]);
if ( ! isset ( $tr_pl [ 'id' ]) || ( int ) $tr_pl [ 'v1' ] < 3 ) {
2023-08-10 14:51:16 +00:00
//263
if ( isset ( $tr_pl [ 'id' ])) {
2024-02-09 17:49:51 +00:00
$at [ $a ][ 'atack' ][ $j ][ 'yron' ][ 'travma' ][ 0 ] = rand ((( int ) $tr_pl [ 'v1' ] + 1 ), 3 );
2023-08-10 14:51:16 +00:00
}
2024-02-09 17:49:51 +00:00
$hasInjuryImmunity = Db :: getValue ( " select count(id) from eff_users where uid = ? and name like '%Защита от травм%' " ) > 0 ;
if ( ! $hasInjuryImmunity && $at [ $a ][ 'atack' ][ $j ][ 'yron' ][ 'travma' ][ 0 ] <= 3 ) {
2023-08-10 14:51:16 +00:00
$mas [ 'text' ] = rtrim ( $mas [ 'text' ], '. ' );
2024-01-05 22:14:35 +00:00
$mas [ 'text' ] .= ', <span style="color: red;">нанеся противнику <strong>' ;
2023-08-10 14:51:16 +00:00
if ( $at [ $a ][ 'atack' ][ $j ][ 'yron' ][ 'travma' ][ 0 ] == 1 ) {
$mas [ 'text' ] .= 'Легкую' ;
2024-01-06 15:30:34 +00:00
Effects :: addInjury ( $u2 , 1 , rand ( 3 , 5 ));
2023-08-10 14:51:16 +00:00
} elseif ( $at [ $a ][ 'atack' ][ $j ][ 'yron' ][ 'travma' ][ 0 ] == 2 ) {
$mas [ 'text' ] .= 'Среднюю' ;
2024-01-06 15:30:34 +00:00
Effects :: addInjury ( $u2 , 2 , rand ( 3 , 5 ));
2023-08-10 14:51:16 +00:00
} elseif ( $at [ $a ][ 'atack' ][ $j ][ 'yron' ][ 'travma' ][ 0 ] == 3 ) {
$mas [ 'text' ] .= 'Тяжелую' ;
2024-01-06 15:30:34 +00:00
Effects :: addInjury ( $u2 , 3 , rand ( 3 , 5 ));
2023-08-10 14:51:16 +00:00
}
2024-01-05 22:14:35 +00:00
$mas [ 'text' ] .= ' травму</strong></span>. ' ;
2023-08-10 14:51:16 +00:00
}
}
unset ( $tr_pl );
}
if ( $at [ $a ][ 'atack' ][ $j ][ 'yron' ][ 'pb' ] == 1 && isset ( $at [ $a ][ 'atack' ][ $j ][ 'yron' ][ 'hp' ])) {
$mas [ 'text' ] = rtrim ( $mas [ 'text' ], '. ' );
$mas [ 'text' ] .= ' <i>пробив броню</i>. ' ;
}
if ( $at [ $a ][ 'atack' ][ $j ][ 3 ] == 1 ) {
$mas [ 'text' ] .= '(контрудар) ' ;
}
if ( isset ( $at [ $a ][ 'atack' ][ $j ][ 'yron' ])) {
if ( $at [ $a ][ 'atack' ][ $j ][ 'yron' ][ 'w' ] == 3 ) {
$mas [ 'textWP' ] = '(правая рука)' ;
} elseif ( $at [ $a ][ 'atack' ][ $j ][ 'yron' ][ 'w' ] == 14 ) {
$mas [ 'textWP' ] = '(левая рука)' ;
} else {
$mas [ 'textWP' ] = '(непонятно чем)' ;
}
2024-01-05 22:14:35 +00:00
if (( $at [ $a ][ 'atack' ][ $j ][ 1 ] == 4 || $at [ $a ][ 'atack' ][ $j ][ 1 ] == 5 || $at [ $a ][ 'atack' ][ $j ][ 1 ] == 1 ) && $at [ $a ][ 'atack' ][ $j ][ 'yron' ][ 'y' ] < 1 ) {
$at [ $a ][ 'atack' ][ $j ][ 'yron' ][ 'r' ] = 0 ;
2023-08-10 14:51:16 +00:00
}
if ( $at [ $a ][ 'atack' ][ $j ][ 1 ] == 4 || $at [ $a ][ 'atack' ][ $j ][ 1 ] == 5 ) {
$stat [ $a ][ 'yrn_krit' ] += - $at [ $a ][ 'atack' ][ $j ][ 'yron' ][ 'r' ];
2024-01-05 22:14:35 +00:00
$mas [ 'text' ] .= ' <span style="color:red" title=' . $mas [ 'textWP' ] . '><strong>' . $at [ $a ][ 'atack' ][ $j ][ 'yron' ][ 'r' ] . '</strong></span>' ;
2023-08-10 14:51:16 +00:00
} else {
2024-01-05 22:14:35 +00:00
$mas [ 'text' ] .= ' <span style="color:#0066aa" title=' . $mas [ 'textWP' ] . '><strong>' . $at [ $a ][ 'atack' ][ $j ][ 'yron' ][ 'r' ] . '</strong></span>' ;
2023-08-10 14:51:16 +00:00
}
$stat [ $a ][ 'yrn' ] += - $at [ $a ][ 'atack' ][ $j ][ 'yron' ][ 'r' ];
}
if ( isset ( $at [ $a ][ 'atack' ][ $j ][ 'yron' ][ 'hp' ])) {
if ( $this -> users [ $this -> uids [ $u2 ]][ 'align' ] == 9 ) {
$at [ $a ][ 'atack' ][ $j ][ 'yron' ][ 'hp' ] = $at [ $a ][ 'atack' ][ $j ][ 'yron' ][ 'hp' ] / ( $at [ $a ][ 'atack' ][ $j ][ 'yron' ][ 'hpAll' ] / 100 );
$at [ $a ][ 'atack' ][ $j ][ 'yron' ][ 'hpAll' ] = '100%' ;
}
$mas [ 'text' ] .= ' [' . floor ( $at [ $a ][ 'atack' ][ $j ][ 'yron' ][ 'hp' ]) . '/' . floor (
$at [ $a ][ 'atack' ][ $j ][ 'yron' ][ 'hpAll' ]
) . ']' ;
}
if ( $mas [ 'text' ] != '' ) {
$mas [ 'text' ] = '{tm1} ' . $mas [ 'text' ];
}
2022-12-19 20:22:19 +00:00
2023-08-10 14:51:16 +00:00
if ( is_array ( $at [ $a ][ 'atack' ][ $j ][ 'yron' ][ 'plog' ])) {
$il = 0 ;
while ( $il <= count ( $at [ $a ][ 'atack' ][ $j ][ 'yron' ][ 'plog' ])) {
if ( isset ( $at [ $a ][ 'atack' ][ $j ][ 'yron' ][ 'plog' ][ $il ])) {
2024-01-05 22:14:35 +00:00
//FIXME EVAL!!!!????
2023-08-10 14:51:16 +00:00
eval ( $at [ $a ][ 'atack' ][ $j ][ 'yron' ][ 'plog' ][ $il ]);
}
$il ++ ;
}
}
2024-02-09 17:28:32 +00:00
Log :: add ( $mas );
2023-08-10 14:51:16 +00:00
$j ++ ;
}
2024-02-10 01:12:05 +00:00
2023-08-10 14:51:16 +00:00
}
2022-12-19 20:22:19 +00:00
2024-01-05 22:14:35 +00:00
//Добавляем статистику + записываем в б а ттл_юзе р с Н Р игроков
$this -> addNewStat ( $stat );
2022-12-19 20:22:19 +00:00
2024-01-05 22:14:35 +00:00
//Вывод в лог смерти персонажа
if ( floor ( $this -> stats [ $this -> uids [ $u1 ]][ 'hpNow' ]) < 1 ) {
$dies [ 1 ] = 1 ;
}
if ( floor ( $this -> stats [ $this -> uids [ $u2 ]][ 'hpNow' ]) < 1 ) {
$dies [ 2 ] = 1 ;
}
if ( $dies [ 1 ] > 0 || $dies [ 2 ] > 0 ) {
2022-12-19 20:22:19 +00:00
2024-01-05 22:14:35 +00:00
$rtngwin = [ 1 , 2 , 3 , 5 , 10 , 20 , 40 , 80 , 160 ];
$rtnglos = [ 0 , 0 , 0 , - 1 , - 2 , - 5 , - 10 , - 20 , - 40 ];
2022-12-19 20:22:19 +00:00
2024-01-06 15:30:34 +00:00
if ( $this -> i -> typebattle == 99 ) {
2024-01-05 22:14:35 +00:00
if ( $this -> finish -> getBtlstatus ()[ 0 ] == 0 ) {
//Кровавые бои обычные
$rtngwin = [ 2 , 4 , 6 , 10 , 20 , 40 , 80 , 160 , 320 ];
2024-01-06 15:30:34 +00:00
if ( $this -> i -> razdel == 5 ) {
2024-01-05 22:14:35 +00:00
//не хаот
$rtnglos = [ 0 , 0 , 0 , - 2 , - 4 , - 10 , - 20 , - 40 , - 80 ];
} else {
//хаот
$rtnglos = [ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ];
}
} elseif ( $this -> finish -> getBtlstatus ()[ 0 ] == 25 ) {
//Кровавая битва
$rtngwin = [ 3 , 6 , 9 , 15 , 30 , 60 , 120 , 240 , 480 ];
$rtnglos = [ 0 , 0 , 0 , - 2 , - 4 , - 10 , - 20 , - 40 , - 80 ];
} elseif ( $this -> finish -> getBtlstatus ()[ 0 ] == 50 ) {
//Кровавая резня
$rtngwin = [ 4 , 8 , 16 , 32 , 64 , 128 , 256 , 512 , 1024 ];
$rtnglos = [ 0 , 0 , 0 , - 2 , - 4 , - 10 , - 20 , - 40 , - 80 ];
} elseif ( $this -> finish -> getBtlstatus ()[ 0 ] == 75 ) {
//Кровавая сеча
$rtngwin = [ 5 , 10 , 20 , 40 , 80 , 160 , 320 , 640 , 1280 ];
$rtnglos = [ 0 , 0 , 0 , - 2 , - 4 , - 10 , - 20 , - 40 , - 80 ];
} elseif ( $this -> finish -> getBtlstatus ()[ 0 ] == 100 ) {
//Кровавое побоище
$rtngwin = [ 6 , 12 , 24 , 48 , 98 , 196 , 392 , 784 , 1568 ];
$rtnglos = [ 0 , 0 , 0 , - 2 , - 4 , - 10 , - 20 , - 40 , - 80 ];
} elseif ( $this -> finish -> getBtlstatus ()[ 0 ] == 150 ) {
//Судный день
$rtngwin = [ 7 , 14 , 28 , 56 , 112 , 224 , 448 , 896 , 1792 ];
2023-08-10 14:51:16 +00:00
$rtnglos = [ 0 , 0 , 0 , - 2 , - 4 , - 10 , - 20 , - 40 , - 80 ];
}
2024-01-05 22:14:35 +00:00
} else {
if ( $this -> finish -> getBtlstatus ()[ 0 ] == 0 ) {
//Обычный поединок
2024-01-06 15:30:34 +00:00
if ( $this -> i -> razdel != 5 ) {
2024-01-05 22:14:35 +00:00
//хаот
$rtnglos = [ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ];
}
} elseif ( $this -> finish -> getBtlstatus ()[ 0 ] == 25 ) {
//великая битва
$rtngwin = [ 2 , 4 , 6 , 10 , 20 , 40 , 80 , 160 , 320 ];
$rtnglos = [ 0 , 0 , 0 , - 2 , - 4 , - 10 , - 20 , - 40 , - 80 ];
} elseif ( $this -> finish -> getBtlstatus ()[ 0 ] == 50 ) {
//величайшая битва
$rtngwin = [ 3 , 6 , 9 , 15 , 30 , 60 , 120 , 240 , 480 ];
$rtnglos = [ 0 , 0 , 0 , - 2 , - 4 , - 10 , - 20 , - 40 , - 80 ];
} elseif ( $this -> finish -> getBtlstatus ()[ 0 ] == 75 ) {
//историческая битва сеча
$rtngwin = [ 4 , 8 , 16 , 32 , 64 , 128 , 256 , 512 , 1024 ];
$rtnglos = [ 0 , 0 , 0 , - 2 , - 4 , - 10 , - 20 , - 40 , - 80 ];
} elseif ( $this -> finish -> getBtlstatus ()[ 0 ] == 100 ) {
//эпохальная битва
$rtngwin = [ 5 , 10 , 20 , 40 , 80 , 160 , 320 , 640 , 1280 ];
$rtnglos = [ 0 , 0 , 0 , - 2 , - 4 , - 10 , - 20 , - 40 , - 80 ];
} elseif ( $this -> finish -> getBtlstatus ()[ 0 ] == 150 ) {
//судный день
$rtngwin = [ 7 , 14 , 28 , 56 , 112 , 224 , 448 , 896 , 1792 ];
$rtnglos = [ 0 , 0 , 0 , - 2 , - 4 , - 10 , - 20 , - 40 , - 80 ];
2023-08-10 14:51:16 +00:00
}
}
2022-12-19 20:22:19 +00:00
2024-01-06 15:30:34 +00:00
if ( $this -> i -> dnId > 0 || $this -> i -> izlom != 0 || $this -> i -> turnir != 0 ) {
2024-01-05 22:14:35 +00:00
//Пещерные бои не считаются и Изломы тоже, ну и Турниры
$rtngwin = [ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ];
$rtnglos = [ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ];
2024-01-06 15:30:34 +00:00
} elseif ( $this -> i -> clan1 > 0 && $this -> i -> clan2 > 0 ) {
2024-01-05 22:14:35 +00:00
//Клановая война
$rtngwin = [ 3 , 6 , 9 , 15 , 30 , 60 , 120 , 240 , 480 ];
$rtnglos = [ - 1 , - 2 , - 4 , - 8 , - 16 , - 32 , - 64 , - 128 , - 256 ];
}
2022-12-19 20:22:19 +00:00
2024-01-05 22:14:35 +00:00
$rtng1 = 0 ;
$rtng2 = 0 ;
2022-12-19 20:22:19 +00:00
2024-01-05 22:14:35 +00:00
if ( $dies [ 1 ] == 1 ) {
2024-01-06 15:30:34 +00:00
if ( $this -> i -> dnId <= 0 && $this -> users [ $this -> uids [ $u1 ]][ 'level' ] >= 4 ) {
2024-01-05 22:14:35 +00:00
$rtng1 += $rtnglos [ $this -> users [ $this -> uids [ $u1 ]][ 'level' ] - 4 ];
$rtng2 += $rtngwin [ $this -> users [ $this -> uids [ $u1 ]][ 'level' ] - 4 ];
}
//Персонаж 1 погиб от рук персонаж 2
$this -> spaCheck ( $this -> users [ $this -> uids [ $u1 ]][ 'id' ]);
2023-08-10 14:51:16 +00:00
}
2024-01-05 22:14:35 +00:00
if ( $dies [ 2 ] == 1 ) {
2024-01-06 15:30:34 +00:00
if ( $this -> i -> dnId <= 0 && $this -> users [ $this -> uids [ $u1 ]][ 'level' ] >= 4 ) {
2024-01-05 22:14:35 +00:00
$rtng1 += $rtnglos [ $this -> users [ $this -> uids [ $u1 ]][ 'level' ] - 4 ];
$rtng2 += $rtngwin [ $this -> users [ $this -> uids [ $u1 ]][ 'level' ] - 4 ];
}
//Персонаж 2 погиб от рук персонаж 1
$this -> spaCheck ( $this -> stats [ $this -> uids [ $u2 ]][ 'id' ]);
2023-08-10 14:51:16 +00:00
}
2024-02-09 17:49:51 +00:00
2024-01-05 22:14:35 +00:00
//Записываем рейтинг
2024-02-09 17:49:51 +00:00
if (
$this -> i -> type != 564 &&
$this -> stats [ $this -> uids [ $u1 ]][ 'inTurnir' ] == 0 &&
$this -> stats [ $this -> uids [ $u2 ]][ 'inTurnir' ] == 0 &&
$this -> i -> dnId == 0 &&
$this -> i -> izlom == 0
) {
2024-01-05 22:14:35 +00:00
if ( $this -> users [ $this -> uids [ $u2 ]][ 'bot' ] == 0 ) {
2024-02-09 17:49:51 +00:00
Db :: sql (
'insert into users_reting (uid, time, val, align, clan) values (?,unix_timestamp(),?,?,?)' ,
[ $u1 , $rtng1 , $this -> users [ $this -> uids [ $u1 ]][ 'align' ], $this -> users [ $this -> uids [ $u1 ]][ 'clan' ]]
2024-01-05 22:14:35 +00:00
);
}
if ( $this -> users [ $this -> uids [ $u1 ]][ 'bot' ] == 0 ) {
2024-02-09 17:49:51 +00:00
Db :: sql (
'insert into users_reting (uid, time, val, align, clan) values (?,unix_timestamp(),?,?,?)' ,
[ $u2 , $rtng2 , $this -> users [ $this -> uids [ $u2 ]][ 'align' ], $this -> users [ $this -> uids [ $u2 ]][ 'clan' ]]
2024-01-05 22:14:35 +00:00
);
}
2023-08-10 14:51:16 +00:00
}
}
2024-01-05 22:14:35 +00:00
$i ++ ;
2022-12-19 20:22:19 +00:00
}
2023-08-10 14:51:16 +00:00
}
2022-12-19 20:22:19 +00:00
2024-01-05 22:14:35 +00:00
public function addlt ( $a , int $id , int $s , $rnd = null ) : string
2023-08-10 14:51:16 +00:00
{
if ( $rnd === null ) {
2024-01-05 22:14:35 +00:00
$rnd = Log :: addLogLine ( $id , $s , true );
$rnd = mt_rand ( 0 , $rnd - 1 );
2022-12-19 20:22:19 +00:00
}
2023-08-10 14:51:16 +00:00
return '{' . $a . 'x' . $id . 'x' . $rnd . '}' ;
2022-12-19 20:22:19 +00:00
}
2024-02-09 18:21:10 +00:00
/**
* Свиток спасения .
*
* Воскрешение мёртвого игрока ( hpnow = 0 ) чтобы он мог продолжать бой .
* @ param int $u1 id игрока
* @ return void
*/
public function spaCheck ( int $u1 ) : void
2022-12-19 20:22:19 +00:00
{
2024-01-05 22:14:35 +00:00
global $u ;
2023-12-19 01:58:37 +00:00
if ( $this -> stats [ $this -> uids [ $u1 ]][ 'hpNow' ] >= 1 ) {
return ;
}
2023-08-10 14:51:16 +00:00
2024-02-09 18:21:10 +00:00
Db :: sql ( 'delete from battle_act where uid1 = ? or uid2 = ?' , [ $u1 , $u1 ]);
2023-12-19 01:58:37 +00:00
if ( $this -> stats [ $this -> uids [ $u1 ]][ 'spasenie' ] > 0 && $this -> users [ $this -> uids [ $u1 ]][ 'tactic7' ] >= 25 ) {
//Свиток спасения
if ( $this -> stats [ $this -> uids [ $u1 ]][ 's7' ] > 49 && $this -> stats [ $this -> uids [ $u1 ]][ 's7' ] < 75 ) {
//Даем призрачку
2024-02-09 18:21:10 +00:00
Effects :: addCustom (
[
'id_eff' => 22 ,
'uid' => $u1 ,
'name' => 'Призрачная защита' ,
'data' => 'add_zmproc=75|add_zaproc=75' ,
'timeUse' => 77 ,
'user_use' => $u1 ,
'v1' => 'priem' ,
'v2' => 141 ,
'img2' => 'spirit_block25.gif' ,
'hod' => 1 ,
]
2023-08-10 14:51:16 +00:00
);
2023-12-19 01:58:37 +00:00
$this -> stats [ $this -> uids [ $u1 ]][ 'hpNow' ] = floor ( $this -> stats [ $this -> uids [ $u1 ]][ 'hpAll' ] * 0.5 );
$this -> stats [ $this -> uids [ $u1 ]][ 'mpNow' ] = floor ( $this -> stats [ $this -> uids [ $u1 ]][ 'mpAll' ] * 0.5 );
} elseif ( $this -> stats [ $this -> uids [ $u1 ]][ 's7' ] > 74 && $this -> stats [ $this -> uids [ $u1 ]][ 's7' ] < 100 ) {
//Абсолютная защита
2024-02-09 18:21:10 +00:00
Effects :: addCustom (
[
'id_eff' => 22 ,
'uid' => $u1 ,
'name' => 'Абсолютная защита' ,
'data' => 'add_zmproc=100|add_zaproc=100' ,
'timeUse' => 77 ,
'user_use' => $u1 ,
'v1' => 'priem' ,
'v2' => 358 ,
'img2' => 'block_absolute.gif' ,
'hod' => 1 ,
]
2023-08-10 14:51:16 +00:00
);
2023-12-19 01:58:37 +00:00
$this -> stats [ $this -> uids [ $u1 ]][ 'hpNow' ] = floor ( $this -> stats [ $this -> uids [ $u1 ]][ 'hpAll' ] * 0.75 );
$this -> stats [ $this -> uids [ $u1 ]][ 'mpNow' ] = floor ( $this -> stats [ $this -> uids [ $u1 ]][ 'mpAll' ] * 0.75 );
} elseif ( $this -> stats [ $this -> uids [ $u1 ]][ 's7' ] > 99 ) {
//Абсолютная защита x2
2024-02-09 18:21:10 +00:00
Effects :: addCustom (
[
'id_eff' => 22 ,
'uid' => $u1 ,
'name' => 'Божественная защита' ,
'data' => 'add_zmproc=100|add_zaproc=100' ,
'timeUse' => 77 ,
'user_use' => $u1 ,
'v1' => 'priem' ,
'v2' => 358 ,
'img2' => 'wis_white_shield.gif' ,
'hod' => 2 ,
]
2023-08-10 14:51:16 +00:00
);
2023-12-19 01:58:37 +00:00
$this -> stats [ $this -> uids [ $u1 ]][ 'hpNow' ] = floor ( $this -> stats [ $this -> uids [ $u1 ]][ 'hpAll' ]);
$this -> stats [ $this -> uids [ $u1 ]][ 'mpNow' ] = floor ( $this -> stats [ $this -> uids [ $u1 ]][ 'mpAll' ]);
}
if ( $this -> stats [ $this -> uids [ $u1 ]][ 'hpNow' ] < 1 ) {
$this -> stats [ $this -> uids [ $u1 ]][ 'hpNow' ] = 1 ;
2023-08-10 14:51:16 +00:00
}
2023-12-19 01:58:37 +00:00
if ( $this -> stats [ $this -> uids [ $u1 ]][ 'mpNow' ] < 1 ) {
$this -> stats [ $this -> uids [ $u1 ]][ 'mpNow' ] = 1 ;
}
if ( $this -> stats [ $this -> uids [ $u1 ]][ 'hpNow' ] > $this -> stats [ $this -> uids [ $u1 ]][ 'hpAll' ]) {
$this -> stats [ $this -> uids [ $u1 ]][ 'hpNow' ] = floor ( $this -> stats [ $this -> uids [ $u1 ]][ 'hpAll' ]);
}
if ( $this -> stats [ $this -> uids [ $u1 ]][ 'mpNow' ] > $this -> stats [ $this -> uids [ $u1 ]][ 'mpAll' ]) {
$this -> stats [ $this -> uids [ $u1 ]][ 'mpNow' ] = floor ( $this -> stats [ $this -> uids [ $u1 ]][ 'mpAll' ]);
}
2024-02-09 18:21:10 +00:00
Db :: sql ( " delete from eff_users where uid = ? and id_eff = 22 and v1 = 'priem' and v2 = 324 " , [ $u1 ]);
Db :: sql ( 'update stats set hpnow = ?, mpnow = ?, tactic7 = tactic7 - 25 where id = ?' , [ $this -> stats [ $this -> uids [ $u1 ]][ 'hpNow' ], $this -> stats [ $this -> uids [ $u1 ]][ 'mpNow' ], $u1 ]);
2024-01-05 22:14:35 +00:00
2023-12-19 01:58:37 +00:00
$this -> priemAddLog (
2024-02-09 18:21:10 +00:00
22 , 1 , 2 , $u -> info [ 'id' ], $u1 ,
2023-12-19 01:58:37 +00:00
' ' ,
2024-02-09 18:21:10 +00:00
'{tm1} <strong>' . $this -> stats [ $this -> uids [ $u1 ]][ 'login' ] . '</strong> убит...<strong>' . $this -> stats [ $this -> uids [ $u1 ]][ 'login' ] . '</strong> был спасен. ' ,
2024-01-05 22:14:35 +00:00
$this -> hodID
2023-12-19 01:58:37 +00:00
);
} elseif ( isset ( $this -> stats [ $this -> uids [ $u1 ]][ 'login' ])) {
2024-02-09 18:21:10 +00:00
Db :: sql ( 'update stats set hpnow = 0, mpnow = 0 where id = ?' , [ $u1 ]);
2023-12-19 01:58:37 +00:00
$this -> stats [ $this -> uids [ $u1 ]][ 'hpNow' ] = 0 ;
$this -> users [ $this -> uids [ $u1 ]][ 'hpNow' ] = 0 ;
$this -> priemAddLog (
2024-02-09 18:21:10 +00:00
22 , 1 , 2 , $u -> info [ 'id' ], $u1 ,
2023-12-19 01:58:37 +00:00
' ' ,
2024-02-09 18:21:10 +00:00
'{tm1} <strong>' . $this -> stats [ $this -> uids [ $u1 ]][ 'login' ] . '</strong> погиб.' ,
$this -> hodID + 1
2023-12-19 01:58:37 +00:00
);
2024-02-09 18:21:10 +00:00
Db :: sql (
'delete from battle_act where uid1 = ? or uid2 = ? or uid2 = ?' ,
[ $this -> stats [ $this -> uids [ $u1 ]][ 'id' ], $this -> stats [ $this -> uids [ $u1 ]][ 'id' ], - $this -> stats [ $this -> uids [ $u1 ]][ 'id' ]]
2023-12-19 01:58:37 +00:00
);
2024-02-09 18:21:10 +00:00
Effects :: removePriems ( $this -> stats [ $this -> uids [ $u1 ]][ 'id' ]);
2022-12-19 20:22:19 +00:00
}
}
2024-01-05 22:14:35 +00:00
public function priemAddLog (
$id ,
$a ,
$b ,
$u1 ,
$u2 ,
$prm ,
$text ,
$hodID ,
$tm1 = 0 ,
$tm2 = 0
2024-05-10 11:32:06 +00:00
) : void
{
2023-08-10 14:51:16 +00:00
$time = time ();
if ( $tm1 == 0 ) {
$tm1 = isset ( $this -> atacks [ $id ]) ? $this -> atacks [ $id ][ 'time' ] : $time ;
2022-12-19 20:22:19 +00:00
}
2023-08-10 14:51:16 +00:00
if ( $tm2 == 0 ) {
$tm2 = isset ( $this -> atacks [ $id ]) ? $this -> atacks [ $id ][ 'time2' ] : $time ;
}
$prm = str_replace ( '=' , '^^^^' , $prm );
$vLog =
'prm=' . $prm .
'||at1=00000||at2=00000||zb1=' . $this -> stats [ $this -> uids [ $u1 ]][ 'zonb' ] .
'||zb2=' . $this -> stats [ $this -> uids [ $u2 ]][ 'zonb' ] .
'||bl1=' . $this -> atacks [ $id ][ 'b' . $a ] .
'||bl2=' . $this -> atacks [ $id ][ 'b' . $b ] .
'||time1=' . $tm1 .
'||time2=' . $tm2 .
'||s' . $a . '=' . $this -> users [ $this -> uids [ $u1 ]][ 'sex' ] .
'||s' . $b . '=' . $this -> users [ $this -> uids [ $u2 ]][ 'sex' ] .
'||t2=' . $this -> users [ $this -> uids [ $u2 ]][ 'team' ] .
'||t1=' . $this -> users [ $this -> uids [ $u1 ]][ 'team' ] .
'||login1=' . $this -> users [ $this -> uids [ $u1 ]][ 'login2' ] .
'||login2=' . $this -> users [ $this -> uids [ $u2 ]][ 'login2' ];
$mas = [
'text' => $text ,
2024-01-06 15:30:34 +00:00
'battle' => $this -> i -> id ,
2023-08-10 14:51:16 +00:00
'id_hod' => $hodID ,
'vars' => $vLog ,
'type' => 1 ,
];
2024-02-09 17:28:32 +00:00
Log :: add ( $mas );
2022-12-19 20:22:19 +00:00
}
2024-02-09 19:41:54 +00:00
/**
* Возращаем зоны блока ?
* @ param $uid1
* @ param $uid2
* @ return void
*/
2023-12-19 01:58:37 +00:00
private function restZonb ( $uid1 , $uid2 ) : void
2022-12-19 20:22:19 +00:00
{
2023-08-10 14:51:16 +00:00
if ( $this -> stnZbVs [ $uid1 ] > 0 ) {
$this -> stats [ $this -> uids [ $uid1 ]][ 'zonb' ] = $this -> stnZbVs [ $uid1 ];
}
if ( $this -> stnZbVs [ $uid2 ] > 0 ) {
$this -> stats [ $this -> uids [ $uid1 ]][ 'zonb' ] = $this -> stnZbVs [ $uid2 ];
2022-12-19 20:22:19 +00:00
}
}
2024-05-10 11:32:06 +00:00
//Расчет МФ
2024-02-09 18:26:44 +00:00
private function saveStats ( $uid ) : void
2022-12-19 20:22:19 +00:00
{
2023-12-19 01:58:37 +00:00
Stats :: saveBattleStats ( $this -> stats [ $this -> uids [ $uid ]], $uid );
2022-12-19 20:22:19 +00:00
}
2023-09-30 20:17:25 +00:00
/** Осторожно ! Подключаются файлы !!!
* @ param $id
* @ param $at
2024-01-05 22:14:35 +00:00
* @ return void
2023-09-30 20:17:25 +00:00
*/
2024-01-05 22:14:35 +00:00
private function priemsRazmenMomentEnd ( $id , $at ) : void
2022-12-19 20:22:19 +00:00
{
2023-08-10 14:51:16 +00:00
$uid1 = $this -> atacks [ $id ][ 'uid1' ];
$uid2 = $this -> atacks [ $id ][ 'uid2' ];
$i = 1 ;
while ( $i <= 2 ) {
if ( $i == 1 ) {
$a = 1 ;
$b = 2 ;
2023-11-02 13:57:39 +00:00
$u1 = $uid1 ;
$u2 = $uid2 ;
2023-08-10 14:51:16 +00:00
} else {
$a = 2 ;
$b = 1 ;
2023-11-02 13:57:39 +00:00
$u1 = $uid2 ;
$u2 = $uid1 ;
2022-12-19 20:22:19 +00:00
}
2023-08-10 14:51:16 +00:00
if ( ! isset ( $at [ 'p' ][ 'p_cast' ])) {
$at [ 'p' ] = $at ;
$at [ 'p' ][ 'p_cast' ] = true ;
2022-12-19 20:22:19 +00:00
}
2024-01-05 22:14:35 +00:00
/** $priem [ 6 ]
* 1 Приемы ухода от удара
* 2 Приемы крита
* 3 Приемы атаки
* 4 Приемы защиты
* 5 Прочие приемы
*/
2023-08-10 14:51:16 +00:00
$j = 0 ;
2024-01-05 22:14:35 +00:00
foreach ( $this -> stats [ $this -> uids [ $u1 ]][ 'u_priem' ] as $priem ) {
if ((
in_array ( $priem [ 6 ], [ 2 , 3 , 4 , 5 ]) && $priem [ 2 ] > 0 ||
$priem [ 6 ] == 1 && $priem [ 2 ] > 0 && empty ( $this -> stats [ $this -> uids [ $u2 ]][ 'nopryh' ])) &&
2024-02-08 13:35:42 +00:00
file_exists ( " Priem/ $priem[1] .php " )
2024-01-05 22:14:35 +00:00
) {
$pr_used_this = $u1 ;
2024-02-08 13:35:42 +00:00
require_once " Priem/ $priem[1] .php " ;
2024-01-05 22:14:35 +00:00
if ( isset ( $fx_priem )) {
$fx_priem ( $id , $at , $u1 , $j );
2023-11-02 13:57:39 +00:00
unset ( $fx_priem );
2023-08-10 14:51:16 +00:00
}
2024-01-05 22:14:35 +00:00
$j ++ ;
if ( $priem [ 6 ] == 1 ) {
$this -> stats [ $this -> uids [ $u2 ]][ 'nopryh' ] -- ;
2023-08-10 14:51:16 +00:00
}
}
2022-12-19 20:22:19 +00:00
}
2023-08-10 14:51:16 +00:00
$i ++ ;
2022-12-19 20:22:19 +00:00
}
}
2024-02-09 19:41:54 +00:00
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
);
2024-02-10 16:18:11 +00:00
Db :: sql ( 'update stats set hpnow = 0 where id = ?' , [ $this -> atacks [ $id ][ 'uid1' ]]);
2024-02-09 19:41:54 +00:00
}
if ( $cn2 > Config :: get ( 'propsk_die' )) {
$this -> priemAddLog (
$id , 1 , 2 , $this -> atacks [ $id ][ 'uid2' ], 0 , '' ,
'{tm1} Персонаж {u1} был убит из-за большого количества пропусков хода.' ,
$this -> hodID
);
2024-02-10 16:18:11 +00:00
Db :: sql ( 'update stats set hpnow = 0 where id = ?' , [ $this -> atacks [ $id ][ 'uid2' ]]);
2024-02-09 19:41:54 +00:00
}
}
2024-05-10 11:32:06 +00:00
//Действия бота (атака)
2023-08-10 14:51:16 +00:00
2023-12-19 01:58:37 +00:00
private function addNewAtack ( User $u ) : void
2022-12-19 20:22:19 +00:00
{
2023-11-02 13:57:39 +00:00
if ( isset ( $this -> ga [ $u -> info [ 'id' ]][ $u -> info [ 'enemy' ]])) {
return ;
}
2023-12-19 01:58:37 +00:00
2023-11-02 13:57:39 +00:00
if ( $this -> stats [ $this -> uids [ $u -> info [ 'id' ]]][ 'hpNow' ] <= 0 ) {
$this -> e = 'Для вас поединок закончен, ожидайте пока завершат другие...' ;
return ;
}
2023-12-19 01:58:37 +00:00
2023-11-02 13:57:39 +00:00
$us = $this -> stats [ $this -> uids [ $u -> info [ 'id' ]]];
2023-12-19 01:58:37 +00:00
$no = false ;
2023-08-10 14:51:16 +00:00
2023-12-19 01:58:37 +00:00
for ( $j = 1 ; $j <= $us [ 'zona' ]; $j ++ ) {
if ( $this -> uAtc [ 'a' ][ $j ] != 0 ) {
continue ;
2023-11-02 13:57:39 +00:00
}
2023-12-19 01:58:37 +00:00
$no = true ;
2023-11-02 13:57:39 +00:00
}
2023-12-19 01:58:37 +00:00
2023-11-02 13:57:39 +00:00
if ( $this -> uAtc [ 'b' ] == 0 ) {
2023-12-19 01:58:37 +00:00
$no = true ;
2023-11-02 13:57:39 +00:00
}
2023-12-19 01:58:37 +00:00
if ( $no ) {
2023-11-02 13:57:39 +00:00
$this -> e = 'Выберите зоны удара и блока' ;
2023-12-19 01:58:37 +00:00
return ;
}
//наносим удар
if ( $u -> info [ 'enemy' ] <= 0 ) {
return ;
}
if ( ! isset ( $this -> ga [ $u -> info [ 'enemy' ]][ $u -> info [ 'id' ]])) {
if (
$this -> stats [ $this -> uids [ $u -> info [ 'id' ]]][ 'hpNow' ] < 1 ||
$this -> stats [ $this -> uids [ $u -> info [ 'enemy' ]]][ 'hpNow' ] < 1
) {
return ;
}
//наносим новый удар
$a = $this -> uAtc [ 'a' ][ 1 ] . $this -> uAtc [ 'a' ][ 2 ] . $this -> uAtc [ 'a' ][ 3 ] . $this -> uAtc [ 'a' ][ 4 ] . $this -> uAtc [ 'a' ][ 5 ];
$b = $this -> uAtc [ 'b' ];
Db :: sql (
'delete from battle_act where battle = ? and uid1 in (?,?) and uid2 in (?,?)' ,
[
2024-01-06 15:30:34 +00:00
$this -> i -> id ,
2023-12-19 01:58:37 +00:00
$u -> info [ 'id' ],
$u -> info [ 'enemy' ],
$u -> info [ 'id' ],
$u -> info [ 'enemy' ],
]
);
Db :: sql (
" insert into battle_act (battle,uid1,uid2,a1,b1,time,a2,b2,invis1,invis2) values (?,?,?,?,?,unix_timestamp(),'',0,0,0) " ,
[
2024-01-06 15:30:34 +00:00
$this -> i -> id ,
2023-12-19 01:58:37 +00:00
$u -> info [ 'id' ],
$u -> info [ 'enemy' ],
$a ,
$b ,
]
);
$this -> ga [ $u -> info [ 'id' ]][ $u -> info [ 'enemy' ]] = Db :: lastInsertId ();
2023-11-02 13:57:39 +00:00
} else {
2023-12-19 01:58:37 +00:00
//отвечаем на удар противника
if (
$this -> stats [ $this -> uids [ $u -> info [ 'id' ]]][ 'hpNow' ] >= 1 &&
$this -> stats [ $this -> uids [ $u -> info [ 'enemy' ]]][ 'hpNow' ] >= 1
&& isset ( $this -> atacks [ $this -> ga [ $u -> info [ 'enemy' ]][ $u -> info [ 'id' ]]][ 'id' ])
) {
$this -> atacks [ $this -> ga [ $u -> info [ 'enemy' ]][ $u -> info [ 'id' ]]][ 'a2' ] = $this -> uAtc [ 'a' ][ 1 ] . '' . $this -> uAtc [ 'a' ][ 2 ] . $this -> uAtc [ 'a' ][ 3 ] . $this -> uAtc [ 'a' ][ 4 ] . $this -> uAtc [ 'a' ][ 5 ];
$this -> atacks [ $this -> ga [ $u -> info [ 'enemy' ]][ $u -> info [ 'id' ]]][ 'b2' ] = $this -> uAtc [ 'b' ];
$this -> startAtack ( $this -> atacks [ $this -> ga [ $u -> info [ 'enemy' ]][ $u -> info [ 'id' ]]][ 'id' ]);
2022-12-19 20:22:19 +00:00
}
}
2023-12-19 01:58:37 +00:00
2022-12-19 20:22:19 +00:00
}
2024-05-10 11:32:06 +00:00
//Проверяем удары, приемы, свитки, зверей
2023-08-10 14:51:16 +00:00
2023-09-30 20:17:25 +00:00
private function botAct ( $uid ) : bool
2022-12-19 20:22:19 +00:00
{
$r = false ;
if ( $this -> users [ $this -> uids [ $uid ]][ 'bot' ] > 0 ) {
if ( $this -> users [ $this -> uids [ $uid ]][ 'online' ] < time () - 3 ) {
$r = true ;
$this -> users [ $this -> uids [ $uid ]][ 'online' ] = time ();
2022-12-30 19:03:37 +00:00
User :: setOnline (( int ) $uid );
2023-12-19 01:58:37 +00:00
} elseif ( mt_rand ( 0 , 2 ) === 0 ) {
2022-12-30 19:03:37 +00:00
$r = true ;
2022-12-19 20:22:19 +00:00
}
}
return $r ;
}
2024-05-10 11:32:06 +00:00
//Действия бота
/**
* Массово встречается в подключаемых файлах приёмов .
* @ param array $arr
* @ return void
* @ deprecated
*/
public function add_log ( array $arr ) : void
{
Log :: add ( $arr );
}
2024-02-09 18:33:59 +00:00
/**
* Запись выбранных ударов и блоков в массив $this -> uAtc .
* Технически это сеттер .
* @ return void
*/
2023-12-19 01:58:37 +00:00
public function addAtack () : void
2022-12-19 20:22:19 +00:00
{
global $js ;
2024-01-08 01:33:20 +00:00
if ( $_POST [ 'atack' ] === '0_0_0_0_0' || $_POST [ 'block' ] === '0' ) {
2023-12-19 01:58:37 +00:00
$this -> e = 'Выберите зоны удара и блока' ;
return ;
}
2024-01-08 01:33:20 +00:00
//atack: '3_2_0_0_0' (length=9)
//block: '5' (length=1)
2023-12-19 01:58:37 +00:00
$na = [ 'a' => [ 1 => 0 , 2 => 0 , 3 => 0 , 4 => 0 , 5 => 0 ]];
$a = explode ( '_' , $_POST [ 'atack' ]);
$na [ 'id' ] = time ();
2024-01-08 01:33:20 +00:00
array_unshift ( $a , 0 );
2023-12-19 01:58:37 +00:00
for ( $i = 1 ; $i <= 5 ; $i ++ ) {
2024-01-08 01:33:20 +00:00
if ( ! isset ( $a [ $i ])) {
2023-12-19 01:58:37 +00:00
continue ;
2022-12-19 20:22:19 +00:00
}
2024-01-08 01:33:20 +00:00
$a [ $i ] = intval ( round ( $a [ $i ]));
if ( $a [ $i ] >= 1 && $a [ $i ] <= 5 ) {
$na [ 'a' ][ $i ] = $a [ $i ];
2023-12-19 01:58:37 +00:00
} else {
$na [ 'a' ][ $i ] = 0 ;
}
}
2022-12-19 20:22:19 +00:00
2023-12-19 01:58:37 +00:00
$na [ 'b' ] = intval ( round ( $_POST [ 'block' ]));
if ( $na [ 'b' ] < 1 || $na [ 'b' ] > 5 ) {
$na [ 'b' ] = 0 ;
2022-12-19 20:22:19 +00:00
}
2023-12-19 01:58:37 +00:00
$this -> uAtc = $na ;
$js .= 'testClearZone();' ;
2022-12-19 20:22:19 +00:00
}
2023-12-19 01:58:37 +00:00
public function teamsTake ( User $u ) : void
2022-12-19 20:22:19 +00:00
{
2024-01-06 15:30:34 +00:00
if ( $this -> i -> id < 1 ) {
2023-12-19 01:58:37 +00:00
return ;
}
2024-01-05 22:14:35 +00:00
$rs = [];
2022-12-19 20:22:19 +00:00
$ts = [];
$tsi = 0 ;
2023-12-19 01:58:37 +00:00
//данные о игроках в бою
$usersInBattle = Db :: getRows (
" select
room , no_ip , twink , stopexp , users . id , notrhod , login , if ( login2 != '' , login2 , login ) as login2 , sex , online , admin ,
2024-01-06 15:30:34 +00:00
align , align_lvl , align_exp , clan , level , battle , obraz , win , lose , nich , animal , stats , hpnow , mpnow , exp , dnow , team ,
battle_yron , battle_exp , enemy , battle_text , uplevel , timego , timegol , bot , lider , btl_cof ,
tactic1 , tactic2 , tactic3 , tactic4 , tactic5 , tactic6 , tactic7 , x , y , battleend , priemslot , priems , priems_z , bet , clone ,
2023-12-19 01:58:37 +00:00
atack , bbexp , res_x , res_y , res_s , last_hp , last_pr , sex , money , bot_id , money3 , money2
2024-01-06 15:30:34 +00:00
from users left join stats on users . id = stats . id where battle = ? " , [ $this->i ->id]
2023-12-19 01:58:37 +00:00
);
2022-12-19 20:22:19 +00:00
2023-12-19 01:58:37 +00:00
$i = 0 ;
$bi = 0 ;
2022-12-19 20:22:19 +00:00
2024-01-06 15:30:34 +00:00
if ( $this -> i -> getStart2 () == 0 ) {
if ( Db :: getValue ( 'select count(id) from battle where id = ? and start2 = 0' , [ $this -> i -> id ]) === 1 ) {
Db :: sql ( 'update battle set start2 = unix_timestamp() where id = ?' , [ $this -> i -> id ]);
2023-12-19 01:58:37 +00:00
} else {
2024-01-06 15:30:34 +00:00
$this -> i -> setStart2 ();
2023-12-19 01:58:37 +00:00
}
}
2022-12-19 20:22:19 +00:00
2023-12-19 01:58:37 +00:00
foreach ( $usersInBattle as $user ) {
//записываем данные
2024-01-08 01:33:20 +00:00
//$this->fighters[] = new Fighter();
2023-12-19 01:58:37 +00:00
$this -> users [ $i ] = $user ;
$this -> uids [ $user [ 'id' ]] = $i ;
2022-12-19 20:22:19 +00:00
2023-12-19 01:58:37 +00:00
if ( $user [ 'bot' ] > 0 ) {
$this -> bots [ $bi ] = $user [ 'id' ];
$this -> iBots [ $user [ 'id' ]] = $bi ;
$bi ++ ;
}
2022-12-19 20:22:19 +00:00
2023-12-19 01:58:37 +00:00
//записываем статы
$stats = new Stats ( $u );
2024-01-08 01:33:20 +00:00
$this -> stats [ $i ] = $stats -> getStats ( uid : $user [ 'id' ], btl_cache : $this -> cached );
2022-12-19 20:22:19 +00:00
2023-12-19 01:58:37 +00:00
//Заносим старт
2024-01-06 15:30:34 +00:00
if ( $this -> i -> getStart2 () == 0 ) {
2023-12-19 01:58:37 +00:00
Db :: sql ( 'update users set notrhod = default where id = ?' , [ $this -> users [ $i ][ 'id' ]]);
$this -> users [ $i ][ 'notrhod' ] = - 1 ;
2022-12-19 20:22:19 +00:00
2023-12-19 01:58:37 +00:00
if ( ! isset ( $ts [ $this -> users [ $i ][ 'team' ]])) {
$tsi ++ ;
$ts [ $this -> users [ $i ][ 'team' ]] = $tsi ;
}
2022-12-19 20:22:19 +00:00
2023-12-19 01:58:37 +00:00
$tactic7LevelModifier = 10 ;
if ( $this -> users [ $i ][ 'level' ] == 8 ) {
$tactic7LevelModifier = 20 ;
} elseif ( $this -> users [ $i ][ 'level' ] == 9 ) {
$tactic7LevelModifier = 30 ;
} elseif ( $this -> users [ $i ][ 'level' ] >= 10 ) {
$tactic7LevelModifier = 40 + $this -> stats [ $i ][ 's7' ];
2022-12-19 20:22:19 +00:00
}
2023-11-02 13:57:39 +00:00
2023-12-19 01:58:37 +00:00
$this -> users [ $i ][ 'tactic7' ] =
floor ( $tactic7LevelModifier / $this -> stats [ $i ][ 'hpAll' ] * $this -> stats [ $i ][ 'hpNow' ]);
if ( $this -> stats [ $i ][ 's7' ] >= 50 ) {
Effects :: addSpasenie ( $this -> users [ $i ][ 'id' ]);
2022-12-19 20:22:19 +00:00
}
2023-12-19 01:58:37 +00:00
// Бафф Зверя animal_bonus
2024-01-08 01:33:20 +00:00
$this -> addAnimalBuff ( $i );
2022-12-19 20:22:19 +00:00
2023-12-19 01:58:37 +00:00
Db :: sql (
'update stats set last_hp = 0, tactic1 = 0, tactic2 = 0, tactic3 = 0, tactic4 = 0, tactic5 = 0, tactic6 = 0, tactic7 = ? where id = ?' ,
[ $this -> users [ $i ][ 'tactic7' ], $this -> users [ $i ][ 'id' ]]
2022-12-30 19:03:37 +00:00
);
2022-12-19 20:22:19 +00:00
2024-01-05 22:14:35 +00:00
$rs [ $this -> users [ $i ][ 'team' ]][] =
( new Login (
$this -> users [ $i ][ 'align' ],
$this -> users [ $i ][ 'clan' ],
$this -> users [ $i ][ 'level' ],
$this -> users [ $i ][ 'login' ]
)) -> fullLogin ;
2023-12-19 01:58:37 +00:00
}
2022-12-19 20:22:19 +00:00
2023-12-19 01:58:37 +00:00
//battle-user (статистика, начальная)
2024-01-06 15:30:34 +00:00
$mybu = Db :: getValue ( 'select id from battle_users where battle = ? and uid = ? limit 1' , [ $this -> i -> id , $user [ 'id' ]]);
2023-12-19 01:58:37 +00:00
if ( ! $mybu ) {
//Пустое значение статистики для данного персонажа за текущий бой
$this -> addstatuser ( $user [ 'id' ]);
}
$i ++ ;
}
//Заносим в лог начало поединка
2024-01-06 15:30:34 +00:00
if ( $this -> i -> getStart1 () != 0 ) {
2023-12-19 01:58:37 +00:00
return ;
}
2024-01-06 15:30:34 +00:00
if ( Db :: getValue ( 'select count(id) from battle where id = ? and start1 = 0' , [ $this -> i -> id ]) !== 1 ) {
2023-12-19 01:58:37 +00:00
return ;
}
2024-01-06 15:30:34 +00:00
Db :: sql ( 'update battle set start1 = unix_timestamp() where id = ?' , [ $this -> i -> id ]);
2023-12-19 01:58:37 +00:00
2024-01-05 22:14:35 +00:00
$teamlist = [];
for ( $j = 1 ; $j <= $tsi ; $j ++ ) { //was 0
2023-12-19 01:58:37 +00:00
if ( empty ( $rs [ $j ])) {
continue ;
2022-12-19 20:22:19 +00:00
}
2024-01-05 22:14:35 +00:00
$teamlist [] = implode ( ', ' , $rs [ $j ]);
2022-12-19 20:22:19 +00:00
}
2023-12-19 01:58:37 +00:00
2024-01-05 22:14:35 +00:00
$vsTeams = implode ( ' и ' , $teamlist );
2023-12-19 01:58:37 +00:00
$this -> hodID ++ ;
2024-01-06 15:30:34 +00:00
$timestart = date ( 'd.m.Y H:i' , $this -> i -> timeStart );
2024-01-05 22:14:35 +00:00
2023-12-19 01:58:37 +00:00
Log :: add (
[
2024-01-05 22:14:35 +00:00
'text' => " Часы показывали <span class='date'> $timestart </span>, когда $vsTeams бросили вызов друг другу. " ,
2024-01-06 15:30:34 +00:00
'battle' => $this -> i -> id ,
2023-12-19 01:58:37 +00:00
'id_hod' => $this -> hodID ,
'vars' => 'time1=' . time () . '||' ,
'type' => '1' ,
]
);
2024-01-06 15:30:34 +00:00
$this -> i -> setStart1 ();
2022-12-19 20:22:19 +00:00
}
2024-02-09 19:41:54 +00:00
/**
* @ param int $i
* @ return void
*/
private function addAnimalBuff ( int $i ) : void
{
if ( $this -> users [ $i ][ 'animal' ] <= 0 ) {
return ;
}
$animal = Db :: getRow ( 'select id, eda, type, level, name from users_animal where id = ? and uid = ? and pet_in_cage = 0' , [ $this -> users [ $i ][ 'animal' ], $this -> users [ $i ][ 'id' ]]);
if ( ! isset ( $animal [ 'id' ]) || $animal [ 'eda' ] < 1 ) {
return ;
}
$animalBonusDataString =
Db :: getValue ( 'select bonus from levels_animal where type = ? and level = ?' , [ $animal [ 'type' ], $animal [ 'level' ]]);
$tpa = [
1 => 'cat' ,
2 => 'owl' ,
3 => 'wisp' ,
4 => 'demon' ,
5 => 'dog' ,
6 => 'pig' ,
7 => 'dragon' ,
];
$tpa3 = [
1 => 'Кошачья Ловкость' ,
2 => 'Интуиция Совы' ,
3 => 'Сила Стихий' ,
4 => 'Демоническая Сила' ,
5 => 'Друг' ,
6 => 'Полная Броня' ,
7 => 'Инферно' ,
];
Effects :: removeByOverType ( $this -> users [ $i ][ 'id' ], 100 );
Effects :: addCustom (
[
'id_eff' => 22 ,
'uid' => $this -> users [ $i ][ 'id' ],
'name' => " { $tpa [ $animal [ 'type' ]] } [ { $animal [ 'level' ] } ] " ,
'timeUse' => 77 ,
'v1' => 'priem' ,
'v2' => 201 ,
'img2' => " summon_pet_ { $tpa [ $animal [ 'type' ]] } .gif " ,
'overType' => 100 ,
'user_use' => $this -> users [ $i ][ 'id' ],
'data' => $animalBonusDataString ,
]
);
//добавление духа от дракона
if ( $animal [ 'type' ] == 7 ) {
$dragonBonus = 0 ;
if ( $animal [ 'level' ] == 10 ) {
$dragonBonus = ( 50 + $this -> stats [ $i ][ 's7' ]) / $this -> stats [ $i ][ 'hpAll' ] * $this -> stats [ $i ][ 'hpNow' ];
} elseif ( $animal [ 'level' ] == 11 ) {
$dragonBonus = ( 65 + $this -> stats [ $i ][ 's7' ]) / $this -> stats [ $i ][ 'hpAll' ] * $this -> stats [ $i ][ 'hpNow' ];
} elseif ( $animal [ 'level' ] == 12 ) {
$dragonBonus = ( 90 + $this -> stats [ $i ][ 's7' ]) / $this -> stats [ $i ][ 'hpAll' ] * $this -> stats [ $i ][ 'hpNow' ];
}
$this -> users [ $i ][ 'tactic7' ] = $dragonBonus ;
}
$animalBonusData = Conversion :: dataStringToArray ( $animalBonusDataString );
$bonusString = '' ;
foreach ( $this -> statnames -> sysBonusNames as $itemBonusSysName ) {
if (
! isset ( $animalBonusData [ 'add_' . $itemBonusSysName ]) ||
$animalBonusData [ 'add_' . $itemBonusSysName ] <= 0
) {
continue ;
}
$bonusString .= match ( $itemBonusSysName ) {
'mib1' => 'Броня головы: +' . $animalBonusData [ 'add_' . $itemBonusSysName ] . ', ' ,
'mib2' => 'Броня корпуса: +' . $animalBonusData [ 'add_' . $itemBonusSysName ] . ', ' ,
'mib3' => 'Броня пояса: +' . $animalBonusData [ 'add_' . $itemBonusSysName ] . ', ' ,
'mib4' => 'Броня ног: +' . $animalBonusData [ 'add_' . $itemBonusSysName ] . ', ' ,
default => $this -> statnames -> bonusNames [ $itemBonusSysName ] . ': +' . $animalBonusData [ 'add_' . $itemBonusSysName ] . ', ' ,
};
}
$bonusString = trim ( $bonusString , ', ' );
if ( $bonusString == '' ) {
$bonusString = 'Эффект отсутсвует' ;
}
Log :: add (
[
'battle' => $this -> i -> id ,
'id_hod' => 1 ,
'vars' =>
'time1=' . time () .
'||s1=' . $this -> users [ $i ][ 'sex' ] .
'||t1=' . $this -> users [ $i ][ 'team' ] .
'||login1=' . $this -> users [ $i ][ 'login' ] .
'||s2=1||t2=' . $this -> users [ $i ][ 'team' ] .
'||login2=' . $animal [ 'name' ] . ' (Зверь ' . $this -> users [ $i ][ 'login' ] . ')' ,
'type' => '1' ,
'text' => '{tm1} {u2} очнулся от медитации, и призвал заклятье "<strong>' .
$tpa3 [ $animal [ 'type' ]] . ' [' . $animal [ 'level' ] . ']</strong>" на {u1}. (' . $bonusString . ')' ,
]
);
Db :: sql ( 'update users_animal set eda = eda - 1 where id = ?' , [ $animal [ 'id' ]]);
}
2023-11-02 13:57:39 +00:00
private function addstatuser ( $uid ) : void
2022-12-19 20:22:19 +00:00
{
2023-11-02 13:57:39 +00:00
if ( $uid <= 0 ) {
return ;
2022-12-19 20:22:19 +00:00
}
2023-11-02 13:57:39 +00:00
$id = $this -> uids [ $uid ];
if ( empty ( $this -> stats [ $id ][ 'hp' ])) {
$this -> stats [ $id ][ 'hp' ] = $this -> stats [ $id ][ 'hpNow' ];
}
2023-12-17 02:32:09 +00:00
Db :: sql (
2024-01-06 15:30:34 +00:00
'insert into battle_users (battle,uid,time_enter,login,level,align,clan,hpall,hp,hpstart,team) values (?,?,unix_timestamp(),?,?,?,?,?,?,?,?)' ,
2023-11-02 13:57:39 +00:00
[
2024-01-06 15:30:34 +00:00
$this -> i -> id ,
2023-11-02 13:57:39 +00:00
$uid ,
$this -> users [ $id ][ 'login' ],
2024-01-05 22:14:35 +00:00
$this -> users [ $id ][ 'level' ],
2023-11-02 13:57:39 +00:00
$this -> users [ $id ][ 'align' ],
$this -> users [ $id ][ 'clan' ],
$this -> stats [ $id ][ 'hpAll' ],
$this -> stats [ $id ][ 'hp' ],
$this -> stats [ $id ][ 'hpNow' ],
$this -> users [ $id ][ 'team' ],
2023-12-17 02:32:09 +00:00
]
);
2022-12-19 20:22:19 +00:00
}
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 ;
}
2022-12-30 19:03:37 +00:00
public function genTeams ( $you ) : string
2022-12-19 20:22:19 +00:00
{
$ret = '' ;
$teams = [];
2023-01-10 16:29:32 +00:00
//выделяем пользователей
2022-12-19 20:22:19 +00:00
$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' ]])) {
2024-02-10 01:12:05 +00:00
$teams [ $this -> users [ $i ][ 'team' ]] = '' ;
2022-12-19 20:22:19 +00:00
$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' ];
}
2024-02-08 12:55:44 +00:00
// Цветная метка тем, кто вылетел за таймаут в 15 минут?
2022-12-19 20:22:19 +00:00
$a1ms = '' ;
2024-02-08 12:55:44 +00:00
$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 ; " ;
2022-12-19 20:22:19 +00:00
}
2024-02-08 12:55:44 +00:00
$a1ms = " style='text-decoration: $actstyle '; $a1ms " ;
2022-12-19 20:22:19 +00:00
}
2024-02-08 12:55:44 +00:00
2022-12-19 20:22:19 +00:00
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 = '' ;
2024-01-06 15:30:34 +00:00
if ( $this -> users [ $i ][ 'lider' ] == $this -> i -> id ) {
2024-02-08 12:55:44 +00:00
$ldr = '<img title=Лидер группы src=//img.new-combats.tech/i/lead' . $this -> users [ $i ][ 'team' ] . '.gif>' ;
2022-12-19 20:22:19 +00:00
}
2024-01-08 01:33:20 +00:00
$teams [ $this -> users [ $i ][ 'team' ]] .= ', ' . $ldr . '<span ' . $a1ms . ' class=\"CSSteam' . $this -> 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' ] . '</span><small> [' . floor (
2022-12-30 19:03:37 +00:00
$this -> stats [ $i ][ 'hpNow' ]
) . '/' . $this -> stats [ $i ][ 'hpAll' ] . ']</small>' ;
2022-12-19 20:22:19 +00:00
}
$i ++ ;
}
2024-02-10 01:12:05 +00:00
2023-01-10 16:29:32 +00:00
//генерируем команды
2022-12-19 20:22:19 +00:00
$i = 0 ;
while ( $i < count ( $tms )) {
$teams [ $tms [ $i ]] = ltrim ( $teams [ $tms [ $i ]], ', ' );
if ( $teams [ $tms [ $i ]] != '' ) {
2024-02-08 12:55:44 +00:00
$teams [ $tms [ $i ]] = '<img src=\"//img.new-combats.tech/i/lock3.gif\" style=\"cursor:pointer\" onClick=\"chat.addto(\'team' . $tms [ $i ] . '\',\'private\'); return false;\"> ' . $teams [ $tms [ $i ]];
2022-12-19 20:22:19 +00:00
$ret .= $teams [ $tms [ $i ]];
if ( count ( $tms ) > $i + 1 ) {
2023-01-10 16:29:32 +00:00
$ret .= ' <span class=\"CSSvs\"> против </span> ' ;
2022-12-19 20:22:19 +00:00
}
}
$i ++ ;
}
return 'genteam("' . $ret . '");' ;
}
2023-12-19 01:58:37 +00:00
public function setIBotsValue ( $key , $value ) : void
{
$this -> iBots [ $key ] = $value ;
}
2022-12-19 20:22:19 +00:00
}