fix: only 1 hero can exist and is deleted upon new hero training start

Closes #261
This commit is contained in:
Martin Ambrus
2017-11-02 11:05:26 +01:00
parent 3105e0754c
commit 7c67e1e7b9
14 changed files with 368 additions and 205 deletions
+4 -6
View File
@@ -8,9 +8,7 @@
| Copyright: TravianX Project All rights reserved |
\*-------------------------------------------------------*/
$hero = mysqli_query($GLOBALS['link'],"SELECT * FROM " . TB_PREFIX . "hero WHERE `uid` = " . (int) $session->uid . "");
$hero_info = mysqli_fetch_array($hero);
$hero_info = $units->Hero($session->uid, 0, true);
$define['reset_level'] = 3; // Until which level you are able to reset your points
?>
@@ -61,7 +59,7 @@
if(isset($_GET['land'])) {
include("37_land.tpl");
} else {
if(mysqli_num_rows($hero) == 0){
if($hero_info === false){
include("37_train.tpl");
}elseif($hero_info['intraining'] == 1){
$timeleft = $generator->getTimeFormat($hero_info['trainingtime'] - time());
@@ -87,10 +85,10 @@
</table>
<?php
}
if(mysqli_num_rows($hero) != 0 AND $hero_info['dead'] == 1 AND $hero_info['intraining'] == 0){
if($hero_info !== false AND $hero_info['dead'] == 1 AND $hero_info['intraining'] == 0){
include("37_revive.tpl");
}
if(mysqli_num_rows($hero) != 0 AND $hero_info['dead'] == 0 AND $hero_info['trainingtime'] <= time() AND $hero_info['inrevive'] == 0 AND $hero_info['intraining'] == 0){
if($hero_info !== false AND $hero_info['dead'] == 0 AND $hero_info['trainingtime'] <= time() AND $hero_info['inrevive'] == 0 AND $hero_info['intraining'] == 0){
include("37_hero.tpl");
}
}
+1 -1
View File
@@ -3,7 +3,7 @@
Copyright: Travianx Project */
$oasisarray = $database->getOasis($village->wid);
if($_GET['gid']==37 && isset($_GET['del'])){
if(isset($_GET['gid']) && $_GET['gid']==37 && isset($_GET['del'])){
if($session->access != BANNED){
$database->removeOases($_GET['del']);
header("Location: build.php?id=".$id."&land");
+83 -62
View File
@@ -1,3 +1,10 @@
<table cellpadding="1" cellspacing="1" class="build_details">
<thead>
<tr>
<th colspan="2"><?php echo REVIVE; ?> <?php echo U0; ?></th>
</tr>
</thead>
<?php
$artefact = count($database->getOwnUniqueArtefactInfo2($session->uid,5,3,0));
$artefact1 = count($database->getOwnUniqueArtefactInfo2($village->wid,5,1,1));
@@ -22,66 +29,75 @@
| Dzoki < dzoki.travian@gmail.com > |
| Copyright: TravianX Project All rights reserved |
\*-------------------------------------------------------*/
if($hero_info['unit'] == 1) {
$heroes = $units->Hero($session->uid, 1);
// check if there is a hero in revive already
$reviving = false;
$training = false;
foreach ($heroes as $hero_datarow) {
if ($hero_datarow['inrevive']) {
$reviving = true;
}
if ($hero_datarow['intraining']) {
$training = true;
}
}
foreach ($heroes as $hero_datarow) {
if($hero_datarow['unit'] == 1) {
$name = U1;
} else if($hero_info['unit'] == 2) {
} else if($hero_datarow['unit'] == 2) {
$name = U2;
} else if($hero_info['unit'] == 3) {
} else if($hero_datarow['unit'] == 3) {
$name = U3;
} else if($hero_info['unit'] == 5) {
} else if($hero_datarow['unit'] == 5) {
$name = U5;
} else if($hero_info['unit'] == 6) {
} else if($hero_datarow['unit'] == 6) {
$name = U6;
} else if($hero_info['unit'] == 11) {
} else if($hero_datarow['unit'] == 11) {
$name = U11;
} else if($hero_info['unit'] == 12) {
} else if($hero_datarow['unit'] == 12) {
$name = U12;
} else if($hero_info['unit'] == 13) {
} else if($hero_datarow['unit'] == 13) {
$name = U13;
} else if($hero_info['unit'] == 15) {
} else if($hero_datarow['unit'] == 15) {
$name = U15;
} else if($hero_info['unit'] == 16) {
} else if($hero_datarow['unit'] == 16) {
$name = U16;
} else if($hero_info['unit'] == 21) {
} else if($hero_datarow['unit'] == 21) {
$name = U21;
} else if($hero_info['unit'] == 22) {
} else if($hero_datarow['unit'] == 22) {
$name = U22;
} else if($hero_info['unit'] == 24) {
} else if($hero_datarow['unit'] == 24) {
$name = U24;
} else if($hero_info['unit'] == 25) {
} else if($hero_datarow['unit'] == 25) {
$name = U25;
} else if($hero_info['unit'] == 26) {
} else if($hero_datarow['unit'] == 26) {
$name = U26;
}
if($hero_info['level'] <= 60){
$wood = (${'h'.$hero_info['unit'].'_full'}[$hero_info['level']]['wood']);
$clay = (${'h'.$hero_info['unit'].'_full'}[$hero_info['level']]['clay']);
$iron = (${'h'.$hero_info['unit'].'_full'}[$hero_info['level']]['iron']);
$crop = (${'h'.$hero_info['unit'].'_full'}[$hero_info['level']]['crop']);
$training_time = $generator->getTimeFormat(round((${'h'.$hero_info['unit'].'_full'}[$hero_info['level']]['time']) / SPEED * $artefact_bonus2 / $artefact_bonus));
$training_time2 = time() + round((${'h'.$hero_info['unit'].'_full'}[$hero_info['level']]['time']) / SPEED * $artefact_bonus2 / $artefact_bonus);
if($hero_datarow['level'] <= 60){
$wood = (${'h'.$hero_datarow['unit'].'_full'}[$hero_datarow['level']]['wood']);
$clay = (${'h'.$hero_datarow['unit'].'_full'}[$hero_datarow['level']]['clay']);
$iron = (${'h'.$hero_datarow['unit'].'_full'}[$hero_datarow['level']]['iron']);
$crop = (${'h'.$hero_datarow['unit'].'_full'}[$hero_datarow['level']]['crop']);
$timeToTrain = round((${'h'.$hero_datarow['unit'].'_full'}[$hero_datarow['level']]['time']) / SPEED * $artefact_bonus2 / $artefact_bonus);
$training_time = $generator->getTimeFormat($timeToTrain);
$training_time2 = time() + $timeToTrain;
}else{
$wood = (${'h'.$hero_info['unit'].'_full'}[60]['wood']);
$clay = (${'h'.$hero_info['unit'].'_full'}[60]['clay']);
$iron = (${'h'.$hero_info['unit'].'_full'}[60]['iron']);
$crop = (${'h'.$hero_info['unit'].'_full'}[60]['crop']);
$training_time = $generator->getTimeFormat(round((${'h'.$hero_info['unit'].'_full'}[60]['time']) / SPEED * $artefact_bonus2 / $artefact_bonus));
$training_time2 = time() + round((${'h'.$hero_info['unit'].'_full'}[60]['time']) / SPEED * $artefact_bonus2 / $artefact_bonus);
$wood = (${'h'.$hero_datarow['unit'].'_full'}[60]['wood']);
$clay = (${'h'.$hero_datarow['unit'].'_full'}[60]['clay']);
$iron = (${'h'.$hero_datarow['unit'].'_full'}[60]['iron']);
$crop = (${'h'.$hero_datarow['unit'].'_full'}[60]['crop']);
$timeToTrain = round((${'h'.$hero_datarow['unit'].'_full'}[60]['time']) / SPEED * $artefact_bonus2 / $artefact_bonus);
$training_time = $generator->getTimeFormat($timeToTrain);
$training_time2 = time() + $timeToTrain;
}
?>
<table cellpadding="1" cellspacing="1" class="build_details">
<thead>
<tr>
<th colspan="2"><?php echo REVIVE; ?> <?php echo U0; ?></th>
</tr>
</thead>
<?php
if($hero_info['inrevive'] == 1) {
$timeleft = $generator->getTimeFormat($hero_info['trainingtime'] - time());
if($hero_datarow['inrevive'] == 1) {
$timeleft = $generator->getTimeFormat($hero_datarow['trainingtime'] - time());
?>
<table id="distribution" cellpadding="1" cellspacing="1">
<thead>
@@ -95,19 +111,19 @@
echo "<tr>
<td class=\"desc\">
<div class=\"tit\">
<img class=\"unit u".$hero_info['unit']."\" src=\"img/x.gif\" alt=\"".$name."\" title=\"".$name."\" />
<img class=\"unit u".$hero_datarow['unit']."\" src=\"img/x.gif\" alt=\"".$name."\" title=\"".$name."\" />
$name ($name1)
</div>"
?>
</tr>
</table>
<?php }else{ if($hero_info['unit'] == 1 OR 11 OR 21){ ?>
<?php }else if (!$reviving) { if($hero_datarow['unit'] == 1 OR 11 OR 21){ ?>
<tr>
<td class="desc">
<div class="tit">
<img class="unit u<?php echo $hero_info['unit']; ?>" src="img/x.gif" alt="<?php echo $name; ?>" title="<?php echo $name; ?>" />
<?php echo $name . " (Level " . $hero_info['level'] . ")"; ?>
<img class="unit u<?php echo $hero_datarow['unit']; ?>" src="img/x.gif" alt="<?php echo $name; ?>" title="<?php echo $name; ?>" />
<?php echo $name . " (Level " . $hero_datarow['level'] . ")"; ?>
</div>
<div class="details">
<img class="r1" src="img/x.gif" alt="Wood" title="<?php echo LUMBER; ?>" /><?php echo $wood; ?>|
@@ -130,7 +146,7 @@
if($village->awood < $wood OR $village->aclay < $clay OR $village->airon < $iron OR $village->acrop < $crop) {
echo "<span class=\"none\">".NOT."".ENOUGH_RESOURCES."</span>";
}else {
echo "<a href=\"build.php?id=".$id."&revive=1\">".REVIVE."</a>";
echo "<a href=\"build.php?id=".$id."&amp;revive=1&amp;hid=".$hero_datarow['heroid']."\">".REVIVE."</a>";
}
?></center></td>
@@ -138,12 +154,12 @@
<?php }else { ?>
<?php if($database->checkIfResearched($village->wid, 't'.$hero_info['unit']) != 0){ ?>
<?php if($database->checkIfResearched($village->wid, 't'.$hero_datarow['unit']) != 0){ ?>
<tr>
<td class="desc">
<div class="tit">
<img class="unit u<?php echo $hero_info['unit']; ?>" src="img/x.gif" alt="<?php echo $name; ?>" title="<?php echo $name; ?>" />
<?php echo $name . " (Level " . $hero_info['level'] . ")"; ?>
<img class="unit u<?php echo $hero_datarow['unit']; ?>" src="img/x.gif" alt="<?php echo $name; ?>" title="<?php echo $name; ?>" />
<?php echo $name . " (Level " . $hero_datarow['level'] . ")"; ?>
</div>
<div class="details">
<img class="r1" src="img/x.gif" alt="Wood" title="<?php echo LUMBER; ?>" /><?php echo $wood; ?>|
@@ -166,34 +182,39 @@
if($village->awood < $wood OR $village->aclay < $clay OR $village->airon < $iron OR $village->acrop < $crop) {
echo "<span class=\"none\">".NOT."".ENOUGH_RESOURCES."</span>";
}else {
echo "<a href=\"build.php?id=".$id."&revive=1\">".REVIVE."</a>";
echo "<a href=\"build.php?id=".$id."&amp;revive=1&amp;hid=".$hero_datarow['heroid']."\">".REVIVE."</a>";
}
?>
</center></td>
</tr>
<?php } }} ?>
</table>
<?php }
}
}
<?php
if(isset($_GET['revive']) && $_GET['revive'] == 1 && $hero_info['inrevive'] == 0 && $hero_info['intraining'] == 0 && $hero_info['dead'] == 1){
if($session->access != BANNED){
mysqli_query($GLOBALS['link'],"UPDATE ".TB_PREFIX."hero SET `inrevive` = '1', `trainingtime` = '".(int) $training_time2."', `wref` = '".(int) $village->wid."' WHERE `uid` = '".(int) $session->uid."'");
if(isset($_GET['revive']) && $_GET['revive'] == 1 && isset($_GET['hid']) && $_GET['hid'] == $hero_datarow['heroid'] && $hero_datarow['inrevive'] == 0 && $hero_datarow['intraining'] == 0 && $hero_datarow['dead'] == 1){
if($session->access != BANNED){
mysqli_query($GLOBALS['link'],"UPDATE ".TB_PREFIX."hero SET `inrevive` = '1', `trainingtime` = '".(int) $training_time2."', `wref` = '".(int) $village->wid."' WHERE `heroid` = ".(int) $_GET['hid']." AND `uid` = '".(int) $session->uid."'");
mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `wood` = `wood` - ".(int) $wood." WHERE `wref` = '" . (int) $village->wid . "'");
mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `clay` = `clay` - ".(int) $clay." WHERE `wref` = '" . (int) $village->wid . "'");
mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `iron` = `iron` - ".(int) $iron ." WHERE `wref` = '" . (int) $village->wid . "'");
mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `crop` = `crop` - ".(int) $crop." WHERE `wref` = '" . (int) $village->wid . "'");
header("Location: build.php?id=".$id."");
exit;
}else{
} else {
header("Location: banned.php");
exit;
}
}
}
if($hero_info['inrevive'] == 0 && $hero_info['intraining'] == 0) {
}
?>
</table>
<?php
if(!$reviving && !$training) {
include ("37_train.tpl");
}
?>
+31 -42
View File
@@ -37,6 +37,11 @@
$result = mysqli_query($GLOBALS['link'],"SELECT * FROM ".TB_PREFIX."units WHERE `vref` = ".(int) $village->wid."");
$units = mysqli_fetch_array($result);
$count_hero = mysqli_fetch_array(mysqli_query($GLOBALS['link'],"SELECT Count(*) as Total FROM " . TB_PREFIX . "hero WHERE `uid` = " . $database->escape($session->uid) . ""), MYSQLI_ASSOC);
$count_hero = $count_hero['Total'];
if ($count_hero < 3) {
$output="<table cellpadding=1 cellspacing=1 class=\"build_details\">
<thead>
<tr>
@@ -613,12 +618,10 @@ $output.="<tr>
//HERO TRAINING
$count_hero = mysqli_num_rows(mysqli_query($GLOBALS['link'],"SELECT * FROM " . TB_PREFIX . "hero WHERE `uid` = " . $database->escape($session->uid) . ""));
if($session->tribe == 1){
if($_GET['train'] == 1){
if(isset($_GET['train']) && $_GET['train'] == 1){
if($session->access != BANNED){
mysqli_query($GLOBALS['link'],"DELETE from " . TB_PREFIX . "hero WHERE `dead` = 1 AND `uid` = '" . $database->escape($session->uid) . "'");
if($count_hero == 0){
if($count_hero < 3){
mysqli_query($GLOBALS['link'],"INSERT INTO ".TB_PREFIX."hero (`uid`, `wref`, `regeneration`, `unit`, `name`, `level`, `points`, `experience`, `dead`, `health`, `attack`, `defence`, `attackbonus`, `defencebonus`, `trainingtime`, `autoregen`, `intraining`) VALUES ('".$database->escape($session->uid)."', '" . (int) $village->wid . "', '0', '1', '".$database->escape($session->username)."', '0', '5', '0', '0', '100', '0', '0', '0', '0', '".round((time() + ($u1['time'] / SPEED)*3))."', '50', '1')");
mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "units SET `u1` = `u1` - 1 WHERE `vref` = '" . (int) $village->wid . "'");
mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `wood` = `wood` - ".(int) $u1['wood']." WHERE `wref` = '" . (int) $village->wid . "'");
@@ -633,10 +636,9 @@ $output.="<tr>
exit;
}
}
if($_GET['train'] == 2){
if(isset($_GET['train']) && $_GET['train'] == 2){
if($session->access != BANNED){
mysqli_query($GLOBALS['link'],"DELETE from " . TB_PREFIX . "hero WHERE `dead` = 1 AND `uid` = '" . $database->escape($session->uid) . "'");
if($count_hero == 0){
if($count_hero < 3){
mysqli_query($GLOBALS['link'],"INSERT INTO ".TB_PREFIX."hero (`uid`, `wref`, `regeneration`, `unit`, `name`, `level`, `points`, `experience`, `dead`, `health`, `attack`, `defence`, `attackbonus`, `defencebonus`, `trainingtime`, `autoregen`, `intraining`) VALUES ('".$database->escape($session->uid)."', '" . (int) $village->wid . "', '0', '2', '".$database->escape($session->username)."', '0', '5', '0', '0', '100', '0', '0', '0', '0', '".round((time() + ($u1['time'] / SPEED)*3))."', '50', '1')");
mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "units SET `u2` = `u2` - 1 WHERE `vref` = '" . (int) $village->wid . "'");
mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `wood` = `wood` - ".(int) $u2['wood']." WHERE `wref` = '" . (int) $village->wid . "'");
@@ -651,9 +653,8 @@ $output.="<tr>
exit;
}
}
if($_GET['train'] == 3){
if(isset($_GET['train']) && $_GET['train'] == 3){
if($session->access != BANNED){
mysqli_query($GLOBALS['link'],"DELETE from " . TB_PREFIX . "hero WHERE `dead` = 1 AND `uid` = '" . $database->escape($session->uid) . "'");
mysqli_query($GLOBALS['link'],"INSERT INTO ".TB_PREFIX."hero (`uid`, `wref`, `regeneration`, `unit`, `name`, `level`, `points`, `experience`, `dead`, `health`, `attack`, `defence`, `attackbonus`, `defencebonus`, `trainingtime`, `autoregen`, `intraining`) VALUES ('".$database->escape($session->uid)."', '" . (int) $village->wid . "', '0', '3', '".$database->escape($session->username)."', '0', '5', '0', '0', '100', '0', '0', '0', '0', '".round((time() + ($u3['time'] / SPEED)*3))."', '50', '1')");
mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "units SET `u3` = `u3` - 1 WHERE `vref` = '" . (int) $village->wid . "'");
mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `wood` = `wood` - ".(int) $u3['wood']." WHERE `wref` = '" . (int) $village->wid . "'");
@@ -667,10 +668,9 @@ $output.="<tr>
exit;
}
}
if($_GET['train'] == 5){
if(isset($_GET['train']) && $_GET['train'] == 5){
if($session->access != BANNED){
mysqli_query($GLOBALS['link'],"DELETE from " . TB_PREFIX . "hero WHERE `dead` = 1 AND `uid` = '" . $database->escape($session->uid) . "'");
if($count_hero == 0){
if($count_hero < 3){
mysqli_query($GLOBALS['link'],"INSERT INTO ".TB_PREFIX."hero (`uid`, `wref`, `regeneration`, `unit`, `name`, `level`, `points`, `experience`, `dead`, `health`, `attack`, `defence`, `attackbonus`, `defencebonus`, `trainingtime`, `autoregen`, `intraining`) VALUES ('".$database->escape($session->uid)."', '" . (int) $village->wid . "', '0', '5', '".$database->escape($session->username)."', '0', '5', '0', '0', '100', '0', '0', '0', '0', '".round((time() + ($u5['time'] / SPEED)*3))."', '50', '1')");
mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "units SET `u5` = `u5` - 1 WHERE `vref` = '" . (int) $village->wid . "'");
mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `wood` = `wood` - ".(int) $u5['wood']." WHERE `wref` = '" . (int) $village->wid . "'");
@@ -685,10 +685,9 @@ $output.="<tr>
exit;
}
}
if($_GET['train'] == 6){
if(isset($_GET['train']) && $_GET['train'] == 6){
if($session->access != BANNED){
mysqli_query($GLOBALS['link'],"DELETE from " . TB_PREFIX . "hero WHERE `dead` = 1 AND `uid` = '" . $database->escape($session->uid) . "'");
if($count_hero == 0){
if($count_hero < 3){
mysqli_query($GLOBALS['link'],"INSERT INTO ".TB_PREFIX."hero (`uid`, `wref`, `regeneration`, `unit`, `name`, `level`, `points`, `experience`, `dead`, `health`, `attack`, `defence`, `attackbonus`, `defencebonus`, `trainingtime`, `autoregen`, `intraining`) VALUES ('".$database->escape($session->uid)."', '" . (int) $village->wid . "', '0', '6', '".$database->escape($session->username)."', '0', '5', '0', '0', '100', '0', '0', '0', '0', '".round((time() + ($u6['time'] / SPEED)*3))."', '50', '1')");
mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "units SET `u6` = `u6` - 1 WHERE `vref` = '" . (int) $village->wid . "'");
mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `wood` = `wood` - ".(int) $u6['wood']." WHERE `wref` = '" . (int) $village->wid . "'");
@@ -705,10 +704,9 @@ $output.="<tr>
}
}
if($session->tribe == 2){
if($_GET['train'] == 11){
if(isset($_GET['train']) && $_GET['train'] == 11){
if($session->access != BANNED){
mysqli_query($GLOBALS['link'],"DELETE from " . TB_PREFIX . "hero WHERE `dead` = 1 AND `uid` = '" . $database->escape($session->uid) . "'");
if($count_hero == 0){
if($count_hero < 3){
mysqli_query($GLOBALS['link'],"INSERT INTO ".TB_PREFIX."hero (`uid`, `wref`, `regeneration`, `unit`, `name`, `level`, `points`, `experience`, `dead`, `health`, `attack`, `defence`, `attackbonus`, `defencebonus`, `trainingtime`, `autoregen`, `intraining`) VALUES ('".$database->escape($session->uid)."', '" . (int) $village->wid . "', '0', '11', '".$database->escape($session->username)."', '0', '5', '0', '0', '100', '0', '0', '0', '0', '".round((time() + ($u11['time'] / SPEED)*3))."', '50', '1')");
mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "units SET `u11` = `u11` - 1 WHERE `vref` = '" . (int) $village->wid . "'");
mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `wood` = `wood` - ".(int) $u11['wood']." WHERE `wref` = '" . (int) $village->wid . "'");
@@ -723,10 +721,9 @@ $output.="<tr>
exit;
}
}
if($_GET['train'] == 12){
if(isset($_GET['train']) && $_GET['train'] == 12){
if($session->access != BANNED){
mysqli_query($GLOBALS['link'],"DELETE from " . TB_PREFIX . "hero WHERE `dead` = 1 AND `uid` = '" . $database->escape($session->uid) . "'");
if($count_hero == 0){
if($count_hero < 3){
mysqli_query($GLOBALS['link'],"INSERT INTO ".TB_PREFIX."hero (`uid`, `wref`, `regeneration`, `unit`, `name`, `level`, `points`, `experience`, `dead`, `health`, `attack`, `defence`, `attackbonus`, `defencebonus`, `trainingtime`, `autoregen`, `intraining`) VALUES ('".$database->escape($session->uid)."', '" . (int) $village->wid . "', '0', '12', '".$database->escape($session->username)."', '0', '5', '0', '0', '100', '0', '0', '0', '0', '".round((time() + ($u12['time'] / SPEED)*3))."', '50', '1')");
mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "units SET `u12` = `u12` - 1 WHERE `vref` = '" . (int) $village->wid . "'");
mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `wood` = `wood` - ".(int) $u12['wood']." WHERE `wref` = '" . (int) $village->wid . "'");
@@ -741,10 +738,9 @@ $output.="<tr>
exit;
}
}
if($_GET['train'] == 13){
if(isset($_GET['train']) && $_GET['train'] == 13){
if($session->access != BANNED){
mysqli_query($GLOBALS['link'],"DELETE from " . TB_PREFIX . "hero WHERE `dead` = 1 AND `uid` = '" . $database->escape($session->uid) . "'");
if($count_hero == 0){
if($count_hero < 3){
mysqli_query($GLOBALS['link'],"INSERT INTO ".TB_PREFIX."hero (`uid`, `wref`, `regeneration`, `unit`, `name`, `level`, `points`, `experience`, `dead`, `health`, `attack`, `defence`, `attackbonus`, `defencebonus`, `trainingtime`, `autoregen`, `intraining`) VALUES ('".$database->escape($session->uid)."', '" . (int) $village->wid . "', '0', '13', '".$database->escape($session->username)."', '0', '5', '0', '0', '100', '0', '0', '0', '0', '".round((time() + ($u13['time'] / SPEED)*3))."', '50', '1')");
mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "units SET `u13` = `u13` - 1 WHERE `vref` = '" . (int) $village->wid . "'");
mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `wood` = `wood` - ".(int) $u13['wood']." WHERE `wref` = '" . (int) $village->wid . "'");
@@ -759,10 +755,9 @@ $output.="<tr>
exit;
}
}
if($_GET['train'] == 15){
if(isset($_GET['train']) && $_GET['train'] == 15){
if($session->access != BANNED){
mysqli_query($GLOBALS['link'],"DELETE from " . TB_PREFIX . "hero WHERE `dead` = 1 AND `uid` = '" . $database->escape($session->uid) . "'");
if($count_hero == 0){
if($count_hero < 3){
mysqli_query($GLOBALS['link'],"INSERT INTO ".TB_PREFIX."hero (`uid`, `wref`, `regeneration`, `unit`, `name`, `level`, `points`, `experience`, `dead`, `health`, `attack`, `defence`, `attackbonus`, `defencebonus`, `trainingtime`, `autoregen`, `intraining`) VALUES ('".$database->escape($session->uid)."', '" . (int) $village->wid . "', '0', '15', '".$database->escape($session->username)."', '0', '5', '0', '0', '100', '0', '0', '0', '0', '".round((time() + ($u15['time'] / SPEED)*3))."', '50', '1')");
mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "units SET `u15` = `u15` - 1 WHERE `vref` = '" . (int) $village->wid . "'");
mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `wood` = `wood` - ".(int) $u15['wood']." WHERE `wref` = '" . (int) $village->wid . "'");
@@ -777,10 +772,9 @@ $output.="<tr>
exit;
}
}
if($_GET['train'] == 16){
if(isset($_GET['train']) && $_GET['train'] == 16){
if($session->access != BANNED){
mysqli_query($GLOBALS['link'],"DELETE from " . TB_PREFIX . "hero WHERE `dead` = 1 AND `uid` = '" . $database->escape($session->uid) . "'");
if($count_hero == 0){
if($count_hero < 3){
mysqli_query($GLOBALS['link'],"INSERT INTO ".TB_PREFIX."hero (`uid`, `wref`, `regeneration`, `unit`, `name`, `level`, `points`, `experience`, `dead`, `health`, `attack`, `defence`, `attackbonus`, `defencebonus`, `trainingtime`, `autoregen`, `intraining`) VALUES ('".$database->escape($session->uid)."', '" . (int) $village->wid . "', '0', '16', '".$database->escape($session->username)."', '0', '5', '0', '0', '100', '0', '0', '0', '0', '".round((time() + ($u16['time'] / SPEED)*3))."', '50', '1')");
mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "units SET `u16` = `u16` - 1 WHERE `vref` = '" . (int) $village->wid . "'");
mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `wood` = `wood` - ".(int) $u16['wood']." WHERE `wref` = '" . (int) $village->wid . "'");
@@ -799,8 +793,7 @@ $output.="<tr>
if($session->tribe == 3){
if(isset($_GET['train']) && $_GET['train'] == 21){
if($session->access != BANNED){
mysqli_query($GLOBALS['link'],"DELETE from " . TB_PREFIX . "hero WHERE `dead` = 1 AND `uid` = '" . $database->escape($session->uid) . "'");
if($count_hero == 0){
if($count_hero < 3){
mysqli_query($GLOBALS['link'],"INSERT INTO ".TB_PREFIX."hero (`uid`, `wref`, `regeneration`, `unit`, `name`, `level`, `points`, `experience`, `dead`, `health`, `attack`, `defence`, `attackbonus`, `defencebonus`, `trainingtime`, `autoregen`, `intraining`) VALUES ('".$database->escape($session->uid)."', '" . (int) $village->wid . "', '0', '21', '".$database->escape($session->username)."', '0', '5', '0', '0', '100', '0', '0', '0', '0', '".round((time() + ($u21['time'] / SPEED)*3))."', '50', '1')");
mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "units SET `u21` = `u21` - 1 WHERE `vref` = '" . (int) $village->wid . "'");
mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `wood` = `wood` - ".(int) $u21['wood']." WHERE `wref` = '" . (int) $village->wid . "'");
@@ -817,8 +810,7 @@ $output.="<tr>
}
if(isset($_GET['train']) && $_GET['train'] == 22){
if($session->access != BANNED){
mysqli_query($GLOBALS['link'],"DELETE from " . TB_PREFIX . "hero WHERE `dead` = 1 AND `uid` = '" . $database->escape($session->uid) . "'");
if($count_hero == 0){
if($count_hero < 3){
mysqli_query($GLOBALS['link'],"INSERT INTO ".TB_PREFIX."hero (`uid`, `wref`, `regeneration`, `unit`, `name`, `level`, `points`, `experience`, `dead`, `health`, `attack`, `defence`, `attackbonus`, `defencebonus`, `trainingtime`, `autoregen`, `intraining`) VALUES ('".$database->escape($session->uid)."', '" . (int) $village->wid . "', '0', '22', '".$database->escape($session->username)."', '0', '5', '0', '0', '100', '0', '0', '0', '0', '".round((time() + ($u22['time'] / SPEED)*3))."', '50', '1')");
mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "units SET `u22` = `u22` - 1 WHERE `vref` = '" . (int) $village->wid . "'");
mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `wood` = `wood` - ".(int) $u22['wood']." WHERE `wref` = '" . (int) $village->wid . "'");
@@ -835,8 +827,7 @@ $output.="<tr>
}
if(isset($_GET['train']) && $_GET['train'] == 24){
if($session->access != BANNED){
mysqli_query($GLOBALS['link'],"DELETE from " . TB_PREFIX . "hero WHERE `dead` = 1 AND `uid` = '" . $database->escape($session->uid) . "'");
if($count_hero == 0){
if($count_hero < 3){
mysqli_query($GLOBALS['link'],"INSERT INTO ".TB_PREFIX."hero (`uid`, `wref`, `regeneration`, `unit`, `name`, `level`, `points`, `experience`, `dead`, `health`, `attack`, `defence`, `attackbonus`, `defencebonus`, `trainingtime`, `autoregen`, `intraining`) VALUES ('".$database->escape($session->uid)."', '" . (int) $village->wid . "', '0', '24', '".$database->escape($session->username)."', '0', '5', '0', '0', '100', '0', '0', '0', '0', '".round((time() + ($u24['time'] / SPEED)*3))."', '50', '1')");
mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "units SET `u24` = `u24` - 1 WHERE `vref` = '" . (int) $village->wid . "'");
mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `wood` = `wood` - ".(int) $u24['wood']." WHERE `wref` = '" . (int) $village->wid . "'");
@@ -853,8 +844,7 @@ $output.="<tr>
}
if(isset($_GET['train']) && $_GET['train'] == 25){
if($session->access != BANNED){
mysqli_query($GLOBALS['link'],"DELETE from " . TB_PREFIX . "hero WHERE `dead` = 1 AND `uid` = '" . $database->escape($session->uid) . "'");
if($count_hero == 0){
if($count_hero < 3){
mysqli_query($GLOBALS['link'],"INSERT INTO ".TB_PREFIX."hero (`uid`, `wref`, `regeneration`, `unit`, `name`, `level`, `points`, `experience`, `dead`, `health`, `attack`, `defence`, `attackbonus`, `defencebonus`, `trainingtime`, `autoregen`, `intraining`) VALUES ('".$database->escape($session->uid)."', '" . (int) $village->wid . "', '0', '25', '".$database->escape($session->username)."', '0', '5', '0', '0', '100', '0', '0', '0', '0', '".round((time() + ($u25['time'] / SPEED)*3))."', '50', '1')");
mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "units SET `u25` = `u25` - 1 WHERE `vref` = '" . (int) $village->wid . "'");
mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `wood` = `wood` - ".(int) $u25['wood']." WHERE `wref` = '" . (int) $village->wid . "'");
@@ -871,8 +861,7 @@ $output.="<tr>
}
if(isset($_GET['train']) && $_GET['train'] == 26){
if($session->access != BANNED){
mysqli_query($GLOBALS['link'],"DELETE from " . TB_PREFIX . "hero WHERE `dead` = 1 AND `uid` = '" . $database->escape($session->uid) . "'");
if($count_hero == 0){
if($count_hero < 3){
mysqli_query($GLOBALS['link'],"INSERT INTO ".TB_PREFIX."hero (`uid`, `wref`, `regeneration`, `unit`, `name`, `level`, `points`, `experience`, `dead`, `health`, `attack`, `defence`, `attackbonus`, `defencebonus`, `trainingtime`, `autoregen`, `intraining`) VALUES ('".$database->escape($session->uid)."', '" . (int) $village->wid . "', '0', '26', '".$database->escape($session->username)."', '0', '5', '0', '0', '100', '0', '0', '0', '0', '".round((time() + ($u26['time'] / SPEED)*3))."', '50', '1')");
mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "units SET `u26` = `u26` - 1 WHERE `vref` = '" . (int) $village->wid . "'");
mysqli_query($GLOBALS['link'],"UPDATE " . TB_PREFIX . "vdata SET `wood` = `wood` - ".(int) $u26['wood']." WHERE `wref` = '" . (int) $village->wid . "'");
@@ -892,7 +881,7 @@ $output.="<tr>
echo $output;
echo $output;
}
?>
</table>