This commit is contained in:
Shadow
2018-08-02 13:31:21 +03:00
34 changed files with 713 additions and 775 deletions
+14 -64
View File
@@ -12,6 +12,7 @@
################################################################################# #################################################################################
include_once("../../Account.php"); include_once("../../Account.php");
include_once("../../Technology.php");
if (!isset($_SESSION)) session_start(); if (!isset($_SESSION)) session_start();
if($_SESSION['access'] < ADMIN) die("Access Denied: You are not Admin!"); if($_SESSION['access'] < ADMIN) die("Access Denied: You are not Admin!");
@@ -29,80 +30,29 @@ foreach ($_POST as $key => $value) {
$_POST[$key] = (int) $value; $_POST[$key] = (int) $value;
} }
$u1 = $_POST['u1']; for($i = 1; $i <= 50; $i++) ${"u".$i} = $_POST['u'.$i];
$u2 = $_POST['u2'];
$u3 = $_POST['u3'];
$u4 = $_POST['u4'];
$u5 = $_POST['u5'];
$u6 = $_POST['u6'];
$u7 = $_POST['u7'];
$u8 = $_POST['u8'];
$u9 = $_POST['u9'];
$u10 = $_POST['u10'];
////////////////////
$u11 = $_POST['u11'];
$u12 = $_POST['u12'];
$u13 = $_POST['u13'];
$u14 = $_POST['u14'];
$u15 = $_POST['u15'];
$u16 = $_POST['u16'];
$u17 = $_POST['u17'];
$u18 = $_POST['u18'];
$u19 = $_POST['u19'];
$u20 = $_POST['u20'];
////////////////////
$u21 = $_POST['u21'];
$u22 = $_POST['u22'];
$u23 = $_POST['u23'];
$u24 = $_POST['u24'];
$u25 = $_POST['u25'];
$u26 = $_POST['u26'];
$u27 = $_POST['u27'];
$u28 = $_POST['u28'];
$u29 = $_POST['u29'];
$u30 = $_POST['u30'];
////////////////////
$u31 = $_POST['u31'];
$u32 = $_POST['u32'];
$u33 = $_POST['u33'];
$u34 = $_POST['u34'];
$u35 = $_POST['u35'];
$u36 = $_POST['u36'];
$u37 = $_POST['u37'];
$u38 = $_POST['u38'];
$u39 = $_POST['u39'];
$u40 = $_POST['u40'];
////////////////////
$u41 = $_POST['u41'];
$u42 = $_POST['u42'];
$u43 = $_POST['u43'];
$u44 = $_POST['u44'];
$u45 = $_POST['u45'];
$u46 = $_POST['u46'];
$u47 = $_POST['u47'];
$u48 = $_POST['u48'];
$u49 = $_POST['u49'];
$u50 = $_POST['u50'];
if($user['tribe'] == 1){ if($user['tribe'] == 1){
$q = "UPDATE ".TB_PREFIX."units SET u1 = $u1, u2 = $u2, u3 = $u3, u4 = $u4, u5 = $u5, u6 = $u6, u7 = $u7, u8 = $u8, u9 = $u9, u10 = $u10 WHERE vref = $id"; $q = "UPDATE ".TB_PREFIX."units SET u1 = $u1, u2 = $u2, u3 = $u3, u4 = $u4, u5 = $u5, u6 = $u6, u7 = $u7, u8 = $u8, u9 = $u9, u10 = $u10 WHERE vref = $id";
mysqli_query($GLOBALS["link"], $q); mysqli_query($GLOBALS["link"], $q);
} else if($user['tribe'] == 2){ } else if($user['tribe'] == 2){
$q = "UPDATE ".TB_PREFIX."units SET u11 = '$u11', u12 = '$u12', u13 = '$u13', u14 = '$u14', u15 = '$u15', u16 = '$u16', u17 = '$u17', u18 = '$u18', u19 = '$u19', u20 = '$u20' WHERE vref = $id"; $q = "UPDATE ".TB_PREFIX."units SET u11 = '$u11', u12 = '$u12', u13 = '$u13', u14 = '$u14', u15 = '$u15', u16 = '$u16', u17 = '$u17', u18 = '$u18', u19 = '$u19', u20 = '$u20' WHERE vref = $id";
mysqli_query($GLOBALS["link"], $q); mysqli_query($GLOBALS["link"], $q);
} else if($user['tribe'] == 3){ } else if($user['tribe'] == 3){
$q = "UPDATE ".TB_PREFIX."units SET u21 = '$u21', u22 = '$u22', u23 = '$u23', u24 = '$u24', u25 = '$u25', u26 = '$u26', u27 = '$u27', u28 = '$u28', u29 = '$u29', u30 = '$u30' WHERE vref = $id"; $q = "UPDATE ".TB_PREFIX."units SET u21 = '$u21', u22 = '$u22', u23 = '$u23', u24 = '$u24', u25 = '$u25', u26 = '$u26', u27 = '$u27', u28 = '$u28', u29 = '$u29', u30 = '$u30' WHERE vref = $id";
mysqli_query($GLOBALS["link"], $q); mysqli_query($GLOBALS["link"], $q);
} else if($user['tribe'] == 4){ } else if($user['tribe'] == 4){
$q = "UPDATE ".TB_PREFIX."units SET u31 = '$u31', u32 = '$u32', u33 = '$u33', u34 = '$u34', u35 = '$u35', u36 = '$u36', u37 = '$u37', u38 = '$u38', u39 = '$u39', u40 = '$u40' WHERE vref = $id"; $q = "UPDATE ".TB_PREFIX."units SET u31 = '$u31', u32 = '$u32', u33 = '$u33', u34 = '$u34', u35 = '$u35', u36 = '$u36', u37 = '$u37', u38 = '$u38', u39 = '$u39', u40 = '$u40' WHERE vref = $id";
mysqli_query($GLOBALS["link"], $q); mysqli_query($GLOBALS["link"], $q);
} else if($user['tribe'] == 5){ } else if($user['tribe'] == 5){
$q = "UPDATE ".TB_PREFIX."units SET u41 = '$u41', u42 = '$u42', u43 = '$u43', u44 = '$u44', u45 = '$u45', u46 = '$u46', u47 = '$u47', u48 = '$u48', u49 = '$u49', u50 = '$u50' WHERE vref = $id"; $q = "UPDATE ".TB_PREFIX."units SET u41 = '$u41', u42 = '$u42', u43 = '$u43', u44 = '$u44', u45 = '$u45', u46 = '$u46', u47 = '$u47', u48 = '$u48', u49 = '$u49', u50 = '$u50' WHERE vref = $id";
mysqli_query($GLOBALS["link"], $q); mysqli_query($GLOBALS["link"], $q);
} }
mysqli_query($GLOBALS["link"], "Insert into ".TB_PREFIX."admin_log values (0,".(int) $_SESSION['id'].",'Changed troop anmount in village <a href=\'admin.php?p=village&did=$id\'>$id</a> ',".time().")"); mysqli_query($GLOBALS["link"], "Insert into ".TB_PREFIX."admin_log values (0,".(int) $_SESSION['id'].",'Changed troop anmount in village <a href=\'admin.php?p=village&did=$id\'>$id</a> ',".time().")");
$database->addStarvationData($village['wref']);
header("Location: ../../../Admin/admin.php?p=addTroops&did=".$id."&d"); header("Location: ../../../Admin/admin.php?p=addTroops&did=".$id."&d");
?> ?>
+4 -8
View File
@@ -9,7 +9,7 @@
## Copyright: TravianZ (c) 2010-2014. All rights reserved. ## ## Copyright: TravianZ (c) 2010-2014. All rights reserved. ##
## ## ## ##
################################################################################# #################################################################################
$unarray = array(1=>U1,U2,U3,U4,U5,U6,U7,U8,U9,U10,U11,U12,U13,U14,U15,U16,U17,U18,U19,U20,U21,U22,U23,U24,U25,U26,U27,U28,U29,U30,U31,U32,U33,U34,U35,U36,U37,U38,U39,U40,U41,U42,U43,U44,U45,U46,U47,U48,U49,U50,U99,U0); $unarray = [1=>U1,U2,U3,U4,U5,U6,U7,U8,U9,U10,U11,U12,U13,U14,U15,U16,U17,U18,U19,U20,U21,U22,U23,U24,U25,U26,U27,U28,U29,U30,U31,U32,U33,U34,U35,U36,U37,U38,U39,U40,U41,U42,U43,U44,U45,U46,U47,U48,U49,U50,U99,U0];
if($_SESSION['access'] < 9) die(ACCESS_DENIED_ADMIN); if($_SESSION['access'] < 9) die(ACCESS_DENIED_ADMIN);
$id = $_GET['did']; $id = $_GET['did'];
if(isset($id)) if(isset($id))
@@ -17,12 +17,8 @@ if(isset($id))
$units = $database->getUnit($village['wref']); $units = $database->getUnit($village['wref']);
$coor = $database->getCoor($village['wref']); $coor = $database->getCoor($village['wref']);
$tribe = $user['tribe']; $tribe = $user['tribe'];
if($tribe ==1){ $img = 0;} $img = ($tribe - 1) * 10;
if($tribe ==2){ $img = 10;}
if($tribe ==3){ $img = 20;}
if($tribe ==4){ $img = 30;}
if($tribe ==5){ $img = 40;}
if($tribe ==6){ $img = 50;}
include("search2.tpl"); include("search2.tpl");
?> ?>
<form action="../GameEngine/Admin/Mods/addTroops.php" method="POST"> <form action="../GameEngine/Admin/Mods/addTroops.php" method="POST">
@@ -34,7 +30,7 @@ if(isset($id))
<th colspan="2">Edit troops</th> <th colspan="2">Edit troops</th>
</tr></thead><tbody> </tr></thead><tbody>
<?php <?php
for($i=1; $i<11; $i++) { for($i = 1; $i < 11; $i++) {
echo '<tr> echo '<tr>
<td class="addTroops"><img src="../img/un/u/'.($img+$i).'.gif"></img> '.$unarray[$img+$i].'</td> <td class="addTroops"><img src="../img/un/u/'.($img+$i).'.gif"></img> '.$unarray[$img+$i].'</td>
<td class="addTroops"><input class="addTroops" name="u'.($img+$i).'" id="u'.($img+$i).'" value="'.$units["u".($img+$i)].'" maxlength="10"> <td class="addTroops"><input class="addTroops" name="u'.($img+$i).'" id="u'.($img+$i).'" value="'.$units["u".($img+$i)].'" maxlength="10">
@@ -5,7 +5,7 @@ $deletedArtifacts = $database->getDeletedArtifacts();
<link href="../<?php echo GP_LOCATE; ?>lang/en/lang.css?f4b7d" rel="stylesheet" type="text/css"> <link href="../<?php echo GP_LOCATE; ?>lang/en/lang.css?f4b7d" rel="stylesheet" type="text/css">
<link href="../<?php echo GP_LOCATE; ?>lang/en/compact.css?f4b7i" rel="stylesheet" type="text/css"> <link href="../<?php echo GP_LOCATE; ?>lang/en/compact.css?f4b7i" rel="stylesheet" type="text/css">
<h1>Artifacts</h1> <h1>Artifacts management</h1>
<form method="post" action="../Admin/admin.php?action=addArtifacts"> <form method="post" action="../Admin/admin.php?action=addArtifacts">
<table id="member"> <table id="member">
<thead> <thead>
@@ -28,8 +28,7 @@ $deletedArtifacts = $database->getDeletedArtifacts();
$artifactArrays = array_merge(Artifacts::NATARS_ARTIFACTS, Artifacts::NATARS_WW_BUILDING_PLANS); $artifactArrays = array_merge(Artifacts::NATARS_ARTIFACTS, Artifacts::NATARS_WW_BUILDING_PLANS);
foreach($artifactArrays as $desc => $artifactType){ foreach($artifactArrays as $desc => $artifactType){
foreach($artifactType as $artifact){ foreach($artifactType as $artifact){
echo ' echo '<option value="'.$artifact['type'].':'.$artifact['size'].':'.$desc.'">'.$artifact['name'].'</option>';
<option value="'.$artifact['type'].':'.$artifact['size'].':'.$desc.'">'.$artifact['name'].'</option>';
} }
} }
@@ -117,8 +116,39 @@ $deletedArtifacts = $database->getDeletedArtifacts();
} }
?> ?>
</tbody> </tbody>
</table> </table><br />
<h1>WW villages management</h1>
<form method="post" action="../Admin/admin.php?action=addWWVillages">
<table id="member">
<thead>
<tr>
<th colspan="2">Add WW village(s)</th>
</tr>
<tr>
<td>Number of village(s)</td>
<td>Player id</td>
</tr>
</thead>
</tbody>
<tr>
<td>
<div style="text-align: center">
<input type="number" value="1" min="1" max="999" name="numberOfVillages">
</div>
</td>
<td>
<div style="text-align: center">
<input type="text" value="<?php echo Artifacts::NATARS_UID; ?>" name="playerId">
</div>
</td>
</tr>
<tr>
<td colspan="2"><div style="text-align: center"><button id="addWWVillages" class="trav_buttons" value="add" name="addWWVillages" onclick="this.disabled=true;this.form.submit();"> Add </button></div></td>
</tr>
</tbody>
</table>
</form>
<script type="text/javascript"> <script type="text/javascript">
function changeArtifactImage(){ function changeArtifactImage(){
+1 -1
View File
@@ -253,7 +253,7 @@ if(isset($id)){
foreach($newResult as $row){ foreach($newResult as $row){
echo " echo "
<tr> <tr>
<td><a href=\"?action=delOas&oid=".$row['wref']."\" onClick=\"return del('oas',".$row['wref'].")\"><img src=\"../img/admin/del.gif\"></a></td> <td><a href=\"?action=delOas&oid=".$row['wref']."&did=".$_GET['did']."\" onClick=\"return del('oas',".$row['wref'].")\"><img src=\"../img/admin/del.gif\"></a></td>
<td class=\"hab\">".$row['name']."</td> <td class=\"hab\">".$row['name']."</td>
<td class=\"hab\"><a href=\"../karte.php?d=".$row['wref']."&c=".$generator->getMapCheck($row['wref'])."\" target=\"blank\">(".$row['x']."|".$row['y'].")</a></td> <td class=\"hab\"><a href=\"../karte.php?d=".$row['wref']."&c=".$generator->getMapCheck($row['wref'])."\" target=\"blank\">(".$row['x']."|".$row['y'].")</a></td>
<td class=\"hab\">".round($row['loyalty'])."%</td> <td class=\"hab\">".round($row['loyalty'])."%</td>
+12 -14
View File
@@ -13,25 +13,23 @@
if(!isset($_SESSION)) session_start(); if(!isset($_SESSION)) session_start();
if($_SESSION['access'] < 9) die(ACCESS_DENIED_ADMIN); if($_SESSION['access'] < 9) die(ACCESS_DENIED_ADMIN);
include_once("../../Database.php"); include_once("../../Database.php");
include_once("../../Technology.php");
include_once("../../Data/unitdata.php");
$id = $_POST['id']; $id = (int)$_POST['id'];
$village = $database->getVillage($id); $village = $database->getVillage($id);
$user = $database->getUserArray($village['owner'],1); $user = $database->getUserArray($village['owner'],1);
$units=""; $units = "";
$tribe = $user['tribe']; $tribe = $user['tribe'];
if($tribe ==1){ $u = 0;} $u = ($tribe - 1) * 10;
if($tribe ==2){ $u = 10;}
if($tribe ==3){ $u = 20;}
if($tribe ==4){ $u = 30;}
if($tribe ==5){ $u = 40;}
if($tribe ==6){ $u = 50;}
for($i=1; $i<11; $i++) { for($i = 1; $i < 11; $i++) {
$units.="u".($u+$i)."=".$database->escape($_POST['u'.($u+$i)].(($i < 10) ? ", " : "")); $units.="u".($u + $i)."=".$database->escape($_POST['u'.($u + $i)].(($i < 10) ? ", " : ""));
} }
$q = "UPDATE ".TB_PREFIX."units SET ".$units." WHERE vref = ".(int) $id;
$q = "UPDATE ".TB_PREFIX."units SET ".$units." WHERE vref = ".$id;
$database->query($q); $database->query($q);
$database->query("Insert into ".TB_PREFIX."admin_log values (0,".(int) $_SESSION['id'].",'Changed troop amounts in village <a href=\'admin.php?p=village&did=$id\'>$id</a> ',".time().")"); $database->query("Insert into ".TB_PREFIX."admin_log values (0,".(int) $_SESSION['id'].",'Changed troop amounts in village <a href=\'admin.php?p=village&did=$id\'>$id</a> ',".time().")");
$database->addStarvationData($id);
header("Location: ../../../Admin/admin.php?p=village&did=".$id."&d"); header("Location: ../../../Admin/admin.php?p=village&did=".$id."&d");
?> ?>
+12 -45
View File
@@ -24,57 +24,24 @@ for ($i = 0; $i < 5; $i++) {
include_once($autoprefix."GameEngine/Database.php"); include_once($autoprefix."GameEngine/Database.php");
$session = (int) $_POST['admid'];
$id = (int) $_POST['id']; $id = (int) $_POST['id'];
$sql = mysqli_query($GLOBALS["link"], "SELECT * FROM ".TB_PREFIX."users WHERE id = ".$session.""); $bonusDuration = [];
$access = mysqli_fetch_array($sql); $time = time();
$sessionaccess = $access['access']; $bonusDuration['plus'] = (int) $_POST['plus'] * 86400; //Plus
$bonusDuration['b1'] = (int) $_POST['wood'] * 86400; //+25% Wood
$bonusDuration['b2'] = (int) $_POST['clay'] * 86400; //+25% Clay
$bonusDuration['b3'] = (int) $_POST['iron'] * 86400; //+25% Iron
$bonusDuration['b4'] = (int) $_POST['crop'] * 86400; //+25% Crop
if($sessionaccess != 9) die("<h1><font color=\"red\">Access Denied: You are not Admin!</font></h1>"); $user = $database->getUserArray($id, 1);
$pdur = (int) $_POST['plus'] * 86400; foreach($bonusDuration as $index => $bonus){
$b1dur = (int) $_POST['wood'] * 86400; $bonusDuration[$index] = $bonusDuration[$index] + ($user[$index] < $time ? $time : $user[$index]);
$b2dur = (int) $_POST['clay'] * 86400; if($bonusDuration[$index] < $time) $bonusDuration[$index] = 0;
$b3dur = (int) $_POST['iron'] * 86400;
$b4dur = (int) $_POST['crop'] * 86400;
$sql1 = mysqli_query($GLOBALS["link"], "SELECT * FROM ".TB_PREFIX."users WHERE id = ".$id."");
$user = mysqli_fetch_array($sql1);
if($user['plus'] < time()){
if($pdur > 1){ $plus = (time() + $pdur); } else { $plus = time(); }
}else{
if($pdur > 1){ $plus = ($user['plus'] + $pdur); } else { $plus = $user['plus']; }
}
if($user['b1'] < time()){
if($b1dur > 1){ $wood = (time() + $b1dur); } else { $wood = time(); }
}else{
if($b1dur > 1){ $wood = ($user['b1'] + $b1dur); } else { $wood = $user['b1']; }
}
if($user['b2'] < time()){
if($b2dur > 1){ $clay = (time() + $b2dur); } else { $clay = time(); }
}else{
if($b2dur > 1){ $clay = ($user['b2'] + $b2dur); } else { $clay = $user['b2']; }
}
if($user['b3'] < time()){
if($b3dur > 1){ $iron = (time() + $b3dur); } else { $iron = time(); }
}else{
if($b3dur > 1){ $iron = ($user['b3'] + $b3dur); } else { $iron = $user['b3']; }
}
if($user['b4'] < time()){
if($b4dur > 1){ $crop = (time() + $b4dur); } else { $crop = time(); }
}else{
if($b4dur > 1){ $crop = ($user['b4'] + $b4dur); } else { $crop = $user['b4']; }
} }
mysqli_query($GLOBALS["link"], "UPDATE ".TB_PREFIX."users SET $database->updateUserField($id, array_keys($bonusDuration), array_values($bonusDuration), 1);
plus = '".$plus."',
b1 = '".$wood."',
b2 = '".$clay."',
b3 = '".$iron."',
b4 = '".$crop."'
WHERE id = $id") or die(mysqli_error($database->dblink));
header("Location: ../../../Admin/admin.php?p=player&uid=".$id.""); header("Location: ../../../Admin/admin.php?p=player&uid=".$id."");
?> ?>
-8
View File
@@ -30,14 +30,6 @@ for ($i = 0; $i < 5; $i++) {
include_once($autoprefix."GameEngine/Database.php"); include_once($autoprefix."GameEngine/Database.php");
$session = (int) $_POST['admid'];
$sql = mysqli_query($GLOBALS["link"], "SELECT * FROM ".TB_PREFIX."users WHERE id = ".$session."");
$access = mysqli_fetch_array($sql);
$sessionaccess = $access['access'];
if($sessionaccess != 9) die("<h1><font color=\"red\">Access Denied: You are not Admin!</font></h1>");
$sql = "SELECT id FROM ".TB_PREFIX."users ORDER BY ID DESC LIMIT 1"; $sql = "SELECT id FROM ".TB_PREFIX."users ORDER BY ID DESC LIMIT 1";
$loops = mysqli_result(mysqli_query($GLOBALS["link"], $sql), 0); $loops = mysqli_result(mysqli_query($GLOBALS["link"], $sql), 0);
+34 -11
View File
@@ -18,6 +18,9 @@
// # ## // # ##
// ################################################################################ // ################################################################################
include_once("../GameEngine/Artifacts.php"); include_once("../GameEngine/Artifacts.php");
include_once("../GameEngine/Units.php");
include_once("../GameEngine/Generator.php");
class funct class funct
{ {
@@ -28,7 +31,7 @@ class funct
function Act($get) function Act($get)
{ {
global $admin, $database; global $admin, $database, $units, $generator;
$artifact = new Artifacts(); $artifact = new Artifacts();
@@ -71,8 +74,8 @@ class funct
// add ban // add ban
break; break;
case "delOas": case "delOas":
$database->query('UPDATE ' . TB_PREFIX . 'odata SET conqured = 0, owner = 2, name = "Unoccupied Oasis" WHERE wref = ' . $get['oid']); $units->returnTroops($get['did'], 1);
// oaza $database->removeOases($get['oid']);
break; break;
case "logout": case "logout":
$this->LogOut(); $this->LogOut();
@@ -93,25 +96,30 @@ class funct
$artifactInfo = $database->getArtefactDetails($_GET['artid'], $_GET['del']); $artifactInfo = $database->getArtefactDetails($_GET['artid'], $_GET['del']);
//Check if the artifact exists //Check if the artifact exists
if(empty($artifactInfo) || $artifactInfo['owner'] == Artifacts::NATARS_UID) { if(empty($artifactInfo)) {
header("location: admin.php");
exit;
}elseif($artifactInfo['owner'] == Artifacts::NATARS_UID){
$database->updateArtifactDetails($_GET['artid'], ['del' => 0]);
header("location: admin.php"); header("location: admin.php");
exit; exit;
} }
//Return the artifacts to the Natars' account
$artifact->returnArtifactToNatars($artifactInfo); $artifact->returnArtifactToNatars($artifactInfo);
break; break;
case "addArtifacts": case "addArtifacts":
$selectedArtifact = $_POST['selectedArtifact']; $selectedArtifact = $_POST['selectedArtifact'];
$artifactQuantity = $_POST['artifactQuantity']; $artifactQuantity = (int)$_POST['artifactQuantity'];
$playerId = $_POST['playerId']; $playerId = (int)$_POST['playerId'];
//Check if the inputs are valid //Check if the inputs are valid
if(!isset($selectedArtifact) || !isset($artifactQuantity) || !isset($playerId) || empty($selectedArtifact) || if(!isset($selectedArtifact) || !isset($artifactQuantity) || !isset($playerId) || empty($selectedArtifact) ||
!is_numeric($artifactQuantity) || !is_numeric($playerId) || strpos($selectedArtifact, ':') === false || !is_numeric($artifactQuantity) || $artifactQuantity <= 0 || $artifactQuantity > 999 || !is_numeric($playerId) ||
$database->getUserField($playerId, "username", 0) == "[?]"){ strpos($selectedArtifact, ':') === false || $database->getUserField($playerId, "username", 0) == "[?]"){
header("location: admin.php"); header("location: admin.php?p=natars&error=0");
exit; exit;
} }
@@ -125,7 +133,7 @@ class funct
//Check if the artifact has been found or if doesn't exist //Check if the artifact has been found or if doesn't exist
if(empty($chosenArtifact)){ if(empty($chosenArtifact)){
header("location: admin.php"); header("location: admin.php?p=natars&error=1");
exit; exit;
} }
@@ -134,9 +142,24 @@ class funct
$artifactArrays[$selectedArtifact[2]][] = $chosenArtifact; $artifactArrays[$selectedArtifact[2]][] = $chosenArtifact;
//Add the artifacts //Add the artifacts
$artifact->addArtifactVillages($artifactArrays, $playerId); $artifact->addArtifactVillages($artifactArrays, $playerId, $playerId == Artifacts::NATARS_UID);
break; break;
case "addWWVillages":
$numberOfVillages = (int)$_POST['numberOfVillages'];
$playerId = (int)$_POST['playerId'];
//Check if the inserted values are valid
if(!is_numeric($numberOfVillages) || $numberOfVillages <= 0 || $numberOfVillages > 999
|| !is_numeric($playerId) || $database->getUserField($playerId, "username", 0) == "[?]"){
header("location: admin.php?p=natars&error=2");
}
//Create the desired WW villages
$artifact->createWWVillages($numberOfVillages, $playerId, $playerId == Artifacts::NATARS_UID);
break;
case "killHero": case "killHero":
$varray = $database->getProfileVillages($get['uid']); $varray = $database->getProfileVillages($get['uid']);
$killhero = false; $killhero = false;
+41 -35
View File
@@ -2,16 +2,16 @@
class Artifacts class Artifacts
{ {
public const const
/** /**
* @var integer Default Natars' uid * @var int Default Natars' uid
*/ */
NATARS_UID = 3, NATARS_UID = 3,
/** /**
* @var integer Default Natars' tribe * @var int Default Natars' tribe
*/ */
NATARS_TRIBE = 5, NATARS_TRIBE = 5,
@@ -35,23 +35,18 @@ class Artifacts
*/ */
NATARS_CAPITAL_COORDINATES = [[WORLD_MAX, WORLD_MAX], NATARS_CAPITAL_COORDINATES = [[WORLD_MAX, WORLD_MAX],
[WORLD_MAX, 0],
[WORLD_MAX, -WORLD_MAX], [WORLD_MAX, -WORLD_MAX],
[0, -WORLD_MAX],
[-WORLD_MAX, -WORLD_MAX], [-WORLD_MAX, -WORLD_MAX],
[WORLD_MAX - 1, WORLD_MAX], [-WORLD_MAX, 0],
[WORLD_MAX, WORLD_MAX - 1], [-WORLD_MAX, WORLD_MAX],
[-WORLD_MAX, WORLD_MAX - 1], [0, WORLD_MAX],
[WORLD_MAX - 1, -WORLD_MAX], [WORLD_MAX / 10, WORLD_MAX / 20],
[WORLD_MAX - 1, WORLD_MAX - 1], [WORLD_MAX / 10, -WORLD_MAX / 10],
[WORLD_MAX, -WORLD_MAX + 1], [-WORLD_MAX / 20, -WORLD_MAX / 10],
[WORLD_MAX - 1, -WORLD_MAX + 1], [-WORLD_MAX / 10, 0],
[-WORLD_MAX + 1, -WORLD_MAX + 1], [-WORLD_MAX / 20, WORLD_MAX / 10]],
[WORLD_MAX - 2, WORLD_MAX],
[WORLD_MAX - 2, -WORLD_MAX],
[WORLD_MAX - 2, WORLD_MAX - 1],
[WORLD_MAX - 1, WORLD_MAX - 2],
[-WORLD_MAX + 2, WORLD_MAX],
[-WORLD_MAX + 2, WORLD_MAX - 1],
[-WORLD_MAX + 2, -WORLD_MAX + 2]],
/** /**
* @var array Normal Natars' artifacts * @var array Normal Natars' artifacts
@@ -91,7 +86,7 @@ class Artifacts
* @var array WW building plans Natars' artifacts * @var array WW building plans Natars' artifacts
*/ */
NATARS_WW_BUILDING_PLANS = [PLAN_DESC => [["type" => 11, "size" => 1, "name" => PLAN,"vname" => PLANVILLAGE, "effect" => "", "quantity" => 13, "img" => 1]]], NATARS_WW_BUILDING_PLANS = [PLAN_DESC => [["type" => 11, "size" => 1, "name" => PLAN, "vname" => PLANVILLAGE, "effect" => "", "quantity" => 13, "img" => 1]]],
/** /**
* @var array Natars' normal artifacts buildings * @var array Natars' normal artifacts buildings
@@ -128,11 +123,17 @@ class Artifacts
"f2" => 6, "f8" => 6, "f9" => 6, "f12" => 6, "f13" => 6, "f15" => 6], "f2" => 6, "f8" => 6, "f9" => 6, "f12" => 6, "f13" => 6, "f15" => 6],
/** /**
* @var integer The base amount of Natars' spying units, used when Natars account is created * @var int The base amount of Natars' spying units, used when Natars account is created
*/ */
NATARS_BASE_SPY = 1500; NATARS_BASE_SPY = 1500,
/**
* @var int the base amount of Natars' WW villages
*/
NATARS_BASE_WW_VILLAGES = 13;
public public
/** /**
@@ -178,7 +179,7 @@ class Artifacts
} }
/** /**
* Called when Natars account need to be created, creates his account and capital village * Called when Natars account needs to be created, creates his account and capital village
* *
*/ */
@@ -263,9 +264,10 @@ class Artifacts
* *
* @param array $artifactArrays The array containing the artifacts to insert * @param array $artifactArrays The array containing the artifacts to insert
* @param int $uid The owner's user ID (Natars) * @param int $uid The owner's user ID (Natars)
* @param bool $addTroops Add troops to the village if true, and vice versa if false
*/ */
public function addArtifactVillages($artifactArrays, $uid = self::NATARS_UID) { public function addArtifactVillages($artifactArrays, $uid = self::NATARS_UID, $addTroops = true) {
global $database; global $database;
//Variables initialization //Variables initialization
@@ -284,7 +286,7 @@ class Artifacts
$unitArrays = ($this->natarsArtifactsUnits)($multiplier); $unitArrays = ($this->natarsArtifactsUnits)($multiplier);
//Generate the unit arrays //Generate the unit arrays
$artifactTroops[1][] = array_values($unitArrays); if($addTroops) $artifactTroops[1][] = array_values($unitArrays);
$artifactBuildings[1][] = array_values(self::NATARS_ARTIFACTS_BUILDINGS); $artifactBuildings[1][] = array_values(self::NATARS_ARTIFACTS_BUILDINGS);
//Generate the artifacts array //Generate the artifacts array
@@ -296,11 +298,11 @@ class Artifacts
} }
//Set the unit types by using the last $unitArrays //Set the unit types by using the last $unitArrays
$artifactTroops[0] = array_keys($unitArrays); if($addTroops) $artifactTroops[0] = array_keys($unitArrays);
$artifactBuildings[0] = array_keys(self::NATARS_ARTIFACTS_BUILDINGS); $artifactBuildings[0] = array_keys(self::NATARS_ARTIFACTS_BUILDINGS);
//Generate the wids //Generate the wids
$wids = array_merge($wids, (array)$database->generateVillages($artifactVillages, $uid, TRIBE5, $artifactTroops, $artifactBuildings)); $wids = array_merge($wids, (array)$database->generateVillages($artifactVillages, $uid, TRIBE5, $addTroops ? $artifactTroops : null, $artifactBuildings));
//Create the artifacts for the generated wids //Create the artifacts for the generated wids
$database->addArtefacts($wids, $artifactsToAdd); $database->addArtefacts($wids, $artifactsToAdd);
@@ -309,22 +311,25 @@ class Artifacts
/** /**
* Called when WW villages need to be created * Called when WW villages need to be created
* *
* @param int $numberOfVillages The number of villages that have to be added
* @param int $uid The player ID
* @param bool $addTroops Add troops to the village if true, and vice versa if false
*/ */
public function createWWVillages(){ public function createWWVillages($numberOfVillages = self::NATARS_BASE_WW_VILLAGES, $uid = self::NATARS_UID, $addTroops = true){
global $database; global $database;
$villageArrays = $troopArrays = $buildingArrays = $wids = []; $villageArrays = $troopArrays = $buildingArrays = $wids = [];
for($i = 1; $i <= 13; $i++){ for($i = 1; $i <= $numberOfVillages; $i++){
$villageArrays[] = ['wid' => 0, 'mode' => 5, 'type' => 3, 'kid' => ($i == 13 ? rand(1, 4) : ($i % 4) + 1), 'capital' => 0, 'pop' => 233, 'name' => WWVILLAGE, 'natar' => 1]; $villageArrays[] = ['wid' => 0, 'mode' => 5, 'type' => 3, 'kid' => ($i == $numberOfVillages ? rand(1, 4) : ($i % 4) + 1), 'capital' => 0, 'pop' => 233, 'name' => WWVILLAGE, 'natar' => 1];
$troopArrays[1][] = array_values(($this->natarsWWVillagesUnits)()); if($addTroops) $troopArrays[1][] = array_values(($this->natarsWWVillagesUnits)());
$buildingArrays[1][] = array_values(self::NATARS_WW_VILLAGES_BUILDINGS); $buildingArrays[1][] = array_values(self::NATARS_WW_VILLAGES_BUILDINGS);
} }
$troopArrays[0] = array_keys(($this->natarsWWVillagesUnits)()); if($addTroops) $troopArrays[0] = array_keys(($this->natarsWWVillagesUnits)());
$buildingArrays[0] = array_keys(self::NATARS_WW_VILLAGES_BUILDINGS); $buildingArrays[0] = array_keys(self::NATARS_WW_VILLAGES_BUILDINGS);
$wids = $database->generateVillages($villageArrays, self::NATARS_UID, TRIBE5, $troopArrays, $buildingArrays); $wids = $database->generateVillages($villageArrays, $uid, null, $addTroops ? $troopArrays : null, $buildingArrays);
} }
/** /**
@@ -411,10 +416,11 @@ class Artifacts
global $database; global $database;
//Set the village arrays //Set the village arrays
$artifactArrays = array_merge(self::NATARS_ARTIFACTS, self::NATARS_WW_BUILDING_PLANS);
$villageArrays = [['wid' => 0, 'mode' => $artifactArray['size'] + 1, 'type' => 3, $villageArrays = [['wid' => 0, 'mode' => $artifactArray['size'] + 1, 'type' => 3,
'kid' => rand(1, 4), 'capital' => 0, 'pop' => 163, 'kid' => rand(1, 4), 'capital' => 0, 'pop' => 163,
'name' => self::NATARS_ARTIFACTS[$artifactArray['desc']][$artifactArray['size'] - 1]['vname'], 'name' => $artifactArrays[$artifactArray['desc']][$artifactArray['size'] - 1]['vname'],
'natar' => $artifactArray['type'] != 11 ? 0 : 1]]; 'natar' => 0]];
//Set the unit arrays //Set the unit arrays
$multiplier = $artifactArray['size'] == 3 ? 4 : $artifactArray['size']; $multiplier = $artifactArray['size'] == 3 ? 4 : $artifactArray['size'];
@@ -427,7 +433,7 @@ class Artifacts
//Set the buildings array //Set the buildings array
$artifactBuildings[1][] = array_values(self::NATARS_ARTIFACTS_BUILDINGS); $artifactBuildings[1][] = array_values(self::NATARS_ARTIFACTS_BUILDINGS);
$artifactBuildings[0] = array_keys(self::NATARS_ARTIFACTS_BUILDINGS); $artifactBuildings[0] = array_keys(self::NATARS_ARTIFACTS_BUILDINGS);
//Generate the village //Generate the village
$wid = $database->generateVillages($villageArrays, self::NATARS_UID, TRIBE5, $artifactTroops, $artifactBuildings); $wid = $database->generateVillages($villageArrays, self::NATARS_UID, TRIBE5, $artifactTroops, $artifactBuildings);
Executable → Regular
+50 -72
View File
@@ -383,7 +383,7 @@ class Automation {
} }
private function buildComplete() { private function buildComplete() {
global $database, $bid18, $bid10, $bid11, $bid38, $bid39; global $database, $technology, $bid18, $bid10, $bid11, $bid38, $bid39;
$time = time(); $time = time();
// IDs of villages that were affected by this building completion update, // IDs of villages that were affected by this building completion update,
@@ -476,7 +476,7 @@ class Automation {
} }
//Update starvation data //Update starvation data
$this->addStarvationData($indi['wid']); $database->addStarvationData($indi['wid']);
// update the requested fields, all at once // update the requested fields, all at once
$database->setVillageFields($indi['wid'], array_keys($fieldsToSet), array_values($fieldsToSet)); $database->setVillageFields($indi['wid'], array_keys($fieldsToSet), array_values($fieldsToSet));
@@ -711,27 +711,33 @@ class Automation {
if(isset($catapultTarget)) if(isset($catapultTarget))
{ {
// currently targeted building/field level //Currently targeted building/field level
$tblevel = (int) $bdo['f'.$catapultTarget]; $tblevel = (int) $bdo['f'.$catapultTarget];
// currently targetet building/field GID (ID of the building/field type - woodcutter, cropland, embassy...) //Currently targetet building/field GID (ID of the building/field type - woodcutter, cropland, embassy...)
$tbgid = (int) $bdo['f'.$catapultTarget.'t']; $tbgid = (int) $bdo['f'.$catapultTarget.'t'];
// currently targeted building/field ID in the database (fdata, the fID field, e.g. f1, f2, f3...) //Currently targeted building/field ID in the database (fdata, the fID field, e.g. f1, f2, f3...)
$tbid = (int) $catapultTarget; $tbid = (int) $catapultTarget;
$newLevel = $battle->CalculateNewBuildingLevel($battlepart['catapults']['moral'], //If we're targeting the WW
$battlepart['catapults']['upgrades'], if($catapultTarget == 40){
$battlepart['catapults']['downgrades'], $battlepart['catapults']['strongerBuildings'] = 1;
$tblevel, $battlepart['catapults']['moraleBonus'] = 1;
$battlepart['catapults']['realAttackers'] / ($twoRowsCatapultSetup ? 2 : 1), }
$data['t8'] / ($twoRowsCatapultSetup ? 2 : 1),
($catapultTarget == 40 ? 1 : $battlepart['catapults']['strongerBuildings'])); $catapultsDamage = $battle->calculateCatapultsDamage($data['t8'],
$battlepart['catapults']['upgrades'],
$battlepart['catapults']['durability'],
$battlepart['catapults']['attackDefenseRatio'],
$battlepart['catapults']['strongerBuildings'],
$battlepart['catapults']['moraleBonus']);
$newLevel = $battle->calculateNewBuildingLevel($tblevel, $catapultsDamage / ($twoRowsCatapultSetup ? 2 : 1));
//If that building was present in the building queue, we have to modify his level or remove it //If that building was present in the building queue, we have to modify his level or remove it
$database->modifyBData($data['to'], $tbid, [$newLevel, $tblevel], $tribe); $database->modifyBData($data['to'], $tbid, [$newLevel, $tblevel], $tribe);
// building/field destroyed // building/field destroyed
if ($newLevel == 0) if ($newLevel == 0){
{
// prepare data to be updated // prepare data to be updated
$fieldsToSet = ["f".$tbid]; $fieldsToSet = ["f".$tbid];
$fieldValuesToSet = [0]; $fieldValuesToSet = [0];
@@ -1266,11 +1272,8 @@ class Automation {
} }
} }
} }
//to battle.php
//fix by ronix //fix by ronix
//MUST TO BE FIX : You need to filter these values
//filter_input_array($battlepart = $battle->calculateBattle($Attacker,$Defender,$def_wall,$att_tribe,$def_tribe,$residence,$attpop,$defpop,$type,$def_ab,$att_ab1,$att_ab2,$att_ab3,$att_ab4,$att_ab5,$att_ab6,$att_ab7,$att_ab8,$tblevel,$stonemason,$walllevel,0,0,0,$AttackerID,$DefenderID,$AttackerWref,$DefenderWref,$conqureby));
if (!isset($walllevel)) $walllevel = 0; if (!isset($walllevel)) $walllevel = 0;
$battlepart = $battle->calculateBattle($Attacker, $Defender, $def_wall, $att_tribe, $def_tribe, $residence, $attpop, $defpop, $type, $def_ab, $att_ab1, $att_ab2, $att_ab3, $att_ab4, $att_ab5, $att_ab6, $att_ab7, $att_ab8, $tblevel, $stonemason, $walllevel, 0, 0, 0, $AttackerID, $DefenderID, $AttackerWref, $DefenderWref, $conqureby, $enforcementarray); $battlepart = $battle->calculateBattle($Attacker, $Defender, $def_wall, $att_tribe, $def_tribe, $residence, $attpop, $defpop, $type, $def_ab, $att_ab1, $att_ab2, $att_ab3, $att_ab4, $att_ab5, $att_ab6, $att_ab7, $att_ab8, $tblevel, $stonemason, $walllevel, 0, 0, 0, $AttackerID, $DefenderID, $AttackerWref, $DefenderWref, $conqureby, $enforcementarray);
@@ -1286,17 +1289,18 @@ class Automation {
else $can_destroy = 0; else $can_destroy = 0;
//Catapults and rams management //Catapults and rams management
//TODO: Move this in Battle.php
if($isoasis == 0){ if($isoasis == 0){
if ($type == 3){ if ($type == 3){
if (($data['t7'] - $traped7) > 0){ if (($data['t7'] - $traped7) > 0){
if($walllevel > 0){ if($walllevel > 0){
$newLevel = $battle->CalculateNewBuildingLevel($battlepart['rams']['moral'], $ramsDamage = $battle->calculateCatapultsDamage($data['t7'],
$battlepart['rams']['upgrades'], $battlepart['rams']['upgrades'],
$battlepart['rams']['downgrades'], $battlepart['rams']['durability'],
$walllevel, $battlepart['rams']['attackDefenseRatio'],
$battlepart['rams']['realAttackers'], $battlepart['rams']['strongerBuildings'],
$data['t7'], $battlepart['rams']['moraleBonus']);
$battlepart['rams']['strongerBuildings']); $newLevel = $battle->calculateNewBuildingLevel($walllevel, $ramsDamage);
if ($newLevel == 0){ if ($newLevel == 0){
$info_ram = "".$ram_pic.",Wall <b>destroyed</b>."; $info_ram = "".$ram_pic.",Wall <b>destroyed</b>.";
@@ -2184,7 +2188,7 @@ class Automation {
// if the defender pop is 0 with no artefact, then destroy the village // if the defender pop is 0 with no artefact, then destroy the village
if($database->getVillageField($data['to'], "pop") == 0 || $targettribe == 5){ if($database->getVillageField($data['to'], "pop") == 0 || $targettribe == 5){
$can_destroy = $village_destroyed = 1; $can_destroy = $village_destroyed = 1;
$info_hero .= " The village has been destroyed."; if(strpos($info_cat, "The village has") === false) $info_hero .= " The village has been destroyed.";
} }
} }
else $info_hero = $hero_pic.",".$artifactError.$xp; else $info_hero = $hero_pic.",".$artifactError.$xp;
@@ -2233,7 +2237,7 @@ class Automation {
}else{ }else{
if(isset($village_destroyed) && $village_destroyed == 1 && $can_destroy==1){ if(isset($village_destroyed) && $village_destroyed == 1 && $can_destroy==1){
//check if village pop=0 and no info destroy //check if village pop=0 and no info destroy
if (strpos($info_cat,"The village has") === false) { if (strpos($info_cat, "The village has") === false) {
$info_cat .= "<tbody class=\"goods\"><tr><th>Information</th><td colspan=\"11\"> $info_cat .= "<tbody class=\"goods\"><tr><th>Information</th><td colspan=\"11\">
<img class=\"unit u".$catp_pic."\" src=\"img/x.gif\" alt=\"Catapult\" title=\"Catapult\" /> The village has been destroyed.</td></tr></tbody>"; <img class=\"unit u".$catp_pic."\" src=\"img/x.gif\" alt=\"Catapult\" title=\"Catapult\" /> The village has been destroyed.</td></tr></tbody>";
} }
@@ -2488,7 +2492,7 @@ class Automation {
} }
//Update starvation data //Update starvation data
$this->addStarvationData($to['wref']); $database->addStarvationData($to['wref']);
//Returning units back to village is not necessary because it will be taken care when processing movement //Returning units back to village is not necessary because it will be taken care when processing movement
// Fix by AL-Kateb // Fix by AL-Kateb
@@ -2579,7 +2583,7 @@ class Automation {
} }
private function sendreinfunitsComplete() { private function sendreinfunitsComplete() {
global $bid23, $database, $battle; global $bid23, $database, $technology, $battle;
$time = time(); $time = time();
$q = " $q = "
@@ -2717,7 +2721,7 @@ class Automation {
} }
//Update starvation data //Update starvation data
$this->addStarvationData($data['to']); $database->addStarvationData($data['to']);
//check empty reinforcement in rally point //check empty reinforcement in rally point
$e_units = ''; $e_units = '';
@@ -2733,7 +2737,7 @@ class Automation {
} }
private function returnunitsComplete() { private function returnunitsComplete() {
global $database; global $database, $technology;
$time = time(); $time = time();
$q = " $q = "
@@ -2783,7 +2787,7 @@ class Automation {
$movementProcIDs[] = $data['moveid']; $movementProcIDs[] = $data['moveid'];
//Update starvation data //Update starvation data
$this->addStarvationData($data['to']); $database->addStarvationData($data['to']);
} }
$database->setMovementProc(implode(', ', $movementProcIDs)); $database->setMovementProc(implode(', ', $movementProcIDs));
@@ -3233,7 +3237,7 @@ class Automation {
} }
private function trainingComplete() { private function trainingComplete() {
global $database; global $database, $technology;
$time = time(); $time = time();
$trainlist = $database->getTrainingList(); $trainlist = $database->getTrainingList();
@@ -3287,7 +3291,7 @@ class Automation {
if ($valuesUpdated) call_user_func(get_class($database).'::clearUnitsCache'); if ($valuesUpdated) call_user_func(get_class($database).'::clearUnitsCache');
//Update starvation data //Update starvation data
$this->addStarvationData($train['vref']); $database->addStarvationData($train['vref']);
} }
} }
} }
@@ -3677,30 +3681,6 @@ class Automation {
} }
} }
} }
/**
* Adds the starvation data in villages with a negative value of crop
*
* @param int $wref The village ID where the crop is negative
*/
private function addStarvationData($wref){
global $database, $technology;
$getVillage = $database->getVillage($wref);
//Exlude Support, Nature, Natars, TaskMaster and Multihunter
if ($getVillage['owner'] > 5){
$crop = $database->getCropProdstarv($wref, false);
$unitArrays = $this->getAllUnits($wref, false);
$villageUpkeep = $getVillage['pop'] + $technology->getUpkeep($unitArrays, 0, $wref);
$starv = $getVillage['starv'];
if ($crop < $villageUpkeep){
//Add starvation data
$database->setVillageFields($wref, ['starv'], [$villageUpkeep]);
}
}
}
/** /**
* Function for starvation - by brainiacX and Shadow * Function for starvation - by brainiacX and Shadow
@@ -3712,23 +3692,23 @@ class Automation {
private function starvation() { private function starvation() {
global $database, $technology; global $database, $technology;
//starvation is disabled during Easter/Holidays/Christmas //Starvation is disabled during Easter/Holidays/Christmas
if(PEACE) return; if(PEACE) return;
$time = time(); $time = time();
//update starvation in every village //Update starvation in every village
$starvarray = $database->getProfileVillages(0, 7); $starvarray = $database->getProfileVillages(0, 7);
foreach($starvarray as $starv) $this->addStarvationData($starv['wref']); foreach($starvarray as $starv) $database->addStarvationData($starv['wref']);
// load villages with minus prod //Load villages with minus prod
$starvarray = []; $starvarray = [];
$starvarray = $database->getStarvation(); $starvarray = $database->getStarvation();
$vilIDs = []; $vilIDs = [];
foreach ($starvarray as $starv) $vilIDs[] = $starv['wref']; foreach ($starvarray as $starv) $vilIDs[] = $starv['wref'];
// cache //Cache
$database->getEnforceVillage($vilIDs, 0); $database->getEnforceVillage($vilIDs, 0);
$database->getOasisEnforce($vilIDs, 2); $database->getOasisEnforce($vilIDs, 2);
$database->getOasisEnforce($vilIDs, 3); $database->getOasisEnforce($vilIDs, 3);
@@ -3758,7 +3738,7 @@ class Automation {
$allTroopsArray = [$enforceArrays, $prisonerArrays, $unitArrays, $attackArrays]; $allTroopsArray = [$enforceArrays, $prisonerArrays, $unitArrays, $attackArrays];
// find the first not-empty array //Find the first not-empty array
foreach($allTroopsArray as $type => $allTroops) foreach($allTroopsArray as $type => $allTroops)
{ {
if(!empty($allTroops)){ if(!empty($allTroops)){
@@ -3771,10 +3751,10 @@ class Automation {
} }
} }
// if the player has no troops, then skip the next instructions //If the player has no troops, then skip the next instructions
if(empty($starvingTroops)) continue; if(empty($starvingTroops)) continue;
// counting //Counting
$timedif = $time - $starv['starvupdate']; $timedif = $time - $starv['starvupdate'];
$cropProd = $database->getCropProdstarv($starv['wref']) - $starv['starv']; $cropProd = $database->getCropProdstarv($starv['wref']) - $starv['starv'];
if($cropProd < 0){ if($cropProd < 0){
@@ -3783,7 +3763,7 @@ class Automation {
$newcrop = 0; $newcrop = 0;
$oldcrop = $database->getVillageField($starv['wref'], 'crop'); $oldcrop = $database->getVillageField($starv['wref'], 'crop');
//if the grain is then tries to send all //If the grain is then tries to send all
if ($oldcrop > 100){ if ($oldcrop > 100){
$difcrop = $difcrop - $oldcrop; $difcrop = $difcrop - $oldcrop;
if($difcrop < 0){ if($difcrop < 0){
@@ -3804,7 +3784,7 @@ class Automation {
$counting = true; $counting = true;
while($difcrop > 0) while($difcrop > 0)
{ {
// search the highest troop //S earch the highest troop
$maxcount = $maxtype = 0; $maxcount = $maxtype = 0;
for($i = $start ; $i <= $end ; $i++) for($i = $start ; $i <= $end ; $i++)
{ {
@@ -3837,10 +3817,8 @@ class Automation {
else if($maxtype == 0) $newCrop = 0; else if($maxtype == 0) $newCrop = 0;
else $newCrop = $GLOBALS['u'.$maxtype]['crop']; else $newCrop = $GLOBALS['u'.$maxtype]['crop'];
if($totalKilledUnits > 0) if($totalKilledUnits > 0){
{ switch($type){
switch($type)
{
case 0: case 0:
if($totalKilledUnits < $totalUnits){ if($totalKilledUnits < $totalUnits){
$database->modifyEnforce($starvingTroops['id'], array_keys($killedUnits), array_values($killedUnits), 0); $database->modifyEnforce($starvingTroops['id'], array_keys($killedUnits), array_values($killedUnits), 0);
+72 -65
View File
@@ -8,7 +8,7 @@
## Filename Battle.php ## ## Filename Battle.php ##
## Developed by: Dzoki & Dixie ## ## Developed by: Dzoki & Dixie ##
## Fixed by: Shadow ## ## Fixed by: Shadow ##
## Thanks to: Akakori & Elmar ## ## Thanks to: Akakori, Elmar & Kirilloid ##
## Reworked and Fix by: ronix ## ## Reworked and Fix by: ronix ##
## Fixed by: InCube - double troops ## ## Fixed by: InCube - double troops ##
## License: TravianZ Project ## ## License: TravianZ Project ##
@@ -21,6 +21,21 @@
class Battle { class Battle {
/**
*
* @author Kirilloid --> https://github.com/kirilloid/travian/blob/master/src/model/base/combat.ts
* @var double The number of attacking catapults: 1 = 100%, 0 = 0%
*
*/
private $sigma;
public function __construct(){
$this->sigma = function($x) { return ($x > 1 ? 2 - $x ** -1.5 : $x ** 1.5) / 2; };
}
public function procSim($post) { public function procSim($post) {
global $form; global $form;
@@ -374,10 +389,10 @@ class Battle {
$abcount += 1; $abcount += 1;
// Points catapult the attacker // Points catapult the attacker
if(in_array($i,$catapult)) $catp += (int) $Attacker['u'.$i]; if(in_array($i, $catapult)) $catp += (int) $Attacker['u'.$i];
// Points of the Rams attacker // Points of the Rams attacker
if(in_array($i,$rams)) $ram += (int) $Attacker['u'.$i]; if(in_array($i, $rams)) $ram += (int) $Attacker['u'.$i];
$involve += (int) $Attacker['u'.$i]; $involve += (int) $Attacker['u'.$i];
$units['Att_unit'][$i] = (int) $Attacker['u'.$i]; $units['Att_unit'][$i] = (int) $Attacker['u'.$i];
@@ -459,7 +474,7 @@ class Battle {
$result['Defend_points'] = $rdp; $result['Defend_points'] = $rdp;
$winner = ($rap > $rdp); $winner = ($rap > $rdp);
// Formula for calculating the Moral // Formula for calculating the Morale bonus
// WW villages aren't affected by this bonus // WW villages aren't affected by this bonus
if($attpop > $defpop && !$isWWVillage) { if($attpop > $defpop && !$isWWVillage) {
$moralbonus = 1 / round(max(0.667, pow($defpop / $attpop, 0.2 * min(1, $rap / ($rdp > 0 ? $rdp : 1)))), 3); $moralbonus = 1 / round(max(0.667, pow($defpop / $attpop, 0.2 * min(1, $rap / ($rdp > 0 ? $rdp : 1)))), 3);
@@ -533,57 +548,54 @@ class Battle {
} }
$result['hero_fealthy'] = $fealthy; $result['hero_fealthy'] = $fealthy;
} }
$ram -= ($winner) ? round($ram * $result[1] / 100) : round($ram * $result[2] / 100); $ram -= ($winner) ? round($ram * $result[1] / 100) : round($ram * $result[2] / 100);
$catp -= ($winner) ? round($catp * $result[1] / 100) : round($catp * $result[2] / 100); $catp -= ($winner) ? round($catp * $result[1] / 100) : round($catp * $result[2] / 100);
} }
// Formula for the calculation of catapults needed
if($catp > 0 && $tblevel != 0) { if($catp > 0 && $tblevel != 0) {
//catapults upgrades //Catapults blacksmith upgrades
$upgrades = round(200 * pow(1.0205, $att_ab8) ) / 200; $upgrades = round(200 * pow(1.0205, $att_ab8)) / 200;
$wctp = pow(($rap / $rdp), 1.5); //Buildings durability
$wctp = ($wctp >= 1) ? 1 - 0.5 / $wctp : 0.5 * $wctp; $durability = ($stonemason > 0 ? $bid34[$stonemason]['attri'] / 100 : 1);
$wctp *= ($catp + $upgrades);
//Calculates the catapults morale bonus
//catapults downgrades $catpMoraleBonus = min(max(($attpop / ($defpop > 0 ? $defpop : 1)) ** 0.3, 1), 3);
$downgrades = ($stonemason > 0 ? $bid34[$stonemason]['attri'] / 100 : 1);
//New level of the building (only for warsim.php)
//catapults moral $catapultsDamage = $this->calculateCatapultsDamage($catp, $upgrades, $durability, $rap / $rdp, $strongerbuildings, $catpMoraleBonus);
$catpMoral = pow($attpop / ($defpop > 0 ? $defpop : 1) , 0.3); $result[3] = $this->calculateNewBuildingLevel($tblevel, $catapultsDamage);
// New level of the building (only for warsim.php)
$result[3] = $this->calculateNewBuildingLevel($catpMoral, $upgrades, $downgrades, $tblevel, $wctp, $catp, $strongerbuildings);
$result[4] = $tblevel; $result[4] = $tblevel;
// Results for Automation.php //Results for Automation.php
$result['catapults']['moral'] = $catpMoral;
$result['catapults']['upgrades'] = $upgrades; $result['catapults']['upgrades'] = $upgrades;
$result['catapults']['downgrades'] = $downgrades; $result['catapults']['durability'] = $durability;
$result['catapults']['realAttackers'] = $wctp; $result['catapults']['attackDefenseRatio'] = $rap / $rdp;
$result['catapults']['strongerBuildings'] = $strongerbuildings; $result['catapults']['strongerBuildings'] = $strongerbuildings;
$result['catapults']['moraleBonus'] = $catpMoraleBonus;
} }
if($ram > 0 && $walllevel != 0) { if($ram > 0 && $walllevel != 0) {
//Rams blacksmith upgrades
$upgrades = round(200 * pow(1.0205, $att_ab7)) / 200; $upgrades = round(200 * pow(1.0205, $att_ab7)) / 200;
$wctp = pow(($rap / $rdp), 1.5);
$wctp = ($wctp >= 1) ? 1 - 0.5 / $wctp : 0.5 * $wctp;
$wctp *= ($ram) + $upgrades;
$downgrades = ($stonemason > 0 ? $bid34[$stonemason]['attri'] / 100 : 1); //Building durability
$durability = ($stonemason > 0 ? $bid34[$stonemason]['attri'] / 100 : 1);
// New level of the building (only for warsim.php) // New level of the building (only for warsim.php)
$result[7] = $this->calculateNewBuildingLevel(1, $upgrades, $downgrades, $walllevel, $wctp, $ram, $strongerbuildings * 5); $ramsDamage = $this->calculateCatapultsDamage($ram, $upgrades, $durability, $rap / $rdp, $strongerbuildings, 1);
$result[7] = $this->calculateNewBuildingLevel($walllevel, $ramsDamage);
$result[8] = $walllevel; $result[8] = $walllevel;
// Results for Automation.php // Results for Automation.php
$result['rams']['moral'] = 1;
$result['rams']['upgrades'] = $upgrades; $result['rams']['upgrades'] = $upgrades;
$result['rams']['downgrades'] = $downgrades; $result['rams']['durability'] = $durability;
$result['rams']['realAttackers'] = $wctp; $result['rams']['attackDefenseRatio'] = $rap / $rdp;
$result['rams']['strongerBuildings'] = $strongerbuildings * 5; $result['rams']['strongerBuildings'] = $strongerbuildings;
$result['rams']['moraleBonus'] = 1;
} }
$result[6] = pow($rap / ($rdp * $moralbonus > 0 ? $rdp * $moralbonus : 1), $Mfactor); $result[6] = pow($rap / ($rdp * $moralbonus > 0 ? $rdp * $moralbonus : 1), $Mfactor);
@@ -608,7 +620,7 @@ class Battle {
if ($hero_health <= $damage_health || $damage_health > 90){ if ($hero_health <= $damage_health || $damage_health > 90){
//hero die //hero die
$result['casualties_attacker']['11'] = 1; $result['casualties_attacker'][11] = 1;
mysqli_query($database->dblink,"update " . TB_PREFIX . "hero set `dead` = 1, `health` = 0 where `heroid`=".(int) $hero_id); mysqli_query($database->dblink,"update " . TB_PREFIX . "hero set `dead` = 1, `health` = 0 where `heroid`=".(int) $hero_id);
}else{ }else{
mysqli_query($database->dblink,"update " . TB_PREFIX . "hero set `health`=`health`-".(int) $damage_health." where `heroid`=".(int) $hero_id); mysqli_query($database->dblink,"update " . TB_PREFIX . "hero set `health`=`health`-".(int) $damage_health." where `heroid`=".(int) $hero_id);
@@ -735,46 +747,41 @@ class Battle {
} }
/** /**
* Calculates the new building level, after catapults/rams have damaged it * @author Kirilloid --> https://github.com/kirilloid/travian/blob/master/src/model/base/combat.ts
* *
* @param float $moral The catapults/rams battle moral, 1 < moral < 3 => (Total attacker points / Total defender points)^3 * Calculates the new building level, after damaging it
* @param int $upgrades Upgrades of catapults/rams made in the blacksmith *
* @param int $downgrades Defender bonuses, such as the stonemason's lodge * @param int $oldLevel The old building level
* @param int $actualLevel The level of the building before the battle * @param float $damage The damage done by catapults
* @param int $realAttackers Effective catapults/rams involved in the building damage * @return int Returns the new building level
* @param int $totalAttackers Total catapults/rams sent in the attack
* @param int $strongerBuildings Indicates the defender artifacts bonus against catapults
* @return int Returns the new level of the damaged building
*/ */
public function CalculateNewBuildingLevel($moral, $upgrades, $downgrades, $actualLevel, $realAttackers, $totalAttackers, $strongerBuildings) public function calculateNewBuildingLevel($oldLevel, $damage){
{ $damage -= 0.5;
if($moral < 1) $moral = 1; if ($damage < 0) return $oldLevel;
elseif($moral > 3) $moral = 3;
while ($damage >= $oldLevel && $oldLevel) $damage -= $oldLevel--;
$needMax = round($this->CalculateNeededCatapults($moral, $upgrades / ($downgrades * $strongerBuildings), $actualLevel));
if($needMax <= $realAttackers) return 0; return $oldLevel;
for($i = $actualLevel - 1; $i >= 1; $i--)
{
$need = $this->CalculateNeededCatapults($moral, $upgrades / ($downgrades * $strongerBuildings), $i);
if(min($realAttackers, $totalAttackers) / ($needMax - $need) <= 1) return ++$i;
}
return $actualLevel;
} }
/** /**
* Calculate the needed catapults/rams to completely destroy a building/wall * @author Kirilloid --> https://github.com/kirilloid/travian/blob/master/src/model/base/combat.ts
* *
* @param float $moral The catapults/rams battle moral * Calculates the damage done by catapults
* @param int $upDown (Upgrades / Downgrades / Stronger buildings) ratio of catapults/rams *
* @param int $actualLevel The level of the building before the battle * @param int $catapultsQuantity The quantity of catapults which take part in the attack
* @return float Returns the needed catapults/rams to destroy a building/wall * @param double $catapultsUpgrade The catapults upgrade multiplier, affected by the cataputls level in the blacksmith
* @param double $durability The building durability, affected by the stonemason's lodge
* @param double $ADRatio The attack points / defensive points ratio
* @param double $strongerBuildings The artifacts multiplier, which strengthens the building, affected by durability artifacts
* @param double $moraleBonus The defender morale bonus
* @return double Returns the damage done by catapults
*/ */
public function CalculateNeededCatapults($moral, $upDown, $actualLevel) public function calculateCatapultsDamage($catapultsQuantity, $catapultsUpgrade, $durability, $ADRatio, $strongerBuildings, $moraleBonus){
{ $catapultsEfficiency = floor($catapultsQuantity / ($durability * $strongerBuildings));
return ($moral * (pow($actualLevel, 2) + $actualLevel + 1) / ($upDown == 0 ? 1 : 8 * $upDown)) + 0.5; return 4 * ($this->sigma)($ADRatio) * $catapultsEfficiency * $catapultsUpgrade / $moraleBonus;
} }
}; };
+55 -24
View File
@@ -808,11 +808,8 @@ class MYSQLi_DB implements IDbConnection {
$pairs[] = $this->escape($fieldName) . ' = ' . (Math::isInt($value[$index]) ? $value[$index] : '"'.$this->escape($value[$index]).'"'); $pairs[] = $this->escape($fieldName) . ' = ' . (Math::isInt($value[$index]) ? $value[$index] : '"'.$this->escape($value[$index]).'"');
} }
if(!$switch) { if(!$switch) $q = "UPDATE " . TB_PREFIX . "users SET ".implode(', ', $pairs)." where username = '$ref'";
$q = "UPDATE " . TB_PREFIX . "users SET ".implode(', ', $pairs)." where username = '$ref'"; else $q = "UPDATE " . TB_PREFIX . "users SET ".implode(', ', $pairs)." where id = " . (int) $ref;
} else {
$q = "UPDATE " . TB_PREFIX . "users SET ".implode(', ', $pairs)." where id = " . (int) $ref;
}
// update cached values // update cached values
if ($ret = mysqli_query($this->dblink,$q)) { if ($ret = mysqli_query($this->dblink,$q)) {
@@ -858,7 +855,9 @@ class MYSQLi_DB implements IDbConnection {
if(!is_array($coordinatesArray[0])) $coordinatesArray = [$coordinatesArray]; if(!is_array($coordinatesArray[0])) $coordinatesArray = [$coordinatesArray];
$conditions = []; $conditions = [];
foreach($coordinatesArray as $coordinate) $conditions[] = "(x = ".$coordinate[0]." AND y = ".$coordinate[1].")"; foreach($coordinatesArray as $coordinate){
$conditions[] = "(x = ".round($coordinate[0])." AND y = ".round($coordinate[1]).")";
}
$q = "SELECT id FROM " . TB_PREFIX . "wdata WHERE ".implode(" OR ", $conditions); $q = "SELECT id FROM " . TB_PREFIX . "wdata WHERE ".implode(" OR ", $conditions);
$result = mysqli_query($this->dblink, $q); $result = mysqli_query($this->dblink, $q);
@@ -1138,20 +1137,20 @@ class MYSQLi_DB implements IDbConnection {
function modifyGold($userid, $amt, $mode) { function modifyGold($userid, $amt, $mode) {
list($userid, $amt, $mode) = $this->escape_input((int) $userid, (int) $amt, $mode); list($userid, $amt, $mode) = $this->escape_input((int) $userid, (int) $amt, $mode);
if(!$mode) { if(!$mode) $q = "UPDATE " . TB_PREFIX . "users set gold = gold - $amt where id = $userid";
$q = "UPDATE " . TB_PREFIX . "users set gold = gold - $amt where id = $userid"; else $q = "UPDATE " . TB_PREFIX . "users set gold = gold + $amt where id = $userid";
} else {
$q = "UPDATE " . TB_PREFIX . "users set gold = gold + $amt where id = $userid";
}
return mysqli_query($this->dblink,$q); return mysqli_query($this->dblink,$q);
} }
/***************************************** /**
Function to retrieve user array via Username or ID * Retrieves the user array via Username or ID
Mode 0: Search by Username *
Mode 1: Search by ID * @param int $ref The user ID or the username
References: Alliance ID * @param int $mode 0 --> Search by username, 1 --> Search by user ID
*****************************************/ * @param bool $use_cache Will use the cache if true
* @return array Returns the user array
*/
function getUserArray($ref, $mode, $use_cache = true) { function getUserArray($ref, $mode, $use_cache = true) {
list($ref, $mode) = $this->escape_input($ref, $mode); list($ref, $mode) = $this->escape_input($ref, $mode);
@@ -1162,11 +1161,9 @@ class MYSQLi_DB implements IDbConnection {
return $cachedValue; return $cachedValue;
} }
if(!$mode) { if(!$mode) $q = "SELECT * FROM " . TB_PREFIX . "users where username = '$ref' LIMIT 1";
$q = "SELECT * FROM " . TB_PREFIX . "users where username = '$ref' LIMIT 1"; else $q = "SELECT * FROM " . TB_PREFIX . "users where id = " . (int) $ref . " LIMIT 1";
} else {
$q = "SELECT * FROM " . TB_PREFIX . "users where id = " . (int) $ref . " LIMIT 1";
}
$result = mysqli_query($this->dblink,$q); $result = mysqli_query($this->dblink,$q);
self::$fieldsCache[$ref.$mode] = mysqli_fetch_array($result); self::$fieldsCache[$ref.$mode] = mysqli_fetch_array($result);
@@ -7697,7 +7694,6 @@ References: User ID/Message ID, Mode
foreach($detailsArray as $field => $value) $values[] = $field."=".$value; foreach($detailsArray as $field => $value) $values[] = $field."=".$value;
$q = "UPDATE ".TB_PREFIX."artefacts SET ".implode(",", $values)." WHERE id = $id"; $q = "UPDATE ".TB_PREFIX."artefacts SET ".implode(",", $values)." WHERE id = $id";
echo $q;
return mysqli_query($this->dblink, $q); return mysqli_query($this->dblink, $q);
} }
@@ -7858,7 +7854,7 @@ References: User ID/Message ID, Mode
case 9: case 9:
case 10: case 10:
case 11: case 11:
$cropo ++; $cropo++;
break; break;
case 12: case 12:
$cropo += 2; $cropo += 2;
@@ -7883,6 +7879,41 @@ References: User ID/Message ID, Mode
return self::$cropProductionStarvationValueCache[$wref]; return self::$cropProductionStarvationValueCache[$wref];
} }
/**
* Adds the starvation data in villages with a negative value of crop
*
* @param int $wref The village ID where the crop is negative
*/
public function addStarvationData($wref){
global $technology;
$getVillage = $this->getVillage($wref);
//Exlude Support, Nature, Natars, TaskMaster and Multihunter
if ($getVillage['owner'] > 5){
$crop = $this->getCropProdstarv($wref, false);
$unitArrays = $technology->getAllUnits($wref, false, 0, false);
$villageUpkeep = $getVillage['pop'] + $technology->getUpkeep($unitArrays, 0, $wref);
$starv = $getVillage['starv'];
if ($crop < $villageUpkeep){
//Add starvation data
$fields = ['starv'];
$values = [$villageUpkeep];
//Update the starvupdate if it's set to 0
if($getVillage['starvupdate'] == 0) {
$fields[] = 'starvupdate';
$values[] = time();
}
//Update the starvation datas
$this->setVillageFields($wref, $fields, $values);
}
}
}
//general statistics //general statistics
function addGeneralAttack($casualties) { function addGeneralAttack($casualties) {
+1
View File
@@ -1031,6 +1031,7 @@ define("YOU_CONSTRUCT","You can construct ");
define("CRANNY_INCREASED","Cranny capacity is increased by"); define("CRANNY_INCREASED","Cranny capacity is increased by");
define("CRANNY_DECRESE","Cranny capacity is decrese by"); define("CRANNY_DECRESE","Cranny capacity is decrese by");
define("WW_BUILDING_PLAN","You can build the Wonder of the World"); define("WW_BUILDING_PLAN","You can build the Wonder of the World");
define("NO_WW","There are no Wonders of the World");
define("NO_PREVIOUS_OWNERS","There are no previous owners."); define("NO_PREVIOUS_OWNERS","There are no previous owners.");
define("TREASURY_DESC","The riches of your empire are kept in the treasury. The treasury has room for one treasure. After you have captured an artefact it takes 24 hours on a normal server or 12 hours on a thrice speed server to be effective."); define("TREASURY_DESC","The riches of your empire are kept in the treasury. The treasury has room for one treasure. After you have captured an artefact it takes 24 hours on a normal server or 12 hours on a thrice speed server to be effective.");
+26 -33
View File
@@ -11,7 +11,7 @@
class Ranking { class Ranking {
public $rankarray = array(); public $rankarray = [];
private $rlastupdate; private $rlastupdate;
public function getRank() { public function getRank() {
@@ -20,14 +20,15 @@
public function getUserRank($id) { public function getUserRank($id) {
global $database; global $database;
$ranking = $this->getRank(); $ranking = $this->getRank();
$users = "SELECT Count(*) as Total FROM " . TB_PREFIX . "users WHERE access < " . (INCLUDE_ADMIN ? "10" : "8"); $users = "SELECT Count(*) as Total FROM " . TB_PREFIX . "users WHERE access < " . (INCLUDE_ADMIN ? "10" : "8");
$users2 = mysqli_fetch_array(mysqli_query($database->dblink,$users), MYSQLI_ASSOC); $users2 = mysqli_fetch_array(mysqli_query($database->dblink,$users), MYSQLI_ASSOC);
$users2 = $users2['Total']; $users2 = $users2['Total'];
$users3 = $users2+1; $users3 = $users2 + 1;
$myrank = 0; $myrank = 0;
if(count($ranking) > 0) { if(count($ranking) > 0) {
for($i=0;$i<($users3);$i++) { for($i = 0;$i < $users3; $i++) {
if( isset( $ranking[$i]['userid'] ) ) { if( isset( $ranking[$i]['userid'] ) ) {
if($ranking[$i]['userid'] == $id && $ranking[$i] != "pad") { if($ranking[$i]['userid'] == $id && $ranking[$i] != "pad") {
$myrank = $i; $myrank = $i;
@@ -197,31 +198,25 @@
} }
public function searchRank($name, $field) { public function searchRank($name, $field) {
while(1) {
//$key = key($this->rankarray); while(1) {
for($key=0;$key<count($this->rankarray);$key++){ //$key = key($this->rankarray);
if($this->rankarray[$key]!="pad") { for($key = 0; $key < count($this->rankarray); $key++){
if($this->rankarray[$key][$field] == $name) { if($this->rankarray[$key]!="pad") {
return $key; if($this->rankarray[$key][$field] == $name) return $key;
break; }
} }
} if(!next($this->rankarray)) {
} if($field != "userid") return $name;
if(!next($this->rankarray)) { else return 0;
if($field != "userid"){ }
return $name;
break; }
}else{
return 0;
break;
}
}
}
} }
public function procRankArray() { public function procRankArray() {
global $multisort, $database; global $multisort, $database;
if($GLOBALS['db']->countUser() > 0){ if($GLOBALS['db']->countUser() > 0){
$holder = array(); $holder = array();
if(SHOW_NATARS == True){ if(SHOW_NATARS == True){
@@ -272,12 +267,10 @@
ORDER BY totalpop DESC, totalvillages DESC, userid DESC"; ORDER BY totalpop DESC, totalvillages DESC, userid DESC";
} }
$datas = array(); $datas = [];
$result = (mysqli_query($database->dblink,$q)); $result = (mysqli_query($database->dblink,$q));
while($row = mysqli_fetch_assoc($result)) { while($row = mysqli_fetch_assoc($result)) $datas[] = $row;
$datas[] = $row;
}
if (count($datas)) { if (count($datas)) {
foreach($datas as $result) { foreach($datas as $result) {
@@ -292,12 +285,12 @@
} }
} }
$newholder = array("pad"); $newholder = ["pad"];
foreach($holder as $key) { foreach($holder as $key) array_push($newholder, $key);
array_push($newholder, $key);
}
$this->rankarray = $newholder; $this->rankarray = $newholder;
}
}
} }
public function procRankRaceArray($race) { public function procRankRaceArray($race) {
+6 -6
View File
@@ -236,13 +236,13 @@ class Technology {
return $ownunit; return $ownunit;
} }
function getAllUnits($base, $InVillageOnly = false, $mode=0) { function getAllUnits($base, $InVillageOnly = false, $mode = 0, $useCache = true) {
global $database; global $database;
$ownunit = $database->getUnit($base); $ownunit = $database->getUnit($base, $useCache);
$ownunit['u99'] -= $ownunit['u99']; $ownunit['u99'] -= $ownunit['u99'];
$ownunit['u99o'] -= $ownunit['u99o']; $ownunit['u99o'] -= $ownunit['u99o'];
$enforcementarray = $database->getEnforceVillage($base, 0); $enforcementarray = $database->getEnforceVillage($base, 0, $useCache);
if(count($enforcementarray) > 0){ if(count($enforcementarray) > 0){
foreach($enforcementarray as $enforce){ foreach($enforcementarray as $enforce){
for($i = 1; $i <= 50; $i++){ for($i = 1; $i <= 50; $i++){
@@ -252,7 +252,7 @@ class Technology {
} }
} }
if($mode == 0){ if($mode == 0){
$enforceoasis = $database->getOasisEnforce($base, 0); $enforceoasis = $database->getOasisEnforce($base, 0, $useCache);
if(count($enforceoasis) > 0){ if(count($enforceoasis) > 0){
foreach($enforceoasis as $enforce){ foreach($enforceoasis as $enforce){
for($i = 1; $i <= 50; $i++){ for($i = 1; $i <= 50; $i++){
@@ -261,7 +261,7 @@ class Technology {
$ownunit['hero'] += $enforce['hero']; $ownunit['hero'] += $enforce['hero'];
} }
} }
$enforceoasis1 = $database->getOasisEnforce($base, 1); $enforceoasis1 = $database->getOasisEnforce($base, 1, $useCache);
if(count($enforceoasis1) > 0){ if(count($enforceoasis1) > 0){
foreach($enforceoasis1 as $enforce){ foreach($enforceoasis1 as $enforce){
for($i = 1; $i <= 50; $i++){ for($i = 1; $i <= 50; $i++){
@@ -271,7 +271,7 @@ class Technology {
} }
} }
$prisoners = $database->getPrisoners($base, 1); $prisoners = $database->getPrisoners($base, 1, $useCache);
if(!empty($prisoners)){ if(!empty($prisoners)){
foreach($prisoners as $prisoner){ foreach($prisoners as $prisoner){
$owner = $database->getVillageField($base, "owner"); $owner = $database->getVillageField($base, "owner");
+1
View File
@@ -224,6 +224,7 @@ class Units {
$to = $database->getVillage($enforce['from']); $to = $database->getVillage($enforce['from']);
$tribe = $database->getUserField($to['owner'], 'tribe', 0); $tribe = $database->getUserField($to['owner'], 'tribe', 0);
$start = ($tribe - 1) * 10 + 1;
$troopsTime = $this->getWalkingTroopsTime($enforce['from'], $enforce['vref'], $to['owner'], $tribe, $enforce, 1); $troopsTime = $this->getWalkingTroopsTime($enforce['from'], $enforce['vref'], $to['owner'], $tribe, $enforce, 1);
$time = $database->getArtifactsValueInfluence($from['owner'], $enforce['from'], 2, $troopsTime); $time = $database->getArtifactsValueInfluence($from['owner'], $enforce['from'], 2, $troopsTime);
+1
View File
@@ -61,6 +61,7 @@ or you have a feature request to be included in the play.
**Thanks** **Thanks**
A big thanks to [Kirilloid](https://github.com/kirilloid) who helped us a lot with the Battle System formulas.
Many thanks to all those who recently played around with the project and tested it both, locally and on their Many thanks to all those who recently played around with the project and tested it both, locally and on their
own servers. This includes [ZZJHONS](https://github.com/ZZJHONS), [DracoMilesX](https://github.com/DracoMilesX), own servers. This includes [ZZJHONS](https://github.com/ZZJHONS), [DracoMilesX](https://github.com/DracoMilesX),
[phaze1G](https://github.com/phaze1G) and many others who were too shy to let us know that they use and enjoy [phaze1G](https://github.com/phaze1G) and many others who were too shy to let us know that they use and enjoy
+2 -1
View File
@@ -4,7 +4,8 @@
$oasisarray = $database->getOasis($village->wid); $oasisarray = $database->getOasis($village->wid);
if(isset($_GET['gid']) && $_GET['gid'] == 37 && isset($_GET['del']) && $database->getOasisField($_GET['del'], 'owner') == $session->uid){ if(isset($_GET['gid']) && $_GET['gid'] == 37 && isset($_GET['del']) && $database->getOasisField($_GET['del'], 'owner') == $session->uid){
$database->removeOases($_GET['del']); $units->returnTroops($village->wid, 1);
$database->removeOases($_GET['del']);
header("Location: build.php?id=".$id."&land"); header("Location: build.php?id=".$id."&land");
exit; exit;
} }
+25 -29
View File
@@ -5,9 +5,7 @@ if(!is_numeric($_SESSION['search'])) {
<?php <?php
$search = 0; $search = 0;
} }
else { else $search = $_SESSION['search'];
$search = $_SESSION['search'];
}
?> ?>
<table cellpadding="1" cellspacing="1" id="alliance" class="row_table_data"> <table cellpadding="1" cellspacing="1" id="alliance" class="row_table_data">
<thead> <thead>
@@ -19,36 +17,34 @@ $search = $_SESSION['search'];
<tr><td></td><td>Alliance</td><td>Player</td><td>&Oslash;</td><td>Points</td></tr> <tr><td></td><td>Alliance</td><td>Player</td><td>&Oslash;</td><td>Points</td></tr>
</thead><tbody> </thead><tbody>
<?php <?php
$rankArray = $ranking->getRank();
if(isset($_GET['rank'])){ if(isset($_GET['rank'])){
$multiplier = 1; $multiplier = 1;
if(is_numeric($_GET['rank'])) { if(is_numeric($_GET['rank'])) {
if($_GET['rank'] > count($ranking->getRank())) { if($_GET['rank'] > count($rankArray)) {
$_GET['rank'] = count($ranking->getRank())-1; $_GET['rank'] = count($rankArray) - 1;
} }
while($_GET['rank'] > (20*$multiplier)) {
$multiplier +=1; while($_GET['rank'] > (20*$multiplier)) $multiplier++;
}
$start = 20*$multiplier-19; $start = 20 * $multiplier - 19;
} else { $start = ($_SESSION['start']+1); } }
} else { $start = ($_SESSION['start']+1); } else $start = ($_SESSION['start'] + 1);
if(count($ranking->getRank()) > 0) { }
$ranking = $ranking->getRank(); else $start = ($_SESSION['start'] + 1);
for($i=$start;$i<($start+20);$i++) {
if(isset($ranking[$i]['name']) && $ranking[$i] != "pad") { if(count($rankArray) > 1) {
if($i == $search) { for($i = $start; $i < $start + 20; $i++) {
echo "<tr class=\"hl\"><td class=\"ra fc\" >"; if(isset($rankArray[$i]['name']) && $rankArray[$i] != "pad") {
} if($i == $search) echo "<tr class=\"hl\"><td class=\"ra fc\" >";
else { else echo "<tr><td class=\"ra \" >";
echo "<tr><td class=\"ra \" >";
} echo $i.".</td><td class=\"al \" ><a href=\"allianz.php?aid=".$rankArray[$i]['id']."\">".$rankArray[$i]['tag']."</a></td><td class=\"pla \" >";
echo $i.".</td><td class=\"al \" ><a href=\"allianz.php?aid=".$ranking[$i]['id']."\">".$ranking[$i]['tag']."</a></td><td class=\"pla \" >"; echo $rankArray[$i]['players']."</td><td class=\"av \" >".$rankArray[$i]['avg']."</td><td class=\"po \">".$rankArray[$i]['totalpop']."</td></tr>";
echo $ranking[$i]['players']."</td><td class=\"av \" >".$ranking[$i]['avg']."</td><td class=\"po \">".$ranking[$i]['totalpop']."</td></tr>";
} }
} }
} }
else { else echo "<td class=\"none\" colspan=\"5\">No alliances found</td>";
echo "<td class=\"none\" colspan=\"5\">No alliance's found</td>";
}
?> ?>
</tbody> </tbody>
</table> </table>
+25 -29
View File
@@ -5,9 +5,7 @@ if(!is_numeric($_SESSION['search'])) {
<?php <?php
$search = 0; $search = 0;
} }
else { else $search = $_SESSION['search'];
$search = $_SESSION['search'];
}
?> ?>
<table cellpadding="1" cellspacing="1" id="alliance_off" class="row_table_data"> <table cellpadding="1" cellspacing="1" id="alliance_off" class="row_table_data">
<thead> <thead>
@@ -19,36 +17,34 @@ $search = $_SESSION['search'];
<tr><td></td><td>Alliance</td><td>Player</td><td>Points</td></tr> <tr><td></td><td>Alliance</td><td>Player</td><td>Points</td></tr>
</thead><tbody> </thead><tbody>
<?php <?php
$rankArray = $ranking->getRank();
if(isset($_GET['rank'])){ if(isset($_GET['rank'])){
$multiplier = 1; $multiplier = 1;
if(is_numeric($_GET['rank'])) { if(is_numeric($_GET['rank'])) {
if($_GET['rank'] > count($ranking->getRank())) { if($_GET['rank'] > count($rankArray)) {
$_GET['rank'] = count($ranking->getRank())-1; $_GET['rank'] = count($rankArray) - 1;
} }
while($_GET['rank'] > (20*$multiplier)) {
$multiplier +=1; while($_GET['rank'] > (20*$multiplier)) $multiplier++;
}
$start = 20*$multiplier-19; $start = 20 * $multiplier - 19;
} else { $start = ($_SESSION['start']+1); } }
} else { $start = ($_SESSION['start']+1); } else $start = ($_SESSION['start'] + 1);
if(count($ranking->getRank()) > 0) { }
$ranking = $ranking->getRank(); else $start = ($_SESSION['start'] + 1);
for($i=$start;$i<($start+20);$i++) {
if(isset($ranking[$i]['name']) && $ranking[$i] != "pad") { if(count($rankArray) > 1) {
if($i == $search) { for($i = $start; $i < $start + 20; $i++) {
echo "<tr class=\"hl\"><td class=\"ra fc\" >"; if(isset($rankArray[$i]['name']) && $rankArray[$i] != "pad") {
} if($i == $search) echo "<tr class=\"hl\"><td class=\"ra fc\" >";
else { else echo "<tr><td class=\"ra \" >";
echo "<tr><td class=\"ra \" >";
} echo $i.".</td><td class=\"al \" ><a href=\"allianz.php?aid=".$rankArray[$i]['id']."\">".$rankArray[$i]['tag']."</a></td><td class=\"pla \" >";
echo $i.".</td><td class=\"al \" ><a href=\"allianz.php?aid=".$ranking[$i]['id']."\">".$ranking[$i]['tag']."</a></td><td class=\"pla \" >"; echo $rankArray[$i]['players']."</td><td class=\"po \">".$rankArray[$i]['Aap']."</td></tr>";
echo $ranking[$i]['players']."</td><td class=\"po \">".$ranking[$i]['Aap']."</td></tr>";
} }
} }
} }
else { else echo "<td class=\"none\" colspan=\"5\">No alliances found</td>";
echo "<td class=\"none\" colspan=\"5\">No users found</td>";
}
?> ?>
</tbody> </tbody>
</table> </table>
+25 -29
View File
@@ -5,9 +5,7 @@ if(!is_numeric($_SESSION['search'])) {
<?php <?php
$search = 0; $search = 0;
} }
else { else $search = $_SESSION['search'];
$search = $_SESSION['search'];
}
?> ?>
<table cellpadding="1" cellspacing="1" id="alliance_def" class="row_table_data"> <table cellpadding="1" cellspacing="1" id="alliance_def" class="row_table_data">
<thead> <thead>
@@ -19,36 +17,34 @@ $search = $_SESSION['search'];
<tr><td></td><td>Alliance</td><td>Player</td><td>Points</td></tr> <tr><td></td><td>Alliance</td><td>Player</td><td>Points</td></tr>
</thead><tbody> </thead><tbody>
<?php <?php
$rankArray = $ranking->getRank();
if(isset($_GET['rank'])){ if(isset($_GET['rank'])){
$multiplier = 1; $multiplier = 1;
if(is_numeric($_GET['rank'])) { if(is_numeric($_GET['rank'])) {
if($_GET['rank'] > count($ranking->getRank())) { if($_GET['rank'] > count($rankArray)) {
$_GET['rank'] = count($ranking->getRank())-1; $_GET['rank'] = count($rankArray) - 1;
} }
while($_GET['rank'] > (20*$multiplier)) {
$multiplier +=1; while($_GET['rank'] > (20*$multiplier)) $multiplier++;
}
$start = 20*$multiplier-19; $start = 20 * $multiplier - 19;
} else { $start = ($_SESSION['start']+1); } }
} else { $start = ($_SESSION['start']+1); } else $start = ($_SESSION['start'] + 1);
if(count($ranking->getRank()) > 0) { }
$ranking = $ranking->getRank(); else $start = ($_SESSION['start'] + 1);
for($i=$start;$i<($start+20);$i++) {
if(isset($ranking[$i]['name']) && $ranking[$i] != "pad") { if(count($rankArray) > 1) {
if($i == $search) { for($i = $start; $i < $start + 20; $i++) {
echo "<tr class=\"hl\"><td class=\"ra fc\" >"; if(isset($rankArray[$i]['name']) && $rankArray[$i] != "pad") {
} if($i == $search) echo "<tr class=\"hl\"><td class=\"ra fc\" >";
else { else echo "<tr><td class=\"ra \" >";
echo "<tr><td class=\"ra \" >";
} echo $i.".</td><td class=\"al \" ><a href=\"allianz.php?aid=".$rankArray[$i]['id']."\">".$rankArray[$i]['tag']."</a></td><td class=\"pla \" >";
echo $i.".</td><td class=\"al \" ><a href=\"allianz.php?aid=".$ranking[$i]['id']."\">".$ranking[$i]['tag']."</a></td><td class=\"pla \" >"; echo $rankArray[$i]['players']."</td><td class=\"po \">".$rankArray[$i]['Adp']."</td></tr>";
echo $ranking[$i]['players']."</td><td class=\"po \">".$ranking[$i]['Adp']."</td></tr>";
} }
} }
} }
else { else echo "<td class=\"none\" colspan=\"5\">No alliances found</td>";
echo "<td class=\"none\" colspan=\"5\">No users found</td>";
}
?> ?>
</tbody> </tbody>
</table> </table>
+1 -1
View File
@@ -12,7 +12,7 @@
$tribe1 = mysqli_fetch_array(mysqli_query($database->dblink,"SELECT Count(*) as Total FROM ".TB_PREFIX."users WHERE tribe = 1"), MYSQLI_ASSOC); $tribe1 = mysqli_fetch_array(mysqli_query($database->dblink,"SELECT Count(*) as Total FROM ".TB_PREFIX."users WHERE tribe = 1"), MYSQLI_ASSOC);
$tribe2 = mysqli_fetch_array(mysqli_query($database->dblink,"SELECT Count(*) as Total FROM ".TB_PREFIX."users WHERE tribe = 2"), MYSQLI_ASSOC); $tribe2 = mysqli_fetch_array(mysqli_query($database->dblink,"SELECT Count(*) as Total FROM ".TB_PREFIX."users WHERE tribe = 2"), MYSQLI_ASSOC);
$tribe3 = mysqli_fetch_array(mysqli_query($database->dblink,"SELECT Count(*) as Total FROM ".TB_PREFIX."users WHERE tribe = 3"), MYSQLI_ASSOC); $tribe3 = mysqli_fetch_array(mysqli_query($database->dblink,"SELECT Count(*) as Total FROM ".TB_PREFIX."users WHERE tribe = 3"), MYSQLI_ASSOC);
$tribes = array($tribe1['Total'], $tribe2['Total'], $tribe3['Total']); $tribes = [$tribe1['Total'], $tribe2['Total'], $tribe3['Total']];
$users = mysqli_fetch_array(mysqli_query($database->dblink,"SELECT Count(*) as Total FROM " . TB_PREFIX . "users WHERE tribe > 0 AND tribe < 4"), MYSQLI_ASSOC); $users = mysqli_fetch_array(mysqli_query($database->dblink,"SELECT Count(*) as Total FROM " . TB_PREFIX . "users WHERE tribe > 0 AND tribe < 4"), MYSQLI_ASSOC);
$users = $users['Total']; $users = $users['Total'];
?> ?>
+26 -30
View File
@@ -26,44 +26,40 @@
<tr><td></td><td>Hero</td><td>Player</td><td>Level</td><td>Experience</td></tr> <tr><td></td><td>Hero</td><td>Player</td><td>Level</td><td>Experience</td></tr>
</thead><tbody> </thead><tbody>
<?php <?php
if(isset($_GET['rank'])) { $rankArray = $ranking->getRank();
$multiplier = 1; if(isset($_GET['rank'])){
if(is_numeric($_GET['rank'])) { $multiplier = 1;
if($_GET['rank'] > count($ranking->getRank())) { if(is_numeric($_GET['rank'])) {
$_GET['rank'] = count($ranking->getRank()) - 1; if($_GET['rank'] > count($rankArray)) {
} $_GET['rank'] = count($rankArray) - 1;
while($_GET['rank'] > (20 * $multiplier)) { }
$multiplier += 1;
} while($_GET['rank'] > (20 * $multiplier)) $multiplier++;
$start = 20 * $multiplier - 19;
} else { $start = 20 * $multiplier - 19;
$start = ($_SESSION['start'] + 1); }
} else $start = ($_SESSION['start'] + 1);
} else {
$start = ($_SESSION['start'] + 1);
} }
if(count($ranking->getRank()) > 0) { else $start = ($_SESSION['start'] + 1);
$ranking = $ranking->getRank();
for($i = $start; $i < ($start + 20); $i++) { if(count($rankArray) > 1) {
if(isset($ranking[$i]['name']) && $ranking[$i] != "pad") { for($i = $start; $i < $start + 20; $i++) {
if($i == $search) { if(isset($rankArray[$i]['name']) && $rankArray[$i] != "pad") {
echo "<tr class=\"hl \"><td class=\"ra fc\" >"; if($i == $search) echo "<tr class=\"hl \"><td class=\"ra fc\" >";
} else { else echo "<tr><td class=\"ra \" >";
echo "<tr><td class=\"ra \" >";
}
echo $i . ".</td> echo $i . ".</td>
<td class=\"hero \"> <td class=\"hero \">
<img class=\"unit u" . $ranking[$i]['unit'] . "\" alt=\"\" title=\"\" src=\"img/x.gif\"> " . $ranking[$i]['name'] . "</td> <img class=\"unit u" . $rankArray[$i]['unit'] . "\" alt=\"\" title=\"\" src=\"img/x.gif\"> " . $rankArray[$i]['name'] . "</td>
<td class=\"pla \"><center><a href=\"spieler.php?uid=" . $ranking[$i]['uid'] . "\">" . $ranking[$i]['owner'] . "</a></center></td> <td class=\"pla \"><center><a href=\"spieler.php?uid=" . $rankArray[$i]['uid'] . "\">" . $rankArray[$i]['owner'] . "</a></center></td>
<td class=\"lev \">" . $ranking[$i]['level'] . "</td> <td class=\"lev \">" . $rankArray[$i]['level'] . "</td>
<td class=\"xp \">" . $ranking[$i]['experience'] . "</td> <td class=\"xp \">" . $rankArray[$i]['experience'] . "</td>
</tr> </tr>
"; ";
} }
} }
} else {
echo "<td class=\"none\" colspan=\"5\">No heros found</td>";
} }
else echo "<td class=\"none\" colspan=\"5\">No heros found</td>";
?> ?>
</tbody> </tbody>
+30 -35
View File
@@ -19,48 +19,43 @@ $search = $_SESSION['search'];
<tr><td></td><td>Player</td><td>Alliance</td><td>Population</td><td>Villages</td></tr> <tr><td></td><td>Player</td><td>Alliance</td><td>Population</td><td>Villages</td></tr>
</thead><tbody> </thead><tbody>
<?php <?php
$rankArray = $ranking->getRank();
if(isset($_GET['rank'])){ if(isset($_GET['rank'])){
$multiplier = 1; $multiplier = 1;
if(is_numeric($_GET['rank'])) { if(is_numeric($_GET['rank'])) {
if($_GET['rank'] > count($ranking->getRank())) { if($_GET['rank'] > count($rankArray)) {
$_GET['rank'] = count($ranking->getRank())-1; $_GET['rank'] = count($rankArray) - 1;
} }
while($_GET['rank'] > (20*$multiplier)) { while($_GET['rank'] > (20 * $multiplier)) $multiplier++;
$multiplier +=1;
} $start = 20 * $multiplier - 19;
$start = 20*$multiplier-19; }
} else { $start = ($_SESSION['start']+1); } else $start = ($_SESSION['start'] + 1);
} else { $start = ($_SESSION['start']+1); } }
if(count($ranking->getRank()) > 0) { else $start = ($_SESSION['start'] + 1);
$ranking = $ranking->getRank();
for($i=$start;$i<($start+20);$i++) { if(count($rankArray) > 1) {
if(isset($ranking[$i]['username']) && $ranking[$i] != "pad") { for($i = $start; $i < $start + 20; $i++) {
if($i == $search) { if(isset($rankArray[$i]['username']) && $rankArray[$i] != "pad") {
echo "<tr class=\"hl\"><td class=\"ra fc\" >"; if($i == $search) echo "<tr class=\"hl\"><td class=\"ra fc\" >";
} else echo "<tr><td class=\"ra \" >";
else {
echo "<tr><td class=\"ra \" >";
}
echo $i.".</td><td class=\"pla \" >"; echo $i.".</td><td class=\"pla \" >";
if(isset($ranking[$i]['access']) && $ranking[$i]['access'] > 2){ if(isset($rankArray[$i]['access']) && $rankArray[$i]['access'] > 2){
echo"<u><a href=\"spieler.php?uid=".$ranking[$i]['userid']."\">".$ranking[$i]['username']."</a></u>"; echo"<u><a href=\"spieler.php?uid=".$rankArray[$i]['userid']."\">".$rankArray[$i]['username']."</a></u>";
} else { } else {
echo"<a href=\"spieler.php?uid=".$ranking[$i]['userid']."\">".$ranking[$i]['username']."</a>"; echo"<a href=\"spieler.php?uid=".$rankArray[$i]['userid']."\">".$rankArray[$i]['username']."</a>";
}
echo"</td><td class=\"al\" >";
if($ranking[$i]['aname'] != "") {
echo "<a href=\"allianz.php?aid=".$ranking[$i]['alliance']."\">".$ranking[$i]['aname']."</a>";
} }
else { echo"</td><td class=\"al\" >";
echo "-"; if($rankArray[$i]['aname'] != "") {
echo "<a href=\"allianz.php?aid=".$rankArray[$i]['alliance']."\">".$rankArray[$i]['aname']."</a>";
} }
echo "</td><td class=\"pop\" >".$ranking[$i]['totalpop']."</td><td class=\"vil\">".$ranking[$i]['totalvillage']."</td></tr>"; else echo "-";
echo "</td><td class=\"pop\" >".$rankArray[$i]['totalpop']."</td><td class=\"vil\">".$rankArray[$i]['totalvillage']."</td></tr>";
} }
} }
} }
else { else echo "<td class=\"none\" colspan=\"5\">No users found</td>";
echo "<td class=\"none\" colspan=\"5\">No users found</td>";
}
?> ?>
</tbody> </tbody>
</table> </table>
+28 -32
View File
@@ -19,48 +19,44 @@ $search = $_SESSION['search'];
<tr><td></td><td>Player</td><td>Alliance</td><td>Population</td><td>Villages</td></tr> <tr><td></td><td>Player</td><td>Alliance</td><td>Population</td><td>Villages</td></tr>
</thead><tbody> </thead><tbody>
<?php <?php
$rankArray = $ranking->getRank();
if(isset($_GET['rank'])){ if(isset($_GET['rank'])){
$multiplier = 1; $multiplier = 1;
if(is_numeric($_GET['rank'])) { if(is_numeric($_GET['rank'])) {
if($_GET['rank'] > count($ranking->getRank())) { if($_GET['rank'] > count($rankArray)) {
$_GET['rank'] = count($ranking->getRank())-1; $_GET['rank'] = count($rankArray) - 1;
} }
while($_GET['rank'] > (20*$multiplier)) { while($_GET['rank'] > (20 * $multiplier)) $multiplier++;
$multiplier +=1;
} $start = 20 * $multiplier - 19;
$start = 20*$multiplier-19; }
} else { $start = ($_SESSION['start']+1); } else $start = ($_SESSION['start'] + 1);
} else { $start = ($_SESSION['start']+1); } }
else $start = ($_SESSION['start'] + 1);
if(count($database->getUserByTribe(1)) > 0) { if(count($database->getUserByTribe(1)) > 0) {
$ranking = $ranking->getRank(); for($i = $start; $i< $start + 20; $i++) {
for($i=$start;$i<($start+20);$i++) { if(isset($rankArray[$i]['username']) && $rankArray[$i] != "pad") {
if(isset($ranking[$i]['username']) && $ranking[$i] != "pad") { if($i == $search) echo "<tr class=\"hl\"><td class=\"ra fc\" >";
if($i == $search) { else echo "<tr><td class=\"ra \" >";
echo "<tr class=\"hl\"><td class=\"ra fc\" >";
}
else {
echo "<tr><td class=\"ra \" >";
}
echo $i.".</td><td class=\"pla \" >"; echo $i.".</td><td class=\"pla \" >";
if(isset($ranking[$i]['access']) && $ranking[$i]['access'] > 2){ if(isset($rankArray[$i]['access']) && $rankArray[$i]['access'] > 2){
echo"<u><a href=\"spieler.php?uid=".$ranking[$i]['userid']."\">".$ranking[$i]['username']."</a></u>"; echo"<u><a href=\"spieler.php?uid=".$rankArray[$i]['userid']."\">".$rankArray[$i]['username']."</a></u>";
} else { } else {
echo"<a href=\"spieler.php?uid=".$ranking[$i]['userid']."\">".$ranking[$i]['username']."</a>"; echo"<a href=\"spieler.php?uid=".$rankArray[$i]['userid']."\">".$rankArray[$i]['username']."</a>";
} }
echo"</td><td class=\"al\" >"; echo"</td><td class=\"al\" >";
if($ranking[$i]['alliance'] != 0) { if($rankArray[$i]['alliance'] > 0) {
echo "<a href=\"allianz.php?aid=".$ranking[$i]['alliance']."\">".$ranking[$i]['aname']."</a>"; echo "<a href=\"allianz.php?aid=".$rankArray[$i]['alliance']."\">".$rankArray[$i]['aname']."</a>";
} }
else { else echo "-";
echo "-";
} echo "</td><td class=\"pop\" >".$rankArray[$i]['totalpop']."</td><td class=\"vil\">".$rankArray[$i]['totalvillage']."</td></tr>";
echo "</td><td class=\"pop\" >".$ranking[$i]['totalpop']."</td><td class=\"vil\">".$ranking[$i]['totalvillage']."</td></tr>";
} }
} }
} }
else { else echo "<td class=\"none\" colspan=\"5\">No users found</td>";
echo "<td class=\"none\" colspan=\"5\">No users found</td>";
}
?> ?>
</tbody> </tbody>
</table> </table>
+30 -34
View File
@@ -19,48 +19,44 @@ $search = $_SESSION['search'];
<tr><td></td><td>Player</td><td>Alliance</td><td>Population</td><td>Villages</td></tr> <tr><td></td><td>Player</td><td>Alliance</td><td>Population</td><td>Villages</td></tr>
</thead><tbody> </thead><tbody>
<?php <?php
$rankArray = $ranking->getRank();
if(isset($_GET['rank'])){ if(isset($_GET['rank'])){
$multiplier = 1; $multiplier = 1;
if(is_numeric($_GET['rank'])) { if(is_numeric($_GET['rank'])) {
if($_GET['rank'] > count($ranking->getRank())) { if($_GET['rank'] > count($rankArray)) {
$_GET['rank'] = count($ranking->getRank())-1; $_GET['rank'] = count($rankArray) - 1;
} }
while($_GET['rank'] > (20*$multiplier)) { while($_GET['rank'] > (20 * $multiplier)) $multiplier++;
$multiplier +=1;
} $start = 20 * $multiplier - 19;
$start = 20*$multiplier-19; }
} else { $start = ($_SESSION['start']+1); } else $start = ($_SESSION['start'] + 1);
} else { $start = ($_SESSION['start']+1); } }
else $start = ($_SESSION['start'] + 1);
if(count($database->getUserByTribe(2)) > 0) { if(count($database->getUserByTribe(2)) > 0) {
$ranking = $ranking->getRank(); for($i = $start; $i< $start + 20; $i++) {
for($i=$start;$i<($start+20);$i++) { if(isset($rankArray[$i]['username']) && $rankArray[$i] != "pad") {
if(isset($ranking[$i]['username']) && $ranking[$i] != "pad") { if($i == $search) echo "<tr class=\"hl\"><td class=\"ra fc\" >";
if($i == $search) { else echo "<tr><td class=\"ra \" >";
echo "<tr class=\"hl\"><td class=\"ra fc\" >";
}
else {
echo "<tr><td class=\"ra \" >";
}
echo $i.".</td><td class=\"pla \" >"; echo $i.".</td><td class=\"pla \" >";
if($ranking[$i]['access'] > 2){ if(isset($rankArray[$i]['access']) && $rankArray[$i]['access'] > 2){
echo"<u><a href=\"spieler.php?uid=".$ranking[$i]['userid']."\">".$ranking[$i]['username']."</a></u>"; echo"<u><a href=\"spieler.php?uid=".$rankArray[$i]['userid']."\">".$rankArray[$i]['username']."</a></u>";
} else { } else {
echo"<a href=\"spieler.php?uid=".$ranking[$i]['userid']."\">".$ranking[$i]['username']."</a>"; echo"<a href=\"spieler.php?uid=".$rankArray[$i]['userid']."\">".$rankArray[$i]['username']."</a>";
}
echo"</td><td class=\"al\" >";
if($ranking[$i]['alliance'] != 0) {
echo "<a href=\"allianz.php?aid=".$ranking[$i]['alliance']."\">".$ranking[$i]['aname']."</a>";
} }
else { echo"</td><td class=\"al\" >";
echo "-"; if($rankArray[$i]['alliance'] > 0) {
echo "<a href=\"allianz.php?aid=".$rankArray[$i]['alliance']."\">".$rankArray[$i]['aname']."</a>";
} }
echo "</td><td class=\"pop\" >".$ranking[$i]['totalpop']."</td><td class=\"vil\">".$ranking[$i]['totalvillage']."</td></tr>"; else echo "-";
echo "</td><td class=\"pop\" >".$rankArray[$i]['totalpop']."</td><td class=\"vil\">".$rankArray[$i]['totalvillage']."</td></tr>";
} }
} }
} }
else { else echo "<td class=\"none\" colspan=\"5\">No users found</td>";
echo "<td class=\"none\" colspan=\"5\">No users found</td>";
}
?> ?>
</tbody> </tbody>
</table> </table>
+30 -34
View File
@@ -19,48 +19,44 @@ $search = $_SESSION['search'];
<tr><td></td><td>Player</td><td>Alliance</td><td>Population</td><td>Villages</td></tr> <tr><td></td><td>Player</td><td>Alliance</td><td>Population</td><td>Villages</td></tr>
</thead><tbody> </thead><tbody>
<?php <?php
$rankArray = $ranking->getRank();
if(isset($_GET['rank'])){ if(isset($_GET['rank'])){
$multiplier = 1; $multiplier = 1;
if(is_numeric($_GET['rank'])) { if(is_numeric($_GET['rank'])) {
if($_GET['rank'] > count($ranking->getRank())) { if($_GET['rank'] > count($rankArray)) {
$_GET['rank'] = count($ranking->getRank())-1; $_GET['rank'] = count($rankArray) - 1;
} }
while($_GET['rank'] > (20*$multiplier)) { while($_GET['rank'] > (20 * $multiplier)) $multiplier++;
$multiplier +=1;
} $start = 20 * $multiplier - 19;
$start = 20*$multiplier-19; }
} else { $start = ($_SESSION['start']+1); } else $start = ($_SESSION['start'] + 1);
} else { $start = ($_SESSION['start']+1); } }
else $start = ($_SESSION['start'] + 1);
if(count($database->getUserByTribe(3)) > 0) { if(count($database->getUserByTribe(3)) > 0) {
$ranking = $ranking->getRank(); for($i = $start; $i< $start + 20; $i++) {
for($i=$start;$i<($start+20);$i++) { if(isset($rankArray[$i]['username']) && $rankArray[$i] != "pad") {
if(isset($ranking[$i]['username']) && $ranking[$i] != "pad") { if($i == $search) echo "<tr class=\"hl\"><td class=\"ra fc\" >";
if($i == $search) { else echo "<tr><td class=\"ra \" >";
echo "<tr class=\"hl\"><td class=\"ra fc\" >";
}
else {
echo "<tr><td class=\"ra \" >";
}
echo $i.".</td><td class=\"pla \" >"; echo $i.".</td><td class=\"pla \" >";
if($ranking[$i]['access'] > 2){ if(isset($rankArray[$i]['access']) && $rankArray[$i]['access'] > 2){
echo"<u><a href=\"spieler.php?uid=".$ranking[$i]['userid']."\">".$ranking[$i]['username']."</a></u>"; echo"<u><a href=\"spieler.php?uid=".$rankArray[$i]['userid']."\">".$rankArray[$i]['username']."</a></u>";
} else { } else {
echo"<a href=\"spieler.php?uid=".$ranking[$i]['userid']."\">".$ranking[$i]['username']."</a>"; echo"<a href=\"spieler.php?uid=".$rankArray[$i]['userid']."\">".$rankArray[$i]['username']."</a>";
}
echo"</td><td class=\"al\" >";
if($ranking[$i]['alliance'] != 0) {
echo "<a href=\"allianz.php?aid=".$ranking[$i]['alliance']."\">".$ranking[$i]['aname']."</a>";
} }
else { echo"</td><td class=\"al\" >";
echo "-"; if($rankArray[$i]['alliance'] > 0) {
echo "<a href=\"allianz.php?aid=".$rankArray[$i]['alliance']."\">".$rankArray[$i]['aname']."</a>";
} }
echo "</td><td class=\"pop\" >".$ranking[$i]['totalpop']."</td><td class=\"vil\">".$ranking[$i]['totalvillage']."</td></tr>"; else echo "-";
echo "</td><td class=\"pop\" >".$rankArray[$i]['totalpop']."</td><td class=\"vil\">".$rankArray[$i]['totalvillage']."</td></tr>";
} }
} }
} }
else { else echo "<td class=\"none\" colspan=\"5\">No users found</td>";
echo "<td class=\"none\" colspan=\"5\">No users found</td>";
}
?> ?>
</tbody> </tbody>
</table> </table>
+31 -32
View File
@@ -19,43 +19,42 @@ $search = $_SESSION['search'];
<tr><td></td><td>Player</td><td>Population</td><td>Villages</td><td>Points</td></tr> <tr><td></td><td>Player</td><td>Population</td><td>Villages</td><td>Points</td></tr>
</thead><tbody> </thead><tbody>
<?php <?php
$rankArray = $ranking->getRank();
if(isset($_GET['rank'])){ if(isset($_GET['rank'])){
$multiplier = 1; $multiplier = 1;
if(is_numeric($_GET['rank'])) { if(is_numeric($_GET['rank'])) {
if($_GET['rank'] > count($ranking->getRank())) { if($_GET['rank'] > count($rankArray)) {
$_GET['rank'] = count($ranking->getRank())-1; $_GET['rank'] = count($rankArray) - 1;
} }
while($_GET['rank'] > (20*$multiplier)) { while($_GET['rank'] > (20 * $multiplier)) $multiplier++;
$multiplier +=1;
} $start = 20 * $multiplier - 19;
$start = 20*$multiplier-19; }
} else { $start = ($_SESSION['start']+1); } else $start = ($_SESSION['start'] + 1);
} else { $start = ($_SESSION['start']+1); } }
if(count($ranking->getRank()) > 0) { else $start = ($_SESSION['start'] + 1);
$ranking = $ranking->getRank();
for($i=$start;$i<($start+20);$i++) { if(count($rankArray) > 1) {
if(isset($ranking[$i]['username']) && $ranking[$i] != "pad") { for($i = $start; $i < $start + 20; $i++) {
if($i == $search){ if(isset($rankArray[$i]['username']) && $rankArray[$i] != "pad") {
echo "<tr class=\"hl\"><td class=\"ra fc\" >"; if($i == $search) echo "<tr class=\"hl\"><td class=\"ra fc\" >";
} else echo "<tr><td class=\"ra \" >";
else {
echo "<tr><td class=\"ra \" >";
}
echo $i.".</td><td class=\"pla \" >"; echo $i.".</td><td class=\"pla \" >";
if($ranking[$i]['access'] > 2){ if($rankArray[$i]['access'] > 2){
echo"<u><a href=\"spieler.php?uid=".$ranking[$i]['id']."\">".$ranking[$i]['username']."</a></u>"; echo"<u><a href=\"spieler.php?uid=".$rankArray[$i]['id']."\">".$rankArray[$i]['username']."</a></u>";
} else { } else {
echo"<a href=\"spieler.php?uid=".$ranking[$i]['id']."\">".$ranking[$i]['username']."</a>"; echo"<a href=\"spieler.php?uid=".$rankArray[$i]['id']."\">".$rankArray[$i]['username']."</a>";
} }
echo"</td><td class=\"pop \" >".$ranking[$i]['totalpop'].""; echo"</td><td class=\"pop \" >".$rankArray[$i]['totalpop']."";
echo "</td><td class=\"vil\">".$ranking[$i]['totalvillages']."</td><td class=\"po \" >".$ranking[$i]['apall']."</td></tr>"; echo "</td><td class=\"vil\">".$rankArray[$i]['totalvillages']."</td><td class=\"po \" >".$rankArray[$i]['apall']."</td></tr>";
} }
} }
} }
else { else echo "<td class=\"none\" colspan=\"5\">No users found</td>";
echo "<td class=\"none\" colspan=\"5\">No users found</td>";
}
?> ?>
<?php </tbody>
</table>
<?php
include("ranksearch.tpl"); include("ranksearch.tpl");
?> ?>
+28 -31
View File
@@ -19,42 +19,39 @@ $search = $_SESSION['search'];
<tr><td></td><td>Player</td><td>Population</td><td>Villages</td><td>Points</td></tr> <tr><td></td><td>Player</td><td>Population</td><td>Villages</td><td>Points</td></tr>
</thead><tbody> </thead><tbody>
<?php <?php
$rankArray = $ranking->getRank();
if(isset($_GET['rank'])){ if(isset($_GET['rank'])){
$multiplier = 1; $multiplier = 1;
if(is_numeric($_GET['rank'])) { if(is_numeric($_GET['rank'])) {
if($_GET['rank'] > count($ranking->getRank())) { if($_GET['rank'] > count($rankArray)) {
$_GET['rank'] = count($ranking->getRank())-1; $_GET['rank'] = count($rankArray) - 1;
} }
while($_GET['rank'] > (20*$multiplier)) { while($_GET['rank'] > (20 * $multiplier)) $multiplier++;
$multiplier +=1;
} $start = 20 * $multiplier - 19;
$start = 20*$multiplier-19; }
} else { $start = ($_SESSION['start']+1); } else $start = ($_SESSION['start'] + 1);
} else { $start = ($_SESSION['start']+1); } }
if(count($ranking->getRank()) > 0) { else $start = ($_SESSION['start'] + 1);
$ranking = $ranking->getRank();
for($i=$start;$i<($start+20);$i++) { if(count($rankArray) > 1) {
if(isset($ranking[$i]['username']) && $ranking[$i] != "pad") { for($i = $start; $i < $start + 20; $i++) {
if($i == $search){ if(isset($rankArray[$i]['username']) && $rankArray[$i] != "pad") {
echo "<tr class=\"hl\"><td class=\"ra fc\" >"; if($i == $search) echo "<tr class=\"hl\"><td class=\"ra fc\" >";
} else echo "<tr><td class=\"ra \" >";
else {
echo "<tr><td class=\"ra \" >";
}
echo $i.".</td><td class=\"pla \" >"; echo $i.".</td><td class=\"pla \" >";
if($ranking[$i]['access'] > 2){ if($rankArray[$i]['access'] > 2){
echo"<u><a href=\"spieler.php?uid=".$ranking[$i]['id']."\">".$ranking[$i]['username']."</a></u>"; echo"<u><a href=\"spieler.php?uid=".$rankArray[$i]['id']."\">".$rankArray[$i]['username']."</a></u>";
} else { } else {
echo"<a href=\"spieler.php?uid=".$ranking[$i]['id']."\">".$ranking[$i]['username']."</a>"; echo"<a href=\"spieler.php?uid=".$rankArray[$i]['id']."\">".$rankArray[$i]['username']."</a>";
} }
echo"</td><td class=\"pop \" >".$ranking[$i]['totalpop']; echo"</td><td class=\"pop \" >".$rankArray[$i]['totalpop']."";
echo "</td><td class=\"vil\">".$ranking[$i]['totalvillages']."</td><td class=\"po \" >".$ranking[$i]['dpall']."</td></tr>"; echo "</td><td class=\"vil\">".$rankArray[$i]['totalvillages']."</td><td class=\"po \" >".$rankArray[$i]['dpall']."</td></tr>";
} }
} }
} }
else { else echo "<td class=\"none\" colspan=\"5\">No users found</td>";
echo "<td class=\"none\" colspan=\"5\">No users found</td>";
}
?> ?>
</tbody> </tbody>
</table> </table>
+9 -12
View File
@@ -15,16 +15,13 @@ if(!isset($_GET['id'])){ $_GET['id']='1'; }
</form> </form>
<div class="navi"> <div class="navi">
<?php <?php
if($start != 1 && $start+20 < count($ranking)) { if(count($rankArray) < 22){
echo "<a href=\"statistiken.php?id=".$_GET['id']."&amp;rank=".($start-20)."\">&laquo; back</a> | <a href=\"statistiken.php?id=".$_GET['id']."&amp;rank=".($start+20)."\">forward &raquo;</a>"; echo "&laquo; back | forward &raquo;";
}else if($start != 1 && $start + 20 < count($rankArray)) {
echo "<a href=\"statistiken.php?id=".$_GET['id']."&amp;rank=".($start - 20)."\">&laquo; back</a> | <a href=\"statistiken.php?id=".$_GET['id']."&amp;rank=".($start + 20)."\">forward &raquo;</a>";
}else if($start == 1 && $start + 20 < count($rankArray)) {
echo "&laquo; back | <a href=\"statistiken.php?id=".$_GET['id']."&amp;rank=".($start + 20)."\">forward &raquo;</a>";
}else if($start != 1 && $start - 20 < count($rankArray)) {
echo "<a href=\"statistiken.php?id=".$_GET['id']."&amp;rank=".($start - 20)."\">&laquo; back</a> | forward &raquo;";
} }
else if($start == 1 && $start+20 < count($ranking)) { ?>
echo "&laquo; back | <a href=\"statistiken.php?id=".$_GET['id']."&amp;rank=".($start+20)."\">forward &raquo;</a>";
}
else if($start != 1 && $start-20 < count($ranking)) {
echo "<a href=\"statistiken.php?id=".$_GET['id']."&amp;rank=".($start-20)."\">&laquo; back</a> | forward &raquo;";
}
else {
echo "&laquo; back | forward &raquo;";
}
?>
+32 -37
View File
@@ -5,9 +5,7 @@ if(!is_numeric($_SESSION['search'])) {
<?php <?php
$search = 0; $search = 0;
} }
else { else $search = $_SESSION['search'];
$search = $_SESSION['search'];
}
?> ?>
<table cellpadding="1" cellspacing="1" id="villages" class="row_table_data"> <table cellpadding="1" cellspacing="1" id="villages" class="row_table_data">
<thead> <thead>
@@ -19,38 +17,35 @@ else {
<tr><td></td><td>Village</td><td>Player</td><td>Inhabitants</td><td>Coordinates</td></tr> <tr><td></td><td>Village</td><td>Player</td><td>Inhabitants</td><td>Coordinates</td></tr>
</thead><tbody> </thead><tbody>
<?php <?php
if(isset($_GET['rank'])){ $rankArray = $ranking->getRank();
$multiplier = 1; if(isset($_GET['rank'])){
if(is_numeric($_GET['rank'])) { $multiplier = 1;
if($_GET['rank'] > count($ranking->getRank())) { if(is_numeric($_GET['rank'])) {
$_GET['rank'] = count($ranking->getRank())-1; if($_GET['rank'] > count($rankArray)) {
} $_GET['rank'] = count($rankArray) - 1;
while($_GET['rank'] > (20*$multiplier)) { }
$multiplier +=1;
} while($_GET['rank'] > (20*$multiplier)) $multiplier++;
$start = 20*$multiplier-19;
} else { $start = ($_SESSION['start']+1); } $start = 20 * $multiplier - 19;
} else { $start = ($_SESSION['start']+1); } }
if(count($ranking->getRank()) > 0) { else $start = ($_SESSION['start'] + 1);
$ranking = $ranking->getRank(); }
for($i=$start;$i<($start+20);$i++) { else $start = ($_SESSION['start'] + 1);
if(isset($ranking[$i]['wref']) && $ranking[$i] != "pad") {
if($i == $search) { if(count($rankArray) > 1) {
echo "<tr class=\"hl\"><td class=\"ra fc\" >"; for($i = $start; $i < $start + 20; $i++) {
} if(isset($rankArray[$i]['wref']) && $rankArray[$i] != "pad") {
else { if($i == $search) echo "<tr class=\"hl\"><td class=\"ra fc\" >";
echo "<tr><td class=\"ra \" >"; else echo "<tr><td class=\"ra \" >";
}
echo $i.".</td><td class=\"vil \" ><a href=\"karte.php?d=".$ranking[$i]['wref']."&amp;c=".$generator->getMapCheck($ranking[$i]['wref'])."\">".$ranking[$i]['name']."</a></td>"; echo $i.".</td><td class=\"vil \" ><a href=\"karte.php?d=".$rankArray[$i]['wref']."&amp;c=".$generator->getMapCheck($rankArray[$i]['wref'])."\">".$rankArray[$i]['name']."</a></td>";
echo "<td class=\"pla \" ><a href=\"spieler.php?uid=".$ranking[$i]['owner']."\">".$ranking[$i]['user']."</a></td>"; echo "<td class=\"pla \" ><a href=\"spieler.php?uid=".$rankArray[$i]['owner']."\">".$rankArray[$i]['user']."</a></td>";
echo "<td class=\"hab\">".$ranking[$i]['pop']."</td><td class=\"aligned_coords \" ><div class=\"cox\">(".$ranking[$i]['x']."</div><div class=\"pi\">|</div><div class=\"coy\">".$ranking[$i]['y'].")</div></td></tr>"; echo "<td class=\"hab\">".$rankArray[$i]['pop']."</td><td class=\"aligned_coords \" ><div class=\"cox\">(".$rankArray[$i]['x']."</div><div class=\"pi\">|</div><div class=\"coy\">".$rankArray[$i]['y'].")</div></td></tr>";
} }
} }
} }
else { else echo "<td class=\"none\" colspan=\"5\">No villages found</td>";
echo "<td class=\"none\" colspan=\"5\">No villages found</td>";
}
?>
<?php
include("ranksearch.tpl"); include("ranksearch.tpl");
?> ?>
</tbody></table>
+21 -13
View File
@@ -14,16 +14,16 @@ if (WW == True)
</tr> </tr>
<tr> <tr>
<td></td> <td></td>
<td>Player</td> <td><?php echo PLAYER; ?></td>
<td>Name</td> <td><?php echo NAME; ?></td>
<td>Alliance</td> <td><?php echo ALLIANCE; ?></td>
<td>Level</td> <td><?php echo LEVEL; ?></td>
<td></td> <td></td>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<?php <?php
$cont = 1; $count = 0;
while ($row = mysqli_fetch_array($result)) while ($row = mysqli_fetch_array($result))
{ {
$ally = $database->getAlliance($row['alliance']); $ally = $database->getAlliance($row['alliance']);
@@ -31,7 +31,7 @@ if (WW == True)
$row2 = @mysqli_fetch_assoc($query); $row2 = @mysqli_fetch_assoc($query);
?> ?>
<tr> <tr>
<td><?php echo $cont; $cont++; ?>.</td> <td><?php echo ++$count; ?>.</td>
<td><?php echo "<a href=\"karte.php?d=" . $row['vref'] . "&amp;c=" . $generator->getMapCheck($row['vref']) . "\">"; ?><?php echo $row['username']; ?></a></td> <td><?php echo "<a href=\"karte.php?d=" . $row['vref'] . "&amp;c=" . $generator->getMapCheck($row['vref']) . "\">"; ?><?php echo $row['username']; ?></a></td>
<td><?php echo $row['wwname']; ?></td> <td><?php echo $row['wwname']; ?></td>
<td><a href="allianz.php?aid=<?php echo $ally['id']; ?>"><?php echo $ally['tag']; ?></a></td> <td><a href="allianz.php?aid=<?php echo $ally['id']; ?>"><?php echo $ally['tag']; ?></a></td>
@@ -44,10 +44,18 @@ if (WW == True)
</tr> </tr>
<?php <?php
} }
}
else if($count == 0){
{ ?>
header("Location: statistiken.php"); <tr>
exit; <td class="none" colspan="7"><?php echo NO_WW; ?></td>
} </tr>
?> <?php
}
}
else
{
header("Location: statistiken.php");
exit;
}
?>
+5 -5
View File
@@ -52,18 +52,18 @@
mysqli_query($database->dblink, "INSERT INTO " . TB_PREFIX . "users SET username = '".$database->escape($_POST['aname'])."', password = '" . password_hash($_POST['apass'], PASSWORD_BCRYPT, ['cost' => 12]) . "', email = '".$database->escape($_POST['aemail'])."', tribe = ".(int) $_POST['atribe'].", access = 9, is_bcrypt = 1") OR DIE (mysqli_error($database->dblink)); mysqli_query($database->dblink, "INSERT INTO " . TB_PREFIX . "users SET username = '".$database->escape($_POST['aname'])."', password = '" . password_hash($_POST['apass'], PASSWORD_BCRYPT, ['cost' => 12]) . "', email = '".$database->escape($_POST['aemail'])."', tribe = ".(int) $_POST['atribe'].", access = 9, is_bcrypt = 1") OR DIE (mysqli_error($database->dblink));
$uid = mysqli_insert_id($database->dblink); $uid = mysqli_insert_id($database->dblink);
$admin_village_created = false; $admin_village_created = false;
$xcoor = 50; $xcoor = round(WORLD_MAX / 2);
$addUnitsWrefs = []; $addUnitsWrefs = [];
$addTechWrefs = []; $addTechWrefs = [];
$addABTechWrefs = []; $addABTechWrefs = [];
while (!$admin_village_created) { while (!$admin_village_created) {
$wid = $admin->getWref($xcoor++, 50); $wid = $admin->getWref($xcoor++, round(WORLD_MAX / 2));
$status = $database->getVillageState($wid); $status = $database->getVillageState($wid);
if($status == 0) { if($status == 0) {
$database->setFieldTaken($wid); $database->setFieldTaken($wid);
$database->addVillage($wid, $uid, $_POST['aname'], 1); $database->addVillage($wid, $uid, $_POST['aname'], 1);
$database->addResourceFields($wid, $database->getVillageType($wid)); $database->addResourceFields($wid, $database->getVillageType($wid, false));
$addUnitsWrefs[] = $wid; $addUnitsWrefs[] = $wid;
$addTechWrefs[] = $wid; $addTechWrefs[] = $wid;
$addABTechWrefs[] = $wid; $addABTechWrefs[] = $wid;
@@ -84,8 +84,8 @@
$status = $database->getVillageState($wid); $status = $database->getVillageState($wid);
if($status == 0) { if($status == 0) {
$database->setFieldTaken($wid); $database->setFieldTaken($wid);
$database->addVillage($wid, $uid, 'Multihunter', '0'); $database->addVillage($wid, $uid, 'Multihunter', 0);
$database->addResourceFields($wid, $database->getVillageType($wid)); $database->addResourceFields($wid, $database->getVillageType($wid, false));
$database->addUnits($wid); $database->addUnits($wid);
$database->addTech($wid); $database->addTech($wid);
$database->addABTech($wid); $database->addABTech($wid);
+1 -1
View File
@@ -72,7 +72,7 @@ if(isset($_POST['result'])) {
include("Templates/Simulator/res_d".$tar.".tpl"); include("Templates/Simulator/res_d".$tar.".tpl");
} }
echo "<p>Type of attack: <b>"; echo "<p>Type of attack: <b>";
echo $form->getValue('ktyp') == 0? "Normal" : "Raid"; echo $form->getValue('ktyp') == 0 ? "Normal" : "Raid";
echo "</b></p>"; echo "</b></p>";
echo "<p>"; echo "<p>";
if (isset($_POST['result'][7]) && isset($_POST['result'][8])){ if (isset($_POST['result'][7]) && isset($_POST['result'][8])){