battles/aren_of_angels.php

250 lines
9.2 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
session_start();
if (empty($_SESSION['uid'])) {
header("Location: index.php");
exit;
}
require_once "functions.php";
$start = db::c()->query('SELECT `value` FROM `variables` WHERE `var` = "arena_of_gods"')->fetch_assoc();
$is_now = db::c()->query('SELECT `id` FROM `battle` WHERE `aren_of` = 1 AND `win` = 3 ORDER BY `id` DESC')->fetch_assoc();
$eff = db::c()->query('SELECT `id` FROM `effects` WHERE `owner` = ?i AND (`type` = 11 OR `type` = 12)', $user['id'])->fetch_assoc();
$w = db::c()->query('SELECT `value` FROM `variables` WHERE `var` = "arena_win"')->fetch_assoc();
$al = aligntype($user['align']);
function join_arena($u, $btl, $team, $at)
{
$bd = mysql_fetch_array(mysql_query('SELECT * FROM `battle` WHERE `id` = "' . $btl . '" LIMIT 1'));
$battle = unserialize($bd['teams']);
$ak = array_keys($battle[$at]);
$battle[$u] = $battle[$ak[0]];
foreach ($battle[$u] as $k => $v) {
$battle[$u][$k] = [0, 0, time()];
$battle[$k][$u] = [0, 0, time()];
}
if ($team == 1) {
$adtxt = 'За сторону <b>Тьмы</b>.';
} else {
$adtxt = 'За сторону <b>Света</b>.';
}
addlog($btl, '<span class=date>' . date("H:i") . '</span> ' . Nick::id($u)->short() . ' вмешался в поединок! ' . $adtxt . '<br />');
mysql_query('UPDATE `battle` SET `teams` = \'' . serialize($battle) . '\', `t' . $team . '` = CONCAT(`t' . $team . '`,\';' . $u . '\') WHERE `id` = "' . $btl . '" LIMIT 1');
mysql_query("UPDATE users SET `battle` = '" . $btl . "', `zayavka` = 0 WHERE `id` = '" . $u . "' LIMIT 1");
header("Location: fbattle.php");
}
function aligntype($a)
{
$lightaligns = ["1.1", "1.2", "1.3", "1.4", "1.5", "1.6", "1.7", "1.8", "1.9"];
$darkaligns = ["2.2", "3", "8.21"];
$neutralaligns = ["2", "8.31"];
if (in_array($a, $lightaligns)) {
return 1;
}
if (in_array($a, $darkaligns)) {
return 2;
}
if (in_array($a, $neutralaligns)) {
return 3;
}
return 0;
}
if ($w['value'] == 1) {
$winers = 'Прошлая победа за Силами Тьмы';
} elseif ($w['value'] == 2) {
$winers = 'Прошлая победа за Силами Света';
} else {
$winers = 'Прошлая битва завершилась ничьей.';
}
$error = '';
if (isset($_GET['append'])) {
if ($_GET['append'] == 1) { ##### team 2
if ($al == 1 || $al == 3) {
if (isset($is_now['id'])) {
if (!isset($eff['id'])) {
if ($user['level'] >= 7) {
if ($user['hp'] > $user['maxhp'] * 0.33) {
if ($user['align'] != 4) {
if ($is_now['time_m'] < (time() + 60 * 60)) {
$bot = db::c()->query('SELECT `id` FROM `bots` WHERE `battle` = ?i AND `prototype` = 10023', $is_now['id'])->fetch_assoc();
join_arena($user['id'], $is_now['id'], 2, $bot['id']);
} else {
$error = 'Время истекло ...';
}
} else {
$error = 'Хаосникам тут не место ...';
}
} else {
$error = 'Вы слишком ослаблены ...';
}
} else {
$error = 'Данный вид поединков доступен с 7 уровня ...';
}
} else {
$error = 'Вы травмированны и не можете принять участие в поединке ...';
}
} else {
$error = 'Поединок не найден ...';
}
} else {
$error = 'Не Ваша склонность ...';
}
} elseif ($_GET['append'] == 2) { ##### team 1
if ($al == 2 || $al == 3) {
if (isset($is_now['id'])) {
if (!isset($eff['id'])) {
if ($user['level'] >= 7) {
if ($user['hp'] > $user['maxhp'] * 0.33) {
if ($user['align'] != 4) {
if ($is_now['time_m'] < (time() + 60 * 60)) {
$bot = db::c()->query('SELECT `id` FROM `bots` WHERE `battle` = ?i AND `prototype` = 10024', $is_now['id'])->fetch_assoc();
join_arena($user['id'], $is_now['id'], 1, $bot['id']);
} else {
$error = 'Время истекло ...';
}
} else {
$error = 'Хаосникам тут не место ...';
}
} else {
$error = 'Вы слишком ослаблены ...';
}
} else {
$error = 'Данный вид поединков доступен с 7 уровня ...';
}
} else {
$error = 'Вы травмированны и не можете принять участие в поединке ...';
}
} else {
$error = 'Поединок не найден ...';
}
} else {
$error = 'Не Ваша склонность ...';
}
}
}
Template::header('Арена Ангелов');
?>
<link href="css/fight.css" rel="stylesheet"/>
<style>
.hs {
font-weight: bold;
font-size: 19px;
color: #8f0000;
font-family: arial, serif;
text-align: center;
}
.bt {
float: right;
border: solid 1px #b0b0b0;
margin-top: 1px;
margin-bottom: 2px;
font-size: 11px;
color: #191970;
background-color: white;
padding: 1px 6px;
}
.credenzaBox {
width: 800px;
height: 367px;
overflow: hidden;
}
.credenzaItem {
width: 540px;
margin: 15px 120px;
padding: 6px 10px;
text-align: center;
}
.credenza-stateCaption {
text-align: center;
font-weight: bold;
margin-bottom: 12px;
color: #FFF;
font: 19px Arial, sans-serif;
text-shadow: red 1px 1px 0, red -1px -1px 0,
red -1px 1px 0, red 1px -1px 0;
}
.buttonContainer {
position: relative;
right: 0;
top: 1px;
text-align: center;
overflow: hidden;
padding: 2px;
zoom: 1;
}
.contentContainer {
margin-left: auto;
margin-right: auto;
width: 800px;
height: auto;
position: relative;
}
h2 {
font-size: 13px;
margin-bottom: 0;
color: #FFF;
font-family: verdana, sans-serif;
}
a {
font-weight: bold;
color: #FFF;
text-decoration: none;
}
a:hover {
color: Red;
}
</style>
<h1>Арена Ангелов</h1>
<div class="contentContainer">
<div class="buttonContainer">
<input type="button" onclick="location.href='city.php?bps=1';" class="bt" value="Вернуться"/>
<input type="button" onclick="location.reload();" class="bt" value="Обновить"/>
</div>
<div class="credenzaBox" style="background: url('/i/im/u1001573_1407648022.jpg') no-repeat center;">
<div class="credenzaItem">
<? if (!isset($is_now['id'])) { ?>
<div class="credenza-stateCaption">
<?= $winers ?>.<br/>Следующая битва для 7-21 ур.
состоится: <?= date("d.m.Y H:i", $start['value']) ?>
</div>
<? } else { ?>
<div class="credenza-stateCaption">
<h2>Идет сражение [7-21 уровни]</h2>
<br/><a href="/logs.php?log=<?= $is_now['id'] ?>" target="_blank" style="text-align: center;">ход
боя »»</a>
</div>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tbody>
<tr>
<td align="left">
<a href="?append=1" style="display: inline;"><img src="/i/im/append_1.png"
height="80"/><br/>Вмешаться</a>
</td>
<td align="center">
<img src="/i/im/logo_big2.png"/>
</td>
<td align="right">
<a href="?append=2" style="display: inline;"><img src="/i/im/append_2.png"
height="80"/><br/>Вмешаться</a>
</td>
</tr>
</tbody>
</table>
<? } ?>
</div>
</div>
</div>
<?= $error ?>