Файл: public_html/cave_battle_town.php
Строк: 974
<?php
require_once './element_options/element_options.php';
if (!$user or $user['lost_town'] == 0) { header('Location: /'); exit; }
$title = 'Бой в пещере';
if (readcache('element_user_mesto'.$user['lost_id']) != $title) writecache('element_user_mesto'.$user['lost_id'], $title);
writecache('element_chat_lost_post_'.$user['lost_id'], time());
if (isset($_GET['monster'])) // AND `action`='1'
{
$my_arena = mysql_fetch_assoc(mysql_query("SELECT * FROM `cave_list_town`
INNER JOIN `cave_monsters_town` ON (`cave_list_town`.`monster`=`cave_monsters_town`.`id`)
WHERE `user`='{$user['lost_id']}' AND `monster`='".mysql_real_escape_string($_GET['monster'])."' LIMIT 1"));
}
else
{
$my_arena = mysql_fetch_assoc(mysql_query("SELECT * FROM `cave_list_town`
INNER JOIN `cave_monsters_town` ON (`cave_list_town`.`monster`=`cave_monsters_town`.`id`)
WHERE `user`='{$user['lost_id']}' LIMIT 1"));
}
if ( ! $my_arena)
{
header('Location: /cave_town.php?1');
exit;
}
if ($my_arena['action'] == '0')
{
$title = 'Подземелье';
require_once './element_include/element_head.php';
require_once './element_include/element_header_user_true.php';
require_once './element_function/element_function_battle.php';
echo '<body><div class="p5">';
$list = mysql_query("SELECT * FROM `cave_list_town`
INNER JOIN `element_user` ON (`lost_id`=`cave_list_town`.`user` AND `lost_town`='{$user_town['lost_id']}')
WHERE `monster`='{$my_arena['monster']}' AND `action`='0'");
$chat_to_user = (isset($_GET['to'])) ? $_GET['to'].', ' : '';
$cache_chat = readcache('chat_cave_town_'.$my_arena['monster']);
if (!is_array($cache_chat)) $cache_chat = array();
if ( ! empty($_POST['text']))
{
$error = '';
$text = trim($_POST['text']);
if (empty($text)) $error = 'Поле 'text' обязательно для ввода';
if (empty($error))
{
$text = addslashes(htmlspecialchars($text));
$send = array('user_id' => $user['lost_id'], 'text' => $text, 'time' => time());
array_push($cache_chat, $send);
if (count($cache_chat) > element_settings_game('lost_chat_max_count')) array_shift($cache_chat);
writecache('chat_cave_town_'.$my_arena['monster'], $cache_chat);
header('Location: /cave_town/battle/'.$my_arena['monster']);
exit;
}
}
if ($go == 'exit')
{
mysql_query("DELETE FROM `cave_list_town` WHERE `monster`='{$my_arena['monster']}' AND `user`='{$user['lost_id']}' LIMIT 1");
header("Location: /cave_town");
exit;
}
$exp_town_set = explode(':', $user['lost_town_other']);
if ($go == 'start' && ($exp_town_set[0] == 5 or $user_town['lost_create_user'] == $user['lost_id']))
{
//if (mysql_num_rows($list) >= $my_arena['players'])
//{
$ttt = time() + 10;
$array = array('other' => array('timer' => $ttt, 'active' => 0), 'team_1_kick' => array(), 'team_2_kick' => array());
$array['team_2'][$my_arena['monster']] = array('battle_hp' => $my_arena['health'], 'other_hp' => $my_arena['health'], 'target' => 0, 'time_udar' => false, 'uron' => 0, 'battle_uron' => 0);
$rand_number_arena = rand(100, 9999999);
$journal = array('other' => array(KeyJournalMassiv($ttt) => '<span class="lngreen bold">Бой начался</span>'));
while ($value = mysql_fetch_assoc($list))
{
$arena_user = cache_user($value['user']);
$arena_user_hp = GenerationMaxHeatpoints($arena_user['lost_params_heatpoints']);
ResetAbilitiesUser($value['user']);
$array['team_1'][$value['user']] = array(
'battle_hp' => $arena_user_hp,
'other_hp' => $arena_user_hp,
'target' => 0,
'time_udar' => false,
'uron' => 0,
'battle_uron' => 0);
mysql_query("UPDATE `cave_list_town` SET `ident`='{$rand_number_arena}', `action`='1' WHERE `id`='{$value['id']}' LIMIT 1");
writecache('cave_town_users'.$value['user'], array('id_team' => $rand_number_arena, 'user_team' => 'team_1', 'user_game' => 1));
$journal[$value['user']] = array();
}
writecache('cave_town_'.$rand_number_arena.'journal', $journal);
writecache('cave_town_'.$rand_number_arena, $array);
//}
header("Location: /cave_town/battle/{$my_arena['monster']}");
exit;
}
echo '<form method="post">
<input class="fdark w98 mb10" type="text" name="text" value="'.$chat_to_user.'" size="20" maxlength="255">
<span class="button w30 mt3"><input type="submit" class="ttl" name="submit" value="Отправить"/></span>
<a class="small ccc" href="/cave_town/battle/'.$my_arena['monster'].'">Обновить</a>
</form>';
if (empty($cache_chat))
{
echo '<div class="p5 cntr"><span class="small ccc">В чате нету сообщений</span></div>';
echo '</div>';
}
else
{
krsort($cache_chat);
require_once './element_function/element_function_pagination.php';
$page = (isset($_GET['page']) AND is_numeric($_GET['page'])) ? (int)$_GET['page'] : 1;
$pagination = pagination(10, $page, count($cache_chat));
foreach(array_slice($cache_chat, $pagination['start'], $pagination['num'], true) as $k => $massiv) {
$chat_user = cache_user($massiv['user_id']);
$on_off = (!empty($online[$massiv['user_id']])) ? 'online' : 'offline';
$text = Color_Privilege($chat_user['lost_privilege'], ReplaceText($user['lost_login'], $massiv['text']));
$text = Smiles($text, true);
echo '
<div class="mt5">
<a class="yellow1 sndr bl" href="/user?id='.$massiv['user_id'].'">
<span class="small fr pt2 lngreen">'.Timer($massiv['time']).'</span>
'.ikonka_user($chat_user['lost_race'], $on_off).' <span class="small">'.$chat_user['lost_login'].'</span>
</a>';
echo '<span class="small">'.$text.'</span>';
echo '<br/><a class="ccc small" href="/cave_town/battle/'.$my_arena['monster'].'?to='.$chat_user['lost_login'].'">[Ответить]</a>';
echo '<br/> </div>';
}
echo '</div>';
echo pagination_echo($pagination['page'],$pagination['total'],'/cave_town/battle/'.$my_arena['monster'].'?page=');
}
echo '<div class="yellow1 mb5 mt5 small cntr">В подземелье ('.mysql_num_rows($list).'/'.$my_arena['players'].')</div>';
echo '<div class="nfl p5 mb5 mt5 small mlra">';
$i = 1;
while ($value = mysql_fetch_assoc($list))
{
$odd = (($i % 2) ? ' odd' : '');
$cache_user = cache_user($value['user']);
echo '<div class="ml5 mr5">
<a class="bl p5 block'.$odd.'" href="/user?id='.$value['user'].'">
<span class="moderator small fr">Рейтинг: <span class="bold">'.$cache_user['lost_dostig_peshera'].'</span></span>
<span class="small mb5 yellow1"><span class="white">'.$i.'.</span>
'.ikonka_user($cache_user['lost_race'], ((!empty($online[$value['user']])) ? 'online' : 'offline')).'
'.$cache_user['lost_login'].'</span></a></div>';
$i++;
}
echo '</div>';
$exp_town_set = explode(':', $user['lost_town_other']);
if ($exp_town_set[0] == 5 or $user_town['lost_create_user'] == $user['lost_id'])
{
echo '<div class="yellow1 mb5 small cntr"><a class="button w40 mt5" href="/cave_town/battle/'.$my_arena['monster'].'?go=start">Начать бой</a></div>';
}
echo '<div class="yellow1 mb5 small cntr"><a class="button w40 mt5" href="/cave_town/battle/'.$my_arena['monster'].'?go=exit">Выйти из очереди</a></div>';
require_once './element_include/element_foot_user_true.php';
die;
}
$time = time();
$arena = readcache('cave_town_'.$my_arena['ident']);
if (!$arena)
{
header('Location: /cave_town.php?2');
exit;
}
$journal = readcache('cave_town_'.$my_arena['ident'].'journal');
if (!empty($arena['team_1'][$user['lost_id']])) { $my_team = 'team_1'; $my_life = true; }
else if (!empty($arena['team_1_kick'][$user['lost_id']])) { $my_team = 'team_1'; $my_life = false; }
else if (!empty($arena['team_2'][$user['lost_id']])) { $my_team = 'team_2'; $my_life = true; }
else { $my_team = 'team_2'; $my_life = false; }
$no_team = ($my_team == 'team_1') ? 'team_2' : 'team_1';
$count_team = array('team_1' => count($arena['team_1']), 'team_2' => count($arena['team_2']));
if ($arena['other']['active'] == 0)
{
$game = ($time > $arena['other']['timer']) ? true : false;
$title = 'Пещера';
require_once './element_include/element_head.php';
require_once './element_include/element_header_user_true.php';
require_once './element_function/element_function_battle.php';
echo '<body><div class="p5">';
if ($game)
{
$timer = $arena['other']['timer'];
if ($my_life)
{
$abil_ogon = AbilitiesOgon($user['lost_abilities_ogon'], $user['lost_race'], false, $user['lost_id']);
$abil_voda = AbilitiesVoda($user['lost_abilities_voda'], $user['lost_race'], false, $user['lost_id']);
$abil_zeml = AbilitiesZemlya($user['lost_abilities_zemlya'], $user['lost_race'], false, $user['lost_id']);
$abil_vosd = AbilitiesVozdyh($user['lost_abilities_vozduh'], $user['lost_race'], false, $user['lost_id']);
$add_hp = 0;
$update = false;
if ($arena[$my_team][$user['lost_id']]['target'] == 0)
{
$rand_target = array_rand($arena[$no_team]);
$arena[$my_team][$user['lost_id']]['target'] = $rand_target;
$target_user = mysql_fetch_assoc(mysql_query("SELECT * FROM `cave_monsters_town` WHERE `id`='{$rand_target}' LIMIT 1"));
$target_user['lost_id'] = $target_user['id'];
$target_user['lost_login'] = $target_user['name'];
$target_user['lost_race'] = 2;
$target_user['lost_abilities_zemlya'] = 0;
$target_user['lost_params_protection'] = $target_user['protect'];
$update = true;
}
else
{
$target_user = cache_user($arena[$my_team][$user['lost_id']]['target']);
$target_user = mysql_fetch_assoc(mysql_query("SELECT * FROM `cave_monsters_town` WHERE `id`='{$my_arena['monster']}' LIMIT 1"));
$target_user['lost_id'] = $target_user['id'];
$target_user['lost_login'] = $target_user['name'];
$target_user['lost_race'] = 2;
$target_user['lost_abilities_zemlya'] = 0;
$target_user['lost_params_protection'] = $target_user['protect'];
}
$uron = 0;
if ($go == 'attaka')
{
$no_abil_zeml = AbilitiesZemlya($target_user['lost_abilities_zemlya'], $target_user['lost_race'], false, $target_user['lost_id']);
if ($id == 1 AND !$abil_ogon['activate'])
{
$abil_ogon = AbilitiesOgon($user['lost_abilities_ogon'], $user['lost_race'], true, $user['lost_id']);
$image = quality_item_name($user['lost_abilities_ogon']);
$journal['other'][KeyJournalMassiv($timer)] = '<span class="yellow1"><span class="bold">'.$user['lost_login'].'</span> активировал '.$image['image'].' <span class="bold">Огненную силу</span></span>';
}
if ($id == 2 AND !$abil_voda['activate'])
{
$abil_voda = AbilitiesVoda($user['lost_abilities_voda'], $user['lost_race'], true, $user['lost_id']);
$image = quality_item_name($user['lost_abilities_voda']);
$journal['other'][KeyJournalMassiv($timer)] = '<span class="yellow1"><span class="bold">'.$user['lost_login'].'</span> активировал '.$image['image'].' <span class="bold">Водяной крит</span></span>';
}
if ($id == 3 AND !$abil_vosd['active'])
{
$abil_vosd = AbilitiesVozdyh($user['lost_abilities_vozduh'], $user['lost_race'], true, $user['lost_id']);
$image = quality_item_name($user['lost_abilities_vozduh']);
$journal['other'][KeyJournalMassiv($timer)] = '<span class="yellow1"><span class="bold">'.$user['lost_login'].'</span> активировал '.$image['image'].' <span class="bold">Ловушку ветра</span></span>';
if ($abil_vosd['add_hp'] > 0)
{
$add_hp = (int)(($arena[$no_team][$target_user['lost_id']]['other_hp'] / 100) * $abil_vosd['add_hp']);
$my_ras_hp = $arena[$my_team][$user['lost_id']]['other_hp'] - $arena[$my_team][$user['lost_id']]['battle_hp'];
if ($add_hp > $my_ras_hp) $add_hp = $my_ras_hp;
$arena[$no_team][$target_user['lost_id']]['battle_hp'] = $arena[$no_team][$target_user['lost_id']]['battle_hp'] - $add_hp;
$arena[$my_team][$user['lost_id']]['battle_hp'] = $arena[$my_team][$user['lost_id']]['battle_hp'] + $add_hp;
$journal['other'][KeyJournalMassiv($timer)] = '<span class="error1"><span class="bold">'.$user['lost_login'].'</span> забрал у <span class="bold">'.$target_user['lost_login'].' '.$add_hp.'</span> здоровья</span>';
} else $journal[$user['lost_id']][KeyJournalMassiv($timer)] = '<span class="error1">Умение не сработало</span>';
}
if ($id == 4 AND !$abil_zeml['activate'])
{
$abil_zeml = AbilitiesZemlya($user['lost_abilities_zemlya'], $user['lost_race'], true, $user['lost_id']);
$image = quality_item_name($user['lost_abilities_zemlya']);
$journal['other'][KeyJournalMassiv($timer)] = '<span class="yellow1"><span class="bold">'.$user['lost_login'].'</span> активировал '.$image['image'].' <span class="bold">Земляную стойкость</span></span>';
}
$uron = GenerationUron($user['lost_params_strlen'], $arena[$my_team][$user['lost_id']]['time_udar'], $abil_ogon['add_procent'], $abil_voda['add_procent'], $no_abil_zeml['add_procent'], GenerationProtection($target_user['lost_params_protection']));
$arena[$no_team][$target_user['lost_id']]['battle_hp'] = $arena[$no_team][$target_user['lost_id']]['battle_hp'] - $uron;
$arena[$no_team][$target_user['lost_id']]['uron'] = $arena[$no_team][$target_user['lost_id']]['uron'] + $uron;
$arena[$my_team][$user['lost_id']]['battle_uron'] = $arena[$my_team][$user['lost_id']]['battle_uron'] + $uron;
$arena[$my_team][$user['lost_id']]['time_udar'] = microtime();
$arena[$my_team][$user['lost_id']]['uron'] = 0;
$journal['other'][KeyJournalMassiv($timer)] = '<span class="bold">'.$user['lost_login'].'</span> ударил <span class="yellow1 bold">'.$target_user['lost_login'].'</span> на <span class="yellow1 bold">'.$uron.'</span> урон '.(($abil_voda['add_procent'] > 0) ? 'крит' : '');
$_art = array_rand($arena[$my_team]);
$_part = cache_user($_art);
$uron = GenerationUron($target_user['power'], $arena[$no_team][$target_user['lost_id']]['time_udar'], 50, 1100, 50, GenerationProtection($_part['lost_params_protection']));
$arena[$my_team][$_art]['battle_hp'] = $arena[$my_team][$_art]['battle_hp'] - $uron;
$arena[$my_team][$_art]['uron'] = $arena[$my_team][$_art]['uron'] + $uron;
$arena[$no_team][$target_user['lost_id']]['battle_uron'] = $arena[$no_team][$target_user['lost_id']]['battle_uron'] + $uron;
$arena[$no_team][$target_user['lost_id']]['time_udar'] = microtime();
$arena[$no_team][$target_user['lost_id']]['uron'] = 0;
$journal['other'][KeyJournalMassiv($timer)] = '<span class="bold">'.$target_user['lost_login'].'</span> ударил <span class="yellow1 bold">'.$_part['lost_login'].'</span> на <span class="yellow1 bold">'.$uron.'</span> урон';
if ($arena[$no_team][$target_user['lost_id']]['battle_hp'] <= 0)
{
$arena[$no_team.'_kick'][$target_user['lost_id']] = $arena[$no_team][$target_user['lost_id']];
unset($arena[$no_team][$target_user['lost_id']]);
$journal['other'][KeyJournalMassiv($timer)] = '<span class="yellow1"><span class="bold">'.$user['lost_login'].'</span> убил <span class="bold">'.$target_user['lost_login'].'</span></span>';
$arena[$my_team][$user['lost_id']]['target'] = 0;
if (count($arena[$no_team]) == 0)
{
$arena['other']['active'] = 1;
$team_win = $arena[$my_team] + $arena[$my_team.'_kick'];
$team_los = $arena[$no_team] + $arena[$no_team.'_kick'];
foreach ($team_win as $id_user => $value)
{
$cache_user = cache_user($id_user);
$cache_user['lost_dostig_peshera'] = $cache_user['lost_dostig_peshera'] + 1;
update_money_exp($cache_user, $target_user['award_exp'], $target_user['award_kr'], $target_user['award_ir'], $target_user['award_gold']);
$shoot_item = users_shoot_item($cache_user['lost_id']);
$create_item = create_item($cache_user['lost_id'], $shoot_item, $my_arena['wear'], $my_arena['procent_str'], $my_arena['procent_hp'], $my_arena['procent_pr'], false, false, false, false, false);
$arena['wear'][$cache_user['lost_id']] = $create_item;
mysql_query("UPDATE `element_item` SET `lost_bag`='-{$cache_user['lost_town']}' WHERE `lost_id` = '$create_item' LIMIT 1");
$shoot_item = town_items($cache_user['lost_id']);
$shoot_item[$create_item] = $create_item;
writecache('town_items_town_id'.$cache_user['lost_town'], $shoot_item);
}
$journal['other'][KeyJournalMassiv($timer)] = '<span class="lngreen bold">Бой закончен!</span>';
writecache('cave_town_'.$my_arena['ident'].'journal', $journal);
writecache('cave_town_'.$my_arena['ident'], $arena);
header('Location: /cave_town/battle/'.$my_arena['monster']);
exit;
}
writecache('cave_town_'.$my_arena['ident'].'journal', $journal);
writecache('cave_town_'.$my_arena['ident'], $arena);
header('Location: /cave_town/battle/'.$my_arena['monster']);
exit;
}
if ($arena[$my_team][$_art]['battle_hp'] <= 0)
{
$arena[$my_team.'_kick'][$_art] = $arena[$my_team][$_art];
unset($arena[$my_team][$_art]);
$journal['other'][KeyJournalMassiv($timer)] = '<span class="yellow1"><span class="bold">'.$target_user['lost_login'].'</span> убил <span class="bold">'.$_part['lost_login'].'</span></span>';
$arena[$no_team][$target_user['lost_id']]['target'] = 0;
if (count($arena[$my_team]) == 0)
{
$arena['other']['active'] = 1;
$team_win = $arena[$no_team] + $arena[$no_team.'_kick'];
$team_los = $arena[$my_team] + $arena[$my_team.'_kick'];
foreach ($team_win as $id_user => $value)
{
$cache_user = cache_user($id_user);
$cache_user['lost_dostig_peshera'] = $cache_user['lost_dostig_peshera'] + 1;
update_money_exp($cache_user, 0, 0, 1, 0);
}
foreach ($team_los as $id_user => $value)
{
$cache_user = cache_user($id_user);
update_money_exp($cache_user, 0, 0, 0, 0);
}
$journal['other'][KeyJournalMassiv($timer)] = '<span class="lngreen bold">Бой закончен!</span>';
writecache('cave_town_'.$my_arena['ident'].'journal', $journal);
writecache('cave_town_'.$my_arena['ident'], $arena);
header('Location: /cave_town/battle/'.$my_arena['monster']);
exit;
}
writecache('cave_town_'.$my_arena['ident'].'journal', $journal);
writecache('cave_town_'.$my_arena['ident'], $arena);
header('Location: /cave_town/battle/'.$my_arena['monster']);
exit;
}
writecache('cave_town_'.$my_arena['ident'].'journal', $journal);
writecache('cave_town_'.$my_arena['ident'], $arena);
$update = false;
}
$my_user = array('user_race' => $user['lost_race'], 'user_hp' => $arena[$my_team][$user['lost_id']]['battle_hp'],
'user_other_hp' => $arena[$my_team][$user['lost_id']]['other_hp'], 'user_name' => $user['lost_login'],
'user_uron' => $arena[$my_team][$user['lost_id']]['uron'], 'user_add_hp' => $add_hp);
$no_user = array('user_race' => $target_user['lost_race'], 'user_hp' => $arena[$no_team][$target_user['lost_id']]['battle_hp'],
'user_other_hp' => $arena[$no_team][$target_user['lost_id']]['other_hp'], 'user_name' => $target_user['lost_login'],
'user_uron' => $uron, 'user_add_hp' => 0);
echo '<div class="small mb5 cntr yellow1">';
echo '<img src="/images/icons/arena_team_1.gif"> Наши: '.$count_team[$my_team].' ';
echo '<img src="/images/icons/arena_team_2.gif"> Враги: '.$count_team[$no_team].' ';
echo '<img src="/images/icons/clock.gif"> '.date("i:s", mktime(0, 0, (time() - $arena['other']['timer'])));
echo '</div>';
EchoTableUsersBattle($my_user, $no_user);
EchoAbiliteBattle($abil_ogon, $abil_voda, $abil_vosd, $abil_zeml, true, 'w15', '30', 0, '/cave_town/battle/'.$my_arena['monster']);
$user_journal = $journal['other'] + $journal[$user['lost_id']];
krsort($user_journal);
if (count($user_journal) > 0)
{
echo '<div class="yellow1 mb5 mt5 small cntr">Журнал боя:</div>';
echo '<div class="nfl p5 mb5 small mlra">';
foreach (array_slice($user_journal, 0, 10, true) as $value)
{
echo '<span class="white">'.$value.'<span><br/>';
}
echo '</div>';
}
echo '<div class="mb5 small error1 cntr"><a class="button w60" href="/">Выйти с боя</a></div>';
if ($update) writecache('cave_town_'.$my_arena['ident'], $arena);
}
else
{
echo '<div class="mb5 small error1 cntr">Вы погибли в бою. Ждите окончания боя.';
echo '<br/><a class="button w40 mt5" href="/cave_town/battle/'.$my_arena['monster'].'">Обновить</a></div>';
echo '<div class="yellow1 mb5 mt5 small cntr">Моя команда:</div>';
echo '<div class="nfl p5 mb5 mt5 small mlra">';
$i = 1;
foreach($arena[$my_team] as $user_id => $value)
{
$odd = (($i % 2) ? ' odd' : '');
$cache_user = cache_user($user_id);
echo '<div class="ml5 mr5">
<a class="bl p5 block'.$odd.'" href="/user?id='.$user_id.'">
<span class="moderator small fr"><img src="/images/icons/heatpoints.png"> <span class="bold">'.$value['battle_hp'].'</span></span>
<span class="small mb5 yellow1"><span class="white">'.$i.'.</span>
'.ikonka_user($cache_user['lost_race'], ((!empty($online[$user_id])) ? 'online' : 'offline')).'
'.$cache_user['lost_login'].'</span></a></div>';
$i++;
}
echo '</div>';
echo '<div class="yellow1 mb5 mt5 small cntr">Противники:</div>';
echo '<div class="nfl p5 mb5 mt5 small mlra">';
$i = 1;
foreach($arena[$no_team] as $user_id => $value)
{
$odd = (($i % 2) ? ' odd' : '');
$cache_user = mysql_fetch_assoc(mysql_query("SELECT * FROM `cave_monsters_town` WHERE `id`='{$my_arena['monster']}' LIMIT 1"));
$cache_user['lost_dostig_peshera'] = '+ 1';
$cache_user['lost_race'] = 2;
$cache_user['lost_login'] = $cache_user['name'];
echo '<div class="ml5 mr5">
<a class="bl p5 block'.$odd.'" href="/user?id='.$user_id.'">
<span class="moderator small fr"><img src="/images/icons/heatpoints.png"> <span class="bold">'.$value['battle_hp'].'</span></span>
<span class="small mb5 yellow1"><span class="white">'.$i.'.</span>
'.ikonka_user($cache_user['lost_race'], ((!empty($online[$user_id])) ? 'online' : 'offline')).'
'.$cache_user['lost_login'].'</span></a></div>';
$i++;
}
echo '</div>';
$user_journal = $journal['other'] + $journal[$user['lost_id']];
krsort($user_journal);
if (count($user_journal) > 0)
{
echo '<div class="yellow1 mb5 mt5 small cntr">Журнал боя:</div>';
echo '<div class="nfl p5 mb5 small mlra">';
foreach (array_slice($user_journal, 0, 10, true) as $value)
{
echo '<span class="white">'.$value.'<span><br/>';
}
echo '</div>';
}
}
}
else
{
echo '<div class="yellow1 mb5 small cntr">Бой начнется через '.($arena['other']['timer'] - time()).' секунд';
echo '<br/><a class="button w40 mt5" href="/cave_town/battle/'.$my_arena['monster'].'">Обновить</a></div>';
echo '<div class="yellow1 mb5 mt5 small cntr">Моя команда:</div>';
echo '<div class="nfl p5 mb5 mt5 small mlra">';
$i = 1;
foreach($arena[$my_team] as $user_id => $value)
{
$odd = (($i % 2) ? ' odd' : '');
$cache_user = cache_user($user_id);
echo '<div class="ml5 mr5">
<a class="bl p5 block'.$odd.'" href="/user?id='.$user_id.'">
<span class="moderator small fr">Рейтинг: <span class="bold">'.$cache_user['lost_dostig_peshera'].'</span></span>
<span class="small mb5 yellow1"><span class="white">'.$i.'.</span>
'.ikonka_user($cache_user['lost_race'], ((!empty($online[$user_id])) ? 'online' : 'offline')).'
'.$cache_user['lost_login'].'</span></a></div>';
$i++;
}
echo '</div>';
echo '<div class="yellow1 mb5 mt5 small cntr">Противник:</div>';
echo '<div class="nfl p5 mb5 mt5 small mlra">';
$i = 1;
foreach($arena[$no_team] as $user_id => $value)
{
$odd = (($i % 2) ? ' odd' : '');
$cache_user = mysql_fetch_assoc(mysql_query("SELECT * FROM `cave_monsters_town` WHERE `id`='{$my_arena['monster']}' LIMIT 1"));
echo '<div class="ml5 mr5">
<div class="bl p5 block'.$odd.'">
<span class="small mb5 yellow1"><span class="white">'.$i.'.</span>
'.ikonka_user(2, ((!empty($online[$user_id])) ? 'online' : 'offline')).'
'.$cache_user['name'].'</span></div></div>';
$i++;
}
echo '</div>';
}
require_once './element_include/element_foot_user_true.php';
exit;
}
else
{
$target_user = mysql_fetch_assoc(mysql_query("SELECT * FROM `cave_monsters_town` WHERE `id`='{$my_arena['monster']}' LIMIT 1"));
//mysql_query("DELETE FROM `cave_list_town` WHERE `user`='".mysql_real_escape_string($user['lost_id'])."' AND `monster`='{$my_arena['monster']}' LIMIT 1");
mysql_query("UPDATE `cave_list_town` SET `action`='2', `next_battle`=UNIX_TIMESTAMP()+'".(($count_team[$my_team] == 0 ? $target_user['ttl_los'] : $target_user['ttl_win']) * 3600)."' WHERE `user`='".mysql_real_escape_string($user['lost_id'])."' AND `monster`='{$my_arena['monster']}' LIMIT 1");
writecache('cave_town_'.$my_arena['ident'], array());
if ($count_team[$my_team] != 0)
{
$next_monster = mysql_fetch_assoc(mysql_query("SELECT `id` FROM `cave_monsters_town` WHERE `id`>'{$my_arena['monster']}' ORDER BY `id` LIMIT 1"));
if (empty($next_monster['id']))
{
$next_monster['id'] = $my_arena['monster'] + 1;
}
$user_town['cave_id'] = $next_monster['id'];
mysql_query("UPDATE `element_town` SET `cave_id`='{$next_monster['id']}' WHERE `lost_id`='{$user_town['lost_id']}' LIMIT 1");
writecache('element_town_id_'.$user_town['lost_id'], $user_town);
}
$title = 'Пещеры';
require_once './element_include/element_head.php';
require_once './element_include/element_header_user_true.php';
require_once './element_function/element_function_battle.php';
echo '<body><div class="p5">';
echo '<div class="cntr title bold">'.(($count_team[$my_team] == 0) ? '<span class="red">Ваша команда проиграла!</span>' : '<span class="lngreen">Ваша команда победила!</span>').'</div>';
echo '<div class="hr w80 mlra mb5 mt5"></div>';
echo '<div class="cntr bold moderator small">';
$statistika = $arena[$my_team] + $arena[$my_team.'_kick'];
echo 'Нанесено урона в бою: '.$statistika[$user['lost_id']]['battle_uron'];
echo (($count_team[$no_team] == 0) ? '<br/>Ирридий: <img src="/images/icons/irridyi.png">+'.$target_user['award_ir'] : '');
echo (($count_team[$no_team] == 0) ? '<br/>Кристалы: <img src="/images/icons/cristall.png">+'.$target_user['award_kr'] : '');
echo (($count_team[$no_team] == 0) ? '<br/>Золото: <img src="/images/icons/gold.png">+'.$target_user['award_gold'] : '');
echo (($count_team[$no_team] == 0) ? '<br/>Рейтинг: '.$user['lost_dostig_peshera'].' (+1)' : '<br/><span class="error1">Рейтинг: '.$user['lost_dostig_peshera'].' (-1)</span>').'';
echo '</div>';
if (isset($arena['wear'][$user['lost_id']]))
{
require_once './element_function/element_function_item.php';
$item_id = cache_item($arena['wear'][$user['lost_id']]);
$genaration_params = item_generation_params($item_id['lost_strlen'], $item_id['lost_heatpoints'], $item_id['lost_protection'], $item_id['lost_comparison']);
$quality = quality_item_name($item_id['lost_quality']);
echo '<div class="mlra"><table class="mlra"><td><img width="50" height="50" src="'.$item_id['lost_avatar'].'"></td>';
echo '<td class="small left" valign="top">';
echo '<span class="ml5 small yellow1">'.$quality['image'].' <a href="/item?id='.$item_id['lost_id'].'">'.$item_id['lost_name'].'</a></span><br/>';
echo '<span class="ml5 small lngreen">'.name_item_mesto($item_id['lost_mesto']).'</span>';
echo '</td></table></div>';
}
echo '<div class="hr w80 mlra mb5 mt5"></div>';
echo '<div class="cntr small"><a class="button w50 mt5" href="/cave_town.php">В пещеру</a></div>';
if ($count_team['team_1'] == 0) { $losse = 'team_1'; $wins = 'team_2'; } else { $losse = 'team_2'; $wins = 'team_1'; }
echo '<div class="yellow1 mb5 mt5 small cntr">Победитель:</div>';
echo '<div class="nfl p5 mb5 mt5 small mlra">';
$i = 1;
foreach(($arena[$wins] + $arena[$wins.'_kick']) as $user_id => $value)
{
$odd = (($i % 2) ? ' odd' : '');
if ($wins == 'team_2')
{
$cache_user = mysql_fetch_assoc(mysql_query("SELECT * FROM `cave_monsters_town` WHERE `id`='{$my_arena['monster']}' LIMIT 1"));
$cache_user['lost_dostig_peshera'] = '+ 1';
$cache_user['lost_race'] = 2;
$cache_user['lost_login'] = $cache_user['name'];
}
else
{
$cache_user = cache_user($user_id);
}
echo '<div class="ml5 mr5">
<a class="bl p5 block'.$odd.'" href="/user?id='.$user_id.'">
<span class="moderator small fr">Рейтинг: <span class="bold">'.$cache_user['lost_dostig_peshera'].', <img src="/images/icons/irridyi.png">+1, '.$value['battle_uron'].'</span></span>
<span class="small mb5 yellow1"><span class="white">'.$i.'.</span>
'.ikonka_user($cache_user['lost_race'], ((!empty($online[$user_id])) ? 'online' : 'offline')).'
'.$cache_user['lost_login'].'</span></a></div>';
$i++;
}
echo '</div>';
echo '<div class="yellow1 mb5 mt5 small cntr">Проигравшие:</div>';
echo '<div class="nfl p5 mb5 mt5 small mlra">';
$i = 1;
foreach(($arena[$losse] + $arena[$losse.'_kick']) as $user_id => $value)
{
$odd = (($i % 2) ? ' odd' : '');
if ($losse == 'team_2')
{
$cache_user = mysql_fetch_assoc(mysql_query("SELECT * FROM `cave_monsters_town` WHERE `id`='{$my_arena['monster']}' LIMIT 1"));
$cache_user['lost_dostig_peshera'] = '+ 1';
$cache_user['lost_race'] = 2;
$cache_user['lost_login'] = $cache_user['name'];
}
else
{
$cache_user = cache_user($user_id);
}
echo '<div class="ml5 mr5">
<a class="bl p5 block'.$odd.'" href="/user?id='.$user_id.'">
<span class="ccc small fr">Рейтинг: <span class="bold">'.$cache_user['lost_dostig_peshera'].', '.$value['battle_uron'].'</span></span>
<span class="small mb5 yellow1"><span class="white">'.$i.'.</span>
'.ikonka_user($cache_user['lost_race'], ((!empty($online[$user_id])) ? 'online' : 'offline')).'
'.$cache_user['lost_login'].'</span> </a></div>';
$i++;
}
echo '</div>';
$user_journal = $journal['other'] + $journal[$user['lost_id']];
krsort($user_journal);
if (count($user_journal) > 0)
{
echo '<div class="yellow1 mb5 mt5 small cntr">Журнал боя:</div>';
echo '<div class="nfl p5 mb5 small mlra">';
foreach (array_slice($user_journal, 0, 10, true) as $value)
{
echo '<span class="white">'.$value.'<span><br/>';
}
echo '</div>';
}
require_once './element_include/element_foot_user_true.php';
}