2018-01-28 16:40:49 +00:00
< ? php
2020-09-30 13:45:10 +00:00
session_start ();
2020-10-29 23:30:05 +00:00
require_once " functions.php " ;
2020-09-30 13:45:10 +00:00
$owntravma = mysql_fetch_array ( mysql_query ( " SELECT * FROM `effects` WHERE `owner` = " . $user [ 'id' ] . " AND (type=13 OR type=12 OR type=14) limit 1; " ));
$klan = mysql_fetch_array ( mysql_query ( " SELECT * FROM `clans` WHERE `id` = ' { $user [ 'klan' ] } ' LIMIT 1; " ));
$cc_date = mysql_fetch_array ( mysql_query ( " SELECT * FROM `variables` WHERE `var`='cc_time' LIMIT 1; " ));
$ccd = $cc_date [ 'value' ];
if ( $_POST [ 'admin_start' ]) {
$tm = time ();
mysql_query ( " UPDATE `variables` SET `value`=' { $tm } ' WHERE `var`='cc_time'; " );
exit ( " <script>location.href='clan_castle.php';</script> " );
}
if ( $_POST [ 'admin_start1' ]) {
$tm = time () - 900 ;
mysql_query ( " UPDATE `variables` SET `value`=' { $tm } ' WHERE `var`='cc_time'; " );
exit ( " <script>location.href='clan_castle.php';</script> " );
}
if ( $_POST [ 'add_zay' ]) {
mysql_query ( " INSERT INTO `clan_castle` VALUES (' { $user [ 'id' ] } ',' { $user [ 'klan' ] } '); " );
exit ( " <script>location.href='clan_castle.php';</script> " );
}
2020-10-28 20:21:08 +00:00
\Battles\Template :: header ( 'Замок Мэра' );
2020-09-30 13:45:10 +00:00
?>
2020-09-30 14:28:34 +00:00
< script >
function refreshPeriodic () {
location . href = 'clan_castle.php' ;
2020-09-30 13:45:10 +00:00
timerID = setTimeout ( " refreshPeriodic() " , 30000 );
2020-09-30 14:28:34 +00:00
}
2018-01-28 16:40:49 +00:00
2020-09-30 14:28:34 +00:00
timerID = setTimeout ( " refreshPeriodic() " , 30000 );
</ script >
2018-01-28 16:40:49 +00:00
2020-09-30 13:45:10 +00:00
< TABLE border = 0 width = 600 cellspacing = " 0 " cellpadding = " 0 " align = left >
2018-01-28 16:40:49 +00:00
2020-09-30 13:45:10 +00:00
< tr >
< td >< h3 > Замок Мэра </ td >
</ tr >
< tr >
< td >
< FORM action = " city.php " method = GET >< INPUT TYPE = " submit " value = " Вернуться в Город " name = " bps " ></ FORM >
</ td >
</ tr >
< tr >
< td > Добро пожаловать в Замок доброго и справедливого Мэра !
Если Вы заинтерисованы в обладании правами на Замок , либо считаете что обладаете достаточными способностями
для исполнения
обязанностей Мэра , приглашаем В а с и Ваших единомышлеников поселиться в Замке ! < br /> < br />
Внимание ! Администрация не несет ответственности за возможные конфликты на основе спора о правах обладания
Замком ,
целость и сохранность Ваших личных вещей , здоровье и жизни посетителей !< br />
< ? php
2020-09-30 14:28:34 +00:00
$own = mysql_fetch_array ( mysql_query ( " SELECT `value` FROM `variables` WHERE `var` = 'castle_owner' " ));
if ( $own [ 'value' ] > 0 ) {
$tmp_k = mysql_fetch_array ( mysql_query ( " SELECT `name` FROM `clans` WHERE `id` = ' { $own [ 'value' ] } ' " ));
}
echo '<br />Над Замком развевается флаг ' ;
if ( $tmp_k [ 'name' ]) {
2020-09-30 22:12:53 +00:00
echo '<strong>клана <img title="' . $tmp_k [ 'name' ] . '" src="i/clan/' . $tmp_k [ 'name' ] . '.png">' . $tmp_k [ 'name' ] . '</strong><br />' ;
2020-09-30 14:28:34 +00:00
} else {
echo '<strong>сил Х а о с а </strong><br />' ;
}
2020-09-30 13:45:10 +00:00
2021-02-01 19:20:23 +00:00
if ( $user -> getAdmin ()) {
2020-09-30 14:28:34 +00:00
echo '<FORM action="clan_castle.php" method=POST><INPUT TYPE="submit" value="Админ: запустить" name="admin_start"><br></FORM>' ;
echo '<FORM action="clan_castle.php" method=POST><INPUT TYPE="submit" value="Админ: старт боя" name="admin_start1"><br></FORM>' ;
}
if ( $ccd >= time ()) {
echo " Следующая битва: " . ( date ( " j.m " , $ccd )) . " в " . ( date ( " H:i " , $ccd ));
2020-09-30 13:45:10 +00:00
} elseif ( $ccd < time () && ( $ccd + 900 ) >= time ()) {
$zays = [];
2020-09-30 14:28:34 +00:00
echo " Заявили права на Замок Мэра: " ;
echo '<TABLE border=0 width=100% cellspacing="0" cellpadding="0" align=left>' ;
2020-09-30 13:45:10 +00:00
$all_c = mysql_query ( " SELECT * FROM `clan_castle`; " );
while ( $a_zay = mysql_fetch_array ( $all_c )) {
$zays [] = $a_zay [ 'clan' ];
$tmp_k = mysql_fetch_array ( mysql_query ( " SELECT `name` FROM `clans` WHERE `id` = ' { $a_zay [ 'clan' ] } ' LIMIT 1; " ));
2020-09-30 22:12:53 +00:00
echo '<tr><td><strong>Клан <img title="' . $tmp_k [ 'name' ] . '" src="i/clan/' . $tmp_k [ 'name' ] . '.png">' . $tmp_k [ 'name' ] . '</strong></td></tr>' ;
2020-09-30 13:45:10 +00:00
}
2020-09-30 14:28:34 +00:00
if ( empty ( $zays )) {
2020-09-30 13:45:10 +00:00
echo '<tr><td><strong>Ждем смелых ...</strong></td></tr>' ;
2020-09-30 14:28:34 +00:00
}
echo '</TABLE>' ;
echo " <br/>Прием заявок до: <strong> " . ( date ( " H:i " , $ccd + 900 )) . " </strong> " ;
2020-09-30 13:45:10 +00:00
$own = mysql_fetch_array ( mysql_query ( " SELECT `value` FROM `variables` WHERE `var` = 'castle_owner' LIMIT 1; " ));
if ( $klan [ 'glava' ] == $user [ 'id' ] && ! in_array ( $user [ 'klan' ], $zays ) && $user [ 'klan' ] != $own [ 'value' ]) {
2020-09-30 14:28:34 +00:00
echo " <br />Прием заявок от глав кланов: " ;
2020-09-30 13:45:10 +00:00
echo '<tr><td><FORM action="clan_castle.php" method=POST><INPUT TYPE="submit" value="Заявиться" name="add_zay"></FORM></td></tr>' ;
}
} elseif (( $ccd + 900 ) < time () && ( $ccd + 90 + 900 ) >= time ()) {
$zays = [];
$all_zay = mysql_query ( " SELECT * FROM `clan_castle`; " );
while ( $a_zay = mysql_fetch_array ( $all_zay )) {
$cur_c = mysql_num_rows ( mysql_query ( " SELECT * FROM `users` WHERE `klan`=' { $a_zay [ 'clan' ] } ' AND `room`='45'; " ));
2020-09-30 14:28:34 +00:00
for ( $cc = 0 ; $cc < $cur_c ; $cc ++ ) {
2020-09-30 13:45:10 +00:00
$zays [] = $a_zay [ 'clan' ];
2020-09-30 14:28:34 +00:00
}
2020-09-30 13:45:10 +00:00
}
$own = mysql_fetch_array ( mysql_query ( " SELECT `value` FROM `variables` WHERE `var` = 'castle_owner' LIMIT 1; " ));
shuffle ( $zays );
$lucky = $zays [ array_rand ( $zays )];
mysql_query ( " UPDATE `variables` SET `value`=' { $lucky } ' WHERE `var`='castle_att'; " );
$tmp_k = mysql_fetch_array ( mysql_query ( " SELECT `name` FROM `clans` WHERE `id` = ' { $lucky } ' LIMIT 1; " ));
2020-09-30 14:28:34 +00:00
if ( $own [ 'value' ] > 0 ) {
2020-09-30 13:45:10 +00:00
$tmp_o = mysql_fetch_array ( mysql_query ( " SELECT `name` FROM `clans` WHERE `id` = ' { $own [ 'value' ] } ' LIMIT 1; " ));
2020-09-30 14:28:34 +00:00
}
2020-09-30 13:45:10 +00:00
2020-09-30 14:28:34 +00:00
if ( $tmp_k ) {
2020-09-30 22:12:53 +00:00
echo 'Внимание!<img title="' . $tmp_k [ 'name' ] . '" src="i/clan/' . $tmp_k [ 'name' ] . '.png"><strong>' . $tmp_k [ 'name' ] . '</strong> собираются штурмовать замок' ;
2020-09-30 14:28:34 +00:00
}
if ( $tmp_k && $own [ 'value' ] > 0 ) {
2020-09-30 22:12:53 +00:00
echo '<img title="' . $tmp_o [ 'name' ] . '" src="i/clan/' . $tmp_o [ 'name' ] . '.png"><strong>' . $tmp_o [ 'name' ] . '</strong>!' ;
2020-09-30 14:28:34 +00:00
}
if ( $tmp_k && ! $own [ 'value' ] > 0 ) {
echo '!' ;
}
2020-09-30 13:45:10 +00:00
} elseif (( $ccd + 90 + 900 ) <= time ()) {
$att = mysql_fetch_array ( mysql_query ( " SELECT `value` FROM `variables` WHERE `var` = 'castle_att' LIMIT 1; " ));
$own = mysql_fetch_array ( mysql_query ( " SELECT `value` FROM `variables` WHERE `var` = 'castle_owner' LIMIT 1; " ));
$at_t = [];
$ow_t = [];
if ( $att [ 'value' ] > 0 ) {
$att_r = mysql_query ( " SELECT `id` FROM `users` WHERE `klan`=' { $att [ 'value' ] } ' AND `room`='45'; " );
while ( $a = mysql_fetch_array ( $att_r )) {
$at_on = mysql_fetch_array ( mysql_query ( " select `id` from `online` WHERE `date` >= " . ( time () - 60 ) . " AND `id` = ' { $a [ 'id' ] } ' LIMIT 1; " ));
2020-09-30 14:28:34 +00:00
if ( $at_on [ 0 ]) {
2020-09-30 13:45:10 +00:00
$at_t [] = $a [ 'id' ];
2020-09-30 14:28:34 +00:00
}
2020-09-30 13:45:10 +00:00
}
}
if ( $own [ 'value' ] > 0 ) {
$def_r = mysql_query ( " SELECT `id` FROM `users` WHERE `klan`=' { $own [ 'value' ] } ' AND `room`='45'; " );
while ( $o = mysql_fetch_array ( $def_r )) {
$df_on = mysql_fetch_array ( mysql_query ( " select `id` from `online` WHERE `date` >= " . ( time () - 60 ) . " AND `id` = ' { $o [ 'id' ] } ' LIMIT 1; " ));
2020-09-30 14:28:34 +00:00
if ( $df_on [ 0 ]) {
2020-09-30 13:45:10 +00:00
$ow_t [] = $o [ 'id' ];
2020-09-30 14:28:34 +00:00
}
2020-09-30 13:45:10 +00:00
}
2018-01-28 16:40:49 +00:00
}
2020-09-30 13:45:10 +00:00
if ( empty ( $at_t )) {
2020-09-30 14:28:34 +00:00
echo " Смелых так и не нашлось...<br/> " ;
2020-09-30 13:45:10 +00:00
} elseif ( empty ( $ow_t ) && ( $own [ 'value' ] > 0 )) {
2020-09-30 14:28:34 +00:00
echo " Хозяева слили замок без боя...<br/> " ;
2020-09-30 13:45:10 +00:00
$cc_own = mysql_fetch_array ( mysql_query ( " SELECT `value` FROM variables WHERE var='castle_owner' LIMIT 1; " ));
$cc_k = mysql_fetch_array ( mysql_query ( " SELECT `name` FROM `clans` WHERE `id` = ' { $cc_own [ 'value' ] } ' LIMIT 1; " ));
$cc_att = mysql_fetch_array ( mysql_query ( " SELECT `value` FROM variables WHERE var='castle_att' LIMIT 1; " ));
$cc_a = mysql_fetch_array ( mysql_query ( " SELECT `name` FROM `clans` WHERE `id` = ' { $cc_att [ 'value' ] } ' LIMIT 1; " ));
2020-09-30 14:28:34 +00:00
2020-09-30 22:12:53 +00:00
AddChatSystem ( '<font color=red><strong>Клан <img title="' . $cc_a [ 'name' ] . '" src="i/clan/' . $cc_a [ 'name' ] . '.png">' . $cc_a [ 'name' ] . '</strong> без боя забрал у <strong>клана <img title="' . $cc_k [ 'name' ] . '" src="i/clan/' . $cc_k [ 'name' ] . '.gif">' . $cc_k [ 'name' ] . '</strong> Замок Мэра</font>' );
2020-09-30 14:28:34 +00:00
2020-09-30 13:45:10 +00:00
$c_prev = mysql_fetch_array ( mysql_query ( " SELECT `glava`,`align` FROM `clans` WHERE `id`=' { $own [ 'value' ] } ' LIMIT 1; " ));
mysql_query ( " UPDATE `users` SET `align`=' { $c_prev [ 'align' ] } ',`abil`='' WHERE `id`=' { $c_prev [ 'glava' ] } '; " );
mysql_query ( " UPDATE `variables` SET `value`=' { $att [ 'value' ] } ' WHERE `var`='castle_owner'; " );
mysql_query ( " UPDATE `variables` SET `value`='0' WHERE `var`='castle_att'; " );
mysql_query ( " UPDATE `variables` SET `value`=' { $tm } ' WHERE `var`='cc_time'; " );
$c_lead = mysql_fetch_array ( mysql_query ( " SELECT `glava` FROM `clans` WHERE `id`=' { $att [ 'value' ] } ' LIMIT 1; " ));
$abil = [];
2020-09-30 14:28:34 +00:00
for ( $i = 0 ; $i < 10 ; $i ++ ) {
$abil [ $i ] = 9 ;
}
2020-09-30 13:45:10 +00:00
mysql_query ( " UPDATE `users` SET `align`='7.97',`abil`=' " . serialize ( $abil ) . " ' WHERE `id`=' { $c_lead [ 'glava' ] } '; " );
mysql_query ( " DELETE FROM `clan_castle` " );
} elseif ( $own [ 'value' ] == 0 ) {
//побоище против ботов
//ставим ботов
$bots_raw = [ " 2897 " , " 2897 " , " 2897 " , " 2897 " , " 2897 " , " 2897 " , " 2897 " , " 2897 " , " 2897 " , " 2897 " , " 4150 " , " 4150 " , " 4156 " , " 4156 " , " 4156 " , " 4156 " ,
" 2895 " , " 2895 " , " 4158 " , " 4158 " , " 4158 " , " 4158 " , " 4158 " , " 2900 " ];
$bots = [];
2020-09-30 14:28:34 +00:00
foreach ( $bots_raw as $bot_id ) {
2020-09-30 13:45:10 +00:00
if ( $bot_id > 0 ) {
$b_pers = mysql_fetch_array ( mysql_query ( " SELECT `login`,`maxhp` FROM users WHERE id=' { $bot_id } ' LIMIT 1; " ));
$bot_hp = $b_pers [ 'maxhp' ];
$bot_name = $b_pers [ 'login' ];
$nb = mysql_fetch_array ( mysql_query ( " SELECT count(`id`) FROM `bots` WHERE `name` LIKE ' " . $bot_name . " %'; " ));
mysql_query ( " INSERT INTO `bots` (`name`,`prototype`,`battle`,`hp`) values (' " . $bot_name . " " . ( $nb [ 0 ] + 1 ) . " ',' " . $bot_id . " ','',' " . $bot_hp . " '); " );
$bots [] = mysql_insert_id ();
}
2020-09-30 14:28:34 +00:00
}
2020-09-30 13:45:10 +00:00
//отаке!
$teams = [];
2020-09-30 14:28:34 +00:00
foreach ( $at_t as $b ) {
2020-09-30 13:45:10 +00:00
foreach ( $bots as $gf ) {
$teams [ $gf ][ $b ] = [ 0 , 0 , time ()];
$teams [ $b ][ $gf ] = [ 0 , 0 , time ()];
}
2020-09-30 14:28:34 +00:00
}
2020-09-30 13:45:10 +00:00
mysql_query ( " INSERT INTO `battle`
2018-01-28 16:40:49 +00:00
(
`id` , `coment` , `teams` , `timeout` , `type` , `status` , `t1` , `t2` , `to1` , `to2` , `blood`
)
VALUES
(
2020-09-30 13:45:10 +00:00
NULL , '' , '" . serialize($teams) . "' , '3' , '1' , '0' , '" . implode(";", $at_t) . "' , '" . implode(";", $bots) . "' , '" . time() . "' , '" . time() . "' , '0'
2018-01-28 16:40:49 +00:00
) " );
2020-09-30 13:45:10 +00:00
$id = mysql_insert_id ();
// создаем лог
$rr = " <b> " ;
foreach ( $at_t as $k => $v ) {
if ( $k != 0 ) {
$rr .= " , " ;
$rrc .= " , " ;
}
$rr .= Nick :: id ( $v ) -> full ( 1 );
$rrc .= Nick :: id ( $v ) -> short ();
addchp ( '<font color=red>Внимание!</font> Ваш бой начался!<BR>\'; top.frames[\'main\'].location=\'fbattle.php\'; var z = \' ' , '{[]}' . Nick :: id ( $v ) -> short () . '{[]}' );
}
$rr .= " </b> и <b> " ;
$rrc .= " </b> и <b> " ;
foreach ( $bots as $k => $v ) {
if ( $k != 0 ) {
$rr .= " , " ;
$rrc .= " , " ;
}
$rr .= Nick :: id ( $v ) -> full ( 1 );
$rrc .= Nick :: id ( $v ) -> short ();
}
$rr .= " </b> " ;
2021-02-01 19:20:23 +00:00
addch ( " <a href=logs.php?log= " . $id . " target=_blank>Поединок</a> между <B> " . $rrc . " </B> начался. " , $user -> getRoom ());
2020-09-30 13:45:10 +00:00
mysql_query ( " INSERT INTO `logs` (`id`,`log`) VALUES(' { $id } ','Часы показывали <span class=date> " . date ( " Y.m.d H.i " ) . " </span>, когда " . $rr . " бросили вызов друг другу. <BR>'); " );
addlog ( $id , " Часы показывали <span class=date> " . date ( " Y.m.d H.i " ) . " </span>, когда " . $rr . " бросили вызов друг другу. <BR> " );
$add_time = time ();
// всех в БОЙ!!!
foreach ( $at_t as $k => $v ) {
mysql_query ( " UPDATE users SET `battle` = { $id } ,`zayavka`=0 WHERE `id`= { $v } " );
}
foreach ( $bots as $k => $v ) {
mysql_query ( " UPDATE `bots` SET `battle` = { $id } WHERE `id`= { $v } " );
}
mysql_query ( " DELETE FROM `clan_castle` " );
} elseif ( ! empty ( $at_t ) && ! empty ( $ow_t )) {
//побоище
$teams = [];
2020-09-30 14:28:34 +00:00
foreach ( $at_t as $b ) {
2020-09-30 13:45:10 +00:00
foreach ( $ow_t as $gf ) {
$teams [ $gf ][ $b ] = [ 0 , 0 , time ()];
$teams [ $b ][ $gf ] = [ 0 , 0 , time ()];
}
2020-09-30 14:28:34 +00:00
}
2020-09-30 13:45:10 +00:00
mysql_query ( " INSERT INTO `battle`
2018-01-28 16:40:49 +00:00
(
`id` , `coment` , `teams` , `timeout` , `type` , `status` , `t1` , `t2` , `to1` , `to2` , `blood`
)
VALUES
(
2020-09-30 13:45:10 +00:00
NULL , '' , '" . serialize($teams) . "' , '3' , '1' , '0' , '" . implode(";", $at_t) . "' , '" . implode(";", $ow_t) . "' , '" . time() . "' , '" . time() . "' , '0'
2018-01-28 16:40:49 +00:00
) " );
2020-09-30 13:45:10 +00:00
$id = mysql_insert_id ();
// создаем лог
$rr = " <b> " ;
foreach ( $at_t as $k => $v ) {
if ( $k != 0 ) {
$rr .= " , " ;
$rrc .= " , " ;
}
$rr .= Nick :: id ( $v ) -> full ( 1 );
$rrc .= Nick :: id ( $v ) -> short ();
addchp ( '<font color=red>Внимание!</font> Ваш бой начался!<BR>\'; top.frames[\'main\'].location=\'fbattle.php\'; var z = \' ' , '{[]}' . Nick :: id ( $v ) -> short () . '{[]}' );
}
$rr .= " </b> и <b> " ;
$rrc .= " </b> и <b> " ;
foreach ( $ow_t as $k => $v ) {
if ( $k != 0 ) {
$rr .= " , " ;
$rrc .= " , " ;
}
$rr .= Nick :: id ( $v ) -> full ( 1 );
$rrc .= Nick :: id ( $v ) -> short ();
addchp ( '<font color=red>Внимание!</font> Ваш бой начался!<BR>\'; top.frames[\'main\'].location=\'fbattle.php\'; var z = \' ' , '{[]}' . Nick :: id ( $v ) -> short () . '{[]}' );
}
$rr .= " </b> " ;
2021-02-01 19:20:23 +00:00
addch ( " <a href=logs.php?log= " . $id . " target=_blank>Поединок</a> между <B> " . $rrc . " </B> начался. " , $user -> getRoom ());
2020-09-30 13:45:10 +00:00
mysql_query ( " INSERT INTO `logs` (`id`,`log`) VALUES(' { $id } ','Часы показывали <span class=date> " . date ( " Y.m.d H.i " ) . " </span>, когда " . $rr . " бросили вызов друг другу. <BR>'); " );
addlog ( $id , " Часы показывали <span class=date> " . date ( " Y.m.d H.i " ) . " </span>, когда " . $rr . " бросили вызов друг другу. <BR> " );
$add_time = time ();
// всех в БОЙ!!!
foreach ( $at_t as $k => $v ) {
mysql_query ( " UPDATE users SET `battle` = { $id } ,`zayavka`=0 WHERE `id`= { $v } " );
}
foreach ( $ow_t as $k => $v ) {
mysql_query ( " UPDATE users SET `battle` = { $id } ,`zayavka`=0 WHERE `id`= { $v } " );
}
mysql_query ( " DELETE FROM `clan_castle` " );
2018-01-28 16:40:49 +00:00
}
2020-09-30 13:45:10 +00:00
$tm = time () + 23 * 60 * 60 ;
mysql_query ( " UPDATE `variables` SET `value`='0' WHERE `var`='castle_att'; " );
mysql_query ( " UPDATE `variables` SET `value`=' { $tm } ' WHERE `var`='cc_time'; " );
2018-01-28 16:40:49 +00:00
mysql_query ( " DELETE FROM `clan_castle` " );
2020-09-30 13:45:10 +00:00
}
?>
</ td >
</ tr >
2018-01-28 16:40:49 +00:00
</ table >
2020-09-30 22:12:53 +00:00
< div align = right >< img width = " 260 " src = " i/castle.jpg " ></ div >