Файл: public_html/system/class.ClanBattle.php
Строк: 343
<?
/**
* @ XxxDIABLOxxX
*
* @ Create class Item
*
* @ Date 13.02.2017 15:03
*/
class ClanBattle {
private $id = null;
/**
* Class constructor. Create a new Item
*
* @param array none
* @return bool
*/
public function __construct($id = null) {
if (is_null($id) AND is_null($this -> id)) {
exit(header('Location: /'));
}
$this -> id = $id;
}
public function ClanBattleStart($ClanUser) {
$ClanListOpponent = mysql_fetch_assoc(mysql_query("SELECT * FROM `clans` WHERE `battle` = '0' AND `battle_cool` <= '6' AND `id` != '".$ClanUser."' ORDER BY RAND()"));
mysql_query("INSERT INTO `clan_battle` SET `clan` = '".$ClanUser."', `opponent` = '".$ClanListOpponent['id']."',`time` = '".(time() + 86400)."' ");
mysql_query("INSERT INTO `clan_battle` SET `clan` = '".$ClanListOpponent['id']."', `opponent` = '".$ClanUser."',`time` = '".(time() + 86400)."'");
mysql_query("UPDATE `clans` SET `battle` = '1' WHERE `id` = '".$ClanUser."'");
mysql_query("UPDATE `clans` SET `battle` = '1' WHERE `id` = '".$ClanListOpponent['id']."'");
}
public function ClanCostReferens($Clan) {
$ClanCost = mysql_query('SELECT * FROM `clan_memb` WHERE `clan` = "'.$Clan.'"');
$ClansListMy = mysql_fetch_array(mysql_query('SELECT * FROM `clans` WHERE `id` = "'.$Clan.'"'));
$ClanBattleList = mysql_fetch_array(mysql_query('SELECT * FROM `clan_battle` WHERE `clan` = "'.$Clan.'"'));
$ClansListOpponent = mysql_fetch_array(mysql_query('SELECT * FROM `clans` WHERE `id` = "'.$ClanBattleList['opponent'].'"'));
while($rows = mysql_fetch_array($ClanCost)) {
mysql_query('UPDATE `users` SET `g` = `g` + 10 WHERE `id` = "'.$rows['user'].'"');
}
mysql_query("DELETE FROM `clan_battle` WHERE `clan` = '".$Clan."'");
mysql_query("DELETE FROM `clan_battle` WHERE `clan` = '".$ClansListOpponent['id']."'");
mysql_query("UPDATE `clans` SET `g` = '".($ClansListMy['g'] + 10000)."' ,`battle_cool` = '".($ClansListMy['battle_cool'] + 1)."', `battle` = '0' WHERE `id` = '".$Clan."'");
mysql_query("UPDATE `clans` SET `battle` = '0', `battle_cool` = '".($ClansListOpponent['battle_cool'] + 1)."' WHERE `id` = '".$ClansListOpponent['id']."'");
mysql_query("INSERT INTO `clan_battle_log` SET
`clan`='".$Clan."',
`time`='".time()."',
`text`='
<img src=/images/icon/clan/".$ClansListMy['r'].".png> <a href=/clan/".$ClansListMy['id'].">".$ClansListMy['name']."</a> vs <img src=/images/icon/clan/".$ClansListOpponent['r'].".png> <a href=/clan/".$ClansListOpponent['id'].">".$ClansListOpponent['name']."</a><br/> <font color=#9C9>Победа</font>'");
mysql_query("INSERT INTO `clan_battle_log` SET
`clan`='".$ClanBattleList['opponent']."',
`time`='".time()."',
`text`='<img src=/images/icon/clan/".$ClansListOpponent['r'].".png> <a href=/clan/".$ClansListOpponent['id'].">".$ClansListOpponent['name']."</a> vs <img src=/images/icon/clan/".$ClansListMy['r'].".png> <a href=/clan/".$ClansListMy['id'].">".$ClansListMy['name']."</a><br/> Поражение'");
}
public function ClanLog($clan) {
$ClanLog = mysql_query("SELECT * FROM `clan_battle_log` ORDER BY `time` DESC LIMIT 7");
$_null = mysql_num_rows($ClanLog);
if($_null >= 1){
while($ClanLogList = mysql_fetch_array($ClanLog))
{
if($ClanLogList['clan'] == $clan) echo '<div class="content" align="center">'.$ClanLogList['text'].'</div><div class="dot-line"></div>';
}
}else echo '<div class="content" align="center">Ваш клан сражается результат еще не известен!</div><div class="line"></div>';
}
public function ClanArenaNotOpponent($exp) {
$i_clan_memb = mysql_fetch_array(mysql_query('SELECT * FROM `clan_memb` WHERE `user` = "'.$this -> id.'"'));
$i_clan = mysql_fetch_array(mysql_query('SELECT * FROM `clans` WHERE `id` = "'.$i_clan_memb['clan'].'"'));
$ClanBattleList = mysql_fetch_array(mysql_query('SELECT * FROM `clan_battle` WHERE `clan` = "'.$i_clan['id'].'"'));
$ClanglobalList = mysql_fetch_assoc(mysql_query("SELECT * FROM `clans` WHERE `battle` = '0' AND `id` != '".$i_clan['id']."'"));
if($ClanBattleList['opponent'] <= 0) {
}else{
if($i_clan['battle_cool'] <= 6) {
if($ClanBattleList['exp'] <= 4999) {
mysql_query('UPDATE `clan_battle` SET `exp` = "'.($ClanBattleList['exp'] + $exp).'" WHERE `clan` = "'.$ClanBattleList['clan'].'"');
}else{
$ArrayStars = array(1 => 'star_1',2 => 'star_2',3 => 'star_3' ,4 => 'star_4',5 => 'star_5');
$Cool = $ArrayStars[$ClanBattleList['cool']];
mysql_query("UPDATE `clan_battle` SET `$Cool` = '1',`exp` = '0',`cool` = `cool` + 1 WHERE `clan`='".$ClanBattleList['clan']."'");
}
}
}
}
public function ReferensClan($Clan, $Opponent) {
$ClansListMy = mysql_fetch_array(mysql_query('SELECT * FROM `clans` WHERE `id` = "'.$Clan.'"'));
$ClanBattleList = mysql_fetch_array(mysql_query('SELECT * FROM `clan_battle` WHERE `clan` = "'.$Clan.'"'));
$ClansListOpponent = mysql_fetch_array(mysql_query('SELECT * FROM `clans` WHERE `id` = "'.$Opponent.'"'));
$pasteClanListUser = mysql_fetch_array(mysql_query('SELECT * FROM `clan_battle` WHERE `clan` = "'.$Clan.'"'));
$pasteClanListOpponent = mysql_fetch_array(mysql_query('SELECT * FROM `clan_battle` WHERE `clan` = "'.$Opponent.'"'));
$MyStar = $pasteClanListUser['star_1'] + $pasteClanListUser['star_2'] + $pasteClanListUser['star_3'] + $pasteClanListUser['star_4'] + $pasteClanListUser['star_5'];
$OppStar = $pasteClanListOpponent['star_1'] + $pasteClanListOpponent['star_2'] + $pasteClanListOpponent['star_3'] + $pasteClanListOpponent['star_4'] + $pasteClanListOpponent['star_5'];
if($MyStar > $OppStar){
mysql_query("DELETE FROM `clan_battle` WHERE `clan` = '".$Clan."'");
mysql_query("DELETE FROM `clan_battle` WHERE `clan` = '".$Opponent."'");
mysql_query("UPDATE `clans` SET `g` = '".($ClansListMy['g'] + 10000)."' ,`battle_cool` = '".($ClansListMy['battle_cool'] + 1)."', `battle` = '0' WHERE `id` = '".$Clan."'");
mysql_query("UPDATE `clans` SET `battle` = '0', `battle_cool` = '".($ClansListOpponent['battle_cool'] + 1)."' WHERE `id` = '".$Opponent."'");
$resultBattle = array('Победа','Поражение');
}else{
mysql_query("DELETE FROM `clan_battle` WHERE `clan` = '".$Clan."'");
mysql_query("DELETE FROM `clan_battle` WHERE `clan` = '".$Opponent."'");
mysql_query("UPDATE `clans` SET `g` = '".($ClansListOpponent['g'] + 10000)."' ,`battle_cool` = '".($ClansListOpponent['battle_cool'] + 1)."', `battle` = '0' WHERE `id` = '".$Opponent."'");
mysql_query("UPDATE `clans` SET `battle` = '0', `battle_cool` = '".($ClansListMy['battle_cool'] + 1)."' WHERE `id` = '".$Clan."'");
$resultBattle = array('Поражение','Победа');
}
mysql_query("INSERT INTO `clan_battle_log` SET
`clan`='".$Clan."',
`time`='".time()."',
`text`='
<img src=/images/icon/clan/".$ClansListMy['r'].".png> <a href=/clan/".$ClansListMy['id'].">".$ClansListMy['name']."</a> vs <img src=/images/icon/clan/".$ClansListOpponent['r'].".png> <a href=/clan/".$ClansListOpponent['id'].">".$ClansListOpponent['name']."</a><br/> <font color=#9C9>".$resultBattle[0]."</font> '");
mysql_query("INSERT INTO `clan_battle_log` SET
`clan`='".$Opponent."',
`time`='".time()."',
`text`='<img src=/images/icon/clan/".$ClansListOpponent['r'].".png> <a href=/clan/".$ClansListOpponent['id'].">".$ClansListOpponent['name']."</a> vs <img src=/images/icon/clan/".$ClansListMy['r'].".png> <a href=/clan/".$ClansListMy['id'].">".$ClansListMy['name']."</a><br/> ".$resultBattle[1]." '");
}
}
?>