2019-01-15 20:02:52 +00:00
< ? php /** @noinspection SqlResolve */
2019-01-15 19:34:35 +00:00
/* Разрушенный замок на замковой улице .
* */
session_start ();
define ( " CASTLE_MAX_LEVEL " , 10 );
2020-09-30 12:01:33 +00:00
if ( $_SESSION [ 'uid' ] == null ) {
header ( " Location: index.php " );
exit ;
}
2019-01-15 19:34:35 +00:00
require_once 'functions.php' ;
2020-09-30 12:01:33 +00:00
if ( ! ( $user -> room >= 37 AND $user -> room <= 41 )) {
2019-01-15 19:34:35 +00:00
header ( " Location: main.php " );
2020-09-30 12:01:33 +00:00
exit ;
2019-01-15 19:34:35 +00:00
}
2019-01-15 20:02:52 +00:00
$castleOwners = db :: c () -> query ( 'SELECT * FROM `clans` WHERE `short` = (SELECT * FROM `variables` WHERE `var` = "?s")' , 'gotzamok' );
if ( $castleOwners [ 'id' ] == $user [ 'klan' ]) {
2019-01-15 19:34:35 +00:00
// если мой клан
2020-09-30 12:01:33 +00:00
if ( $_GET [ 'goto' ] == 'arsenal' ) $user -> room = 38 ;
if ( $_GET [ 'goto' ] == 'home' ) $user -> room = 37 ;
if ( $_GET [ 'goto' ] == 'dvor' ) $user -> room = 39 ;
if ( $_GET [ 'goto' ] == 'master' ) $user -> room = 40 ;
if ( $_GET [ 'goto' ] == 'rest' ) $user -> room = 41 ;
2019-01-15 19:34:35 +00:00
if ( in_array ( $_GET [ 'goto' ], [ 'arsenal' , 'home' , 'dvor' , 'master' , 'rest' ])) {
2020-09-30 12:01:33 +00:00
db :: c () -> query ( 'UPDATE `users`,`online` SET `users`.`room` = ?i,`online`.`room` = ?i WHERE `online`.`id` = `users`.`id` AND `online`.`id` = ?i' , $user -> room , $user -> room , $_SESSION [ 'uid' ]);
2019-01-15 19:34:35 +00:00
header ( 'location: gotzamok.php' );
} else $status = 'В этом замке нет такого места!' ;
}
2020-09-30 12:01:33 +00:00
switch ( $user -> room ) {
2019-01-15 19:34:35 +00:00
case '37' :
$backgroundImage = '689_small_550.jpg' ;
break ;
case '41' :
$backgroundImage = 'ko.jpg' ;
break ;
}
2020-09-30 12:01:33 +00:00
if ( $user -> room == 38 ) {
2019-01-15 19:34:35 +00:00
$glava = db :: c () -> query ( 'SELECT `glava` FROM `clans` WHERE `short` = "?s"' , $user [ 'klan' ]) -> fetch_assoc ();
// возврат шмотки
if ( $_GET [ 'back' ]) {
$item = db :: c () -> query ( 'SELECT * FROM `gotzam_arsenal` WHERE `id` = ?i' , $_GET [ 'back' ]) -> fetch_assoc ();
if ( $_SESSION [ 'uid' ] == $item [ 'owner' ] OR $_SESSION [ 'uid' ] == $glava [ 'glava' ]) {
$status = 'Вы забрали вещь из арсенала.' ;
db :: c () -> query ( 'UPDATE `inventory` SET `owner` = ?i WHERE `id` = ?i' , $_SESSION [ 'uid' ], $item [ 'id_it' ]);
db :: c () -> query ( 'DELETE FROM `gotzam_arsenal` WHERE `id` = ?i' , $_GET [ 'back' ]);
}
}
// положить шмотку
if ( $_GET [ 'add' ]) {
$item = db :: c () -> query ( 'SELECT * FROM `inventory` WHERE `dressed`=0 AND `setsale` = 0 AND `owner` =?i AND `id` = ?i' , $_SESSION [ 'uid' ], $_GET [ 'add' ]) -> fetch_assoc ();
2019-01-15 20:02:52 +00:00
if ( $_SESSION [ 'uid' ] == $item [ 'owner' ]) {
2019-01-15 19:34:35 +00:00
$status = 'Вы оставили вещь в арсенале.' ;
db :: c () -> query ( 'UPDATE `inventory` SET `owner` = ?i WHERE `id` = ?i' , - 5 , $item [ 'id' ]);
db :: c () -> query ( 'INSERT INTO `gotzam_arsenal` (`id_it`, `owner`) VALUES (?i, ?i)' , $item [ 'id' ], $_SESSION [ 'uid' ]);
}
}
}
2020-09-30 12:01:33 +00:00
if ( $user -> room == 40 ) {
2019-01-15 19:34:35 +00:00
$at = db :: c () -> query ( 'SELECT * FROM `variables` WHERE `var` = "?s"' , 'gotzam_att' ) -> fetch_assoc ();
$def = db :: c () -> query ( 'SELECT * FROM `variables` WHERE `var` = "?s"' , 'gotzam_def' ) -> fetch_assoc ();
if ( $_GET [ 'up' ] == 'at' ) {
if ( $at [ 1 ] >= CASTLE_MAX_LEVEL ) $status = 'Укрепление достигло максимального уровня!' ;
elseif (( pow ( 52 , $at [ 1 ] + 1 )) <= $user [ 'money' ]) {
db :: c () -> query ( 'UPDATE `users` SET `money` = `money` - ?i WHERE `id` = ?i' , pow ( 52 , $at [ 1 ] + 1 ), $_SESSION [ 'uid' ]);
db :: c () -> query ( 'UPDATE `variables` SET `value` = `value` + 1 WHERE `var` = "?s"' , 'gotzam_att' );
$at += 1 ;
} else $status = 'Н е хватает денег!' ;
}
if ( $_GET [ 'up' ] == 'def' ) {
if ( $def [ 1 ] >= CASTLE_MAX_LEVEL ) $status = 'Укрепление достигло максимального уровня!' ;
elseif (( pow ( 32 , $def [ 1 ] + 1 )) <= $user [ 'money' ]) {
db :: c () -> query ( 'UPDATE `users` SET `money` = `money` - ?i WHERE `id` = ?i' , pow ( 52 , $def [ 1 ] + 1 ), $_SESSION [ 'uid' ]);
db :: c () -> query ( 'UPDATE `variables` SET `value` = `value` + 1 WHERE `var` = "?s"' , 'gotzam_def' );
$def += 1 ;
} else $status = 'Н е хватает денег!' ;
}
}
2018-01-28 16:40:49 +00:00
?>
2019-01-15 19:34:35 +00:00
< HTML >
< head >
< link rel = stylesheet href = " css/main.css " >
< script src = " js/main.js " ></ script >
2019-01-15 20:02:52 +00:00
< meta charset = " utf-8 " >
2019-01-15 19:34:35 +00:00
< style >
body {
background : url ( 'i/<?= $backgroundImage ?>.jpg' ) no - repeat top right ;
}
</ style >
2018-01-28 16:40:49 +00:00
</ head >
2019-01-15 19:34:35 +00:00
< body >
2020-08-27 12:17:02 +00:00
< h3 > Приветствую тебя в замке < img src = 'i/clan/<?= $castleOwners[' short '] ?>.gif' > < ? = $castleOwners [ 'name' ] ?> , воин!</h3>
2019-01-15 19:34:35 +00:00
< div style = " text-align: right; " >
< button onClick = " hrefToFrame('city.php?bps') " > Вернуться </ button >
</ div >
< div >< ? php if ( ! empty ( $status )) err ( $status ); ?> </div>
2018-01-28 16:40:49 +00:00
2019-01-15 19:34:35 +00:00
< ? php
2019-01-15 20:02:52 +00:00
if ( $castleOwners [ 'id' ] == $user [ 'klan' ]) { ?>
2019-01-15 19:34:35 +00:00
< h4 > Приветствую в родной обители , собрат < b >< ? = $user [ 'login' ] ?> !</b></h4>
< table width = 100 %>
< TR >
< TD valign = top style = " width:250px; " >
< INPUT TYPE = button style = " width:200px; " value = " Перейти в приемную "
onClick = " hrefToFrame('gotzamok.php?goto=home') " >
2020-09-30 12:01:33 +00:00
< ? if ( $user -> room == 37 ) : ?>
2019-01-15 19:34:35 +00:00
< img src = 'i/flag.gif' >
< ? php endif ; ?> <BR>
< INPUT TYPE = button style = " width:200px; " value = " Перейти в арсенал "
onClick = " hrefToFrame('gotzamok.php?goto=arsenal') " >
2020-09-30 12:01:33 +00:00
< ? if ( $user -> room == 38 ) : ?>
2019-01-15 19:34:35 +00:00
< img src = 'i/flag.gif' >
< ? php endif ; ?> <BR>
< INPUT TYPE = button style = " width:200px; " value = " Перейти во внутренний двор "
onClick = " hrefToFrame('gotzamok.php?goto=dvor') " >
2020-09-30 12:01:33 +00:00
< ? if ( $user -> room == 39 ) : ?>
2019-01-15 19:34:35 +00:00
< img src = 'i/flag.gif' >
< ? php endif ; ?> <BR>
< INPUT TYPE = button style = " width:200px; " value = " Перейти в мастерские "
onClick = " hrefToFrame('gotzamok.php?goto=master') " >
2020-09-30 12:01:33 +00:00
< ? if ( $user -> room == 40 ) : ?>
2019-01-15 19:34:35 +00:00
< img src = 'i/flag.gif' >
< ? php endif ; ?> <BR>
< INPUT TYPE = button style = " width:200px; " value = " Перейти в опочивальни "
onClick = " hrefToFrame('gotzamok.php?goto=rest') " >
2020-09-30 12:01:33 +00:00
< ? if ( $user -> room == 41 ) : ?>
2019-01-15 19:34:35 +00:00
< img src = 'i/flag.gif' >
< ? php endif ; ?> <BR>
</ td >
< td valign = top >
2020-09-30 12:01:33 +00:00
< ? php if ( $user -> room == 38 ) : ?>
2019-01-15 19:34:35 +00:00
< h4 > Арсенал </ h4 >
< button onClick = " hrefToFrame('gotzamok.php?do=zdat') " > Сдать в арсенал </ button >
< div style = " background: silver; border: 1px solid dimgray; " >
Хранилище вещей клана . Если замок будет захвачен , все предметы перейдут к захватчикам .
</ div >
< ? php if ( ! $_GET [ 'do' ]) : $data = db :: c () -> query ( 'SELECT * FROM `gotzam_arsenal`' ); ?>
< TABLE class = " zebra " WIDTH = 100 % CELLSPACING = " 1 " CELLPADDING = " 2 " >
< ? php while ( $item = $data -> fetch_assoc ()) :
$row = db :: c () -> query ( 'SELECT * FROM `inventory` WHERE `id` = ?i' , $item [ 'id_it' ]) -> fetch_assoc ();
?>
< TR >
< TD align = center width = 20 %>
< IMG SRC = " i/sh/<?= $row['img'] ?> " >
< BR >
2020-08-27 12:17:02 +00:00
< small > Положил : < ? = Nick :: id ( $item [ 'owner' ]) -> full ( 1 ) ?> <BR></small>
2019-01-15 19:34:35 +00:00
< ? php
if ( $_SESSION [ 'uid' ] == $item [ 'owner' ] OR $_SESSION [ 'uid' ] == $glava [ 'glava' ]) : ?>
< A HREF = " ?back=<?= $item['id'] ?> " > забрать </ A >< BR >
< ? php else : $status = 'Вы не можете забрать эту вещь из арсенала.' ;
endif ; ?>
</ TD >
2019-02-12 18:31:23 +00:00
< TD valign = top > Тут был showitem ( $row ); </ TD >
2019-01-15 19:34:35 +00:00
</ TR >
< ? php endwhile ; ?>
</ table >
< ? php else : ?>
< TABLE class = " zebra " WIDTH = 100 % CELLSPACING = " 1 " CELLPADDING = " 2 " >
< ? php
$data = db :: c () -> query ( 'SELECT * FROM `inventory` WHERE `dressed` = 0 AND `setsale` = 0 AND `owner` = ?i ORDER BY `update` DESC ' , $_SESSION [ 'uid' ]);
while ( $row = $data -> fetch_assoc ()) : ?>
< TR >
< TD align = center style = 'width:150px' >
< IMG SRC = " i/sh/<?= $row['img'] ?> " >
< BR >< A HREF = " ?add=<?= $row['id'] ?>&sid=&sale=1 " > сдать в арсенал </ A >
</ TD >
2019-02-12 18:31:23 +00:00
< TD valign = top > Тут был showitem ( $row ); </ TD >
2019-01-15 19:34:35 +00:00
</ TR >
< ? php endwhile ; ?>
</ table >
< ? php
endif ;
endif ;
2020-09-30 12:01:33 +00:00
if ( $user -> room == 40 ) : ?>
2019-01-15 19:34:35 +00:00
< h4 > Мастерские </ h4 >
< div style = " background: silver; border: 1px solid dimgray; " >
Здесь вы можете улучшить оборонные способности вашего замка .
< br > Максимальный уровень ваших укреплений : < b >< ? = CASTLE_MAX_LEVEL ?> </b>
< div >
< img src = 'i/at.gif' > < b > Атакующие </ b > укрепления :
< br > Построено : < b >< ? = $at [ 1 ] ?> </b>
< a href = '?up=at' > улучшить за < ? = ( pow ( 52 , $at [ 1 ] + 1 )) ?> кр.</a>
</ div >
< div >
< img src = 'i/def.gif' > < b > Защитные </ b > укрепления :
< br > Построено : < b >< ? = $def [ 1 ] ?> </b>
< a href = '?up=at' > улучшить за < ? = ( pow ( 32 , $def [ 1 ] + 1 )) ?> кр.</a>
</ div >
</ div >
< ? php endif ;
2020-09-30 12:01:33 +00:00
if ( $user -> room == 41 ) : ?>
2019-01-15 19:34:35 +00:00
< h4 > Комнаты отдыха </ h4 >
< div style = " background: silver; border: 1px solid dimgray; " >
Посиди в тишине , внутри стен . Тут нет врагов . Тут спокойно .
</ div >
< ? php endif ; ?>
</ td >
</ tr >
</ table >
< ? } else $status = 'Ворота замка закрыты, привратник отказывается даже разговаривать с тобой...' ; ?>
</ body >
</ HTML >