2020-10-29 23:30:05 +00:00
< ? php
/* Разрушенный замок на замковой улице. */
2022-01-26 23:15:33 +00:00
use Battles\Template ;
use Battles\User , Battles\Database\Db ;
2021-08-25 15:24:12 +00:00
const CASTLE_MAX_LEVEL = 10 ;
2019-01-15 19:34:35 +00:00
require_once 'functions.php' ;
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 19:12:34 +00:00
if ( $_GET [ 'goto' ] == 'arsenal' ) {
2022-01-26 23:15:33 +00:00
User :: getInstance () -> setRoom ( 38 );
2020-09-30 19:12:34 +00:00
}
if ( $_GET [ 'goto' ] == 'home' ) {
2022-01-26 23:15:33 +00:00
User :: getInstance () -> setRoom ( 37 );
2020-09-30 19:12:34 +00:00
}
if ( $_GET [ 'goto' ] == 'dvor' ) {
2022-01-26 23:15:33 +00:00
User :: getInstance () -> setRoom ( 39 );
2020-09-30 19:12:34 +00:00
}
if ( $_GET [ 'goto' ] == 'master' ) {
2022-01-26 23:15:33 +00:00
User :: getInstance () -> setRoom ( 40 );
2020-09-30 19:12:34 +00:00
}
if ( $_GET [ 'goto' ] == 'rest' ) {
2022-01-26 23:15:33 +00:00
User :: getInstance () -> setRoom ( 41 );
2020-09-30 19:12:34 +00:00
}
2019-01-15 19:34:35 +00:00
if ( in_array ( $_GET [ 'goto' ], [ 'arsenal' , 'home' , 'dvor' , 'master' , 'rest' ])) {
2022-01-26 23:15: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 :: getInstance () -> getRoom (), User :: getInstance () -> getRoom (), User :: getInstance () -> getId ());
2019-01-15 19:34:35 +00:00
header ( 'location: gotzamok.php' );
2020-09-30 19:12:34 +00:00
} else {
$status = 'В этом замке нет такого места!' ;
}
2019-01-15 19:34:35 +00:00
}
2022-01-26 23:15:33 +00:00
$i = User :: getInstance () -> getRoom ();
if ( $i == '37' ) {
$backgroundImage = '689_small_550.jpg' ;
} elseif ( $i == '41' ) {
$backgroundImage = 'ko.jpg' ;
2019-01-15 19:34:35 +00:00
}
2022-01-26 23:15:33 +00:00
if ( User :: getInstance () -> getRoom () == 38 ) {
2021-02-01 19:20:23 +00:00
$glava = db :: c () -> query ( 'SELECT owner_id FROM `clans` WHERE `short` = "?s"' , $user [ 'klan' ]) -> fetch_assoc ();
2019-01-15 19:34:35 +00:00
// возврат шмотки
if ( $_GET [ 'back' ]) {
$item = db :: c () -> query ( 'SELECT * FROM `gotzam_arsenal` WHERE `id` = ?i' , $_GET [ 'back' ]) -> fetch_assoc ();
2020-09-30 19:12:34 +00:00
if ( $_SESSION [ 'uid' ] == $item [ 'owner' ] or $_SESSION [ 'uid' ] == $glava [ 'glava' ]) {
2019-01-15 19:34:35 +00:00
$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' ]);
}
}
}
2022-01-26 23:15:33 +00:00
if ( User :: getInstance () -> getRoom () == 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' ) {
2022-01-26 23:15:33 +00:00
if ( $at [ 1 ] >= CASTLE_MAX_LEVEL ) {
$status = 'Укрепление достигло максимального уровня!' ;
}
2019-01-15 19:34:35 +00:00
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 ;
2022-01-26 23:15:33 +00:00
} else {
$status = 'Н е хватает денег!' ;
}
2019-01-15 19:34:35 +00:00
}
if ( $_GET [ 'up' ] == 'def' ) {
2022-01-26 23:15:33 +00:00
if ( $def [ 1 ] >= CASTLE_MAX_LEVEL ) {
$status = 'Укрепление достигло максимального уровня!' ;
}
2019-01-15 19:34:35 +00:00
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 ;
2022-01-26 23:15:33 +00:00
} else {
$status = 'Н е хватает денег!' ;
}
2019-01-15 19:34:35 +00:00
}
}
2022-01-26 23:15:33 +00:00
Template :: header ( 'Клановый замок' );
2018-01-28 16:40:49 +00:00
?>
2019-01-15 19:34:35 +00:00
< script src = " js/main.js " ></ script >
< style >
body {
background : url ( 'i/<?= $backgroundImage ?>.jpg' ) no - repeat top right ;
}
</ style >
2020-09-30 22:12:53 +00:00
< h3 > Приветствую тебя в замке < img src = 'i/clan/<?= $castleOwners[' short '] ?>.png' > < ? = $castleOwners [ 'name' ] ?> ,
2020-09-30 19:12:34 +00:00
воин !</ h3 >
< div style = " text-align: right; " >
< button onClick = " hrefToFrame('city.php?bps') " > Вернуться </ button >
</ div >
2022-01-26 23:15:33 +00:00
< 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') " >
2022-01-26 23:15:33 +00:00
< ? if ( User :: getInstance () -> getRoom () == 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') " >
2022-01-26 23:15:33 +00:00
< ? if ( User :: getInstance () -> getRoom () == 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') " >
2022-01-26 23:15:33 +00:00
< ? if ( User :: getInstance () -> getRoom () == 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') " >
2022-01-26 23:15:33 +00:00
< ? if ( User :: getInstance () -> getRoom () == 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') " >
2022-01-26 23:15:33 +00:00
< ? if ( User :: getInstance () -> getRoom () == 41 ) : ?>
2019-01-15 19:34:35 +00:00
< img src = 'i/flag.gif' >
< ? php endif ; ?> <BR>
</ td >
< td valign = top >
2022-01-26 23:15:33 +00:00
< ? php if ( User :: getInstance () -> getRoom () == 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
2020-09-30 19:12:34 +00:00
if ( $_SESSION [ 'uid' ] == $item [ 'owner' ] or $_SESSION [ 'uid' ] == $glava [ 'glava' ]) : ?>
2019-01-15 19:34:35 +00:00
< A HREF = " ?back=<?= $item['id'] ?> " > забрать </ A >< BR >
< ? php else : $status = 'Вы не можете забрать эту вещь из арсенала.' ;
endif ; ?>
</ TD >
2020-09-30 19:12:34 +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 >
2020-09-30 19:12:34 +00:00
< TD valign = top > Тут был showitem ( $row ); </ TD >
2019-01-15 19:34:35 +00:00
</ TR >
< ? php endwhile ; ?>
</ table >
< ? php
endif ;
endif ;
2022-01-26 23:15:33 +00:00
if ( User :: getInstance () -> getRoom () == 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 ;
2022-01-26 23:15:33 +00:00
if ( User :: getInstance () -> getRoom () == 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 >
2022-01-26 23:15:33 +00:00
< ? } else {
$status = 'Ворота замка закрыты, привратник отказывается даже разговаривать с тобой...' ;
} ?>