Artifacts fix

+Added the possibility to add WW villages to a player, in the admin
panel
+Fixed the WW villages counter
+Deleted Natars' artifacts can now be recovered from the admin panel
This commit is contained in:
iopietro
2018-07-25 15:32:14 +02:00
parent 94447708ad
commit 1f86162179
5 changed files with 76 additions and 20 deletions
@@ -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/compact.css?f4b7i" rel="stylesheet" type="text/css">
<h1>Artifacts</h1>
<h1>Artifacts management</h1>
<form method="post" action="../Admin/admin.php?action=addArtifacts">
<table id="member">
<thead>
@@ -28,8 +28,7 @@ $deletedArtifacts = $database->getDeletedArtifacts();
$artifactArrays = array_merge(Artifacts::NATARS_ARTIFACTS, Artifacts::NATARS_WW_BUILDING_PLANS);
foreach($artifactArrays as $desc => $artifactType){
foreach($artifactType as $artifact){
echo '
<option value="'.$artifact['type'].':'.$artifact['size'].':'.$desc.'">'.$artifact['name'].'</option>';
echo '<option value="'.$artifact['type'].':'.$artifact['size'].':'.$desc.'">'.$artifact['name'].'</option>';
}
}
@@ -117,8 +116,39 @@ $deletedArtifacts = $database->getDeletedArtifacts();
}
?>
</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">
function changeArtifactImage(){
+3 -3
View File
@@ -61,8 +61,8 @@ if (!empty($_GET['p'])) {
$subpage = 'Map';
break;
case 'artifacts':
$subpage = 'Artifacts';
case 'natars':
$subpage = 'Natars Management';
break;
case 'search':
@@ -506,7 +506,7 @@ if (!empty($_GET['p'])) {
<li><a href="?p=report">Players Report</a></li>
<li><a href="?p=msg">Players Message</a></li>
<li><a href="?p=map">Map</a></li>
<li><a href="?p=artifacts">Artifacts</a></li>
<li><a href="?p=natars">Natars Management</a></li>
</ul>
</li>
<li class="sub"><a href="#">Search</a>
+27 -7
View File
@@ -93,25 +93,30 @@ class funct
$artifactInfo = $database->getArtefactDetails($_GET['artid'], $_GET['del']);
//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");
exit;
}
$artifact->returnArtifactToNatars($artifactInfo);
break;
case "addArtifacts":
$selectedArtifact = $_POST['selectedArtifact'];
$artifactQuantity = $_POST['artifactQuantity'];
$playerId = $_POST['playerId'];
$artifactQuantity = (int)$_POST['artifactQuantity'];
$playerId = (int)$_POST['playerId'];
//Check if the inputs are valid
if(!isset($selectedArtifact) || !isset($artifactQuantity) || !isset($playerId) || empty($selectedArtifact) ||
!is_numeric($artifactQuantity) || !is_numeric($playerId) || strpos($selectedArtifact, ':') === false ||
$database->getUserField($playerId, "username", 0) == "[?]"){
header("location: admin.php?p=artifacts&error=0");
!is_numeric($artifactQuantity) || $artifactQuantity <= 0 || $artifactQuantity > 999 || !is_numeric($playerId) ||
strpos($selectedArtifact, ':') === false || $database->getUserField($playerId, "username", 0) == "[?]"){
header("location: admin.php?p=natars&error=0");
exit;
}
@@ -125,7 +130,7 @@ class funct
//Check if the artifact has been found or if doesn't exist
if(empty($chosenArtifact)){
header("location: admin.php?p=artifacts&error=1");
header("location: admin.php?p=natars&error=1");
exit;
}
@@ -137,6 +142,21 @@ class funct
$artifact->addArtifactVillages($artifactArrays, $playerId);
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);
break;
case "killHero":
$varray = $database->getProfileVillages($get['uid']);
$killhero = false;
+11 -5
View File
@@ -131,8 +131,14 @@ class Artifacts
* @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
/**
@@ -311,12 +317,12 @@ class Artifacts
*
*/
public function createWWVillages(){
public function createWWVillages($numberOfVillages = self::NATARS_BASE_WW_VILLAGES, $uid = self::NATARS_UID){
global $database;
$villageArrays = $troopArrays = $buildingArrays = $wids = [];
for($i = 1; $i <= 13; $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];
for($i = 1; $i <= $numberOfVillages; $i++){
$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)());
$buildingArrays[1][] = array_values(self::NATARS_WW_VILLAGES_BUILDINGS);
}
@@ -324,7 +330,7 @@ class Artifacts
$troopArrays[0] = array_keys(($this->natarsWWVillagesUnits)());
$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, $troopArrays, $buildingArrays);
}
/**
+1 -1
View File
@@ -31,7 +31,7 @@ if (WW == True)
$row2 = @mysqli_fetch_assoc($query);
?>
<tr>
<td><?php echo $count++; ?>.</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 $row['wwname']; ?></td>
<td><a href="allianz.php?aid=<?php echo $ally['id']; ?>"><?php echo $ally['tag']; ?></a></td>