battles/gotzamok.php

246 lines
11 KiB
PHP
Raw Normal View History

2018-01-28 16:40:49 +00:00
<?
//error_reporting(E_ALL);
//ini_set("display_errors", 1);
session_start();
if ($_SESSION['uid'] == null) header("Location: index.php");
include "config.php";
$user = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `id` = '{$_SESSION['uid']}' LIMIT 1;"));
include "functions.php";
if (!($user['room'] >= 37 AND $user['room'] <= 41 )) { header("Location: main.php"); die(); }
$zam = mysql_fetch_array(mysql_query("SELECT * FROM `variables` WHERE `var` = 'gotzamok' LIMIT 1;"));
if ($zam['value'] == $user['klan']) {
// если мой клан
if($_GET['goto']=='arsenal') {
mysql_query("UPDATE `users`,`online` SET `users`.`room` = '38',`online`.`room` = '38' WHERE `online`.`id` = `users`.`id` AND `online`.`id` = '{$_SESSION['uid']}' ;");
header('location: gotzamok.php');
$user['room']=38;
}
if($_GET['goto']=='home') {
mysql_query("UPDATE `users`,`online` SET `users`.`room` = '37',`online`.`room` = '37' WHERE `online`.`id` = `users`.`id` AND `online`.`id` = '{$_SESSION['uid']}' ;");
header('location: gotzamok.php');
$user['room']=37;
}
if($_GET['goto']=='dvor') {
mysql_query("UPDATE `users`,`online` SET `users`.`room` = '39',`online`.`room` = '39' WHERE `online`.`id` = `users`.`id` AND `online`.`id` = '{$_SESSION['uid']}' ;");
header('location: gotzamok.php');
$user['room']=39;
}
if($_GET['goto']=='master') {
mysql_query("UPDATE `users`,`online` SET `users`.`room` = '40',`online`.`room` = '40' WHERE `online`.`id` = `users`.`id` AND `online`.`id` = '{$_SESSION['uid']}' ;");
header('location: gotzamok.php');
$user['room']=40;
}
if($_GET['goto']=='rest') {
mysql_query("UPDATE `users`,`online` SET `users`.`room` = '41',`online`.`room` = '41' WHERE `online`.`id` = `users`.`id` AND `online`.`id` = '{$_SESSION['uid']}' ;");
header('location: gotzamok.php');
$user['room']=41;
}
}
?>
<HTML><HEAD>
<link rel=stylesheet type="text/css" href="css/main.css">
<meta content="text/html; charset=utf-8" http-equiv=Content-type>
<META Http-Equiv=Cache-Control Content=no-cache>
<meta http-equiv=PRAGMA content=NO-CACHE>
<META Http-Equiv=Expires Content=0>
<style>
legend {
padding: 0.2em 0.5em;
color:#A52A2A;
FONT-WEIGHT: bold;
}
body {
background-image: url('i/<?
switch($user['room']) {
case '37' :
echo '689_small_550';
break;
case '41' :
echo 'ko';
break;
}
?>.jpg');
background-repeat: no-repeat;
background-position: top right;
}
</style>
<script>
function returned2(s){
//if (top.oldlocation != '') { top.frames['main'].navigate(top.oldlocation+'?'+s+'tmp='+Math.random()); top.oldlocation=''; }
//else {
top.frames['main'].location='city.php?'+s+'tmp='+Math.random()
//}
}
function returned(s){
top.frames['main'].location='gotzamok.php?'+s+'tmp='+Math.random();
}
</script>
</head>
<body leftmargin=5 topmargin=0 marginwidth=0 marginheight=0 bgcolor=#d4d4d4>
<table width=100%>
<Tr>
<td align=center><h3>Приветствую тебя в замке <?
echo "<img src='i/klan/".$zam['value'].".gif'>".$zam['value'];
?>, воин!</h3></td>
<td align=right width=60><INPUT TYPE=button value="Вернуться" onClick="returned2('bps=1&');"></td>
</tr>
</table>
<?php
if ($zam['value'] == $user['klan']) {
// если мой клан
echo "<h4>Приветствую в родной обители, собрат <b>".$user['login']."!</b></h4>";
?>
<table width=100%>
<TR><TD valign=top style="width:250px;">
<INPUT TYPE=button style="width:200px;" value="Перейти в приемную" onClick="returned('goto=home&');"><? if($user['room']==37) { echo "<img src='i/flag.gif'>"; } ?><BR>
<INPUT TYPE=button style="width:200px;" value="Перейти в арсенал" onClick="returned('goto=arsenal&');"><? if($user['room']==38) { echo "<img src='i/flag.gif'>"; } ?><BR>
<INPUT TYPE=button style="width:200px;" value="Перейти во внутренний двор" onClick="returned('goto=dvor&');"><? if($user['room']==39) { echo "<img src='i/flag.gif'>"; } ?><BR>
<INPUT TYPE=button style="width:200px;" value="Перейти в мастерские" onClick="returned('goto=master&');"><? if($user['room']==40) { echo "<img src='i/flag.gif'>"; } ?><BR>
<INPUT TYPE=button style="width:200px;" value="Перейти в опочивальни" onClick="returned('goto=rest&');"><? if($user['room']==41) { echo "<img src='i/flag.gif'>"; } ?><BR>
</td><td valign=top>
<?
if($user['room'] == 38) {
$glava = mysql_fetch_array(mysql_query("SELECT `glava` FROM `clans` WHERE `short` = '".$user['klan']."' LIMIT 1;"));
echo "<h4>Арсенал</h4>";
?>
<INPUT TYPE=button style="width:200px;" value="Сдать в арсенал" onClick="returned('do=zdat&');">
<?
echo "<table bgcolor=#dcdcdc width=100% style='border: 1px solid #adadad;'>
<tr><td>Хранилище вещей клана. К сожалению перкочует к новому владельцу вместе с замком...</td></tr></table>";
// возврат шмотки
if($_GET['back']) {
$it = mysql_fetch_array(mysql_query("SELECT * FROM `gotzam_arsenal` WHERE `id` = ".$_GET['back'].";"));
if($it['owner'] ==$user['id'] OR $user['id']==$glava[0]) {
err("Вы забрали вещь из арсенала.");
mysql_query("update `inventory` SET `owner` = ".$user['id']." WHERE `id` = ".$it['id_it'].";");
mysql_query("delete from `gotzam_arsenal` WHERE `id` = ".$_GET['back'].";");
}
}
// положить шмотку
if($_GET['add']) {
$it = mysql_fetch_array(mysql_query("SELECT * FROM `inventory` WHERE `dressed`=0 AND `setsale` = 0 AND `owner` =".$user['id']." AND `id` = ".$_GET['add'].";"));
if($it['owner'] ==$user['id']) {
err("Вы оставили вещь в арсенале.");
mysql_query("update `inventory` SET `owner` = '' WHERE `id` = ".$it['id'].";");
mysql_query("insert `gotzam_arsenal` (`id_it`,`owner`) values (".$it['id'].",".$user['id'].");");
}
}
if(!$_GET['do']) {
$data = mysql_query("SELECT * FROM `gotzam_arsenal`;");
echo '<TABLE BORDER=0 WIDTH=100% CELLSPACING="1" CELLPADDING="2" BGCOLOR="#A5A5A5">';
while($it = mysql_fetch_array($data)) {
$row = mysql_fetch_array(mysql_query("SELECT * FROM `inventory` WHERE `id` = '{$it['id_it']}' LIMIT 1;"));
$row['count'] = 1;
if ($i==0) { $i = 1; $color = '#C7C7C7';} else { $i = 0; $color = '#D5D5D5'; }
echo "<TR bgcolor={$color}><TD align=center width=20%><IMG SRC=\"i/sh/{$row['img']}\" BORDER=0>
<BR><small>
Положил: ".nick::id($it['owner'])->full(1)."<BR> </small>";
2018-01-28 16:40:49 +00:00
?>
<?
if($it['owner'] ==$user['id'] OR $user['id']==$glava[0]) {
?><A HREF="?back=<?=$it['id']?>">забрать</A><BR><?
}
else {
echo '<small>Вы не можете забрать эту вещь из арсенала</small>';
}
?>
</TD>
<?php
echo "<TD valign=top>";
showitem ($row);
echo "</TD></TR>";
}
echo "</table>"; }
else {
echo '<TABLE BORDER=0 WIDTH=100% CELLSPACING="1" CELLPADDING="2" BGCOLOR="#A5A5A5">';
$data = mysql_query("SELECT * FROM `inventory` WHERE `owner` = '{$_SESSION['uid']}' AND `dressed` = 0 AND `setsale`=0 ORDER by `update` DESC; ");
while($row = mysql_fetch_array($data)) {
$row['count'] = 1;
if ($i==0) { $i = 1; $color = '#C7C7C7';} else { $i = 0; $color = '#D5D5D5'; }
echo "<TR bgcolor={$color}><TD align=center style='width:150px'><IMG SRC=\"i/sh/{$row['img']}\" BORDER=0>";
?>
<BR><A HREF="?add=<?=$row['id']?>&sid=&sale=1">сдать в арсенал</A>
</TD>
<?php
echo "<TD valign=top>";
showitem ($row);
echo "</TD></TR>";
}
echo "</table>";
}
}
if($user['room'] == 40) {
$at = mysql_fetch_array(mysql_query("SELECT * FROM `variables` WHERE `var` = 'gotzam_att' LIMIT 1;"));
$def = mysql_fetch_array(mysql_query("SELECT * FROM `variables` WHERE `var` = 'gotzam_def' LIMIT 1;"));
$level = mysql_fetch_array(mysql_query("SELECT `level` FROM `users` WHERE `id` = (SELECT `glava` FROM `clans` WHERE `short` = '".$user['klan']."') LIMIT 1;"));
if($_GET['up']=='at') {
if($at[1] >= $level[0]) {
err("Укрепление достигло максимального уровня");
}
elseif((pow(52,$at[1]+1)) <= $user['money']) {
mysql_query("update users set money = money - ".(pow(52,$at[1]+1))." where id = ".$user['id'].";");
mysql_query("update `variables` set value=value+1 WHERE `var` = 'gotzam_att' LIMIT 1;");
$at = mysql_fetch_array(mysql_query("SELECT * FROM `variables` WHERE `var` = 'gotzam_att' LIMIT 1;"));
$def = mysql_fetch_array(mysql_query("SELECT * FROM `variables` WHERE `var` = 'gotzam_def' LIMIT 1;"));
$level = mysql_fetch_array(mysql_query("SELECT `level` FROM `users` WHERE `id` = (SELECT `glava` FROM `clans` WHERE `short` = '".$user['klan']."') LIMIT 1;"));
}
else {
err("Не хватает денег");
}
}
if($_GET['up']=='def') {
if($def[1] >= $level[0]) {
err("Укрепление достигло максимального уровня");
}
elseif((pow(32,$at[1]+1)) <= $user['money']) {
mysql_query("update users set money = money - ".(pow(32,$at[1]+1))." where id = ".$user['id'].";");
mysql_query("update `variables` set value=value+1 WHERE `var` = 'gotzam_def' LIMIT 1;");
$at = mysql_fetch_array(mysql_query("SELECT * FROM `variables` WHERE `var` = 'gotzam_att' LIMIT 1;"));
$def = mysql_fetch_array(mysql_query("SELECT * FROM `variables` WHERE `var` = 'gotzam_def' LIMIT 1;"));
$level = mysql_fetch_array(mysql_query("SELECT `level` FROM `users` WHERE `id` = (SELECT `glava` FROM `clans` WHERE `short` = '".$user['klan']."') LIMIT 1;"));
}
else {
err("Не хватает денег");
}
}
echo "<h4>Мастерские</h4><table bgcolor=#dcdcdc width=100% style='border: 1px solid #adadad;'>
<tr><td>Здесь вы можете улучшить оборонные способности вашего замка!<BR>
<i>Максимальный уровень ваших укреплений: <B>".$level[0]."</b></i><BR>
<table><tr>
<td><img src='i/at.gif'></td>
<td><b>Атакующие</b> укрепления:<BR>Развито: <B>".$at[1]."</B> <a href='?up=at'>строить за ".(pow(52,$at[1]+1))." кр.</a></td>
</tr>
</table>
<table><tr>
<td><img src='i/def.gif'></td>
<td><b>Защитные</b> укрепления:<BR>Развито: <B>".$def[1]."</B> <a href='?up=def'>строить за ".(pow(32,$def[1]+1))." кр.</a></td>
</tr>
</table>
</td></tr></table>";
}
if($user['room'] == 41) {
echo "<h4>Комнаты отдыха</h4><table bgcolor=#dcdcdc width=100% style='border: 1px solid #adadad;'>
<tr><td>В этих палатах ваше здоровье восстанавливается быстрее...</td></tr></table>";
}
?>
</td></tr></table>
<?
}
?>