2022-08-11 10:38:38 +00:00
< ? php
2023-04-15 19:52:33 +00:00
namespace User ;
2023-11-02 13:57:39 +00:00
use Core\Config ;
2022-12-30 19:03:37 +00:00
use Core\Db ;
2023-11-10 15:52:38 +00:00
use Helper\Comparsion ;
2023-08-15 22:48:29 +00:00
use Helper\Conversion ;
2023-04-15 19:52:33 +00:00
use User ;
2022-08-11 10:38:38 +00:00
2023-04-15 19:52:33 +00:00
class Stats
2022-08-11 10:38:38 +00:00
{
2023-08-15 22:48:29 +00:00
private User $u ;
2023-11-10 15:52:38 +00:00
/** Список разрешённых для бонусов системных названий статов
* @ var array
*/
private array $sysNames ;
2023-08-15 22:48:29 +00:00
public function __construct ( User $user )
{
$this -> u = $user ;
2023-11-09 17:24:47 +00:00
$this -> sysNames = Db :: getColumn ( 'select sys_name from const_stats where is_bonus = true' );
$this -> sysNames [ 'hpAll' ] = $this -> sysNames [ 'hpall' ];
$this -> sysNames [ 'mpAll' ] = $this -> sysNames [ 'mpall' ];
unset ( $this -> sysNames [ 'hpall' ], $this -> sysNames [ 'mpall' ]);
2023-08-15 22:48:29 +00:00
}
2022-08-11 10:38:38 +00:00
/**
2023-08-15 22:48:29 +00:00
* Собирает суммы всех бонусов с одетых предметов , комплектов предметов , активных эфектов .
* @ param int $userId
2022-08-11 10:38:38 +00:00
* @ return array
*/
2023-08-15 22:48:29 +00:00
public static function getAllBonuses ( int $userId ) : array
2022-08-11 10:38:38 +00:00
{
2023-08-15 22:48:29 +00:00
$iData = [];
$im = ItemsModel :: getWearedItems ( $userId );
foreach ( $im as $item ) {
$iData [] = $item [ 'data' ];
}
$iData [] = Db :: getValue ( 'select data from eff_users where uid = ? and `delete` = 0' , [ $userId ]);
2022-12-30 19:03:37 +00:00
2022-08-11 10:38:38 +00:00
$params = [];
2023-08-15 22:48:29 +00:00
$complects = [];
2022-08-11 10:38:38 +00:00
foreach ( $iData as $datum ) {
2023-08-15 22:48:29 +00:00
$arr = Conversion :: dataStringToArray ( $datum );
foreach ( $arr as $k => $v ) {
if ( $k === 'complect' ) {
if ( isset ( $complects [ $v ])) {
$complects [ $v ] ++ ;
2022-08-11 10:38:38 +00:00
} else {
2023-08-15 22:48:29 +00:00
$complects [ $v ] = 1 ;
2022-08-11 10:38:38 +00:00
}
}
2023-11-10 15:52:38 +00:00
if ( ! str_contains ( $k , 'add_' )) {
2023-08-15 22:48:29 +00:00
continue ;
}
$k = str_replace ( 'add_' , '' , $k );
self :: setBonusValue ( $params , $k , $v );
}
}
2023-11-10 15:52:38 +00:00
return self :: addComplectsBonuses ( $complects , $params );
2023-08-15 22:48:29 +00:00
}
2023-11-10 15:52:38 +00:00
private static function setBonusValue ( array & $array , $key , $value ) : void
2023-08-15 22:48:29 +00:00
{
if ( isset ( $array [ $key ])) {
$array [ $key ] += $value ;
} else {
$array [ $key ] = $value ;
}
}
/**
* @ param array $complects
* @ param array $params
* @ return array
*/
private static function addComplectsBonuses ( array $complects , array $params ) : array
{
$cdata = [];
if ( ! empty ( $complects )) {
foreach ( $complects as $complectId => $wearedItemsQuantity ) {
$cdata [] = Db :: getValue ( 'select data from complects where com = ? and x <= ? order by x desc limit 1' , [ $complectId , $wearedItemsQuantity ]);
}
foreach ( $cdata as $datum ) {
$arr = Conversion :: dataStringToArray ( $datum );
foreach ( $arr as $k => $v ) {
self :: setBonusValue ( $params , $k , $v );
}
2022-08-11 10:38:38 +00:00
}
}
return $params ;
}
2023-04-15 19:17:40 +00:00
/** Данные для отрисовки логина и полосок жизни\маны .
* @ param User $u
* @ return object
*/
public static function getLoginHpManaBars ( User $u ) : object
{
$hpNow = floor ( $u -> stats [ 'hpNow' ]);
$hpAll = $u -> stats [ 'hpAll' ];
$mpNow = floor ( $u -> stats [ 'mpNow' ]);
$mpAll = $u -> stats [ 'mpAll' ];
//floor(120 / 100 * ($hpNow / $hpAll * 100)); // ??????
$ph = ( $hpAll > 0 && $hpNow > 0 ) ? floor ( 120 / $hpNow / $hpAll ) : 0 ;
$pm = ( $mpAll > 0 && $mpNow > 0 ) ? floor ( 120 / $mpNow / $mpAll ) : 0 ;
return ( object )[
'uid' => $u -> info [ 'id' ],
'login' => $u -> microLogin ( $u -> info [ 'id' ]),
'hpbarwidth' => $ph ,
'mpbarwidth' => $pm ,
'hpbartext' => ' ' . $hpNow . '/' . $hpAll ,
'mpbartext' => ' ' . $mpNow . '/' . $mpAll ,
'divstyle' => $pm === 0 ? ' margin-top:13px;' : '' ,
'hasmana' => $mpAll > 0 ,
];
}
2023-04-15 19:52:33 +00:00
2023-11-02 13:57:39 +00:00
public function getStats ( int | array | null $uid = null , $i1 = 0 , $res = 0 , $reimg = false , $btl_cache = false ) : array
2023-08-15 22:48:29 +00:00
{
2023-11-02 13:57:39 +00:00
if ( empty ( $uid ) || $uid == $this -> u -> info [ 'id' ] && $res != 1 ) {
//$u = $this->u->info;
2023-08-15 22:48:29 +00:00
$u = User :: getInfo ( $uid );
2023-11-02 13:57:39 +00:00
} elseif ( is_array ( $uid )) {
$u = $uid ;
2023-08-15 22:48:29 +00:00
} else {
2023-11-02 13:57:39 +00:00
$u = User :: getInfo ( $uid );
2023-08-15 22:48:29 +00:00
}
2023-11-02 13:57:39 +00:00
if ( ! isset ( $u [ 'id' ])) {
2023-08-15 22:48:29 +00:00
return [];
}
2023-11-10 15:52:38 +00:00
// Как? Нахуя 4 переменные разные для одного и того же?
2023-11-09 17:24:47 +00:00
$st = array_fill_keys ( $this -> sysNames , 0 );
2023-11-10 15:52:38 +00:00
$sti = $st ;
$s_v = $st ;
$s_vi = $st ;
2023-11-09 17:24:47 +00:00
2023-08-15 22:48:29 +00:00
$u [ 'clanpos' ] = 0 ;
if ( $u [ 'clan' ] > 0 ) {
$r1 = Db :: getValue ( 'select pos from aaa_clan_reting_list where clan = ? and date = ? limit 1' , [ $u [ 'clan' ], date ( 'dmY' )]);
if ( ! empty ( $r1 )) {
$st [ 'clanpos' ] = $r1 ;
}
}
$lvl = Db :: getRow ( 'select * from levels where upLevel = ?' , [ $u [ 'upLevel' ]]);
if ( isset ( $lvl [ 'upLevel' ])) {
$st [ 'levels' ] = $lvl ;
} else {
$st [ 'levels' ] = 'undefined' ;
}
2023-11-02 13:57:39 +00:00
2023-08-15 22:48:29 +00:00
$st [ 'id' ] = $u [ 'id' ];
$st [ 'login' ] = $u [ 'login' ];
$st [ 'lvl' ] = $u [ 'level' ];
$st [ 'hpNow' ] = $u [ 'hpNow' ];
$st [ 'hpAll' ] = 0 ;
$st [ 'mpNow' ] = $u [ 'mpNow' ];
$st [ 'mpAll' ] = 0 ;
$st [ 'zona' ] = 1 ;
$st [ 'zonb' ] = 2 ;
$st [ 'items' ] = [];
$st [ 'effects' ] = [];
$st [ 'reting' ] = 0 ;
$st [ 'vip' ] = $u [ 'vip' ];
$stats = Conversion :: dataStringToArray ( $u [ 'stats' ]);
foreach ( $stats as $stat => $value ) {
if ( isset ( $st [ $stat ]) && is_numeric ( $value )) {
$st [ $stat ] += $value ;
} else {
$st [ $stat ] = $value ;
}
}
unset ( $stats );
2023-11-02 13:57:39 +00:00
$baseStats = $st ;
2023-08-15 22:48:29 +00:00
//Шаблонные картинки
if ( $this -> u -> info [ 'id' ] === $u [ 'id' ] || $reimg ) {
$itemsImages = Db :: getRows ( 'select * from items_img where uid = ? and img_id != 0' , [ $u [ 'id' ]]);
2023-04-15 19:52:33 +00:00
2023-08-15 22:48:29 +00:00
foreach ( $itemsImages as $itemsImage ) {
$reimage = Db :: getRow ( 'select * from reimage where ((uid = ? and clan = 0) or clan = ?) and good > 0 and bad = 0 and id = ?' , [ $u [ 'id' ], $u [ 'clan' ], $itemsImage [ 'img_id' ]]);
if ( isset ( $reimage [ 'id' ])) {
$st [ 'items_img' ][ $itemsImage [ 'type' ]] = $reimage [ 'id' ] . '.' . $reimage [ 'format' ];
} else {
Db :: sql ( 'update items_img set img_id = 0 where id = ?' , [ $itemsImage [ 'id' ]]);
}
}
}
2023-11-10 15:52:38 +00:00
[ $hnd1 , $hnd2 , $sht1 , $oza , $ozm , $dom , $coms ] = $this -> addWearedItemsBonuses ( $u [ 'id' ], $st , $s_v , $baseStats );
$this -> addMedalsBonuses ( $u [ 'id' ], $st );
$noeffectbattle = false ;
if ( $u [ 'battle' ] > 0 ) {
$noeffectbattle = ( bool ) Db :: getValue ( " select 1 from battle_actions where uid = ? and vars = 'noeffectbattle1' and btl = ? limit 1 " , [ $u [ 'id' ], $u [ 'battle' ]]);
}
//Характеристики от эффектов
$h = 0 ;
$nbs = array_fill_keys ( range ( 4899 , 4909 ), 0 );
$prsu = [];
if ( ! $noeffectbattle ) {
$efs = Db :: getRows ( " select * from eff_users left join eff_main on id2 = id_eff where uid = ? and deactiveTime < unix_timestamp() and v1 != 'priem' order by id desc " , [ $u [ 'id' ]]);
foreach ( $efs as $e ) {
if ( $u [ 'dnow' ] == 0 ) {
if ( $u [ 'battle' ] == 0 ) {
Db :: sql ( 'delete from eff_users where id_eff = ? and uid = ? and id != ?' , [ $e [ 'id_eff' ], $u [ 'id' ], $e [ 'id' ]]);
//Переводим в заряды
if ( $e [ 'hod' ] != - 1 ) {
Db :: sql ( 'update eff_users set hod = -1, timeUse = unix_timestamp() + ? where id = ?' , [ $e [ 'hod' ] * Config :: get ( 'effz' ) - $e [ 'actionTime' ], $e [ 'id' ]]);
}
} elseif ( Config :: get ( 'effz' ) > 0 && $e [ 'hod' ] == - 1 ) {
$efzz = round (( $e [ 'timeUse' ] + $e [ 'actionTime' ] + $e [ 'timeAce' ]) - time ());
if ( $efzz > 0 ) {
Db :: sql ( 'update eff_users set hod = ? where id = ?' , [ $efzz / Config :: get ( 'effz' ), $e [ 'id' ]]);
}
}
}
if ( $e [ 'timeUse' ] + $e [ 'timeAce' ] + $e [ 'actionTime' ] > time () || $e [ 'timeUse' ] == 77 ) {
if ( $e [ 'v1' ] == 'priem' ) {
$prsu [ $e [ 'v2' ]] = 0 + $prsu [ 'x' ];
}
$st [ 'effects' ][ $h ] = $e ;
$h ++ ;
$sts = Conversion :: dataStringToArray ( $e [ 'data' ]);
if ( isset ( $sts [ 'itempl' ]) && $sts [ 'itempl' ] > 0 ) {
$nbs [ $sts [ 'itempl' ]] += 1 ;
}
if ( isset ( $sts [ 'puti' ])) {
$st [ 'puti' ] = $sts [ 'puti' ];
}
if ( isset ( $sts [ 'add_silver' ])) {
$st [ 'slvtm' ] = $e [ 'timeUse' ] + $e [ 'actionTime' ];
}
$this -> addValuesToAllArrays ( $sts , $st , $sti , $s_v , $s_vi );
} else {
//удаляем эффект
if (
$e [ 'img2' ] != 'tz.gif' ||
$u [ 'id' ] == $this -> u -> info [ 'id' ]
) {
if ( $e [ 'sleeptime' ] == 0 ) {
$this -> u -> endEffect ( $e [ 'id' ], $u );
}
$st [ 'act' ] = 1 ;
}
}
}
} else {
$st [ 'noeffectbattle1' ] = 1 ;
}
$this -> addWearedItemsIllusion ( $nbs , $st );
$this -> addInBattlePriemsBonuses ( $u , $st , $prsu , $sti , $s_v , $s_vi );
//Характеристики от статов
$st [ 'hpAll' ] += $st [ 's4' ] * 5 ;
$st [ 'mpAll' ] += $st [ 's6' ] * 10 ;
//Турнир
$st [ 'm1' ] += $st [ 's3' ] * 5 ;
// мф.анти-крит = 2.5
$st [ 'm2' ] += $st [ 's3' ] * 5 ;
// мф.уворот = 2.5
$st [ 'm4' ] += $st [ 's2' ] * 5 ;
// мф.анти-уворот = 2.5
$st [ 'm5' ] += $st [ 's2' ] * 5 ;
$st [ 'za' ] += $st [ 's4' ] * 1.0 ;
$st [ 'zm' ] += $st [ 's4' ] * 0.0 ;
$st [ 'm19' ] += round ( $st [ 's3' ] * 0.03 );
//Мощности
//Мощность против "Мощность крит. урона". Гамс
$st [ 'antm3' ] += $st [ 's5' ] * 0.5 ;
//Бонусы комплектов
if ( is_iterable ( $coms [ 'new' ])) {
foreach ( $coms [ 'new' ] as $complect ) {
$com = Db :: getValue ( 'select data from complects where com = ? and x <= ? order by x desc limit 1' ,
[
( int ) $complect ,
( int ) $coms [ 'com' ][ $complect ], // кол-во предметов данного комплекта
]);
if ( ! $com ) {
continue ;
}
$sti = Conversion :: dataStringToArray ( $com );
foreach ( $this -> sysNames as $stat ) {
if ( ! isset ( $sti [ $stat ])) {
continue ;
}
$st [ $stat ] += $sti [ $stat ];
}
}
}
//Замена свитков
if ( $u [ 'autospell' ] != 0 && $u [ 'battle' ] == 0 ) {
//проверяем свитки
$sparr = [];
foreach ( Db :: getRows ( 'select item_id, inOdet from items_users where inOdet between 40 and 50 and uid = ? order by item_id desc' , [ $u [ 'id' ]]) as $scroll ) {
$sparr [] = " { $scroll [ 'item_id' ] } - { $scroll [ 'inOdet' ] } " ;
}
$splink = implode ( ',' , $sparr );
//Запоминаем новый комплект свитков
if ( $u [ 'autospell' ] == 1 ) {
$u [ 'autospell' ] = $splink ;
Db :: sql ( 'update users set autospell = ? where id = ?' , [ $splink , $u [ 'id' ]]);
}
//Выдаем нужный свиток, если он есть в инвентаре
if ( $u [ 'autospell' ] != $splink ) {
$spe1 = explode ( ',' , $splink );
$spe2 = explode ( ',' , $u [ 'autospell' ]);
$spe1g = [];
$spe2g = [];
for ( $i = 0 ; $i <= 20 ; $i ++ ) {
$spe1a = explode ( '-' , $spe1 [ $i ]);
$spe2a = explode ( '-' , $spe2 [ $i ]);
if ( isset ( $spe1a [ 0 ])) {
$spe1g [ $spe1a [ 1 ]] = $spe1a [ 0 ];
}
if ( isset ( $spe2a [ 0 ])) {
$spe2g [ $spe2a [ 1 ]] = $spe2a [ 0 ];
}
}
for ( $i = 40 ; $i <= 50 ; $i ++ ) {
if ( $spe1g [ $i ] == $spe2g [ $i ] || $spe1g [ $i ] != 0 ) {
continue ;
}
Db :: sql ( 'update items_users set inOdet = ? where inOdet = 0 and `delete` = 0 and inTransfer = 0 and inShop = 0 and inGroup = 0 and item_id = ? and uid = ?' ,
[ $i , $spe2g [ $i ], $u [ 'id' ]]);
}
}
}
//Бонусы статов
$this -> addStatBonuses ( $st );
//если второе оружие одето
if ( $hnd2 == 1 && $hnd1 == 1 ) {
$st [ 'zona' ] ++ ;
}
if ( $sht1 == 1 ) {
$st [ 'zonb' ] ++ ;
} /* Владения */
//mib1-mib4, mab1-mab4 armor??
if ( isset ( $st [ 's5' ])) {
$st [ 'pm1' ] += $st [ 's5' ] * 0.5 ;
$st [ 'pm2' ] += $st [ 's5' ] * 0.5 ;
$st [ 'pm3' ] += $st [ 's5' ] * 0.5 ;
$st [ 'pm4' ] += $st [ 's5' ] * 0.5 ;
$st [ 'pm5' ] += $st [ 's5' ] * 0.5 ;
$st [ 'pm6' ] += $st [ 's5' ] * 0.5 ;
$st [ 'pm7' ] += $st [ 's5' ] * 0.5 ;
}
if ( isset ( $st [ 'm11a' ])) {
$st [ 'pm1' ] += $st [ 'm11a' ] * 0.5 ;
$st [ 'pm2' ] += $st [ 'm11a' ] * 0.5 ;
$st [ 'pm3' ] += $st [ 'm11a' ] * 0.5 ;
$st [ 'pm4' ] += $st [ 'm11a' ] * 0.5 ;
$st [ 'pm5' ] += $st [ 'm11a' ] * 0.5 ;
$st [ 'pm6' ] += $st [ 'm11a' ] * 0.5 ;
$st [ 'pm7' ] += $st [ 'm11a' ] * 0.5 ;
}
if ( isset ( $st [ 'aall' ])) {
$st [ 'a1' ] += $st [ 'aall' ];
$st [ 'a2' ] += $st [ 'aall' ];
$st [ 'a3' ] += $st [ 'aall' ];
$st [ 'a4' ] += $st [ 'aall' ];
$st [ 'a5' ] += $st [ 'aall' ];
$st [ 'a6' ] += $st [ 'aall' ];
$st [ 'a7' ] += $st [ 'aall' ];
}
if ( isset ( $st [ 'm2all' ])) {
$st [ 'mg1' ] += $st [ 'm2all' ];
$st [ 'mg2' ] += $st [ 'm2all' ];
$st [ 'mg3' ] += $st [ 'm2all' ];
$st [ 'mg4' ] += $st [ 'm2all' ];
$st [ 'mg5' ] += $st [ 'm2all' ];
$st [ 'mg6' ] += $st [ 'm2all' ];
$st [ 'mg7' ] += $st [ 'm2all' ];
}
if ( isset ( $st [ 'zm' ])) {
$st [ 'zm1' ] += $st [ 'zm' ];
$st [ 'zm2' ] += $st [ 'zm' ];
$st [ 'zm3' ] += $st [ 'zm' ];
$st [ 'zm4' ] += $st [ 'zm' ];
$st [ 'zm5' ] += $st [ 'zm' ];
$st [ 'zm6' ] += $st [ 'zm' ];
$st [ 'zm7' ] += $st [ 'zm' ];
}
if ( isset ( $st [ 'zma' ])) {
$st [ 'zm1' ] += $st [ 'zma' ];
$st [ 'zm2' ] += $st [ 'zma' ];
$st [ 'zm3' ] += $st [ 'zma' ];
$st [ 'zm4' ] += $st [ 'zma' ];
$st [ 'zm5' ] += $st [ 'zma' ];
$st [ 'zm6' ] += $st [ 'zma' ];
$st [ 'zm7' ] += $st [ 'zma' ];
}
if ( isset ( $st [ 'mall' ])) {
$st [ 'mg1' ] += $st [ 'mall' ];
$st [ 'mg2' ] += $st [ 'mall' ];
$st [ 'mg3' ] += $st [ 'mall' ];
$st [ 'mg4' ] += $st [ 'mall' ];
}
if ( isset ( $st [ 'm11' ])) {
$st [ 'pm1' ] += $st [ 'm11' ];
$st [ 'pm2' ] += $st [ 'm11' ];
$st [ 'pm3' ] += $st [ 'm11' ];
$st [ 'pm4' ] += $st [ 'm11' ];
}
if ( isset ( $st [ 'm10' ])) {
$st [ 'pa1' ] += $st [ 'm10' ];
$st [ 'pa2' ] += $st [ 'm10' ];
$st [ 'pa3' ] += $st [ 'm10' ];
$st [ 'pa4' ] += $st [ 'm10' ];
}
if ( isset ( $st [ 'za' ])) {
$st [ 'za1' ] += $st [ 'za' ];
$st [ 'za2' ] += $st [ 'za' ];
$st [ 'za3' ] += $st [ 'za' ];
$st [ 'za4' ] += $st [ 'za' ];
}
$st [ 'yzm1' ] += $st [ 'yzma' ];
$st [ 'yzm2' ] += $st [ 'yzma' ];
$st [ 'yzm3' ] += $st [ 'yzma' ];
$st [ 'yzm4' ] += $st [ 'yzma' ];
$st [ 'yzm5' ] += $st [ 'yzma' ];
$st [ 'yzm6' ] += $st [ 'yzma' ];
$st [ 'yzm7' ] += $st [ 'yzma' ];
$st [ 'yzm1' ] += $st [ 'yzm' ]; //стихийный урон только
$st [ 'yzm2' ] += $st [ 'yzm' ];
$st [ 'yzm3' ] += $st [ 'yzm' ];
$st [ 'yzm4' ] += $st [ 'yzm' ];
$st [ 'yza1' ] += $st [ 'yza' ]; //урон оружия
$st [ 'yza2' ] += $st [ 'yza' ];
$st [ 'yza3' ] += $st [ 'yza' ];
$st [ 'yza4' ] += $st [ 'yza' ];
//Отнимает от защиты от урона
if ( $st [ 'yza1' ] > 0 ) {
$st [ 'za1' ] = max ( $st [ 'za1' ] / 100 * ( 100 + $st [ 'yza1' ]), 0 );
}
if ( $st [ 'yza2' ] > 0 ) {
$st [ 'za2' ] = max ( $st [ 'za2' ] / 100 * ( 100 + $st [ 'yza2' ]), 0 );
}
if ( $st [ 'yza3' ] > 0 ) {
$st [ 'za3' ] = max ( $st [ 'za3' ] / 100 * ( 100 + $st [ 'yza3' ]), 0 );
}
if ( $st [ 'yza4' ] > 0 ) {
$st [ 'za4' ] = max ( $st [ 'za4' ] / 100 * ( 100 + $st [ 'yza4' ]), 0 );
}
//Отнимает от защиты от магии
if ( $st [ 'yzm1' ] > 0 ) {
$st [ 'zm1' ] = max ( $st [ 'zm1' ] / 100 * ( 100 + $st [ 'yzm1' ]), 0 );
}
if ( $st [ 'yzm2' ] > 0 ) {
$st [ 'zm2' ] = max ( $st [ 'zm2' ] / 100 * ( 100 + $st [ 'yzm2' ]), 0 );
}
if ( $st [ 'yzm3' ] > 0 ) {
$st [ 'zm3' ] = max ( $st [ 'zm3' ] / 100 * ( 100 + $st [ 'yzm3' ]), 0 );
}
if ( $st [ 'yzm4' ] > 0 ) {
$st [ 'zm4' ] = max ( $st [ 'zm4' ] / 100 * ( 100 + $st [ 'yzm4' ]), 0 );
}
if ( $st [ 'yzm7' ] > 0 ) {
$st [ 'zm7' ] = max ( $st [ 'zm7' ] / 100 * ( 100 + $st [ 'yzm7' ]), 0 );
}
if ( ! empty ( $st [ 'hpVinos' ])) {
$st [ 'hpAll' ] += round ( $st [ 'hpVinos' ] * $st [ 's4' ]);
}
if ( ! empty ( $st [ 'mpVinos' ])) {
$st [ 'mpAll' ] += round ( $st [ 'mpVinos' ] * $st [ 's6' ]);
}
if ( ! empty ( $st [ 'hpProc' ])) {
$st [ 'hpAll' ] += round ( $st [ 'hpAll' ] / 100 * $st [ 'hpProc' ]);
}
if ( ! empty ( $st [ 'mpProc' ])) {
$st [ 'mpAll' ] += round ( $st [ 'mpAll' ] / 100 * $st [ 'mpProc' ]);
}
//Реген. - 250 ед.
//конец бонусов
$st [ 'hpNow' ] = Comparsion :: minimax ( $st [ 'hpNow' ], 0 , $st [ 'hpAll' ]);
$st [ 'mpNow' ] = Comparsion :: minimax ( $st [ 'mpNow' ], 0 , $st [ 'mpAll' ]);
//зоны блока и удара
if ( $st [ 'zona' ] < 1 ) {
$st [ 'zona' ] = 1 ;
}
if ( $st [ 'zona' ] > 5 ) {
$st [ 'zona' ] = 5 ;
}
if ( $st [ 'zonb' ] < 1 ) {
$st [ 'zonb' ] = 1 ;
}
if ( $st [ 'zonb' ] > 3 ) {
$st [ 'zonb' ] = 3 ;
}
$st [ 'ozash' ] = $oza ;
$st [ 'ozmsh' ] = $ozm ;
$st [ 'weapon1' ] = $hnd1 ;
$st [ 'weapon2' ] = $hnd2 ;
$st [ 'sheld1' ] = $sht1 ;
$st [ 'sv_' ] = $s_v ;
$st [ 'sv_i' ] = $s_vi ;
$st [ 'dom' ] = $dom ;
$st [ 'prsu' ] = $prsu ;
$st [ 'x' ] = $u [ 'x' ];
$st [ 'y' ] = $u [ 'y' ];
$st [ 's' ] = $u [ 's' ];
$this -> addDungeonsBonuses ( $u [ 'id' ], $st );
//Добавочный подьем для игроков
$st [ 'maxves' ] += 100 ;
$this -> addAdminBonuses ( $u , $st );
if ( date ( 'H' ) >= 22 && date ( 'H' ) <= 10 ) {
$st [ 'exp' ] += 25 ;
}
//Сохраняем рейтинг игрока
$st [ 'reting' ] = floor ( $st [ 'reting' ]);
if ( isset ( $st [ 'btl_cof' ], $st [ 'prckr' ]) && $st [ 'btl_cof' ] != $st [ 'prckr' ]) {
$st [ 'btl_cof' ] = $st [ 'prckr' ];
Db :: sql ( 'update stats set btl_cof = ? where id = ?' , [ $st [ 'prckr' ], $st [ 'id' ]]);
}
if ( $st [ 'hpAll' ] < 1 ) {
$st [ 'hpAll' ] = 1 ;
}
if ( $st [ 'mpAll' ] < 0 ) {
$st [ 'mpAll' ] = 0 ;
}
if ( stristr ( $u [ 'login' ], '(зверь ' ) || ( stristr ( $u [ 'login' ], 'Каменный страж' ) && $u [ 'ip' ] == '0' )) {
$st [ 'this_animal' ] = 1 ;
} else {
$st [ 'this_animal' ] = 0 ;
}
$rt = [];
if ( $i1 == 1 ) {
$rt [ 0 ] = $st ;
$rt [ 1 ] = $baseStats ; //родные статы
} else {
$rt = $st ;
}
if ( $u [ 'hpAll' ] != $st [ 'hpAll' ] || $u [ 'mpAll' ] != $st [ 'mpAll' ]) {
Db :: sql ( 'update stats set hpAll = ?, mpAll = ? where id = ?' , [ $st [ 'hpAll' ], $st [ 'mpAll' ], $u [ 'id' ]]);
}
if ( $btl_cache ) {
$dataca = [
'st' => $st ,
'st2' => $baseStats ,
];
$dataca = json_encode ( $dataca );
Db :: sql ( 'insert into battle_cache (battle, uid, time, data) values (?,?,unix_timestamp(),?)' , [ $u [ 'battle' ], $u [ 'id' ], $dataca ]);
}
return $rt ;
}
private function addWearedItemsBonuses ( int $uid , array & $st , array & $s_v , array $baseStats ) : array
{
2023-08-15 22:48:29 +00:00
//Характеристики от предметов //Т У Т tr_lvl
// Вся вторая строчка - спасибо Users.
$wearedItems = Db :: getRows ( ' select type , data , inOdet ,
item_id , inslot , useInBattle , btl_zd , iznosNOW , iznosMAX , magic_inci , name , items_users . id , img , `2h`
2023-11-10 15:52:38 +00:00
from items_users left join items_main on items_main . id = item_id where inOdet != 0 and uid = ? ' , [ $uid ]);
2023-08-15 22:48:29 +00:00
$h = 0 ;
$hnd1 = 0 ;
$hnd2 = 0 ;
$sht1 = 0 ;
$reitm = [];
$coms = []; // комплекты
$dom = [];
$oza = [
1 => [ 0 , 0 ],
2 => [ 0 , 0 ],
3 => [ 0 , 0 ],
4 => [ 0 , 0 ],
]; //особенности защиты
$ozm = [
1 => [ 0 , 0 ],
2 => [ 0 , 0 ],
3 => [ 0 , 0 ],
4 => [ 0 , 0 ],
]; //особенности магии
$st [ 'reting' ] = 0 ;
foreach ( $wearedItems as $wearedItem ) {
$st [ 'wp' . $wearedItem [ 'inOdet' ] . 'id' ] = $h ;
$st [ 'items' ][ $h ] = $wearedItem ;
$h ++ ;
2023-11-10 15:52:38 +00:00
if ( $wearedItem [ 'inOdet' ] == 3 &&
(( $wearedItem [ 'type' ] >= 18 && $wearedItem [ 'type' ] <= 24 ) ||
$wearedItem [ 'type' ] == 26 ||
$wearedItem [ 'type' ] == 27 ||
$wearedItem [ 'type' ] == 28 )) {
2023-08-15 22:48:29 +00:00
$hnd1 = 1 ;
}
2023-11-10 15:52:38 +00:00
if ( $wearedItem [ 'inOdet' ] == 14 &&
(( $wearedItem [ 'type' ] >= 18 && $wearedItem [ 'type' ] <= 24 ) ||
$wearedItem [ 'type' ] == 26 ||
$wearedItem [ 'type' ] == 27 ||
$wearedItem [ 'type' ] == 28 )) {
2023-08-15 22:48:29 +00:00
$hnd2 = 1 ;
} elseif ( $wearedItem [ 'inOdet' ] == 14 && $wearedItem [ 'type' ] == 13 ) {
$sht1 = 1 ;
}
2023-11-09 17:24:47 +00:00
$sti = Conversion :: dataStringToArray ( $wearedItem [ 'data' ]);
2023-08-15 22:48:29 +00:00
if ( $wearedItem [ 'inOdet' ] <= 18 && $wearedItem [ 'inOdet' ] > 0 ) {
$st [ 'reting' ] += 1 ;
}
$ko = 1 ;
while ( $ko <= 4 ) {
if ( isset ( $sti [ 'add_oza' . $ko ])) {
if ( isset ( $sti [ 'add_oza' ])) {
if ( $sti [ 'add_oza' ] == 1 ) {
//Слабая
$oza [ $ko ][ 0 ] += 1 ;
$oza [ $ko ][ 1 ] += 9 ;
} elseif ( $sti [ 'add_oza' ] == 2 ) {
//Нормальная
$oza [ $ko ][ 0 ] += 20 ;
$oza [ $ko ][ 1 ] += 39 ;
} elseif ( $sti [ 'add_oza' ] == 3 ) {
//Хорошая
$oza [ $ko ][ 0 ] += 40 ;
$oza [ $ko ][ 1 ] += 69 ;
} elseif ( $sti [ 'add_oza' ] == 4 ) {
//Посредственная
$oza [ $ko ][ 0 ] += 10 ;
$oza [ $ko ][ 1 ] += 19 ;
} elseif ( $sti [ 'add_oza' ] == 5 ) {
//Великолепная
$oza [ $ko ][ 0 ] += 70 ;
$oza [ $ko ][ 1 ] += 89 ;
}
}
if ( isset ( $sti [ 'add_ozm' ])) {
if ( $sti [ 'add_ozm' ] == 1 ) {
//Слабая
$ozm [ $ko ][ 0 ] += 1 ;
$ozm [ $ko ][ 1 ] += 9 ;
} elseif ( $sti [ 'add_ozm' ] == 2 ) {
//Нормальная
$ozm [ $ko ][ 0 ] += 20 ;
$ozm [ $ko ][ 1 ] += 39 ;
} elseif ( $sti [ 'add_ozm' ] == 3 ) {
//Хорошая
$ozm [ $ko ][ 0 ] += 40 ;
$ozm [ $ko ][ 1 ] += 69 ;
} elseif ( $sti [ 'add_ozm' ] == 4 ) {
//Посредственная
$ozm [ $ko ][ 0 ] += 10 ;
$ozm [ $ko ][ 1 ] += 19 ;
} elseif ( $sti [ 'add_ozm' ] == 5 ) {
//Великолепная
$ozm [ $ko ][ 0 ] += 70 ;
$ozm [ $ko ][ 1 ] += 89 ;
}
} else {
$ozm [ $ko ][ 0 ] += 1 ;
$ozm [ $ko ][ 1 ] += 9 ;
}
if ( $sti [ 'add_oza' . $ko ] == 1 ) {
//Слабая
$oza [ $ko ][ 0 ] += 1 ;
$oza [ $ko ][ 1 ] += 9 ;
} elseif ( $sti [ 'add_oza' . $ko ] == 2 ) {
//Нормальная
$oza [ $ko ][ 0 ] += 20 ;
$oza [ $ko ][ 1 ] += 39 ;
} elseif ( $sti [ 'add_oza' . $ko ] == 3 ) {
//Хорошая
$oza [ $ko ][ 0 ] += 40 ;
$oza [ $ko ][ 1 ] += 69 ;
} elseif ( $sti [ 'add_oza' . $ko ] == 4 ) {
//Посредственная
$oza [ $ko ][ 0 ] += 10 ;
$oza [ $ko ][ 1 ] += 19 ;
} elseif ( $sti [ 'add_oza' . $ko ] == 5 ) {
//Великолепная
$oza [ $ko ][ 0 ] += 70 ;
$oza [ $ko ][ 1 ] += 89 ;
}
if ( isset ( $sti [ 'add_ozm' . $ko ])) {
if ( $sti [ 'add_ozm' . $ko ] == 1 ) {
//Слабая
$ozm [ $ko ][ 0 ] += 1 ;
$ozm [ $ko ][ 1 ] += 9 ;
} elseif ( $sti [ 'add_ozm' . $ko ] == 2 ) {
//Нормальная
$ozm [ $ko ][ 0 ] += 20 ;
$ozm [ $ko ][ 1 ] += 39 ;
} elseif ( $sti [ 'add_ozm' . $ko ] == 3 ) {
//Хорошая
$ozm [ $ko ][ 0 ] += 40 ;
$ozm [ $ko ][ 1 ] += 69 ;
} elseif ( $sti [ 'add_ozm' . $ko ] == 4 ) {
//Посредственная
$ozm [ $ko ][ 0 ] += 10 ;
$ozm [ $ko ][ 1 ] += 19 ;
} elseif ( $sti [ 'add_ozm' . $ko ] == 5 ) {
//Великолепная
$ozm [ $ko ][ 0 ] += 70 ;
$ozm [ $ko ][ 1 ] += 89 ;
}
} else {
$ozm [ $ko ][ 0 ] += 1 ;
$ozm [ $ko ][ 1 ] += 9 ;
}
}
$ko ++ ;
}
if ( isset ( $sti [ 'art' ])) {
if ( ! isset ( $st [ 'art' ])) {
$st [ 'art' ] = 0 ;
}
$st [ 'art' ] += $sti [ 'art' ];
}
if ( isset ( $sti [ 'maks_itm' ])) {
if ( ! isset ( $st [ 'maks_itm' ])) {
$st [ 'maks_itm' ] = 0 ;
}
$st [ 'maks_itm' ] += $sti [ 'maks_itm' ];
}
if ( isset ( $sti [ 'complect' ])) {
$coms [ count ( $coms )][ 'id' ] = $sti [ 'complect' ];
if ( ! isset ( $coms [ 'com' ][ $sti [ 'complect' ]])) {
$coms [ 'com' ][ $sti [ 'complect' ]] = 0 ;
if ( ! isset ( $coms [ 'new' ])) {
$coms [ 'new' ] = [];
}
$coms [ 'new' ][ count ( $coms [ 'new' ])] = $sti [ 'complect' ];
}
$coms [ 'com' ][ $sti [ 'complect' ]] ++ ;
}
2023-11-10 15:52:38 +00:00
2023-08-15 22:48:29 +00:00
if ( isset ( $sti [ 'complect2' ])) {
$coms [ count ( $coms )][ 'id' ] = $sti [ 'complect2' ];
if ( ! isset ( $coms [ 'com' ][ $sti [ 'complect2' ]])) {
$coms [ 'com' ][ $sti [ 'complect2' ]] = 0 ;
if ( ! isset ( $coms [ 'new' ])) {
$coms [ 'new' ] = [];
}
$coms [ 'new' ][ count ( $coms [ 'new' ])] = $sti [ 'complect2' ];
}
$coms [ 'com' ][ $sti [ 'complect2' ]] ++ ;
}
if ( isset ( $sti [ 'zonb' ]) && $sti [ 'zonb' ] != 0 ) {
if ( ! isset ( $st [ 'zonb' ])) {
$st [ 'zonb' ] = 0 ;
}
$st [ 'zonb' ] += $sti [ 'zonb' ];
}
if ( isset ( $sti [ 'zona' ]) && $sti [ 'zona' ] != 0 ) {
if ( ! isset ( $st [ 'zona' ])) {
$st [ 'zona' ] = 0 ;
}
$st [ 'zona' ] += $sti [ 'zona' ];
}
//Добавляем статы от данного предмета
if ( ! isset ( $sti [ 'restart_stats' ])) {
2023-11-10 15:52:38 +00:00
foreach ( $this -> sysNames as $stat ) {
if ( ! isset ( $sti [ 'add_' . $stat ])) {
continue ;
2023-08-15 22:48:29 +00:00
}
2023-11-10 15:52:38 +00:00
$st [ $stat ] += ( int ) $sti [ 'add_' . $stat ];
2023-08-15 22:48:29 +00:00
}
} else {
$reitm [] = $sti ;
}
2023-11-09 17:24:47 +00:00
2023-11-10 15:52:38 +00:00
foreach ( $this -> sysNames as $stat ) {
if ( ! isset ( $sti [ 'sv_' . $stat ])) {
continue ;
2023-08-15 22:48:29 +00:00
}
2023-11-10 15:52:38 +00:00
$s_v [ $stat ] += ( int ) $sti [ 'sv_' . $stat ];
2023-08-15 22:48:29 +00:00
}
}
//Сохраненные х а р -ки и умения
if ( ! empty ( $reitm )) {
$i39 = [ 0 => 0 , 1 => 0 , 2 => 0 ];
$i = 0 ;
while ( $i < count ( $reitm )) {
if ( isset ( $reitm [ $i ][ 'sm_skill' ]) && $i39 [ 0 ] == 0 ) {
//умения
$i9 = 1 ;
$i39 [ 0 ] = 1 ;
while ( $i9 <= 7 ) {
2023-11-02 13:57:39 +00:00
$st [ 'a' . $i9 ] = $st [ 'a' . $i9 ] - $baseStats [ 'a' . $i9 ] + $reitm [ $i ][ 'add_a' . $i9 ];
$st [ 'mg' . $i9 ] = $st [ 'mg' . $i9 ] - $baseStats [ 'mg' . $i9 ] + $reitm [ $i ][ 'add_mg' . $i9 ];
2023-08-15 22:48:29 +00:00
$i9 ++ ;
}
} elseif ( isset ( $reitm [ $i ][ 'sm_abil' ]) && $i39 [ 1 ] == 0 ) {
//статы
$i9 = 1 ;
$i39 [ 1 ] = 1 ;
while ( $i9 <= 12 ) {
2023-11-02 13:57:39 +00:00
$st [ 's' . $i9 ] = $st [ 's' . $i9 ] - $baseStats [ 's' . $i9 ] + $reitm [ $i ][ 'add_s' . $i9 ];
2023-08-15 22:48:29 +00:00
$i9 ++ ;
}
} elseif ( isset ( $reitm [ $i ][ 'sm_skill2' ]) && $i39 [ 2 ] == 0 ) {
//навыки
$i39 [ 2 ] = 1 ;
}
$i ++ ;
}
}
2023-11-10 15:52:38 +00:00
return [ $hnd1 , $hnd2 , $sht1 , $oza , $ozm , $dom , $coms ];
}
2023-08-15 22:48:29 +00:00
2023-11-10 15:52:38 +00:00
private function addMedalsBonuses ( int $uid , array & $st ) : void
{
//Харки от иконок
2023-08-15 22:48:29 +00:00
2023-11-10 15:52:38 +00:00
$efs = Db :: getColumn ( 'select bonus from users_ico where uid = ? and (endTime > unix_timestamp() or endTime = 0)' , [ $uid ]);
foreach ( $efs as $data ) {
$sts = Conversion :: dataStringToArray ( $data );
foreach ( $sts as $paramName => $value ) {
//todo убедиться, что не могут прилететь параметры, которых нет в словарей бонусов предметов
if ( ! str_contains ( implode ( ',' , $this -> sysNames ), 'add_' . $paramName )) { // есть ли параметр в разрешенных?
continue ;
2023-08-15 22:48:29 +00:00
}
2023-11-10 15:52:38 +00:00
if ( empty ( $st [ 'add_' . $paramName ])) {
$st [ 'add_' . $paramName ] = 0 ;
}
$st [ 'add_' . $paramName ] += ( int ) $value ;
}
}
}
2023-11-09 17:24:47 +00:00
2023-11-10 15:52:38 +00:00
private function addValuesToAllArrays ( array $sts , array & $st , array & $sti , array & $s_v , array & $s_vi ) : void
{
foreach ( $this -> sysNames as $stat ) {
if ( ! isset ( $sts [ 'add_' . $stat ])) {
continue ;
}
$st [ $stat ] += intval ( $sts [ 'add_' . $stat ]);
$sti [ $stat ] += intval ( $sts [ 'add_' . $stat ]);
2023-11-09 17:24:47 +00:00
2023-11-10 15:52:38 +00:00
if ( ! isset ( $sts [ 'sv_' . $stat ])) {
continue ;
2023-08-15 22:48:29 +00:00
}
2023-11-10 15:52:38 +00:00
$s_v [ $stat ] += intval ( $sts [ 'sv_' . $stat ]);
$s_vi [ $stat ] += intval ( $sts [ 'sv_' . $stat ]);
}
}
private function addWearedItemsIllusion ( array $nbs , array & $st ) : void
{
//Заглушки от эффектов
2023-08-15 22:48:29 +00:00
if ( $nbs [ 4899 ] > 0 ) {
//Зеленый комплект
$st [ 'items_img' ][ 8 ] = 'robe_illusion4.gif' ;
$st [ 'items_img' ][ 11 ] = 'leg_illusion4.gif' ;
} elseif ( $nbs [ 4900 ] > 0 ) {
//Золото комплект
$st [ 'items_img' ][ 8 ] = 'robe_illusion5.gif' ;
$st [ 'items_img' ][ 11 ] = 'leg_illusion5.gif' ;
} elseif ( $nbs [ 4901 ] > 0 ) {
//Голубой комплект
$st [ 'items_img' ][ 8 ] = 'robe_illusion3.gif' ;
$st [ 'items_img' ][ 11 ] = 'leg_illusion3.gif' ;
} elseif ( $nbs [ 4902 ] > 0 ) {
//Синий комплект
$st [ 'items_img' ][ 8 ] = 'robe_illusion6.gif' ;
$st [ 'items_img' ][ 11 ] = 'leg_illusion6.gif' ;
} elseif ( $nbs [ 4903 ] > 0 ) {
//Желтый комплект
$st [ 'items_img' ][ 8 ] = 'robe_illusion8.gif' ;
$st [ 'items_img' ][ 11 ] = 'leg_illusion8.gif' ;
} elseif ( $nbs [ 4904 ] > 0 ) {
//Сиреневое платье
$st [ 'items_img' ][ 8 ] = 'robe_illusion7.gif' ;
$st [ 'items_img' ][ 11 ] = 'leg_illusion7.gif' ;
} elseif ( $nbs [ 4905 ] > 0 ) {
//Оранжевое платье
$st [ 'items_img' ][ 8 ] = 'robe_illusion9.gif' ;
$st [ 'items_img' ][ 11 ] = 'leg_illusion9.gif' ;
} elseif ( $nbs [ 4908 ] > 0 ) {
//Н а б о р Темной Одежды
$st [ 'items_img' ][ 8 ] = 'robe_illusion2.gif' ;
$st [ 'items_img' ][ 11 ] = 'leg_illusion2.gif' ;
$st [ 'items_img' ][ 10 ] = 'boots_illusion2.gif' ;
$st [ 'items_img' ][ 9 ] = 'belt_illusion2.gif' ;
$st [ 'items_img' ][ 5 ] = 'naruchi_illusion2.gif' ;
$st [ 'items_img' ][ 4 ] = 'helmet_illusion2.gif' ;
$st [ 'items_img' ][ 12 ] = 'perchi_illusion2.gif' ;
} elseif ( $nbs [ 4906 ] > 0 ) {
//Н а б о р Бриллиантовой Одежды
$st [ 'items_img' ][ 8 ] = 'robe_illusion1.gif' ;
$st [ 'items_img' ][ 11 ] = 'leg_illusion1.gif' ;
$st [ 'items_img' ][ 10 ] = 'boots_illusion1.gif' ;
$st [ 'items_img' ][ 9 ] = 'belt_illusion1.gif' ;
$st [ 'items_img' ][ 5 ] = 'naruchi_illusion1.gif' ;
$st [ 'items_img' ][ 4 ] = 'helmet_illusion1.gif' ;
$st [ 'items_img' ][ 12 ] = 'perchi_illusion1.gif' ;
}
if ( $nbs [ 4909 ] > 0 ) {
//Н а б о р Золотых украшений
$st [ 'items_img' ][ 13 ] = 'ring_illusion2.gif' ;
$st [ 'items_img' ][ 17 ] = 'ring_illusion2.gif' ;
$st [ 'items_img' ][ 18 ] = 'ring_illusion2.gif' ;
$st [ 'items_img' ][ 14 ] = 'amulet_illusion2.gif' ;
$st [ 'items_img' ][ 15 ] = 'earrings_illusion2.gif' ;
} elseif ( $nbs [ 4907 ] > 0 ) {
//Н а б о р Золотых украшений
$st [ 'items_img' ][ 13 ] = 'ring_illusion1.gif' ;
$st [ 'items_img' ][ 17 ] = 'ring_illusion1.gif' ;
$st [ 'items_img' ][ 18 ] = 'ring_illusion1.gif' ;
$st [ 'items_img' ][ 14 ] = 'amulet_illusion1.gif' ;
$st [ 'items_img' ][ 15 ] = 'earrings_illusion1.gif' ;
}
2023-11-10 15:52:38 +00:00
}
2023-08-15 22:48:29 +00:00
2023-11-10 15:52:38 +00:00
private function addInBattlePriemsBonuses ( array $u , array & $st , array & $prsu , array & $sti , array & $s_v , array & $s_vi ) : void
{
if ( $u [ 'battle' ] <= 0 ) {
return ;
}
//Характеристики от приемов
$st [ 'set_pog' ] = [];
$st [ 'set_pog2' ] = [];
$efs = Db :: getRows ( " select * from eff_users where uid = ? and deactiveTime < unix_timestamp() and v1 = 'priem' order by id " , [ $u [ 'id' ]]);
$h = 0 ;
foreach ( $efs as $e ) {
$e [ 'type1' ] = 14 ;
$e [ 'img' ] = $e [ 'img2' ];
if ( $e [ 'tr_life_user' ] > 0 ) {
$trlu = Db :: getValue ( 'select hpNow from stats where id = ?' , [ $e [ 'tr_life_user' ]]);
if ( ! $trlu || $trlu < 1 ) {
2023-08-15 22:48:29 +00:00
$this -> u -> endEffect ( $e [ 'id' ], $u );
$st [ 'act' ] = 1 ;
}
}
2023-11-10 15:52:38 +00:00
if ( $e [ 'timeUse' ] + $e [ 'timeAce' ] + $e [ 'actionTime' ] > time () || $e [ 'timeUse' ] == 77 ) {
if ( $e [ 'v1' ] == 'priem' ) {
$prsu [ $e [ 'v2' ]] = 0 + $prsu [ 'x' ];
2023-08-15 22:48:29 +00:00
}
2023-11-10 15:52:38 +00:00
$st [ 'effects' ][ $h ] = $e ;
$h ++ ;
$sts = Conversion :: dataStringToArray ( $e [ 'data' ]);
if ( $e [ 'v2' ] == 217 ) {
$st [ 'raztac' ] = 1 ;
2023-11-02 13:57:39 +00:00
}
2023-11-10 15:52:38 +00:00
if ( isset ( $sts [ 'add_pog' ])) {
$ctt = count ( $st [ 'set_pog' ]);
$st [ 'set_pog' ][ $ctt ][ 'id' ] = $h ;
$st [ 'set_pog' ][ $ctt ][ 'y' ] = $sts [ 'add_pog' ];
unset ( $ctt );
2023-11-02 13:57:39 +00:00
}
2023-11-10 15:52:38 +00:00
if ( isset ( $sts [ 'natoe' ])) {
$st [ 'set_natoe' ][ 'id' ] = $h ;
$st [ 'set_natoe' ][ 'a' ] = 0 + $sts [ 'natoe_end' ];
$st [ 'set_natoe' ][ 'b' ] = 0 + $sts [ 'natoe' ];
$st [ 'set_natoe' ][ 'eff_id' ] = $e [ 'id' ];
$st [ 'set_natoe' ][ 't' ] = 0 + $sts [ 'natoe_type' ];
$st [ 'set_natoe' ][ 'user_id' ] = $e [ 'tr_life_user' ];
2023-11-02 13:57:39 +00:00
}
2023-11-10 15:52:38 +00:00
if ( isset ( $sts [ 'add_pog2' ])) {
$ctt = count ( $st [ 'set_pog2' ]);
$st [ 'set_pog2' ][ $ctt ][ 'id' ] = $h ;
$st [ 'set_pog2' ][ $ctt ][ 'y' ] = $sts [ 'add_pog2' ];
$st [ 'set_pog2' ][ $ctt ][ 'p' ] = $sts [ 'add_pog2p' ];
$st [ 'set_pog2' ][ $ctt ][ 'm' ] = $sts [ 'add_pog2mp' ];
unset ( $ctt );
2023-11-02 13:57:39 +00:00
}
2023-11-10 15:52:38 +00:00
$this -> addValuesToAllArrays ( $sts , $st , $sti , $s_v , $s_vi );
2023-11-02 13:57:39 +00:00
2023-11-10 15:52:38 +00:00
} else {
//удаляем эффект
$this -> u -> endEffect ( $e [ 'id' ], $u );
$st [ 'act' ] = 1 ;
2023-11-02 13:57:39 +00:00
}
}
}
private function addStatBonuses ( array & $st ) : void
{
$this -> addStrengthBonuses ( $st );
$this -> addDexterityBonuses ( $st );
$this -> addIntuitionBonuses ( $st );
$this -> addEnduranceBonuses ( $st );
$this -> addIntelligenceBonuses ( $st );
$this -> addWisdomBonuses ( $st );
}
private function addStrengthBonuses ( array & $st ) : void
{
2023-08-15 22:48:29 +00:00
if ( $st [ 's1' ] > 24 && $st [ 's1' ] < 50 ) {
$st [ 'm2' ] += 15 ;
}
if ( $st [ 's1' ] > 49 && $st [ 's1' ] < 75 ) {
$st [ 'pa2' ] += 2 ;
$st [ 'm2' ] += 35 ;
}
if ( $st [ 's1' ] > 74 && $st [ 's1' ] < 100 ) {
$st [ 'pa2' ] += 5 ;
$st [ 'm2' ] += 50 ;
}
if ( $st [ 's1' ] > 99 && $st [ 's1' ] < 125 ) {
$st [ 'pa2' ] += 8 ;
$st [ 'm2' ] += 80 ;
}
if ( $st [ 's1' ] > 124 && $st [ 's1' ] < 150 ) {
$st [ 'pa2' ] += 12 ;
$st [ 'm2' ] += 105 ;
}
if ( $st [ 's1' ] > 149 && $st [ 's1' ] < 175 ) {
$st [ 'pa2' ] += 17 ;
$st [ 'm7' ] += 2 ;
}
if ( $st [ 's1' ] > 174 && $st [ 's1' ] < 200 ) {
$st [ 'pa2' ] += 23 ;
$st [ 'm7' ] += 5 ;
}
if ( $st [ 's1' ] > 199 ) {
$st [ 'pa2' ] += 30 ;
$st [ 'm7' ] += 7 ;
}
2023-11-02 13:57:39 +00:00
}
private function addDexterityBonuses ( array & $st ) : void
{
2023-08-15 22:48:29 +00:00
if ( $st [ 's2' ] > 24 && $st [ 's2' ] < 50 ) {
$st [ 'pa1' ] += 2 ;
$st [ 'm4' ] += 35 ;
}
if ( $st [ 's2' ] > 49 && $st [ 's2' ] < 75 ) {
$st [ 'pa1' ] += 5 ;
$st [ 'm2' ] += 40 ;
$st [ 'm4' ] += 75 ;
}
if ( $st [ 's2' ] > 74 && $st [ 's2' ] < 100 ) {
$st [ 'pa1' ] += 8 ;
$st [ 'm2' ] += 65 ;
$st [ 'm4' ] += 90 ;
}
if ( $st [ 's2' ] > 99 && $st [ 's2' ] < 125 ) {
$st [ 'pa1' ] += 12 ;
$st [ 'm2' ] += 75 ;
$st [ 'm4' ] += 105 ;
}
if ( $st [ 's2' ] > 124 && $st [ 's2' ] < 150 ) {
$st [ 'pa1' ] += 17 ;
$st [ 'm2' ] += 85 ;
$st [ 'm4' ] += 105 ;
$st [ 'm15' ] += 1 ;
}
if ( $st [ 's2' ] > 149 && $st [ 's2' ] < 175 ) {
$st [ 'pa1' ] += 20 ;
$st [ 'm2' ] += 110 ;
$st [ 'm4' ] += 115 ;
$st [ 'm15' ] += 2 ;
}
if ( $st [ 's2' ] > 174 && $st [ 's2' ] < 200 ) {
$st [ 'pa1' ] += 23 ;
$st [ 'm2' ] += 145 ;
$st [ 'm4' ] += 145 ;
$st [ 'm15' ] += 3 ;
}
if ( $st [ 's2' ] > 199 ) {
$st [ 'pa1' ] += 30 ;
$st [ 'm2' ] += 165 ;
$st [ 'm4' ] += 165 ;
$st [ 'm15' ] += 5 ;
2023-11-02 13:57:39 +00:00
}
}
private function addIntuitionBonuses ( array & $st ) : void
{
2023-11-10 15:52:38 +00:00
if ( $st [ 's3' ] >= 200 ) {
2023-08-15 22:48:29 +00:00
$st [ 'm1' ] += 185 ;
2023-11-10 15:52:38 +00:00
$st [ 'm3' ] += 40 ;
2023-08-15 22:48:29 +00:00
$st [ 'm5' ] += 65 ;
$st [ 'm14' ] += 5 ;
2023-11-10 15:52:38 +00:00
$st [ 'pa4' ] += 30 ;
} elseif ( $st [ 's3' ] >= 175 ) {
$st [ 'm1' ] += 165 ;
$st [ 'm3' ] += 35 ;
$st [ 'm5' ] += 55 ;
$st [ 'm14' ] += 3 ;
$st [ 'pa4' ] += 23 ;
} elseif ( $st [ 's3' ] >= 150 ) {
$st [ 'm1' ] += 145 ;
$st [ 'm3' ] += 30 ;
$st [ 'm5' ] += 50 ;
$st [ 'm14' ] += 2 ;
$st [ 'pa4' ] += 20 ;
} elseif ( $st [ 's3' ] >= 125 ) {
$st [ 'm1' ] += 125 ;
$st [ 'm3' ] += 20 ;
$st [ 'm5' ] += 45 ;
$st [ 'm14' ] += 1 ;
$st [ 'pa4' ] += 17 ;
} elseif ( $st [ 's3' ] >= 100 ) {
$st [ 'm1' ] += 105 ;
$st [ 'm3' ] += 15 ;
$st [ 'm5' ] += 35 ;
$st [ 'pa4' ] += 12 ;
} elseif ( $st [ 's3' ] >= 75 ) {
$st [ 'm1' ] += 75 ;
$st [ 'm3' ] += 10 ;
$st [ 'm5' ] += 25 ;
$st [ 'pa4' ] += 8 ;
} elseif ( $st [ 's3' ] >= 50 ) {
$st [ 'm1' ] += 55 ;
$st [ 'm3' ] += 5 ;
$st [ 'pa4' ] += 5 ;
} elseif ( $st [ 's3' ] >= 25 ) {
$st [ 'm1' ] += 25 ;
$st [ 'm3' ] += 2 ;
$st [ 'pa4' ] += 2 ;
2023-11-02 13:57:39 +00:00
}
}
private function addEnduranceBonuses ( array & $st ) : void
{
//выносливость
2023-08-15 22:48:29 +00:00
if ( $st [ 's4' ] > 0 ) {
$st [ 'hpAll' ] += 30 ;
}
if ( $st [ 's4' ] > 24 && $st [ 's4' ] < 50 ) {
$st [ 'hpAll' ] += 50 ;
}
if ( $st [ 's4' ] > 49 && $st [ 's4' ] < 75 ) {
$st [ 'hpAll' ] += 100 ;
}
if ( $st [ 's4' ] > 74 && $st [ 's4' ] < 100 ) {
$st [ 'hpAll' ] += 175 ;
$st [ 'm19' ] += 2 ;
}
if ( $st [ 's4' ] > 99 && $st [ 's4' ] < 125 ) {
$st [ 'hpAll' ] += 250 ;
$st [ 'm19' ] += 4 ;
}
if ( $st [ 's4' ] > 124 && $st [ 's4' ] < 150 ) {
$st [ 'hpAll' ] += 400 ;
$st [ 'za' ] += 25 ;
$st [ 'zm' ] += 25 ;
}
if ( $st [ 's4' ] > 149 && $st [ 's4' ] < 175 ) {
$st [ 'hpAll' ] += 450 ;
$st [ 'za' ] += 50 ;
$st [ 'zm' ] += 50 ;
}
if ( $st [ 's4' ] > 174 && $st [ 's4' ] < 200 ) {
$st [ 'hpAll' ] += 600 ;
$st [ 'za' ] += 100 ;
$st [ 'zm' ] += 100 ;
}
if ( $st [ 's4' ] > 199 ) {
$st [ 'hpAll' ] += 850 ;
$st [ 'za' ] += 125 ;
$st [ 'zm' ] += 125 ;
2023-11-02 13:57:39 +00:00
}
}
private function addIntelligenceBonuses ( array & $st ) : void
{
//интелект
2023-08-15 22:48:29 +00:00
if ( $st [ 's5' ] > 24 && $st [ 's5' ] < 50 ) {
$st [ 'm11' ] += 10 ;
}
if ( $st [ 's5' ] > 49 && $st [ 's5' ] < 75 ) {
$st [ 'm11' ] += 15 ;
}
if ( $st [ 's5' ] > 74 && $st [ 's5' ] < 100 ) {
$st [ 'm11' ] += 20 ;
}
if ( $st [ 's5' ] > 99 && $st [ 's5' ] < 125 ) {
$st [ 'm11' ] += 25 ;
}
if ( $st [ 's5' ] > 124 && $st [ 's5' ] < 150 ) {
$st [ 'm11' ] += 35 ;
}
if ( $st [ 's5' ] > 149 && $st [ 's5' ] < 175 ) {
$st [ 'm11' ] += 50 ;
}
if ( $st [ 's5' ] > 174 ) {
$st [ 'm11' ] += 65 ;
$st [ 'pzm' ] += 2 ;
}
if ( $st [ 's5' ] > 199 ) {
$st [ 'pzm' ] += 5 ;
2023-11-02 13:57:39 +00:00
}
}
private function addWisdomBonuses ( array & $st ) : void
{
//мудрость
2023-08-15 22:48:29 +00:00
if ( $st [ 's6' ] > 24 && $st [ 's6' ] < 50 ) {
$st [ 'mpAll' ] += 150 ;
$st [ 'speedmp' ] += 100 ;
}
if ( $st [ 's6' ] > 49 && $st [ 's6' ] < 75 ) {
$st [ 'mpAll' ] += 200 ;
$st [ 'speedmp' ] += 200 ;
}
if ( $st [ 's6' ] > 74 && $st [ 's6' ] < 100 ) {
$st [ 'mpAll' ] += 250 ;
$st [ 'speedmp' ] += 350 ;
}
if ( $st [ 's6' ] > 99 && $st [ 's6' ] < 125 ) {
$st [ 'mpAll' ] += 350 ;
$st [ 'speedmp' ] += 500 ;
}
if ( $st [ 's6' ] > 124 && $st [ 's6' ] < 150 ) {
$st [ 'mpAll' ] += 500 ;
$st [ 'speedmp' ] += 500 ;
$st [ 'pzm' ] += 2 ;
}
if ( $st [ 's6' ] > 149 && $st [ 's6' ] < 175 ) {
$st [ 'mpAll' ] += 700 ;
$st [ 'speedmp' ] += 600 ;
$st [ 'pzm' ] += 3 ;
}
if ( $st [ 's6' ] > 174 && $st [ 's6' ] < 200 ) {
$st [ 'mpAll' ] += 900 ;
$st [ 'speedmp' ] += 700 ;
$st [ 'pzm' ] += 5 ;
}
if ( $st [ 's6' ] > 199 ) {
$st [ 'mpAll' ] += 900 ;
$st [ 'speedmp' ] += 700 ;
$st [ 'pzm' ] += 7 ;
}
2023-11-02 13:57:39 +00:00
}
2023-08-15 22:48:29 +00:00
2023-11-02 13:57:39 +00:00
private function addDungeonsBonuses ( int $id , array & $st ) : void
{
$finishedDungeons = Db :: getValue ( ' select
if ( repcapitalcity > 24999 , 1 , 0 ) +
if ( repdemonscity > 24999 , 1 , 0 ) +
if ( repangelscity > 24999 , 1 , 0 ) +
if ( repdevilscity > 24999 , 1 , 0 ) +
if ( repmooncity > 24999 , 1 , 0 ) +
if ( repsuncity > 24999 , 1 , 0 ) +
if ( repsandcity > 24999 , 1 , 0 ) +
if ( repemeraldscity > 24999 , 1 , 0 ) +
if ( repizlom > 24999 , 1 , 0 ) +
0 as finished from rep where id = ? ' , [ $id ]);
//Бонус за количество полностью вырытых пещер.
$st [ 'm10' ] += 10 * $finishedDungeons ;
$st [ 'pzm' ] += $finishedDungeons ;
2023-08-15 22:48:29 +00:00
}
2023-11-10 15:52:38 +00:00
private function addAdminBonuses ( array $u , array & $st ) : void
{
if ( ! $u [ 'admin' ]) {
return ;
}
$st [ 'speed_dungeon' ] = 500 ;
$st [ 'speedhp' ] = 500 ;
if ( ! $u [ 'battle' ]) {
return ;
}
Db :: sql ( " update stats set
tactic1 = tactic2 = tactic3 = tactic4 = tactic5 = tactic6 = tactic7 = 25 ,
priems_z = '0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|'
where id = ? " , [ $u['id'] ]);
}
2023-08-15 22:48:29 +00:00
}