mirror of
https://github.com/Shadowss/TravianZ.git
synced 2026-07-14 00:26:07 +00:00
Artifacts update and optimizations
+Added the "Artifacts" section in the Admin Panel, which contains two options: return a deleted artifact to the Natars and create new Artifacts, assigned to a specified player +Return to Natars coded, in the village section of the Admin Panel +Moved a lot of functions and costants from Automation.php to the "new" class Artifacts.php +Optimized a lot the whole Natars creation process, decreased the number of query of about 600 +Optimized a lot the function which deletes a player's account, it's now executed almost instantly, even with players with a lot of villages +Redesigned the map spawn system, using a more Travian-like village distribution +Fixed a bug that did show a broken village in the artifact chronology, if that village was destroyed +Reduced the amount of redundant code (about 230 lines) for 27_1.tpl/27_2.tpl and 27_3.tpl +Fixed a bug that permitted to build the Great Granary and the Great Warehouse in the whole account, with only a village effect artifact +Fixed a bug in the Admin Panel map that didn't permit to show village informations, if that village contained single quotes in its name
This commit is contained in:
@@ -100,11 +100,11 @@ else
|
||||
else
|
||||
{
|
||||
// Register them and build the village
|
||||
$uid = $database->register($userName, password_hash($password, PASSWORD_BCRYPT, ['cost' => 12]), $email, $tribe ,$act);
|
||||
$uid = $database->register($userName, password_hash($password, PASSWORD_BCRYPT, ['cost' => 12]), $email, $tribe, $act);
|
||||
if($uid)
|
||||
{
|
||||
/*
|
||||
* [MENTION=6887]Tod[/MENTION]O
|
||||
* [MENTION=6887]Todo[/MENTION]
|
||||
*
|
||||
* Allow option to create (random) bigger villages,
|
||||
* upgrade fields, granary, warehouse, wall etc
|
||||
@@ -130,12 +130,12 @@ else
|
||||
// already exists
|
||||
$protection = time();
|
||||
mysqli_query($GLOBALS["link"], "UPDATE ".TB_PREFIX."users SET
|
||||
protect = '".$protection."'
|
||||
WHERE id = ".(int) $uid) or die(mysqli_error($database->dblink));
|
||||
protect = '".$protection."'
|
||||
WHERE id = ".(int) $uid) or die(mysqli_error($database->dblink));
|
||||
}
|
||||
|
||||
$database->updateUserField($uid,"act","",1);
|
||||
$wid = $database->generateBase($kid);
|
||||
$wid = $database->generateBase($kid, 1);
|
||||
$database->setFieldTaken($wid);
|
||||
|
||||
//calculate random generate value and level building
|
||||
|
||||
+14
-22
@@ -42,10 +42,10 @@ function aktiv() {this.srcElement.className='fl1'; }
|
||||
function inaktiv() {event.srcElement.className='fl2'; }
|
||||
|
||||
function del(e,id){
|
||||
if(e == 'did'){ var conf = confirm('Dou you really want delete village id '+id+'?'); }
|
||||
if(e == 'arti'){ var conf = confirm('Dou you really want delete artifact id '+id+'?'); }
|
||||
if(e == 'unban'){ var conf = confirm('Dou you really want unban player '+id+'?'); }
|
||||
if(e == 'stopDel'){ var conf = confirm('Dou you really want stop deleting user '+id+'?'); }
|
||||
if(e == 'did'){ var conf = confirm('Do you really want to delete village id '+id+'?'); }
|
||||
if(e == 'arti'){ var conf = confirm('Do you really want to delete artifact id '+id+'?'); }
|
||||
if(e == 'unban'){ var conf = confirm('Do you really want to unban player '+id+'?'); }
|
||||
if(e == 'stopDel'){ var conf = confirm('Do you really want to stop deleting user '+id+'?'); }
|
||||
return conf;
|
||||
}
|
||||
|
||||
@@ -86,30 +86,22 @@ return conf;
|
||||
|
||||
if($funct->CheckLogin()){
|
||||
if($_POST or $_GET){
|
||||
if($_GET['p'] and $_GET['p']!="search"){
|
||||
if($_GET['p'] && $_GET['p'] != "search"){
|
||||
$filename = '../Templates/Admin/'.$_GET['p'].'.tpl';
|
||||
if(file_exists($filename)){
|
||||
include($filename);
|
||||
}else{
|
||||
include('../Templates/Admin/404.tpl');
|
||||
}
|
||||
}else{
|
||||
include('../Templates/Admin/search.tpl');
|
||||
if(file_exists($filename)) include($filename);
|
||||
else include('../Templates/Admin/404.tpl');
|
||||
}
|
||||
if($_POST['p'] and $_POST['s']){
|
||||
else include('../Templates/Admin/search.tpl');
|
||||
|
||||
if($_POST['p'] && $_POST['s']){
|
||||
$filename = '../Templates/Admin/results_'.$_POST['p'].'.tpl';
|
||||
if(file_exists($filename)){
|
||||
include($filename);
|
||||
}else{
|
||||
include('../Templates/Admin/404.tpl');
|
||||
}
|
||||
if(file_exists($filename)) include($filename);
|
||||
else include('../Templates/Admin/404.tpl');
|
||||
}
|
||||
}else{
|
||||
include('../Templates/Admin/home.tpl');
|
||||
}
|
||||
}else{
|
||||
include('../Templates/Admin/login.tpl');
|
||||
else include('../Templates/Admin/home.tpl');
|
||||
}
|
||||
else include('../Templates/Admin/login.tpl');
|
||||
?>
|
||||
|
||||
</div>
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
// # Source code: https://github.com/Shadowss/TravianZ ##
|
||||
// # ##
|
||||
// ################################################################################
|
||||
include_once("../GameEngine/Artifacts.php");
|
||||
class funct
|
||||
{
|
||||
|
||||
@@ -29,6 +30,8 @@ class funct
|
||||
{
|
||||
global $admin, $database;
|
||||
|
||||
$artifact = new Artifacts();
|
||||
|
||||
switch ($get['action']) {
|
||||
case "recountPop":
|
||||
$admin->recountPop($get['did']);
|
||||
@@ -74,12 +77,66 @@ class funct
|
||||
case "logout":
|
||||
$this->LogOut();
|
||||
break;
|
||||
case "delArtifact":
|
||||
if(isset($_GET['artid']) && is_numeric($_GET['artid'])) $database->deleteArtifact($_GET['artid']);
|
||||
break;
|
||||
case "returnArtifact":
|
||||
|
||||
case "delArtifact":
|
||||
if(isset($_GET['artid']) && is_numeric($_GET['artid'])) $database->updateArtifactDetails($_GET['artid'], ['del' => 1]);
|
||||
break;
|
||||
|
||||
case "returnArtifact":
|
||||
//Check if the artifact id is valid
|
||||
if(!isset($_GET['artid']) || !is_numeric($_GET['artid'])){
|
||||
header("location: admin.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
//Get the informations of the artifact
|
||||
$artifactInfo = $database->getArtefactDetails($_GET['artid'], $_GET['del']);
|
||||
|
||||
//Check if the artifact exists
|
||||
if(empty($artifactInfo) || $artifactInfo['owner'] == Artifacts::NATARS_UID) {
|
||||
header("location: admin.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
$artifact->returnArtifactToNatars($artifactInfo);
|
||||
break;
|
||||
|
||||
case "addArtifacts":
|
||||
|
||||
$selectedArtifact = $_POST['selectedArtifact'];
|
||||
$artifactQuantity = $_POST['artifactQuantity'];
|
||||
$playerId = $_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");
|
||||
exit;
|
||||
}
|
||||
|
||||
//The first element [0] is the type of the artifact, the second one [1] is the size of it
|
||||
//and the third one, is the artifact description
|
||||
$selectedArtifact = explode(":", $selectedArtifact);
|
||||
|
||||
//Add the chosen artifact(s)
|
||||
$artifactsArray = array_merge(Artifacts::NATARS_ARTIFACTS, Artifacts::NATARS_WW_BUILDING_PLANS);
|
||||
$chosenArtifact = $artifactsArray[$selectedArtifact[2]][$selectedArtifact[1] - 1];
|
||||
|
||||
//Check if the artifact has been found or if doesn't exist
|
||||
if(empty($chosenArtifact)){
|
||||
header("location: admin.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
//Create the artifacts array
|
||||
$chosenArtifact['quantity'] = $artifactQuantity;
|
||||
$artifactArrays[$selectedArtifact[2]][] = $chosenArtifact;
|
||||
|
||||
//Add the artifacts
|
||||
$artifact->addArtifactVillages($artifactArrays, $playerId);
|
||||
break;
|
||||
|
||||
case "killHero":
|
||||
$varray = $database->getProfileVillages($get['uid']);
|
||||
$killhero = false;
|
||||
|
||||
Reference in New Issue
Block a user