Файл: pages/combat/arena.php
Строк: 2217
<?php
// Physical module map v50.6: public URL stays clean while code lives in /pages.
if (!defined('GAME_ROOT')) define('GAME_ROOT', dirname(__DIR__, 2));
chdir(GAME_ROOT);
if (PHP_SAPI !== 'cli') { $_SERVER['PHP_SELF']='/arena.php'; $_SERVER['SCRIPT_NAME']='/arena.php'; }
/* Обновление игры под PHP 8.4 / PDO и усиление безопасности: by Метриум (Стэлп) */
include './system/common.php';
include './system/functions.php';
include './system/user.php';
include './system/menu.php';
if(!$user) {
header('location: /');
exit;
}
$title = 'Арена';
$arenaAttackRequested = isset($_GET['attack']) && (string)$_GET['attack']==='true'; // только явное нажатие: by Метриум (Стэлп)
// Значения по умолчанию для старой боевой логики PHP 8.4; by Метриум (Стэлп)
$a_1 = $a_2 = $a_3 = $a_4 = $a_5 = false;
$a_1_bonus = $a_2_bonus = $a_3_bonus = $a_4_bonus = $a_5_bonus = 0;
$a_3_crit_chanse = 0;
$a_f = ['on/off' => 0];
$fights = 0; $klu = 0;
$CollectorSystem = ['coll' => 999];
/* Надёжный подбор противника Арены + резервные NPC: by Метриум (Стэлп) */
function arena_npc_opponent(array $user, int $seed = 1): array {
$names = ['Страж Арены','Костолом','Северный Волк','Пепельный Воин','Клинок Титанов','Безымянный Гладиатор'];
$seed = max(1, $seed);
$factor = [0.72,0.80,0.88,0.94,1.00,1.06][($seed-1)%6];
$baseLevel = max(1,(int)($user['level'] ?? 1));
$mk = static fn(string $k): int => max(8,(int)round(max(10,(int)($user[$k] ?? 10))*$factor));
return [
'id' => -1000-(($seed-1)%6),
'login' => $names[($seed-1)%6],
'sex' => (($seed-1)%2),
'r' => (($seed-1)%2),
'level' => $baseLevel,
'str' => $mk('str'), 'vit' => $mk('vit'), 'agi' => $mk('agi'), 'def' => $mk('def'),
'w_1'=>0,'w_2'=>0,'w_3'=>0,'w_4'=>0,'w_5'=>0,'w_6'=>0,'w_7'=>0,'w_8'=>0,
];
}
function arena_load_opponent(int $id, array $user): array {
if ($id < 0) return arena_npc_opponent($user, abs($id) % 6 + 1);
if ($id > 0) {
$row = db_fetch_one('SELECT * FROM `users` WHERE `id` = :id LIMIT 1', ['id'=>$id]);
if ($row && (int)$row['id'] !== (int)$user['id']) return $row;
}
return arena_npc_opponent($user, max(1, ((int)($user['boy_arena'] ?? 0) % 6) + 1));
}
function arena_pick_opponent(array $user): array {
// На Арене встречаются и реальные игроки, и виртуальные мобы. by Метриум (Стэлп)
// NPC не создаются в users и не засоряют базу аккаунтами.
if (random_int(1,100) <= 40) {
$seed=max(1,((int)($user['boy_arena'] ?? 0)+random_int(1,6))%6+1);
return arena_npc_opponent($user,$seed);
}
$power = max(1,(int)$user['str']+(int)$user['vit']+(int)$user['agi']+(int)$user['def']);
try {
$stmt = db_prepare('SELECT * FROM `users` WHERE `id` <> :id AND `save` = 1 AND `block` = 0 AND `login` IS NOT NULL AND `login` <> '' ORDER BY ABS((`str`+`vit`+`agi`+`def`) - :power) ASC, `id` DESC LIMIT 8', ['id'=>(int)$user['id'],'power'=>$power]);
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
if ($rows) return $rows[array_rand($rows)];
} catch (Throwable $e) {
if (function_exists('app_log_write')) app_log_write('ARENA', 'Opponent selection fallback', ['error'=>$e->getMessage()]);
}
return arena_npc_opponent($user, max(1, ((int)($user['boy_arena'] ?? 0) % 6) + 1));
}
include './system/h.php';
/* Старые разрозненные подсказки заменены единым NPC-наставником: by Метриум (Стэлп) */
$sunduk = db_fetch_assoc(db_query("SELECT * FROM `sunduk_start` WHERE `zena` != 0 AND `time` > ".time()." ORDER BY `time` DESC LIMIT 1")) ?: ['time'=>0,'zena'=>0];
//
if((int)($ClanBattle['BATTLE'] ?? 0) === 1) {
include './system/class.ClanBattle.php';
$battleArena = new ClanBattle($user['id']);
}
//
$skidka = db_fetch_array(db_query('SELECT * FROM `skilka` WHERE `id` = 2')) ?: ['zena'=>0];
if(!is_array($skidka) || (int)($skidka['time']??0)<=time()) $skidka=['zena'=>0,'time'=>0];
$sk = (int)($skidka['zena'] ?? 0);
db_query("CREATE TABLE IF NOT EXISTS `arena_bulk_usage` (`user` INT NOT NULL,`uses` INT NOT NULL DEFAULT 0,PRIMARY KEY (`user`)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci");
db_query("CREATE TABLE IF NOT EXISTS `arena_stage_progress` (`user` INT NOT NULL,`manual_fights` INT NOT NULL DEFAULT 0,`all_runs` INT NOT NULL DEFAULT 0,`paid_runs` INT NOT NULL DEFAULT 0,PRIMARY KEY (`user`)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci");
/* Пошаговое открытие ускоренных боёв Арены: by Метриум (Стэлп)
* 1) первые 5 боёв игрок проводит вручную;
* 2) после этого открывается «Восстановить и провести все бои»;
* 3) после 10 использований этой кнопки открывается режим 5 серий подряд.
* Цена повышается каждые 5 оплаченных серий.
*/
function arena_bulk_cost_for_use(int $useIndex): int {
if ($useIndex < 5) return 25;
if ($useIndex < 10) return 75;
if ($useIndex < 15) return 150;
return 300;
}
function arena_bulk_cost_for_pack(int $used, int $count): int {
return arena_bulk_cost_for_use($used) * max(1,$count);
}
function arena_stage_state(int $uid): array {
$row=db_fetch_assoc(db_query('SELECT `manual_fights`,`all_runs`,`paid_runs` FROM `arena_stage_progress` WHERE `user`='.(int)$uid.' LIMIT 1'));
return $row ?: ['manual_fights'=>0,'all_runs'=>0,'paid_runs'=>0];
}
function arena_render_bulk_actions(array $user): void {
$stage=arena_stage_state((int)$user['id']);
$manual=(int)$stage['manual_fights'];
$runs=(int)$stage['all_runs'];
$used=(int)($stage['paid_runs'] ?? 0);
echo '<div class="arena-bulk-v41 center">';
if($manual < 5){
echo '<div class="grey small">Сначала проведи вручную ещё <b>'.(5-$manual).'</b> '.((5-$manual)===1?'бой':'боёв').'. После этого откроется восстановление и проведение всех боёв.</div>';
echo '</div>';
return;
}
$one=arena_bulk_cost_for_use($used);
if ((int)$user['g'] >= $one) {
echo '<form method="post" action="/arena/">'.security_csrf_field().'<button class="old-btn arena-action-btn" type="submit" name="arena_all_mana" value="1">Восстановить здоровье и ману и провести все бои <img src="/images/icon/gold.png" alt=""> '.$one.'</button></form>';
} else {
echo '<div class="dred">Не хватает золота. Нужно <img src="/images/icon/gold.png" alt=""> '.$one.'</div>';
}
if ($runs >= 10) {
$five=arena_bulk_cost_for_pack($used,5);
echo '<div class="separ"></div><div class="dgreen bold">Открыто ускорение: 5 серий подряд</div>';
if ((int)$user['g'] >= $five) {
echo '<form method="post" action="/arena/">'.security_csrf_field().'<button class="old-btn arena-action-btn arena-five-btn" type="submit" name="arena_five_runs" value="1">Восстановить 5 раз и провести бои <img src="/images/icon/gold.png" alt=""> '.$five.'</button></form>';
} else {
echo '<div class="grey small">Для 5 серий нужно <img src="/images/icon/gold.png" alt=""> '.$five.' золота</div>';
}
} else {
echo '<div class="grey small">До режима 5 серий подряд: ещё <b>'.(10-$runs).'</b> использ. восстановления и всех боёв.</div>';
}
echo '</div>';
}
$arenaBulkUses=(int)(arena_stage_state((int)$user['id'])['paid_runs'] ?? 0);
$arenaBulkCost=arena_bulk_cost_for_use($arenaBulkUses);
$arenaFiveCost=arena_bulk_cost_for_pack($arenaBulkUses, 5);
$lastPlayer = (($_SERVER['REQUEST_METHOD']??'GET')==='POST' && isset($_POST['arena_all_mana'])) ? true : null;
if(isset($lastPlayer)){
security_require_csrf();
$arenaStage=arena_stage_state((int)$user['id']);
if((int)$arenaStage['manual_fights'] < 5 || $user['g'] < $arenaBulkCost OR $user['level'] < 4) {
header('Location:/arena');
exit;
}
$_SESSION['arena'] = (int)($_SESSION['arena'] ?? 0) + 1;
// Единая кнопка Арены: восстановить HP/MP и провести все бои. by Метриум (Стэлп)
$user['hp']=max(1,(int)$user['vit']*2);
$user['mp']=max(50,(int)$user['mana']);
db_execute('UPDATE `users` SET `hp`=:hp,`mp`=:mp WHERE `id`=:u',['hp'=>$user['hp'],'mp'=>$user['mp'],'u'=>(int)$user['id']]);
$fights = max(1,(int)floor($user['mp'] / 50));
$win = 0;
$los = 0;
$_exp = 0;
$_s = 0;
$_c = 0;
for($fight = 1; $fight <= $fights; $fight++) {
$arenaStr = max(1, (int)$user['str']);
$dmg = random_int(max(1, (int)floor($arenaStr / 2)), $arenaStr);
$opponent = array("str"=>"".($dmg)."", "vit"=>"".($dmg)."", "agi"=>"".($dmg)."","def"=>"".($dmg)."");
$dmg = 0;
$opponent_dmg = 0;
for($round = 1; $round < 6; $round++) {
if($user['ability_1'] > 0) {
switch($user['ability_1']) {
case 0:
$a_1_bonus = 25;
$a_1_chanse = 5;
break;
case 1:
$a_1_bonus = 25;
$a_1_chanse = 5;
break;
case 2:
$a_1_bonus = 30;
$a_1_chanse = 5;
break;
case 3:
$a_1_bonus = 35;
$a_1_chanse = 5;
break;
case 4:
$a_1_bonus = 40;
$a_1_chanse = 5;
break;
case 5:
$a_1_bonus = 45;
$a_1_chanse = 5;
break;
case 6:
$a_1_bonus = 45;
$a_1_chanse = 8;
break;
case 7:
$a_1_bonus = 50;
$a_1_chanse = 8;
break;
case 8:
$a_1_bonus = 55;
$a_1_chanse = 8;
break;
case 9:
$a_1_bonus = 60;
$a_1_chanse = 8;
break;
case 10:
$a_1_bonus = 65;
$a_1_chanse = 8;
break;
case 11:
$a_1_bonus = 65;
$a_1_chanse = 11;
break;
case 12:
$a_1_bonus = 70;
$a_1_chanse = 11;
break;
case 13:
$a_1_bonus = 75;
$a_1_chanse = 11;
break;
case 14:
$a_1_bonus = 80;
$a_1_chanse = 11;
break;
case 15:
$a_1_bonus = 85;
$a_1_chanse = 11;
break;
case 16:
$a_1_bonus = 85;
$a_1_chanse = 14;
break;
case 17:
$a_1_bonus = 90;
$a_1_chanse = 14;
break;
case 18:
$a_1_bonus = 95;
$a_1_chanse = 14;
break;
case 19:
$a_1_bonus = 100;
$a_1_chanse = 14;
break;
case 20:
$a_1_bonus = 105;
$a_1_chanse = 14;
break;
case 21:
$a_1_bonus = 105;
$a_1_chanse = 17;
break;
case 22:
$a_1_bonus = 145;
$a_1_chanse = 20;
break;
case 23:
$a_1_bonus = 165;
$a_1_chanse = 23;
break;
case 24:
$a_1_bonus = 165;
$a_1_chanse = 23;
break;
}
if(mt_rand(0, 100) <= $a_1_chanse) {
$a_1 = true;
}
}
if($user['ability_2'] > 0) {
switch($user['ability_2']) {
case 0:
$a_2_bonus = 25;
$a_2_chanse = 5;
break;
case 1:
$a_2_bonus = 25;
$a_2_chanse = 5;
break;
case 2:
$a_2_bonus = 30;
$a_2_chanse = 5;
break;
case 3:
$a_2_bonus = 35;
$a_2_chanse = 5;
break;
case 4:
$a_2_bonus = 40;
$a_2_chanse = 5;
break;
case 5:
$a_2_bonus = 45;
$a_2_chanse = 5;
break;
case 6:
$a_2_bonus = 45;
$a_2_chanse = 8;
break;
case 7:
$a_2_bonus = 50;
$a_2_chanse = 8;
break;
case 8:
$a_2_bonus = 55;
$a_2_chanse = 8;
break;
case 9:
$a_2_bonus = 60;
$a_2_chanse = 8;
break;
case 10:
$a_2_bonus = 65;
$a_2_chanse = 8;
break;
case 11:
$a_2_bonus = 65;
$a_2_chanse = 11;
break;
case 12:
$a_2_bonus = 70;
$a_2_chanse = 11;
break;
case 13:
$a_2_bonus = 75;
$a_2_chanse = 11;
break;
case 14:
$a_2_bonus = 80;
$a_2_chanse = 11;
break;
case 15:
$a_2_bonus = 85;
$a_2_chanse = 11;
break;
case 16:
$a_2_bonus = 85;
$a_2_chanse = 14;
break;
case 17:
$a_2_bonus = 90;
$a_2_chanse = 14;
break;
case 18:
$a_2_bonus = 95;
$a_2_chanse = 14;
break;
case 19:
$a_2_bonus = 100;
$a_2_chanse = 14;
break;
case 20:
$a_2_bonus = 105;
$a_2_chanse = 14;
break;
case 21:
$a_2_bonus = 105;
$a_2_chanse = 17;
break;
case 22:
$a_2_bonus = 145;
$a_2_chanse = 20;
break;
case 23:
$a_2_bonus = 165;
$a_2_chanse = 23;
break;
case 24:
$a_2_bonus = 165;
$a_2_chanse = 23;
break;
}
if(mt_rand(0, 100) <= $a_2_chanse) {
$a_2 = true;
}
}
if($user['ability_3'] > 0) {
switch($user['ability_3']) {
case 0:
$a_3_bonus = 5;
$a_3_crit_chanse = 5;
$a_3_chanse = 20;
break;
case 1:
$a_3_bonus = 5;
$a_3_crit_chanse = 5;
$a_3_chanse = 20;
break;
case 2:
$a_3_bonus = 8;
$a_3_crit_chanse = 5;
$a_3_chanse = 20;
break;
case 3:
$a_3_bonus = 11;
$a_3_crit_chanse = 5;
$a_3_chanse = 20;
break;
case 4:
$a_3_bonus = 14;
$a_3_crit_chanse = 5;
$a_3_chanse = 20;
break;
case 5:
$a_3_bonus = 17;
$a_3_crit_chanse = 5;
$a_3_chanse = 20;
break;
case 6:
$a_3_bonus = 17;
$a_3_crit_chanse = 7;
$a_3_chanse = 25;
break;
case 7:
$a_3_bonus = 20;
$a_3_crit_chanse = 7;
$a_3_chanse = 25;
break;
case 8:
$a_3_bonus = 23;
$a_3_crit_chanse = 7;
$a_3_chanse = 25;
break;
case 9:
$a_3_bonus = 26;
$a_3_crit_chanse = 7;
$a_3_chanse = 25;
break;
case 10:
$a_3_bonus = 29;
$a_3_crit_chanse = 7;
$a_3_chanse = 25;
break;
case 11:
$a_3_bonus = 29;
$a_3_crit_chanse = 9;
$a_3_chanse = 30;
break;
case 12:
$a_3_bonus = 32;
$a_3_crit_chanse = 9;
$a_3_chanse = 30;
break;
case 13:
$a_3_bonus = 35;
$a_3_crit_chanse = 9;
$a_3_chanse = 30;
break;
case 14:
$a_3_bonus = 38;
$a_3_crit_chanse = 9;
$a_3_chanse = 30;
break;
case 15:
$a_3_bonus = 41;
$a_3_crit_chanse = 9;
$a_3_chanse = 30;
break;
case 16:
$a_3_bonus = 41;
$a_3_crit_chanse = 11;
$a_3_chanse = 35;
break;
case 17:
$a_3_bonus = 44;
$a_3_crit_chanse = 11;
$a_3_chanse = 35;
break;
case 18:
$a_3_bonus = 47;
$a_3_crit_chanse = 11;
$a_3_chanse = 35;
break;
case 19:
$a_3_bonus = 50;
$a_3_crit_chanse = 11;
$a_3_chanse = 35;
break;
case 20:
$a_3_bonus = 53;
$a_3_crit_chanse = 11;
$a_3_chanse = 35;
break;
case 21:
$a_3_bonus = 53;
$a_3_crit_chanse = 13;
$a_3_chanse = 40;
break;
case 22:
$a_3_bonus = 77;
$a_3_crit_chanse = 15;
$a_3_chanse = 45;
break;
case 23:
$a_3_bonus = 89;
$a_3_crit_chanse = 17;
$a_3_chanse = 50;
break;
case 24:
$a_3_bonus = 89;
$a_3_crit_chanse = 17;
$a_3_chanse = 50;
break;
}
if(mt_rand(0, 100) <= $a_3_chanse) {
$a_3 = true;
}
}
if($user['ability_5'] > 0) {
switch($user['ability_5']) {
case 0:
$a_5_bonus = 20;
$a_5_chanse = 5;
break;
case 1:
$a_5_bonus = 20;
$a_5_chanse = 5;
break;
case 2:
$a_5_bonus = 22;
$a_5_chanse = 5;
break;
case 3:
$a_5_bonus = 24;
$a_5_chanse = 5;
break;
case 4:
$a_5_bonus = 26;
$a_5_chanse = 5;
break;
case 5:
$a_5_bonus = 28;
$a_5_chanse = 5;
break;
case 6:
$a_5_bonus = 28;
$a_5_chanse = 10;
break;
case 7:
$a_5_bonus = 30;
$a_5_chanse = 10;
break;
case 8:
$a_5_bonus = 32;
$a_5_chanse = 10;
break;
case 9:
$a_5_bonus = 34;
$a_5_chanse = 10;
break;
case 10:
$a_5_bonus = 36;
$a_5_chanse = 10;
break;
case 11:
$a_5_bonus = 36;
$a_5_chanse = 15;
break;
case 12:
$a_5_bonus = 38;
$a_5_chanse = 15;
break;
case 13:
$a_5_bonus = 40;
$a_5_chanse = 15;
break;
case 14:
$a_5_bonus = 42;
$a_5_chanse = 15;
break;
case 15:
$a_5_bonus = 44;
$a_5_chanse = 15;
break;
case 16:
$a_5_bonus = 44;
$a_5_chanse = 20;
break;
case 17:
$a_5_bonus = 46;
$a_5_chanse = 20;
break;
case 18:
$a_5_bonus = 48;
$a_5_chanse = 20;
break;
case 19:
$a_5_bonus = 50;
$a_5_chanse = 20;
break;
case 20:
$a_5_bonus = 52;
$a_5_chanse = 20;
break;
case 21:
$a_5_bonus = 52;
$a_5_chanse = 25;
break;
case 22:
$a_5_bonus = 68;
$a_5_chanse = 30;
break;
case 23:
$a_5_bonus = 76;
$a_5_chanse = 35;
break;
case 24:
$a_5_bonus = 76;
$a_5_chanse = 35;
break;
}
if(mt_rand(0, 100) <= $a_5_chanse) {
$a_5 = true;
}
}
$dmg +=mt_rand((int)floor(((int)$user['str'])/6), max((int)floor(((int)$user['str'])/6),(int)ceil(((int)$user['str'])/4)));
if($a_1 == true) {
$dmg += round(($dmg / 100) * $a_1_bonus);
}
$dmg -= mt_rand((int)floor(((int)$opponent['def'])/12), max((int)floor(((int)$opponent['def'])/12),(int)ceil(((int)$opponent['def'])/7)));
if($dmg < 0) {
$dmg = 0;
}
if($a_3 == true) {
$crit = ( (rand(1,2) * ($user['agi'] / 100) + $a_3_crit_chanse ) - (rand(1,2) * ($opponent['agi'] / 100)));
}
else
{
$crit = ( (rand(1,2) * ($user['agi'] / 100) ) - (rand(1,2) * ($opponent['agi'] / 100)));
}
if(mt_rand(0, 100) <= $crit) {
$dmg *= 2;
if($a_3 == true) {
$dmg += round(($dmg / 100) * $a_3_bonus);
}
}
$dodge = ( (rand(1,2) * ($opponent['agi'] / 100) ) - (rand(1,2) * ($user['agi'] / 100)));
if(mt_rand(0, 100) <= $dodge) {
$dmg = 0;
}
$opponent_dmg +=mt_rand((int)floor(((int)$opponent['str'])/6), max((int)floor(((int)$opponent['str'])/6),(int)ceil(((int)$opponent['str'])/4)));
if($a_2 == true) {
$opponent_dmg -= round(($opponent_dmg / 100) * $a_2_bonus);
}
$opponent_dmg -= mt_rand((int)floor(((int)$user['def'])/12), max((int)floor(((int)$user['def'])/12),(int)ceil(((int)$user['def'])/7)));
if($opponent_dmg < 0) {
$opponent_dmg = 0;
}
$opponent_crit = ( (rand(1,2) * ($opponent['agi'] / 100) ) - (rand(1,2) * ($user['agi'] / 100)));
if(mt_rand(0, 100) <= $opponent_crit) {
$opponent_dmg *= 2;
if($a_4 == true) {
$opponent_dmg -= round(($opponent_dmg / 100) * $a_4_bonus);
}
}
$opponent_dodge = ( (rand(1,2) * ($user['agi'] / 100) ) - (rand(1,2) * ($opponent['agi'] / 100)));
if(mt_rand(0, 100) <= $opponent_dodge) {
$opponent_dmg = 0;
}
}
//////награда за спус маны////
if($dmg > $opponent_dmg) {
$_c +=1;
$_s += round(rand(2,4) * $user['level']);
$_exp += round(rand(4,7) * $user['level']);
$win+= 1;
}
else
{
$_s += round(rand(1,2) / $user['level']);
$_exp += round(rand(4,7) / $user['level']);
$los+= 1;
}
}
if($clan_memb && $clan_memb['v'] > 0) {
$_exp += round($_exp/100) * $clan_memb['v'];
}
$lab_1 = db_fetch_array(db_query("SELECT * FROM `lab_` WHERE `user` = '".$user['id']."' AND `type` = '1'"));
$lab_2 = db_fetch_array(db_query("SELECT * FROM `lab_` WHERE `user` = '".$user['id']."' AND `type` = '2'"));
$lab_3 = db_fetch_array(db_query("SELECT * FROM `lab_` WHERE `user` = '".$user['id']."' AND `type` = '2'"));
if($premium) {
$_exp+= round($_exp/ 100) * 25;
}
if($clan_memb && $clan['build_act']>time()) {
$_exp+= $clan['build_1']*rand(1,2);
}
if($clan_memb && $clan['build_act']>time()) {
$_s+= $clan['build_2'];
}
if($user['vip_time'] >= time()) {
$_exp+= round($_exp/ 100) * 50;
}
if($lab_1) {
$_exp+= round($_exp/ 100) * 75;
}
if($lab_2) {
$_exp+= round($_exp/ 100) * 25;
}
if($lab_3) {
$_exp+= round($_exp/ 100) * 25;
}
$V_C = db_fetch_array(db_query('SELECT * FROM `v_clan` WHERE `user` = '.(int)$user['id']));
$vClanExpBonus = (int)($V_C['v'] ?? 0);
if (in_array($vClanExpBonus, [10, 50, 100, 150, 200], true)) {
$_exp += (int)round($_exp / 100 * $vClanExpBonus);
}
$_exp += round($_exp/ 100) * $sk;
for($i = 1; $i <= 3; $i++) {
if((int)($_effshop['effshop_'.$i] ?? 0) > time()) $_exp += round($_exp/ 100) * 25;
}
/*
by Метриум (Стэлп) */
////// Подсчет боев ////
$Arena1 = $win + $los;
db_query('UPDATE `users` SET `mp` = `mp` - '.($fights * 50).',
`exp` = `exp` + '.$_exp.',
`s` = `s` + '.$_s.',
`boy_arena` = `boy_arena` + '.$Arena1.',
`g` = `g` - '.(int)$arenaBulkCost.' WHERE `id` = "'.$user['id'].'"');
db_query('INSERT INTO `arena_bulk_usage` (`user`,`uses`) VALUES ('.(int)$user['id'].',1) ON DUPLICATE KEY UPDATE `uses`=`uses`+1');
db_query('INSERT INTO `arena_stage_progress` (`user`,`manual_fights`,`all_runs`,`paid_runs`) VALUES ('.(int)$user['id'].',0,1,1) ON DUPLICATE KEY UPDATE `all_runs`=`all_runs`+1,`paid_runs`=`paid_runs`+1');
//
if((int)($CollectorSystem['coll'] ?? 999) <= 6) {
$ArenaStat = $win + $los;
db_query('UPDATE `users` SET `battle_collector` = `battle_collector` + '.$ArenaStat.' WHERE `id` = "'.$user['id'].'"');
}
//
//
if((int)($ClanBattle['BATTLE'] ?? 0) === 1) {
$battleArena->ClanArenaNotOpponent($_exp);
}
//
if((int)($a_f['on/off'] ?? 0) > time() && db_result(db_query('SELECT COUNT(*) FROM `tj_users` WHERE `id_user` = "'.$user['id'].'" LIMIT 1'),0) == '1'){
db_query("UPDATE `users` SET `alex_dobl` = `alex_dobl` + '1' WHERE `id` = '".$user['id']."'");
db_query("UPDATE `tj_users` SET `wins` = `wins` + ".$win." WHERE `id_user` = '$user[id]'") or die(db_error());
if ($win > 0) db_query("UPDATE `users` SET `win_battle`=`win_battle`+1 WHERE `id`='".(int)$user['id']."'");
}
if($clan) {
// Клановые задания: q1/q2 считают проведённые бои, q7 — победы. v50.6
if(game_clan_quest_is_week_open()){
$questFights=max(0,(int)$win+(int)$los);
if($questFights>0){
game_clan_quest_increment((int)$clan['id'],1,(int)$user['id'],$questFights);
game_clan_quest_increment((int)$clan['id'],2,(int)$user['id'],$questFights);
}
if((int)$win>0) game_clan_quest_increment((int)$clan['id'],7,(int)$user['id'],(int)$win);
}
//конец
db_query('UPDATE `clans` SET `exp` = `exp` + '.$_exp.' WHERE `id` = "'.$clan['id'].'"');
db_query('UPDATE `clan_memb` SET `exp` = `exp` + '.$_exp.' WHERE `clan` = "'.$clan['id'].'" AND `user` = "'.$user['id'].'"');
db_query('UPDATE `clans` SET `arena` = `arena` + '.$_c.' WHERE `id` = "'.$clan['id'].'"');
/* clan_memb has no arena column in the production schema; clan total is stored in clans.arena. by Метриум (Стэлп) */
}
$vsego = $win + $los;
?>
<div class='center'><div class='block_light'><h2 class='dgreen' style='font-weight:bold;'><img src='/images/icon/2hit.png' alt=''/> Проведено <?=$vsego?> боев <img src='/images/icon/2hit.png' alt=''/></h2><div class='separ'></div><img src='/images/icon/1.png' alt=''/> <span class='dgreen'>Побед: <span class='bold'><?=$win?></span></span> | <img src='/images/icon/2.png' alt=''/> <span class='dred'>Поражений: <span class='bold'><?=$los?></span></span> <div class='separ'></div><span class='blue'>Награда:</span> <img src='/images/icon/silver.png' alt=''/> <?=$_s?> серебра <img src='/images/icon/exp.png' alt='exp'/> <?=$_exp?> опыта<br/>
<?php
game_quest_progress_event((int)$user['id'],1,max(0,((int)$win+(int)$los)*1),max(0,(int)$win*1));
// Единый прогресс заданий арены v50.7.
if($a_1 == true OR $a_2 == true OR $a_3 == true OR $a_4 == true OR $a_5 == true) {
?>
<div clasa='separ'></div>
<?php
if($a_1 == true) echo ' <img src='/images/ability/1.'.$user['ability_1_quality'].'.png' width='25px' height='25px' alt='*'/> ';
if($a_2 == true) echo ' <img src='/images/ability/2.'.$user['ability_2_quality'].'.png' width='25px' height='25px' alt='*'/> ';
if($a_3 == true) echo ' <img src='/images/ability/3.'.$user['ability_3_quality'].'.png' width='25px' height='25px' alt='*'/> ';
if($a_4 == true) echo ' <img src='/images/ability/4.'.$user['ability_4_quality'].'.png' width='25px' height='25px' alt='*'/> ';
if($a_5 == true) echo ' <img src='/images/ability/5.'.$user['ability_5_quality'].'.png' width='25px' height='25px' alt='*'/> ';
}
$w_chanse = rand(1,100);
$chanse = rand(1,10) * rand(1,100);
if($chanse < $w_chanse) {
$w = db_query('SELECT * FROM `shop` WHERE `id` < 73 ORDER BY RAND() LIMIT 1');
$w = db_fetch_array($w);
if(db_result(db_query('SELECT COUNT(*) FROM `inv` WHERE `place` = "0" AND `user` = "'.$user['id'].'"'),0) + 1 < 20) {
db_query('INSERT INTO `inv` (`user`,
`item`,
`bonus`,
`_str`,
`_vit`,
`_agi`,
`_def`) VALUES ("'.$user['id'].'",
"'.$w['id'].'",
"'.$w['bonus'].'",
"'.$w['_str'].'",
"'.$w['_vit'].'",
"'.$w['_agi'].'",
"'.$w['_def'].'")');
$w_id = db_insert_id();
$w = db_query('SELECT * FROM `inv` WHERE `id` = "'.$w_id.'"');
$w = db_fetch_array($w);
$item = db_query('SELECT * FROM `items` WHERE `id` = "'.$w['item'].'"');
$item = db_fetch_array($item);
db_query('UPDATE `inv` SET `quality` = '.$item['quality'].' WHERE `id` = '.$w_id);
{
?>
<div class='separator'></div>
<font color='#f0c060'>Новая вещь в твоей <img src='/images/icon/bag.png' alt=''/> <a href='/inv/bag/'><u>сумке</u></a>!</font><br/>
<?php
switch($item['quality']) {
case 0:
$bonus = 0;
$quality = 'Простой';
$quality_color = "#908060";
break;
case 1:
$bonus = 5;
$quality = 'Обычный';
$quality_color = "#60c030";
break;
case 2:
$bonus = 10;
$quality = 'Редкий';
$quality_color = "#6090c0";
break;
case 3:
$bonus = 15;
$quality = 'Эпический';
$quality_color = "#c060f0";
break;
case 4:
$bonus = 20;
$quality = 'Легендарный';
$quality_color = "#f06000";
break;
case 5:
$bonus = 50;
$quality = 'Божественный';
$quality_color = "#909090";
break;
case 6:
$bonus = 65;
$quality = 'Титанический';
$quality_color = "#909090";
break;
}
?>
<div align='center'>
<table cellpadding='0' cellspacing='0'>
<tr>
<td><img src='/itemImage.php?id=<?=$w['item']?>' alt='*'/></td>
<td valign='top' align='left' style='padding-left: 5px;'><img src='/images/icon/quality/<?=$item['quality']?>.png' alt='*'/> <a href='/item/<?=$w['id']?>/'><?=$item['name']?></a>
<br/>
<small><small>
<font color="<?=$quality_color?>"><?=$quality?> [<?=$w['bonus']?>/<?=$bonus?>]</font>
<?php
if($user['w_'.$item['w']] != 0) {
$equip_item = db_query('SELECT * FROM `inv` WHERE `id` = "'.$user['w_'.$item['w']].'"');
$equip_item = db_fetch_array($equip_item) ?: ['_str'=>0,'_vit'=>0,'_agi'=>0,'_def'=>0];
if(($w['_str'] + $w['_vit'] + $w['_agi'] + $w['_def']) - ($equip_item['_str'] + $equip_item['_vit'] + $equip_item['_agi'] + $equip_item['_def']) > 0) {
?>
<font color='#30c030'>+<?=($w['_str'] + $w['_vit'] + $w['_agi'] + $w['_def']) - ($equip_item['_str'] + $equip_item['_vit'] + $equip_item['_agi'] + $equip_item['_def'])?></font>
<?php
}
}
else
{
?>
<font color="#30c030">+<?=($w['_str'] + $w['_vit'] + $w['_agi'] + $w['_def'])?></font>
<?php
}
?>
</small></small></td></tr></table>
</div>
<?php
}
}
}
?>
<div class='mb10'></div>
<?php arena_render_bulk_actions($user); ?><div class='mb5'></div><a class='grey' href='/arena/'>Назад на арену</a></div></div>
<?php
}
$lastPlayer2 = (($_SERVER['REQUEST_METHOD']??'GET')==='POST' && isset($_POST['arena_five_runs'])) ? true : null;
if(isset($lastPlayer2)){
security_require_csrf();
$arenaBulkUses=(int)(arena_stage_state((int)$user['id'])['paid_runs'] ?? 0);
$arenaFiveCost=arena_bulk_cost_for_pack($arenaBulkUses, 5);
$arenaStage=arena_stage_state((int)$user['id']);
if((int)$arenaStage['all_runs'] < 10 || $user['g'] < $arenaFiveCost OR $user['level'] < 4) {
header('Location:/arena');
exit;
}
$user['hp']=max(1,(int)$user['vit']*2);
$user['mp']=max(50,(int)$user['mana']);
db_execute('UPDATE `users` SET `hp`=:hp,`mp`=:mp WHERE `id`=:u',['hp'=>$user['hp'],'mp'=>$user['mp'],'u'=>(int)$user['id']]);
$fights = max(1,(int)floor($user['mp'] / 50));
$win = 0;
$los = 0;
$_exp = 0;
$_s = 0;
$_c = 0;
for($fight = 1; $fight <= $fights; $fight++) {
$arenaStr = max(1, (int)$user['str']);
$dmg = random_int(max(1, (int)floor($arenaStr / 2)), $arenaStr);
$opponent = array("str"=>"".($dmg)."", "vit"=>"".($dmg)."", "agi"=>"".($dmg)."","def"=>"".($dmg)."");
$dmg = 0;
$opponent_dmg = 0;
for($round = 1; $round < 6; $round++) {
if($user['ability_1'] > 0) {
switch($user['ability_1']) {
case 0:
$a_1_bonus = 25;
$a_1_chanse = 5;
break;
case 1:
$a_1_bonus = 25;
$a_1_chanse = 5;
break;
case 2:
$a_1_bonus = 30;
$a_1_chanse = 5;
break;
case 3:
$a_1_bonus = 35;
$a_1_chanse = 5;
break;
case 4:
$a_1_bonus = 40;
$a_1_chanse = 5;
break;
case 5:
$a_1_bonus = 45;
$a_1_chanse = 5;
break;
case 6:
$a_1_bonus = 45;
$a_1_chanse = 8;
break;
case 7:
$a_1_bonus = 50;
$a_1_chanse = 8;
break;
case 8:
$a_1_bonus = 55;
$a_1_chanse = 8;
break;
case 9:
$a_1_bonus = 60;
$a_1_chanse = 8;
break;
case 10:
$a_1_bonus = 65;
$a_1_chanse = 8;
break;
case 11:
$a_1_bonus = 65;
$a_1_chanse = 11;
break;
case 12:
$a_1_bonus = 70;
$a_1_chanse = 11;
break;
case 13:
$a_1_bonus = 75;
$a_1_chanse = 11;
break;
case 14:
$a_1_bonus = 80;
$a_1_chanse = 11;
break;
case 15:
$a_1_bonus = 85;
$a_1_chanse = 11;
break;
case 16:
$a_1_bonus = 85;
$a_1_chanse = 14;
break;
case 17:
$a_1_bonus = 90;
$a_1_chanse = 14;
break;
case 18:
$a_1_bonus = 95;
$a_1_chanse = 14;
break;
case 19:
$a_1_bonus = 100;
$a_1_chanse = 14;
break;
case 20:
$a_1_bonus = 105;
$a_1_chanse = 14;
break;
case 21:
$a_1_bonus = 105;
$a_1_chanse = 17;
break;
case 22:
$a_1_bonus = 145;
$a_1_chanse = 20;
break;
case 23:
$a_1_bonus = 165;
$a_1_chanse = 23;
break;
case 24:
$a_1_bonus = 165;
$a_1_chanse = 23;
break;
}
if(mt_rand(0, 100) <= $a_1_chanse) {
$a_1 = true;
}
}
if($user['ability_2'] > 0) {
switch($user['ability_2']) {
case 0:
$a_2_bonus = 25;
$a_2_chanse = 5;
break;
case 1:
$a_2_bonus = 25;
$a_2_chanse = 5;
break;
case 2:
$a_2_bonus = 30;
$a_2_chanse = 5;
break;
case 3:
$a_2_bonus = 35;
$a_2_chanse = 5;
break;
case 4:
$a_2_bonus = 40;
$a_2_chanse = 5;
break;
case 5:
$a_2_bonus = 45;
$a_2_chanse = 5;
break;
case 6:
$a_2_bonus = 45;
$a_2_chanse = 8;
break;
case 7:
$a_2_bonus = 50;
$a_2_chanse = 8;
break;
case 8:
$a_2_bonus = 55;
$a_2_chanse = 8;
break;
case 9:
$a_2_bonus = 60;
$a_2_chanse = 8;
break;
case 10:
$a_2_bonus = 65;
$a_2_chanse = 8;
break;
case 11:
$a_2_bonus = 65;
$a_2_chanse = 11;
break;
case 12:
$a_2_bonus = 70;
$a_2_chanse = 11;
break;
case 13:
$a_2_bonus = 75;
$a_2_chanse = 11;
break;
case 14:
$a_2_bonus = 80;
$a_2_chanse = 11;
break;
case 15:
$a_2_bonus = 85;
$a_2_chanse = 11;
break;
case 16:
$a_2_bonus = 85;
$a_2_chanse = 14;
break;
case 17:
$a_2_bonus = 90;
$a_2_chanse = 14;
break;
case 18:
$a_2_bonus = 95;
$a_2_chanse = 14;
break;
case 19:
$a_2_bonus = 100;
$a_2_chanse = 14;
break;
case 20:
$a_2_bonus = 105;
$a_2_chanse = 14;
break;
case 21:
$a_2_bonus = 105;
$a_2_chanse = 17;
break;
case 22:
$a_2_bonus = 145;
$a_2_chanse = 20;
break;
case 23:
$a_2_bonus = 165;
$a_2_chanse = 23;
break;
case 24:
$a_2_bonus = 165;
$a_2_chanse = 23;
break;
}
if(mt_rand(0, 100) <= $a_2_chanse) {
$a_2 = true;
}
}
if($user['ability_3'] > 0) {
switch($user['ability_3']) {
case 0:
$a_3_bonus = 5;
$a_3_crit_chanse = 5;
$a_3_chanse = 20;
break;
case 1:
$a_3_bonus = 5;
$a_3_crit_chanse = 5;
$a_3_chanse = 20;
break;
case 2:
$a_3_bonus = 8;
$a_3_crit_chanse = 5;
$a_3_chanse = 20;
break;
case 3:
$a_3_bonus = 11;
$a_3_crit_chanse = 5;
$a_3_chanse = 20;
break;
case 4:
$a_3_bonus = 14;
$a_3_crit_chanse = 5;
$a_3_chanse = 20;
break;
case 5:
$a_3_bonus = 17;
$a_3_crit_chanse = 5;
$a_3_chanse = 20;
break;
case 6:
$a_3_bonus = 17;
$a_3_crit_chanse = 7;
$a_3_chanse = 25;
break;
case 7:
$a_3_bonus = 20;
$a_3_crit_chanse = 7;
$a_3_chanse = 25;
break;
case 8:
$a_3_bonus = 23;
$a_3_crit_chanse = 7;
$a_3_chanse = 25;
break;
case 9:
$a_3_bonus = 26;
$a_3_crit_chanse = 7;
$a_3_chanse = 25;
break;
case 10:
$a_3_bonus = 29;
$a_3_crit_chanse = 7;
$a_3_chanse = 25;
break;
case 11:
$a_3_bonus = 29;
$a_3_crit_chanse = 9;
$a_3_chanse = 30;
break;
case 12:
$a_3_bonus = 32;
$a_3_crit_chanse = 9;
$a_3_chanse = 30;
break;
case 13:
$a_3_bonus = 35;
$a_3_crit_chanse = 9;
$a_3_chanse = 30;
break;
case 14:
$a_3_bonus = 38;
$a_3_crit_chanse = 9;
$a_3_chanse = 30;
break;
case 15:
$a_3_bonus = 41;
$a_3_crit_chanse = 9;
$a_3_chanse = 30;
break;
case 16:
$a_3_bonus = 41;
$a_3_crit_chanse = 11;
$a_3_chanse = 35;
break;
case 17:
$a_3_bonus = 44;
$a_3_crit_chanse = 11;
$a_3_chanse = 35;
break;
case 18:
$a_3_bonus = 47;
$a_3_crit_chanse = 11;
$a_3_chanse = 35;
break;
case 19:
$a_3_bonus = 50;
$a_3_crit_chanse = 11;
$a_3_chanse = 35;
break;
case 20:
$a_3_bonus = 53;
$a_3_crit_chanse = 11;
$a_3_chanse = 35;
break;
case 21:
$a_3_bonus = 53;
$a_3_crit_chanse = 13;
$a_3_chanse = 40;
break;
case 22:
$a_3_bonus = 77;
$a_3_crit_chanse = 15;
$a_3_chanse = 45;
break;
case 23:
$a_3_bonus = 89;
$a_3_crit_chanse = 17;
$a_3_chanse = 50;
break;
case 24:
$a_3_bonus = 89;
$a_3_crit_chanse = 17;
$a_3_chanse = 50;
break;
}
if(mt_rand(0, 100) <= $a_3_chanse) {
$a_3 = true;
}
}
if($user['ability_5'] > 0) {
switch($user['ability_5']) {
case 0:
$a_5_bonus = 20;
$a_5_chanse = 5;
break;
case 1:
$a_5_bonus = 20;
$a_5_chanse = 5;
break;
case 2:
$a_5_bonus = 22;
$a_5_chanse = 5;
break;
case 3:
$a_5_bonus = 24;
$a_5_chanse = 5;
break;
case 4:
$a_5_bonus = 26;
$a_5_chanse = 5;
break;
case 5:
$a_5_bonus = 28;
$a_5_chanse = 5;
break;
case 6:
$a_5_bonus = 28;
$a_5_chanse = 10;
break;
case 7:
$a_5_bonus = 30;
$a_5_chanse = 10;
break;
case 8:
$a_5_bonus = 32;
$a_5_chanse = 10;
break;
case 9:
$a_5_bonus = 34;
$a_5_chanse = 10;
break;
case 10:
$a_5_bonus = 36;
$a_5_chanse = 10;
break;
case 11:
$a_5_bonus = 36;
$a_5_chanse = 15;
break;
case 12:
$a_5_bonus = 38;
$a_5_chanse = 15;
break;
case 13:
$a_5_bonus = 40;
$a_5_chanse = 15;
break;
case 14:
$a_5_bonus = 42;
$a_5_chanse = 15;
break;
case 15:
$a_5_bonus = 44;
$a_5_chanse = 15;
break;
case 16:
$a_5_bonus = 44;
$a_5_chanse = 20;
break;
case 17:
$a_5_bonus = 46;
$a_5_chanse = 20;
break;
case 18:
$a_5_bonus = 48;
$a_5_chanse = 20;
break;
case 19:
$a_5_bonus = 50;
$a_5_chanse = 20;
break;
case 20:
$a_5_bonus = 52;
$a_5_chanse = 20;
break;
case 21:
$a_5_bonus = 52;
$a_5_chanse = 25;
break;
case 22:
$a_5_bonus = 68;
$a_5_chanse = 30;
break;
case 23:
$a_5_bonus = 76;
$a_5_chanse = 35;
break;
case 24:
$a_5_bonus = 76;
$a_5_chanse = 35;
break;
}
if(mt_rand(0, 100) <= $a_5_chanse) {
$a_5 = true;
}
}
$dmg +=mt_rand((int)floor(((int)$user['str'])/6), max((int)floor(((int)$user['str'])/6),(int)ceil(((int)$user['str'])/4)));
if($a_1 == true) {
$dmg += round(($dmg / 100) * $a_1_bonus);
}
$dmg -= mt_rand((int)floor(((int)$opponent['def'])/12), max((int)floor(((int)$opponent['def'])/12),(int)ceil(((int)$opponent['def'])/7)));
if($dmg < 0) {
$dmg = 0;
}
if($a_3 == true) {
$crit = ( (rand(1,2) * ($user['agi'] / 100) + $a_3_crit_chanse ) - (rand(1,2) * ($opponent['agi'] / 100)));
}
else
{
$crit = ( (rand(1,2) * ($user['agi'] / 100) ) - (rand(1,2) * ($opponent['agi'] / 100)));
}
if(mt_rand(0, 100) <= $crit) {
$dmg *= 2;
if($a_3 == true) {
$dmg += round(($dmg / 100) * $a_3_bonus);
}
}
$dodge = ( (rand(1,2) * ($opponent['agi'] / 100) ) - (rand(1,2) * ($user['agi'] / 100)));
if(mt_rand(0, 100) <= $dodge) {
$dmg = 0;
}
$opponent_dmg +=mt_rand((int)floor(((int)$opponent['str'])/6), max((int)floor(((int)$opponent['str'])/6),(int)ceil(((int)$opponent['str'])/4)));
if($a_2 == true) {
$opponent_dmg -= round(($opponent_dmg / 100) * $a_2_bonus);
}
# by Метриум (Стэлп)
// старт
if($clan_memb && $clan['build_act']>time()) {
$_exp+= $clan['build_1']*rand(1,2);
}
if($clan_memb && $clan['build_act']>time()) {
$_s+= $clan['build_2'];
}
// конец
$opponent_dmg -= mt_rand((int)floor(((int)$user['def'])/12), max((int)floor(((int)$user['def'])/12),(int)ceil(((int)$user['def'])/7)));
if($opponent_dmg < 0) {
$opponent_dmg = 0;
}
$opponent_crit = ( (rand(1,2) * ($opponent['agi'] / 100) ) - (rand(1,2) * ($user['agi'] / 100)));
if(mt_rand(0, 100) <= $opponent_crit) {
$opponent_dmg *= 2;
if($a_4 == true) {
$opponent_dmg -= round(($opponent_dmg / 100) * $a_4_bonus);
}
}
$opponent_dodge = ( (rand(1,2) * ($user['agi'] / 100) ) - (rand(1,2) * ($opponent['agi'] / 100)));
if(mt_rand(0, 100) <= $opponent_dodge) {
$opponent_dmg = 0;
}
}
//////награда за спус маны////
if($dmg > $opponent_dmg) {
$_c +=1;
$_s += round(rand(1,4) * $user['level']);
$_exp += round(rand(1,4) * $user['level']);
$win+= 1;
}
else
{
$_s += round(rand(1,2) / $user['level']);
$_exp += round(rand(4,7) / $user['level']);
$los+= 1;
}
}
if($clan_memb && $clan_memb['v'] > 0) {
$_exp += round($_exp/100) * $clan_memb['v'];
}
$lab_1 = db_fetch_array(db_query("SELECT * FROM `lab_` WHERE `user` = '".$user['id']."' AND `type` = '1'"));
$lab_2 = db_fetch_array(db_query("SELECT * FROM `lab_` WHERE `user` = '".$user['id']."' AND `type` = '2'"));
$lab_3 = db_fetch_array(db_query("SELECT * FROM `lab_` WHERE `user` = '".$user['id']."' AND `type` = '2'"));
if($premium) {
$_exp+= round($_exp/ 100) * 25;
}
// старт
if($clan_memb && $clan['build_act']>time()) {
$_exp+= $clan['build_1']*rand(1,2);
}
if($clan_memb && $clan['build_act']>time()) {
$_s+= $clan['build_2'];
}
// конец
if($user['vip_time'] >= time()) {
$_exp+= round($_exp/ 100) * 50;
}
if($lab_1) {
$_exp+= round($_exp/ 100) * 75;
}
if($lab_2) {
$_exp+= round($_exp/ 100) * 25;
}
if($lab_3) {
$_exp+= round($_exp/ 100) * 25;
}
$V_C = db_fetch_array(db_query('SELECT * FROM `v_clan` WHERE `user` = '.(int)$user['id']));
$vClanExpBonus = (int)($V_C['v'] ?? 0);
if (in_array($vClanExpBonus, [10, 50, 100, 150, 200], true)) {
$_exp += (int)round($_exp / 100 * $vClanExpBonus);
}
$_exp += round($_exp/ 100) * $sk;
for($i = 1; $i <= 3; $i++) {
if((int)($_effshop['effshop_'.$i] ?? 0) > time()) $_exp += round($_exp/ 100) * 25;
}
$ArenaStat = $win + $los;
db_query('UPDATE `users` SET `mp` = 0,
`exp` = `exp` + '.($_exp * 5).',
`s` = `s` + '.($_s * 5).',
`boy_arena` = `boy_arena` + '.($fights * 5).',
`g` = `g` - '.(int)$arenaFiveCost.' WHERE `id` = "'.$user['id'].'"');
db_query('INSERT INTO `arena_bulk_usage` (`user`,`uses`) VALUES ('.(int)$user['id'].',5) ON DUPLICATE KEY UPDATE `uses`=`uses`+5');
db_query('INSERT INTO `arena_stage_progress` (`user`,`manual_fights`,`all_runs`,`paid_runs`) VALUES ('.(int)$user['id'].',0,5,5) ON DUPLICATE KEY UPDATE `all_runs`=`all_runs`+5,`paid_runs`=`paid_runs`+5');
//
if((int)($CollectorSystem['coll'] ?? 999) <= 6) {
$ArenaStat = $win + $los;
db_query('UPDATE `users` SET `battle_collector` = `battle_collector` + '.($ArenaStat * 5).' WHERE `id` = "'.$user['id'].'"');
}
//
//
if((int)($ClanBattle['BATTLE'] ?? 0) === 1) {
$battleArena->ClanArenaNotOpponent($_exp);
}
//
if((int)($a_f['on/off'] ?? 0) > time() && db_result(db_query('SELECT COUNT(*) FROM `tj_users` WHERE `id_user` = "'.$user['id'].'" LIMIT 1'),0) == '1'){
db_query("UPDATE `tj_users` SET `wins` = `wins` + ".($win * 5)." WHERE `id_user` = '$user[id]'") or die(db_error());
db_query("UPDATE `users` SET `win_battle` = `win_battle` + ".($win * 5)." WHERE `id` = '$user[id]'");
}
if($clan) {
// Клановые задания для серии из пяти боёв. v50.6
if(game_clan_quest_is_week_open()){
$questFights=max(0,((int)$win+(int)$los)*5);
if($questFights>0){
game_clan_quest_increment((int)$clan['id'],1,(int)$user['id'],$questFights);
game_clan_quest_increment((int)$clan['id'],2,(int)$user['id'],$questFights);
}
if((int)$win>0) game_clan_quest_increment((int)$clan['id'],7,(int)$user['id'],(int)$win*5);
}
//конец
db_query('UPDATE `clans` SET `exp` = `exp` + '.($_exp * 5).' WHERE `id` = "'.$clan['id'].'"');
db_query('UPDATE `clan_memb` SET `exp` = `exp` + '.($_exp * 5).' WHERE `clan` = "'.$clan['id'].'" AND `user` = "'.$user['id'].'"');
db_query('UPDATE `clans` SET `arena` = `arena` + '.($_c * 5).' WHERE `id` = "'.$clan['id'].'"');
/* clan_memb has no arena column in the production schema; clan total is stored in clans.arena. by Метриум (Стэлп) */
}
$vsego = $win + $los;
?>
<div class='center'><div class='block_light'><h2 class='dgreen' style='font-weight:bold;'><img src='/images/icon/2hit.png' alt=''/> Проведено <?=($vsego * 5)?> боев <img src='/images/icon/2hit.png' alt=''/></h2><div class='separ'></div><img src='/images/icon/1.png' alt=''/> <span class='dgreen'>Побед: <span class='bold'><?=($win * 5)?></span></span> | <img src='/images/icon/2.png' alt=''/> <span class='dred'>Поражений: <span class='bold'><?=($los * 5)?></span></span> <div class='separ'></div><span class='blue'>Награда:</span> <img src='/images/icon/silver.png' alt=''/> <?=($_s * 5)?> серебра <img src='/images/icon/exp.png' alt='exp'/> <?=($_exp * 5)?> опыта<br/>
<?php
game_quest_progress_event((int)$user['id'],1,max(0,((int)$win+(int)$los)*5),max(0,(int)$win*5));
// Единый прогресс заданий арены v50.7.
if($a_1 == true OR $a_2 == true OR $a_3 == true OR $a_4 == true OR $a_5 == true) {
?>
<div clasa='separ'></div>
<?php
if($a_1 == true) echo ' <img src='/images/ability/1.'.$user['ability_1_quality'].'.png' width='25px' height='25px' alt='*'/> ';
if($a_2 == true) echo ' <img src='/images/ability/2.'.$user['ability_2_quality'].'.png' width='25px' height='25px' alt='*'/> ';
if($a_3 == true) echo ' <img src='/images/ability/3.'.$user['ability_3_quality'].'.png' width='25px' height='25px' alt='*'/> ';
if($a_4 == true) echo ' <img src='/images/ability/4.'.$user['ability_4_quality'].'.png' width='25px' height='25px' alt='*'/> ';
if($a_5 == true) echo ' <img src='/images/ability/5.'.$user['ability_5_quality'].'.png' width='25px' height='25px' alt='*'/> ';
}
$w_chanse = rand(1,100);
$chanse = rand(1,10) * rand(1,100);
if($chanse < $w_chanse) {
$w = db_query('SELECT * FROM `shop` WHERE `id` < 73 ORDER BY RAND() LIMIT 1');
$w = db_fetch_array($w);
if(db_result(db_query('SELECT COUNT(*) FROM `inv` WHERE `place` = "0" AND `user` = "'.$user['id'].'"'),0) + 1 < 20) {
db_query('INSERT INTO `inv` (`user`,
`item`,
`bonus`,
`_str`,
`_vit`,
`_agi`,
`_def`) VALUES ("'.$user['id'].'",
"'.$w['id'].'",
"'.$w['bonus'].'",
"'.$w['_str'].'",
"'.$w['_vit'].'",
"'.$w['_agi'].'",
"'.$w['_def'].'")');
$w_id = db_insert_id();
$w = db_query('SELECT * FROM `inv` WHERE `id` = "'.$w_id.'"');
$w = db_fetch_array($w);
$item = db_query('SELECT * FROM `items` WHERE `id` = "'.$w['item'].'"');
$item = db_fetch_array($item);
db_query('UPDATE `inv` SET `quality` = '.$item['quality'].' WHERE `id` = '.$w_id);
{
?>
<div class='separator'></div>
<font color='#f0c060'>Новая вещь в твоей <img src='/images/icon/bag.png' alt=''/> <a href='/inv/bag/'><u>сумке</u></a>!</font><br/>
<?php
switch($item['quality']) {
case 0:
$bonus = 0;
$quality = 'Простой';
$quality_color = "#908060";
break;
case 1:
$bonus = 5;
$quality = 'Обычный';
$quality_color = "#60c030";
break;
case 2:
$bonus = 10;
$quality = 'Редкий';
$quality_color = "#6090c0";
break;
case 3:
$bonus = 15;
$quality = 'Эпический';
$quality_color = "#c060f0";
break;
case 4:
$bonus = 20;
$quality = 'Легендарный';
$quality_color = "#f06000";
break;
case 5:
$bonus = 50;
$quality = 'Божественный';
$quality_color = "#909090";
break;
case 6:
$bonus = 65;
$quality = 'Титанический';
$quality_color = "#909090";
break;
}
?>
<div align='center'>
<table cellpadding='0' cellspacing='0'>
<tr>
<td><img src='/itemImage.php?id=<?=$w['item']?>' alt='*'/></td>
<td valign='top' align='left' style='padding-left: 5px;'><img src='/images/icon/quality/<?=$item['quality']?>.png' alt='*'/> <a href='/item/<?=$w['id']?>/'><?=$item['name']?></a>
<br/>
<small><small>
<font color="<?=$quality_color?>"><?=$quality?> [<?=$w['bonus']?>/<?=$bonus?>]</font>
<?php
if($user['w_'.$item['w']] != 0) {
$equip_item = db_query('SELECT * FROM `inv` WHERE `id` = "'.$user['w_'.$item['w']].'"');
$equip_item = db_fetch_array($equip_item);
if(($w['_str'] + $w['_vit'] + $w['_agi'] + $w['_def']) - ($equip_item['_str'] + $equip_item['_vit'] + $equip_item['_agi'] + $equip_item['_def']) > 0) {
?>
<font color='#30c030'>+<?=($w['_str'] + $w['_vit'] + $w['_agi'] + $w['_def']) - ($equip_item['_str'] + $equip_item['_vit'] + $equip_item['_agi'] + $equip_item['_def'])?></font>
<?php
}
}
else
{
?>
<font color="#30c030">+<?=($w['_str'] + $w['_vit'] + $w['_agi'] + $w['_def'])?></font>
<?php
}
?>
</small></small></td></tr></table>
</div>
<?php
}
}
}
?>
<div class='mb10'></div>
<?php arena_render_bulk_actions($user); ?><div class='mb5'></div><a class='grey' href='/arena/'>Назад на арену</a></div></div>
<?php
}
if(db_result(db_query('SELECT * FROM `arena` WHERE `user` = "'.$user['id'].'"'),0) == 0) {
db_query('INSERT INTO `arena` (`user`) VALUES ("'.$user['id'].'")');
}
$arena = db_query('SELECT * FROM `arena` WHERE `user` = "'.$user['id'].'"');
$arena = db_fetch_array($arena);
if(($_GET['last'] ?? false) == true) {
$opponent = arena_pick_opponent($user);
$arena['opponent'] = (int)$opponent['id'];
db_execute('UPDATE `arena` SET `opponent` = :opponent WHERE `user` = :user', ['opponent'=>$arena['opponent'],'user'=>(int)$user['id']]);
header('Location: /arena/');
exit;
}
if (empty($arena['opponent'])) {
$opponent = arena_pick_opponent($user);
$arena['opponent'] = (int)$opponent['id'];
db_execute('UPDATE `arena` SET `opponent` = :opponent WHERE `user` = :user', ['opponent'=>$arena['opponent'],'user'=>(int)$user['id']]);
} else {
$opponent = arena_load_opponent((int)$arena['opponent'], $user);
if (!$opponent || (int)$opponent['id'] === (int)$user['id']) {
$opponent = arena_pick_opponent($user);
$arena['opponent'] = (int)$opponent['id'];
db_execute('UPDATE `arena` SET `opponent` = :opponent WHERE `user` = :user', ['opponent'=>$arena['opponent'],'user'=>(int)$user['id']]);
}
}
if($arenaAttackRequested) {
if((time() - $arena['time']) < 0)
{
header("Location: /arena");
exit();
}
if($user['mp'] > 49 && $user['hp'] > ( ( ($user['vit'] * 2) / 100 ) * 10 )) {
$dmg = 0;
$opponent_dmg = 0;
for($round = 1; $round < 6; $round++) {
if($user['ability_1'] > 0) {
switch($user['ability_1']) {
case 0:
$a_1_bonus = 25;
$a_1_chanse = 5;
break;
case 1:
$a_1_bonus = 25;
$a_1_chanse = 5;
break;
case 2:
$a_1_bonus = 30;
$a_1_chanse = 5;
break;
case 3:
$a_1_bonus = 35;
$a_1_chanse = 5;
break;
case 4:
$a_1_bonus = 40;
$a_1_chanse = 5;
break;
case 5:
$a_1_bonus = 45;
$a_1_chanse = 5;
break;
case 6:
$a_1_bonus = 45;
$a_1_chanse = 8;
break;
case 7:
$a_1_bonus = 50;
$a_1_chanse = 8;
break;
case 8:
$a_1_bonus = 55;
$a_1_chanse = 8;
break;
case 9:
$a_1_bonus = 60;
$a_1_chanse = 8;
break;
case 10:
$a_1_bonus = 65;
$a_1_chanse = 8;
break;
case 11:
$a_1_bonus = 65;
$a_1_chanse = 11;
break;
case 12:
$a_1_bonus = 70;
$a_1_chanse = 11;
break;
case 13:
$a_1_bonus = 75;
$a_1_chanse = 11;
break;
case 14:
$a_1_bonus = 80;
$a_1_chanse = 11;
break;
case 15:
$a_1_bonus = 85;
$a_1_chanse = 11;
break;
case 16:
$a_1_bonus = 85;
$a_1_chanse = 14;
break;
case 17:
$a_1_bonus = 90;
$a_1_chanse = 14;
break;
case 18:
$a_1_bonus = 95;
$a_1_chanse = 14;
break;
case 19:
$a_1_bonus = 100;
$a_1_chanse = 14;
break;
case 20:
$a_1_bonus = 105;
$a_1_chanse = 14;
break;
case 21:
$a_1_bonus = 105;
$a_1_chanse = 17;
break;
case 22:
$a_1_bonus = 145;
$a_1_chanse = 20;
break;
case 23:
$a_1_bonus = 165;
$a_1_chanse = 23;
break;
case 24:
$a_1_bonus = 165;
$a_1_chanse = 23;
break;
}
if(mt_rand(0, 100) <= $a_1_chanse) {
$a_1 = true;
}
}
if($user['ability_2'] > 0) {
switch($user['ability_2']) {
case 0:
$a_2_bonus = 25;
$a_2_chanse = 5;
break;
case 1:
$a_2_bonus = 25;
$a_2_chanse = 5;
break;
case 2:
$a_2_bonus = 30;
$a_2_chanse = 5;
break;
case 3:
$a_2_bonus = 35;
$a_2_chanse = 5;
break;
case 4:
$a_2_bonus = 40;
$a_2_chanse = 5;
break;
case 5:
$a_2_bonus = 45;
$a_2_chanse = 5;
break;
case 6:
$a_2_bonus = 45;
$a_2_chanse = 8;
break;
case 7:
$a_2_bonus = 50;
$a_2_chanse = 8;
break;
case 8:
$a_2_bonus = 55;
$a_2_chanse = 8;
break;
case 9:
$a_2_bonus = 60;
$a_2_chanse = 8;
break;
case 10:
$a_2_bonus = 65;
$a_2_chanse = 8;
break;
case 11:
$a_2_bonus = 65;
$a_2_chanse = 11;
break;
case 12:
$a_2_bonus = 70;
$a_2_chanse = 11;
break;
case 13:
$a_2_bonus = 75;
$a_2_chanse = 11;
break;
case 14:
$a_2_bonus = 80;
$a_2_chanse = 11;
break;
case 15:
$a_2_bonus = 85;
$a_2_chanse = 11;
break;
case 16:
$a_2_bonus = 85;
$a_2_chanse = 14;
break;
case 17:
$a_2_bonus = 90;
$a_2_chanse = 14;
break;
case 18:
$a_2_bonus = 95;
$a_2_chanse = 14;
break;
case 19:
$a_2_bonus = 100;
$a_2_chanse = 14;
break;
case 20:
$a_2_bonus = 105;
$a_2_chanse = 14;
break;
case 21:
$a_2_bonus = 105;
$a_2_chanse = 17;
break;
case 22:
$a_2_bonus = 145;
$a_2_chanse = 20;
break;
case 23:
$a_2_bonus = 165;
$a_2_chanse = 23;
break;
case 24:
$a_2_bonus = 165;
$a_2_chanse = 23;
break;
}
if(mt_rand(0, 100) <= $a_2_chanse) {
$a_2 = true;
}
}
if($user['ability_3'] > 0) {
switch($user['ability_3']) {
case 0:
$a_3_bonus = 5;
$a_3_crit_chanse = 5;
$a_3_chanse = 20;
break;
case 1:
$a_3_bonus = 5;
$a_3_crit_chanse = 5;
$a_3_chanse = 20;
break;
case 2:
$a_3_bonus = 8;
$a_3_crit_chanse = 5;
$a_3_chanse = 20;
break;
case 3:
$a_3_bonus = 11;
$a_3_crit_chanse = 5;
$a_3_chanse = 20;
break;
case 4:
$a_3_bonus = 14;
$a_3_crit_chanse = 5;
$a_3_chanse = 20;
break;
case 5:
$a_3_bonus = 17;
$a_3_crit_chanse = 5;
$a_3_chanse = 20;
break;
case 6:
$a_3_bonus = 17;
$a_3_crit_chanse = 7;
$a_3_chanse = 25;
break;
case 7:
$a_3_bonus = 20;
$a_3_crit_chanse = 7;
$a_3_chanse = 25;
break;
case 8:
$a_3_bonus = 23;
$a_3_crit_chanse = 7;
$a_3_chanse = 25;
break;
case 9:
$a_3_bonus = 26;
$a_3_crit_chanse = 7;
$a_3_chanse = 25;
break;
case 10:
$a_3_bonus = 29;
$a_3_crit_chanse = 7;
$a_3_chanse = 25;
break;
case 11:
$a_3_bonus = 29;
$a_3_crit_chanse = 9;
$a_3_chanse = 30;
break;
case 12:
$a_3_bonus = 32;
$a_3_crit_chanse = 9;
$a_3_chanse = 30;
break;
case 13:
$a_3_bonus = 35;
$a_3_crit_chanse = 9;
$a_3_chanse = 30;
break;
case 14:
$a_3_bonus = 38;
$a_3_crit_chanse = 9;
$a_3_chanse = 30;
break;
case 15:
$a_3_bonus = 41;
$a_3_crit_chanse = 9;
$a_3_chanse = 30;
break;
case 16:
$a_3_bonus = 41;
$a_3_crit_chanse = 11;
$a_3_chanse = 35;
break;
case 17:
$a_3_bonus = 44;
$a_3_crit_chanse = 11;
$a_3_chanse = 35;
break;
case 18:
$a_3_bonus = 47;
$a_3_crit_chanse = 11;
$a_3_chanse = 35;
break;
case 19:
$a_3_bonus = 50;
$a_3_crit_chanse = 11;
$a_3_chanse = 35;
break;
case 20:
$a_3_bonus = 53;
$a_3_crit_chanse = 11;
$a_3_chanse = 35;
break;
case 21:
$a_3_bonus = 53;
$a_3_crit_chanse = 13;
$a_3_chanse = 40;
break;
case 22:
$a_3_bonus = 77;
$a_3_crit_chanse = 15;
$a_3_chanse = 45;
break;
case 23:
$a_3_bonus = 89;
$a_3_crit_chanse = 17;
$a_3_chanse = 50;
break;
case 24:
$a_3_bonus = 89;
$a_3_crit_chanse = 17;
$a_3_chanse = 50;
break;
}
if(mt_rand(0, 100) <= $a_3_chanse) {
$a_3 = true;
}
}
if($user['ability_4'] > 0) {
switch($user['ability_4']) {
case 0:
$a_4_bonus = 20;
$a_4_chanse = 5;
break;
case 1:
$a_4_bonus = 20;
$a_4_chanse = 5;
break;
case 2:
$a_4_bonus = 22;
$a_4_chanse = 5;
break;
case 3:
$a_4_bonus = 24;
$a_4_chanse = 5;
break;
case 4:
$a_4_bonus = 26;
$a_4_chanse = 5;
break;
case 5:
$a_4_bonus = 28;
$a_4_chanse = 5;
break;
case 6:
$a_4_bonus = 28;
$a_4_chanse = 10;
break;
case 7:
$a_4_bonus = 30;
$a_4_chanse = 10;
break;
case 8:
$a_4_bonus = 32;
$a_4_chanse = 10;
break;
case 9:
$a_4_bonus = 34;
$a_4_chanse = 10;
break;
case 10:
$a_4_bonus = 36;
$a_4_chanse = 10;
break;
case 11:
$a_4_bonus = 36;
$a_4_chanse = 15;
break;
case 12:
$a_4_bonus = 38;
$a_4_chanse = 15;
break;
case 13:
$a_4_bonus = 40;
$a_4_chanse = 15;
break;
case 14:
$a_4_bonus = 42;
$a_4_chanse = 15;
break;
case 15:
$a_4_bonus = 44;
$a_4_chanse = 15;
break;
case 16:
$a_4_bonus = 44;
$a_4_chanse = 20;
break;
case 17:
$a_4_bonus = 46;
$a_4_chanse = 20;
break;
case 18:
$a_4_bonus = 48;
$a_4_chanse = 20;
break;
case 19:
$a_4_bonus = 50;
$a_4_chanse = 20;
break;
case 20:
$a_4_bonus = 52;
$a_4_chanse = 20;
break;
case 21:
$a_4_bonus = 52;
$a_4_chanse = 25;
break;
case 22:
$a_4_bonus = 68;
$a_4_chanse = 30;
break;
case 23:
$a_4_bonus = 76;
$a_4_chanse = 35;
break;
case 24:
$a_4_bonus = 76;
$a_4_chanse = 35;
break;
}
if(mt_rand(0, 100) <= $a_4_chanse) {
$a_4 = true;
}
}
$dmg +=mt_rand((int)floor(((int)$user['str'])/6), max((int)floor(((int)$user['str'])/6),(int)ceil(((int)$user['str'])/4)));
if($a_1 == true) {
$dmg += round(($dmg / 100) * $a_1_bonus);
}
$dmg -= mt_rand((int)floor(((int)$opponent['def'])/12), max((int)floor(((int)$opponent['def'])/12),(int)ceil(((int)$opponent['def'])/7)));
if($dmg < 0) {
$dmg = 0;
}
if($a_3 == true) {
$crit = ( (rand(1,2) * ($user['agi'] / 100) + $a_3_crit_chanse ) - (rand(1,2) * ($opponent['agi'] / 100)));
}
else
{
$crit = ( (rand(1,2) * ($user['agi'] / 100) ) - (rand(1,2) * ($opponent['agi'] / 100)));
}
if(mt_rand(0, 100) <= $crit) {
$dmg *= 2;
if($a_3 == true) {
$dmg += round(($dmg / 100) * $a_3_bonus);
}
}
$dodge = ( (rand(1,2) * ($opponent['agi'] / 100) ) - (rand(1,2) * ($user['agi'] / 100)));
if(mt_rand(0, 100) <= $dodge) {
$dmg = 0;
}
$opponent_dmg +=mt_rand((int)floor(((int)$opponent['str'])/6), max((int)floor(((int)$opponent['str'])/6),(int)ceil(((int)$opponent['str'])/4)));
if($a_2 == true) {
$opponent_dmg -= round(($opponent_dmg / 100) * $a_2_bonus);
}
$opponent_dmg -= mt_rand((int)floor(((int)$user['def'])/12), max((int)floor(((int)$user['def'])/12),(int)ceil(((int)$user['def'])/7)));
if($opponent_dmg < 0) {
$opponent_dmg = 0;
}
$opponent_crit = ( (rand(1,2) * ($opponent['agi'] / 100) ) - (rand(1,2) * ($user['agi'] / 100)));
if(mt_rand(0, 100) <= $opponent_crit) {
$opponent_dmg *= 2;
if($a_4 == true) {
$opponent_dmg -= round(($opponent_dmg / 100) * $a_4_bonus);
}
}
$opponent_dodge = ( (rand(1,2) * ($user['agi'] / 100) ) - (rand(1,2) * ($opponent['agi'] / 100)));
if(mt_rand(0, 100) <= $opponent_dodge) {
$opponent_dmg = 0;
}
}
if($dmg > $opponent_dmg) {
$_hp = round($opponent_dmg / 4);
}
else
{
$_hp = round($opponent_dmg / 2);
}
if($_hp > $user['hp']) {
$_hp = $user['hp'];
}
db_query('UPDATE `users` SET `hp` = `hp` - '.$_hp.',
`mp` = `mp` - 50,
`boy_arena` = `boy_arena` + 1 WHERE `id` = "'.$user['id'].'"');
$user['boy_arena'] = (int)($user['boy_arena'] ?? 0) + 1;
db_query('INSERT INTO `arena_stage_progress` (`user`,`manual_fights`,`all_runs`,`paid_runs`) VALUES ('.(int)$user['id'].',1,0,0) ON DUPLICATE KEY UPDATE `manual_fights`=`manual_fights`+1');
?>
<div class='block center'>
<?php
$win = ($dmg > $opponent_dmg) ? 1 : 0;
$los = $win ? 0 : 1;
if($dmg > $opponent_dmg) {
$_s = rand(1,100) + (rand(1,10) * $opponent['level']);
$_exp = rand(1,5) * $opponent['level'];
if($clan_memb && $clan_memb['v'] > 0) {
$_exp += round($_exp/100) * $clan_memb['v'];
}
?>
<div class='center'><div class='block_light'>
<img src='/images/icon/2hit.png' alt='*'/> <font color='#90c090'><b>Победа!</b></font> <img src='/images/icon/2hit.png' alt='*'/>
<?php
}
else
{
$_s = rand(1,3) + (rand(1,3) * $opponent['level']);
$_exp = rand(1,2) * $opponent['level'];
if($clan_memb && $clan_memb['v'] > 0) {
$_exp += round($_exp/100) * $clan_memb['v'];
}
?>
<img src='/images/icon/2hit.png' alt='*'/> <font color='#c06060'><b>Поражение!</b></font> <img src='/images/icon/2hit.png' alt='*'/>
<?php
}
if ($dmg > $opponent_dmg) { db_execute("UPDATE `users` SET `arena_pobed` = CAST(COALESCE(NULLIF(`arena_pobed`, ''), '0') AS UNSIGNED) + 1 WHERE `id` = :id", ['id'=>(int)$user['id']]); }
if($_s < 1) {
$_s = 1;
}
if($_exp < 1) {
$_exp = 1;
}
$lab_1 = db_fetch_array(db_query("SELECT * FROM `lab_` WHERE `user` = '".$user['id']."' AND `type` = '1'"));
$lab_2 = db_fetch_array(db_query("SELECT * FROM `lab_` WHERE `user` = '".$user['id']."' AND `type` = '2'"));
$lab_3 = db_fetch_array(db_query("SELECT * FROM `lab_` WHERE `user` = '".$user['id']."' AND `type` = '3'"));
if($premium) {
$_exp+= round($_exp/ 100) * 25;
}
if($user['vip_time'] >= time()) {
$_exp+= round($_exp/ 100) * 50;
}
if($lab_1) {
$_exp+= round($_exp/ 100) * 25;
}
if($lab_2) {
$_exp+= round($_exp/ 100) * 25;
}
if($lab_3) {
$_exp+= round($_exp/ 100) * 25;
}
if($win > 0 && (int)($a_f['on/off'] ?? 0) > time() && db_result(db_query('SELECT COUNT(*) FROM `tj_users` WHERE `id_user` = "'.$user['id'].'" LIMIT 1'),0) == '1'){
db_query("UPDATE `tj_users` SET `wins` = `wins` + 1 WHERE `id_user` = '$user[id]'") or die(db_error());
db_query("UPDATE `users` SET `win_battle`=`win_battle`+1 WHERE `id`='".(int)$user['id']."'");
}
if($clan) {
// Клановые задания для одиночного боя. v50.6
if(game_clan_quest_is_week_open()){
game_clan_quest_increment((int)$clan['id'],1,(int)$user['id'],1);
game_clan_quest_increment((int)$clan['id'],2,(int)$user['id'],1);
if((int)$win>0) game_clan_quest_increment((int)$clan['id'],7,(int)$user['id'],1);
}
//конец
db_query('UPDATE `clans` SET `exp` = `exp` + '.$_exp.' WHERE `id` = "'.$clan['id'].'"');
db_query('UPDATE `clan_memb` SET `exp` = `exp` + '.$_exp.' WHERE `clan` = "'.$clan['id'].'" AND `user` = "'.$user['id'].'"');
db_query('UPDATE `clans` SET `arena` = `arena` + 1 WHERE `id` = "'.$clan['id'].'"');
/* clan_memb has no arena column in the production schema; clan total is stored in clans.arena. by Метриум (Стэлп) */
}
$opponent = arena_pick_opponent($user);
$arena['opponent'] = (int)$opponent['id'];
db_execute('UPDATE `arena` SET `opponent` = :opponent, `time` = :time WHERE `user` = :user', [
'opponent'=>$arena['opponent'], 'time'=>time()+1, 'user'=>(int)$user['id']
]);
?>
<div class='separ'></div>
<?php
if($a_1 == true OR $a_2 == true OR $a_3 == true OR $a_4 == true OR $a_5 == true) {
?>
<?php
if($a_1 == true) echo ' <img src='/images/ability/1.'.$user['ability_1_quality'].'.png' width='25px' height='25px' alt='*'/> ';
if($a_2 == true) echo ' <img src='/images/ability/2.'.$user['ability_2_quality'].'.png' width='25px' height='25px' alt='*'/> ';
if($a_3 == true) echo ' <img src='/images/ability/3.'.$user['ability_3_quality'].'.png' width='25px' height='25px' alt='*'/> ';
if($a_4 == true) echo ' <img src='/images/ability/4.'.$user['ability_4_quality'].'.png' width='25px' height='25px' alt='*'/> ';
if($a_5 == true) echo ' <img src='/images/ability/5.'.$user['ability_5_quality'].'.png' width='25px' height='25px' alt='*'/> ';
?>
<div class='separ'></div>
<?php
}
?>
<img src='/images/icon/silver.png' alt="*"/> <?=n_f($_s)?> серебра <img src='/images/icon/exp.png' alt='*'/> <?=n_f($_exp)?> опыта
<?php
$w_chanse = rand(1,50);
$chanse = rand(1,10) * rand(1,70);
if($chanse < $w_chanse) {
$w = db_fetch_array(db_query('SELECT * FROM `shop` WHERE `quality` < '3' ORDER BY RAND() LIMIT 1'));
if(db_num_rows(db_query('SELECT * FROM `inv` WHERE `place` = '0' AND `user` = ''.$user['id'].''')) + 1 < $user['inv']) {
db_query('INSERT INTO `inv` (`user`,
`item`,
`quality`,
`bonus`,
`_str`,
`_vit`,
`_agi`,
`_def`) VALUES (''.$user['id'].'',
''.$w['id'].'',
''.$w['quality'].'',
''.$w['bonus'].'',
''.$w['_str'].'',
''.$w['_vit'].'',
''.$w['_agi'].'',
''.$w['_def'].'')');
$w_id = db_insert_id();
$w = db_fetch_array(db_query('SELECT * FROM `inv` WHERE `id` = ''.$w_id.'''));
$item = db_fetch_array(db_query('SELECT * FROM `items` WHERE `id` = ''.$w['item'].'''));
{
?>
<div class='separator'></div>
<font color='#f0c060'>Новая вещь в твоей <img src='/images/icon/bag.png' alt=''/> <a href='/inv/bag/'><u>сумке</u></a>!</font><br/>
<?php
switch($w['quality']) {
case 0:
$bonus = 0;
$quality = 'Простой';
$quality_color = "#908060";
break;
case 1:
$bonus = 5;
$quality = 'Обычный';
$quality_color = "#60c030";
break;
case 2:
$bonus = 10;
$quality = 'Редкий';
$quality_color = "#6090c0";
break;
case 3:
$bonus = 15;
$quality = 'Эпический';
$quality_color = "#c060f0";
break;
case 4:
$bonus = 20;
$quality = 'Легенарный';
$quality_color = "#f06000";
break;
case 5:
$bonus = 50;
$quality = 'Божественный';
$quality_color = "#909090";
break;
case 6:
$bonus = 65;
$quality = 'Сверх Божественный';
$quality_color = "#909090";
break;
}
?>
<div align='center'>
<table cellpadding='0' cellspacing='0'>
<tr>
<td><img src='/itemImage.php?id=<?=$w['item']?>' alt='*'/></td>
<td valign='top' align='left' style='padding-left: 5px;'><img src='/images/icon/quality/<?=$w['quality']?>.png' alt='*'/> <a href='/item/<?=$w['id']?>/'><?=$item['name']?></a>
<br/>
<small><small>
<font color="<?=$quality_color?>"><?=$quality?> [<?=$w['bonus']?>/<?=$bonus?>]</font>
<?php
if($user['w_'.$item['w']] != 0) {
$equip_item = db_query('SELECT * FROM `inv` WHERE `id` = "'.$user['w_'.$item['w']].'"');
$equip_item = db_fetch_array($equip_item);
if(($w['_str'] + $w['_vit'] + $w['_agi'] + $w['_def']) - ($equip_item['_str'] + $equip_item['_vit'] + $equip_item['_agi'] + $equip_item['_def']) > 0) {
?>
<font color='#30c030'>+<?=($w['_str'] + $w['_vit'] + $w['_agi'] + $w['_def']) - ($equip_item['_str'] + $equip_item['_vit'] + $equip_item['_agi'] + $equip_item['_def'])?></font>
<?php
}
}
else
{
?>
<font color="#30c030">+<?=($w['_str'] + $w['_vit'] + $w['_agi'] + $w['_def'])?></font>
<?php
}
?>
</small></small></td></tr></table>
</div>
<?php
}
}
}
if($user['level'] > 4) {
?>
<?php
}
?>
</div>
</div></div>
<?php
db_query('UPDATE `users` SET `mp` = `mp` - '.($fights * 50).',
`exp` = `exp` + '.$_exp.',
`s` = `s` + '.$_s.',
`klu` = `klu` + "'.$klu.'" WHERE `id` = "'.$user['id'].'"');
if((int)($CollectorSystem['coll'] ?? 999) <= 6) {
db_query('UPDATE `users` SET `battle_collector` = `battle_collector` + 1 WHERE `id` = "'.$user['id'].'"');
}
////
if((int)($ClanBattle['BATTLE'] ?? 0) === 1) {
$battleArena->ClanArenaNotOpponent($_exp);
}
//
}
else
{
?>
<div class='mini-line'></div>
<div class='block' align='center'>
<font color='#c06060'>Для нападения надо минимум <img src='/images/icon/health.png' alt='*'/> 10% жизни и <img src='/images/icon/mana.png' alt='*'/> 50 маны</font>
<div class='separ'></div>
<table cellpadding='0' cellspacing='0'>
<tr>
<td><img src='/images/alchemy/potion.png' alt='*'/></td>
<td valign='top' style='padding-left: 5px;' align='left'><b>Настойка бодрости</b><br/>
<small><small>+100% маны и жизни</small></small></td>
</tr></table>
<div class='separ'></div>
<div align='center'>
<a class='btn' href='/lab/wiz/?potion=true&referal=/arena'><span class='end'><span class='label'>Купить</span></span></a>
<br/><br/>
<font color='#909090'>Цена: <img src='/images/icon/gold.png' alt='*'/> 15 золота</font>
</div>
</div>
<div class='mini-line'></div>
<?php
}
}
if($arenaAttackRequested) {
}
else
{
?>
<?php
}
$opponent = arena_load_opponent((int)($arena['opponent'] ?? 0), $user);
$w_1 = db_query('SELECT * FROM `inv` WHERE `user` = "'.$opponent['id'].'" AND `id` = "'.$opponent['w_1'].'"');
$w_1 = db_fetch_array($w_1) ?: ['item' => 0];
$w_2 = db_query('SELECT * FROM `inv` WHERE `user` = "'.$opponent['id'].'" AND `id` = "'.$opponent['w_2'].'"');
$w_2 = db_fetch_array($w_2) ?: ['item' => 0];
$w_3 = db_query('SELECT * FROM `inv` WHERE `user` = "'.$opponent['id'].'" AND `id` = "'.$opponent['w_3'].'"');
$w_3 = db_fetch_array($w_3) ?: ['item' => 0];
$w_4 = db_query('SELECT * FROM `inv` WHERE `user` = "'.$opponent['id'].'" AND `id` = "'.$opponent['w_4'].'"');
$w_4 = db_fetch_array($w_4) ?: ['item' => 0];
$w_5 = db_query('SELECT * FROM `inv` WHERE `user` = "'.$opponent['id'].'" AND `id` = "'.$opponent['w_5'].'"');
$w_5 = db_fetch_array($w_5) ?: ['item' => 0];
$w_6 = db_query('SELECT * FROM `inv` WHERE `user` = "'.$opponent['id'].'" AND `id` = "'.$opponent['w_6'].'"');
$w_6 = db_fetch_array($w_6) ?: ['item' => 0];
$w_7 = db_query('SELECT * FROM `inv` WHERE `user` = "'.$opponent['id'].'" AND `id` = "'.$opponent['w_7'].'"');
$w_7 = db_fetch_array($w_7) ?: ['item' => 0];
$w_8 = db_query('SELECT * FROM `inv` WHERE `user` = "'.$opponent['id'].'" AND `id` = "'.$opponent['w_8'].'"');
$w_8 = db_fetch_array($w_8) ?: ['item' => 0];
if(!isset($lastPlayer) && !isset($lastPlayer2)){
arena_render_bulk_actions($user);
?>
<div class='main'>
<div class='block_zero'>
<?php
$league = array( '', 'новичков', 'опытных', 'претендентов', 'мастеров', 'титанов', 'избранных' );
?>
<?php /* Дубль старого обучения удалён. by Метриум (Стэлп) */ ?>
<div class='menuList'><li><a href='/league/'><span class='yellow'><img src='/images/icon/league.png' alt=''/><span class='bold'>Лига <?=$league[$user['league']]?></span><span class='green'><?=( $user['league_fights'] > 1 ? '<font color='#30c030'>(+)</font>':'')?></span></span><div class='float-right'></span></div></a></li></div>
<div class='mini-line'>
<div class='main' align='center'><div class='block_zero'>
<font color='#90b0c0'>Побеждай врагов и становись сильнее!</font>
</div></div>
<div class='mini-line'></div>
<div class="block_zero center">
<div class="float-left"> <img src='/images/icon/race/<?=$opponent['r']?>.png' alt='*'/> <?=$opponent['login']?></div>
<div class="float-right">Мощь противника: <img src="/images/icon/2hit.png" alt=""> <?=$opponent['str']?></div>
<div style='margin-bottom:5px;clear:both;'></div>
<div class="arena_bg center">
<center/><a href='/arena/?attack=true'><img src='/manekenImage2/<?=((int)($opponent['sex'] ?? 0) === 1 ? 1 : 0)?>/<?=$w_1['item']?>/<?=$w_2['item']?>/<?=$w_3['item']?>/<?=$w_4['item']?>/<?=$w_5['item']?>/<?=$w_6['item']?>/<?=$w_7['item']?>/<?=$w_8['item']?>/' width='120' height='160' alt='Противник'/></a>
</div>
<div class="dot-line"></div>
<div style='margin-bottom:5px;'></div>
<a href='/arena/?attack=true' class="btns _g"><span class="end"><span class="label">Атакoвать</span></span></a>
</div><div class="mini-line"></div>
<div class="block_zero">Моя сила: <img src="/images/icon/2hit.png" alt=""> <?=$user['str']?> <br></div><div class="mini-line"></div>
<ul class="hint"><li>Чем сильнее противник, тем больше опыта и серебра получишь за победу!</li></ul>
</div></div>
<div class='max-line'></div>
<div class='player menuList'>
<?php
}
include './system/f.php';
?>