mirror of
https://github.com/Shadowss/TravianZ.git
synced 2026-06-28 00:24:23 +00:00
General fixes
+Fixed a bug that didn't delete artifacts when a player deleted his account +Added "(artifact)" if a village has an artifact in the village overview +Added the artifact section in the multihunter panel (return to natars doesn't work yet) NOTE: To play this version of the game, you have to run this query first (where "s1_" is the prefix of your server): ALTER TABLE `s1_artefacts` ADD `del` TINYINT(1) NULL DEFAULT '0' AFTER `lastupdate`; ALTER TABLE `testtravian`.`s1_artefacts` ADD INDEX `active-owner-conquered-del` (`active`, `owner`, `conquered`, `del`);
This commit is contained in:
+326
-224
@@ -1,236 +1,338 @@
|
||||
<?php
|
||||
#################################################################################
|
||||
## ##
|
||||
## -= YOU MUST NOT REMOVE OR CHANGE THIS NOTICE =- ##
|
||||
## ##
|
||||
## --------------------------------------------------------------------------- ##
|
||||
## ##
|
||||
## Project: TravianZ ##
|
||||
## Version: 05.03.2014 ##
|
||||
## Filename: Admin/function.php ##
|
||||
## Developed by: Dzoki ##
|
||||
## Edited by: Shadow and ronix ##
|
||||
## License: Creative Commons BY-NC-SA 3.0 ##
|
||||
## Copyright: TravianZ (c) 2014 - All rights reserved ##
|
||||
## URLs: http://travian.shadowss/ro ##
|
||||
## Source code: https://github.com/Shadowss/TravianZ ##
|
||||
## ##
|
||||
#################################################################################
|
||||
|
||||
class funct {
|
||||
// ################################################################################
|
||||
// # ##
|
||||
// # -= YOU MUST NOT REMOVE OR CHANGE THIS NOTICE =- ##
|
||||
// # ##
|
||||
// # --------------------------------------------------------------------------- ##
|
||||
// # ##
|
||||
// # Project: TravianZ ##
|
||||
// # Version: 05.03.2014 ##
|
||||
// # Filename: Admin/function.php ##
|
||||
// # Developed by: Dzoki ##
|
||||
// # Edited by: Shadow and ronix ##
|
||||
// # License: Creative Commons BY-NC-SA 3.0 ##
|
||||
// # Copyright: TravianZ (c) 2014 - All rights reserved ##
|
||||
// # URLs: http://travian.shadowss/ro ##
|
||||
// # Source code: https://github.com/Shadowss/TravianZ ##
|
||||
// # ##
|
||||
// ################################################################################
|
||||
class funct
|
||||
{
|
||||
|
||||
function CheckLogin(){
|
||||
if(isset($_SESSION['access']) && $_SESSION['access'] >= MULTIHUNTER and $_SESSION['id']){
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function Act($get){
|
||||
global $admin,$database;
|
||||
|
||||
switch($get['action']){
|
||||
case "recountPop":
|
||||
$admin->recountPop($get['did']);
|
||||
$admin->recountCP($get['did']);
|
||||
break;
|
||||
case "recountPopUsr":
|
||||
$admin->recountPopUser($get['uid']);
|
||||
break;
|
||||
case "StopDel":
|
||||
//stop deleting
|
||||
break;
|
||||
case "delVil":
|
||||
if($get['mode'] != 1){
|
||||
$admin->DelVillage($get['did']);
|
||||
}else{
|
||||
$admin->DelVillage($get['did'], 1);
|
||||
}
|
||||
break;
|
||||
case "delBan":
|
||||
$admin->DelBan($get['uid'],$get['id']);
|
||||
//remove ban
|
||||
break;
|
||||
case "addBan":
|
||||
if($get['time']){$end = time()+$get['time']; }else{$end = '';}
|
||||
|
||||
if(is_numeric($get['uid'])){
|
||||
$get['uid'] = $get['uid'];
|
||||
}else{
|
||||
$get['uid'] = $database->getUserField(addslashes($get['uid']),'id',1);
|
||||
}
|
||||
|
||||
$admin->AddBan($get['uid'],$end,$get['reason']);
|
||||
//add ban
|
||||
break;
|
||||
case "delOas":
|
||||
$database->query('UPDATE '.TB_PREFIX.'odata SET conqured = 0, owner = 2, name = "Unoccupied Oasis" WHERE wref = '.$get['oid']);
|
||||
//oaza
|
||||
break;
|
||||
case "logout":
|
||||
$this->LogOut();
|
||||
break;
|
||||
case "killHero":
|
||||
$varray = $database->getProfileVillages($get['uid']);
|
||||
$killhero=false;
|
||||
$error="";
|
||||
for ($i = 0; $i <= count($varray)-1; $i++) {
|
||||
$killhero=$database->FindHeroInVil($varray[$i]['wref']);
|
||||
if ($killhero) break;
|
||||
$killhero=$database->FindHeroInDef($varray[$i]['wref']);
|
||||
if ($killhero) break;
|
||||
$killhero=$database->FindHeroInMovement($varray[$i]['wref']);
|
||||
if ($killhero) break;
|
||||
}
|
||||
if (!$killhero){
|
||||
$killhero=$database->FindHeroInOasis($get['uid']);
|
||||
}
|
||||
|
||||
$database->KillMyHero($get['uid']);
|
||||
$error="&kc=1";
|
||||
|
||||
header("Location: admin.php?p=player&uid=".$get['uid'].$error);
|
||||
exit;
|
||||
case "reviveHero":
|
||||
$livingHeroesCount = mysqli_fetch_array($database->query("SELECT Count(*) as Total FROM ".TB_PREFIX."hero WHERE uid=".(int) $get['uid']." AND (dead = 0 OR inrevive = 1 OR intraining = 1)"), MYSQLI_ASSOC);
|
||||
|
||||
if ($livingHeroesCount['Total'] > 0) {
|
||||
header("Location: admin.php?p=player&uid=".$get['uid']."&re=1");
|
||||
exit;
|
||||
}
|
||||
|
||||
$result = $database->query("SELECT * FROM ".TB_PREFIX."hero WHERE heroid = ".(int) $get['hid']." AND uid=".(int) $get['uid']);
|
||||
$hdata = mysqli_fetch_array($result);
|
||||
$database->query("UPDATE ".TB_PREFIX."units SET hero = 1 WHERE vref = ".(int) $hdata['wref']);
|
||||
$database->query("UPDATE ".TB_PREFIX."hero SET `dead` = '0', `inrevive` = '0', `health` = '100', `lastupdate` = ".time()." WHERE `heroid` = ".(int) $get['hid']." AND `uid` = ".(int) $get['uid']);
|
||||
header("Location: admin.php?p=player&uid=".$get['uid']."&rc=1");
|
||||
exit;
|
||||
case "addHero":
|
||||
$user = $database->getUserArray($get['uid'],1);
|
||||
$vilarray=$database->getVrefCapital($get['uid']);
|
||||
if (!$vilarray) {
|
||||
return;
|
||||
}
|
||||
|
||||
$database->query("INSERT INTO ".TB_PREFIX."hero (`uid`, `wref`, `regeneration`, `unit`, `name`, `level`, `points`,
|
||||
`experience`, `dead`, `health`, `attack`, `defence`, `attackbonus`, `defencebonus`, `trainingtime`, `autoregen`,
|
||||
`intraining`) VALUES (".(int) $get['uid'].", " . (int) $vilarray['wref'] . ", '0', ".(int) $get['u'].", '".addslashes($user['username'])."',
|
||||
'0', '5', '0', '0', '100', '0', '0', '0', '0', '".time()."', '50', '0')");
|
||||
|
||||
$database->query("UPDATE ".TB_PREFIX."units SET hero = 1 WHERE vref = ".(int) $vilarray['wref']);
|
||||
|
||||
header("Location: admin.php?p=player&uid=".$get['uid']."&ac=1");
|
||||
exit;
|
||||
}
|
||||
if($get['action'] == 'logout'){
|
||||
header("Location: admin.php");
|
||||
}else{
|
||||
header("Location: ".$_SERVER['HTTP_REFERER']);
|
||||
function CheckLogin()
|
||||
{
|
||||
return isset($_SESSION['access']) && $_SESSION['access'] >= MULTIHUNTER && $_SESSION['id'];
|
||||
}
|
||||
}
|
||||
|
||||
function Act2($post){
|
||||
global $admin,$database;
|
||||
switch($post['action']){
|
||||
case "DelPlayer":
|
||||
if ($admin->DelPlayer($post['uid'],$post['pass'])) {
|
||||
header("Location: ?p=search&msg=ursdel");
|
||||
} else {
|
||||
die('Invalid Admin password, cannot delete player. Please go back and retry.');
|
||||
}
|
||||
break;
|
||||
case "punish":
|
||||
$admin->Punish($post);
|
||||
header("Location: ".$_SERVER['HTTP_REFERER']);
|
||||
break;
|
||||
case "addVillage":
|
||||
$admin->AddVillage($post);
|
||||
header("Location: ".$_SERVER['HTTP_REFERER']);
|
||||
break;
|
||||
}
|
||||
}
|
||||
function Act($get)
|
||||
{
|
||||
global $admin, $database;
|
||||
|
||||
switch ($get['action']) {
|
||||
case "recountPop":
|
||||
$admin->recountPop($get['did']);
|
||||
$admin->recountCP($get['did']);
|
||||
break;
|
||||
case "recountPopUsr":
|
||||
$admin->recountPopUser($get['uid']);
|
||||
break;
|
||||
case "StopDel":
|
||||
// stop deleting
|
||||
break;
|
||||
case "delVil":
|
||||
if ($get['mode'] != 1) {
|
||||
$admin->DelVillage($get['did']);
|
||||
} else {
|
||||
$admin->DelVillage($get['did'], 1);
|
||||
}
|
||||
break;
|
||||
case "delBan":
|
||||
$admin->DelBan($get['uid'], $get['id']);
|
||||
// remove ban
|
||||
break;
|
||||
case "addBan":
|
||||
if ($get['time']) {
|
||||
$end = time() + $get['time'];
|
||||
} else {
|
||||
$end = '';
|
||||
}
|
||||
|
||||
if (is_numeric($get['uid'])) {
|
||||
$get['uid'] = $get['uid'];
|
||||
} else {
|
||||
$get['uid'] = $database->getUserField(addslashes($get['uid']), 'id', 1);
|
||||
}
|
||||
|
||||
$admin->AddBan($get['uid'], $end, $get['reason']);
|
||||
// add ban
|
||||
break;
|
||||
case "delOas":
|
||||
$database->query('UPDATE ' . TB_PREFIX . 'odata SET conqured = 0, owner = 2, name = "Unoccupied Oasis" WHERE wref = ' . $get['oid']);
|
||||
// oaza
|
||||
break;
|
||||
case "logout":
|
||||
$this->LogOut();
|
||||
break;
|
||||
case "delArtifact":
|
||||
if(isset($_GET['artid']) && is_numeric($_GET['artid'])) $database->deleteArtifact($_GET['artid']);
|
||||
break;
|
||||
case "returnArtifact":
|
||||
|
||||
break;
|
||||
case "killHero":
|
||||
$varray = $database->getProfileVillages($get['uid']);
|
||||
$killhero = false;
|
||||
$error = "";
|
||||
for ($i = 0; $i <= count($varray) - 1; $i ++) {
|
||||
$killhero = $database->FindHeroInVil($varray[$i]['wref']);
|
||||
if ($killhero)
|
||||
break;
|
||||
$killhero = $database->FindHeroInDef($varray[$i]['wref']);
|
||||
if ($killhero)
|
||||
break;
|
||||
$killhero = $database->FindHeroInMovement($varray[$i]['wref']);
|
||||
if ($killhero)
|
||||
break;
|
||||
}
|
||||
if (! $killhero) {
|
||||
$killhero = $database->FindHeroInOasis($get['uid']);
|
||||
}
|
||||
|
||||
$database->KillMyHero($get['uid']);
|
||||
$error = "&kc=1";
|
||||
|
||||
header("Location: admin.php?p=player&uid=" . $get['uid'] . $error);
|
||||
exit();
|
||||
case "reviveHero":
|
||||
$livingHeroesCount = mysqli_fetch_array($database->query("SELECT Count(*) as Total FROM " . TB_PREFIX . "hero WHERE uid=" . (int) $get['uid'] . " AND (dead = 0 OR inrevive = 1 OR intraining = 1)"), MYSQLI_ASSOC);
|
||||
|
||||
if ($livingHeroesCount['Total'] > 0) {
|
||||
header("Location: admin.php?p=player&uid=" . $get['uid'] . "&re=1");
|
||||
exit();
|
||||
}
|
||||
|
||||
$result = $database->query("SELECT * FROM " . TB_PREFIX . "hero WHERE heroid = " . (int) $get['hid'] . " AND uid=" . (int) $get['uid']);
|
||||
$hdata = mysqli_fetch_array($result);
|
||||
$database->query("UPDATE " . TB_PREFIX . "units SET hero = 1 WHERE vref = " . (int) $hdata['wref']);
|
||||
$database->query("UPDATE " . TB_PREFIX . "hero SET `dead` = '0', `inrevive` = '0', `health` = '100', `lastupdate` = " . time() . " WHERE `heroid` = " . (int) $get['hid'] . " AND `uid` = " . (int) $get['uid']);
|
||||
header("Location: admin.php?p=player&uid=" . $get['uid'] . "&rc=1");
|
||||
exit();
|
||||
case "addHero":
|
||||
$user = $database->getUserArray($get['uid'], 1);
|
||||
$vilarray = $database->getVrefCapital($get['uid']);
|
||||
if (! $vilarray) {
|
||||
return;
|
||||
}
|
||||
|
||||
$database->query("INSERT INTO " . TB_PREFIX . "hero (`uid`, `wref`, `regeneration`, `unit`, `name`, `level`, `points`,
|
||||
`experience`, `dead`, `health`, `attack`, `defence`, `attackbonus`, `defencebonus`, `trainingtime`, `autoregen`,
|
||||
`intraining`) VALUES (" . (int) $get['uid'] . ", " . (int) $vilarray['wref'] . ", '0', " . (int) $get['u'] . ", '" . addslashes($user['username']) . "',
|
||||
'0', '5', '0', '0', '100', '0', '0', '0', '0', '" . time() . "', '50', '0')");
|
||||
|
||||
$database->query("UPDATE " . TB_PREFIX . "units SET hero = 1 WHERE vref = " . (int) $vilarray['wref']);
|
||||
|
||||
header("Location: admin.php?p=player&uid=" . $get['uid'] . "&ac=1");
|
||||
exit();
|
||||
}
|
||||
if ($get['action'] == 'logout') {
|
||||
header("Location: admin.php");
|
||||
} else {
|
||||
header("Location: " . $_SERVER['HTTP_REFERER']);
|
||||
}
|
||||
}
|
||||
|
||||
function LogIN($username,$password){
|
||||
global $admin,$database;
|
||||
if($admin->Login($username,$password)){
|
||||
$_SESSION['admin_username'] = $username;
|
||||
$_SESSION['access'] = $database->getUserField($username,'access',1);
|
||||
$_SESSION['id'] = $database->getUserField($username,'id',1);
|
||||
header("Location: ".$_SERVER['HTTP_REFERER']);
|
||||
//header("Location: admin.php");
|
||||
}else{
|
||||
echo "Error";
|
||||
}
|
||||
}
|
||||
function Act2($post)
|
||||
{
|
||||
global $admin, $database;
|
||||
switch ($post['action']) {
|
||||
case "DelPlayer":
|
||||
if ($admin->DelPlayer($post['uid'], $post['pass'])) {
|
||||
header("Location: ?p=search&msg=ursdel");
|
||||
} else {
|
||||
die('Invalid Admin password, cannot delete player. Please go back and retry.');
|
||||
}
|
||||
break;
|
||||
case "punish":
|
||||
$admin->Punish($post);
|
||||
header("Location: " . $_SERVER['HTTP_REFERER']);
|
||||
break;
|
||||
case "addVillage":
|
||||
$admin->AddVillage($post);
|
||||
header("Location: " . $_SERVER['HTTP_REFERER']);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function LogOut(){
|
||||
$_SESSION['access'] = '';
|
||||
$_SESSION['id'] = '';
|
||||
}
|
||||
function LogIN($username, $password)
|
||||
{
|
||||
global $admin, $database;
|
||||
if ($admin->Login($username, $password)) {
|
||||
$_SESSION['admin_username'] = $username;
|
||||
$_SESSION['access'] = $database->getUserField($username, 'access', 1);
|
||||
$_SESSION['id'] = $database->getUserField($username, 'id', 1);
|
||||
header("Location: " . $_SERVER['HTTP_REFERER']);
|
||||
// header("Location: admin.php");
|
||||
} else {
|
||||
echo "Error";
|
||||
}
|
||||
}
|
||||
|
||||
public function procResType($ref) {
|
||||
global $session;
|
||||
switch($ref) {
|
||||
case 1: $build = "Woodcutter"; break;
|
||||
case 2: $build = "Clay Pit"; break;
|
||||
case 3: $build = "Iron Mine"; break;
|
||||
case 4: $build = "Cropland"; break;
|
||||
case 5: $build = "Sawmill"; break;
|
||||
case 6: $build = "Brickyard"; break;
|
||||
case 7: $build = "Iron Foundry"; break;
|
||||
case 8: $build = "Grain Mill"; break;
|
||||
case 9: $build = "Bakery"; break;
|
||||
case 10: $build = "Warehouse"; break;
|
||||
case 11: $build = "Granary"; break;
|
||||
case 12: $build = "Blacksmith"; break;
|
||||
case 13: $build = "Armoury"; break;
|
||||
case 14: $build = "Tournament Square"; break;
|
||||
case 15: $build = "Main Building"; break;
|
||||
case 16: $build = "Rally Point"; break;
|
||||
case 17: $build = "Marketplace"; break;
|
||||
case 18: $build = "Embassy"; break;
|
||||
case 19: $build = "Barracks"; break;
|
||||
case 20: $build = "Stable"; break;
|
||||
case 21: $build = "Workshop"; break;
|
||||
case 22: $build = "Academy"; break;
|
||||
case 23: $build = "Cranny"; break;
|
||||
case 24: $build = "Town Hall"; break;
|
||||
case 25: $build = "Residence"; break;
|
||||
case 26: $build = "Palace"; break;
|
||||
case 27: $build = "Treasury"; break;
|
||||
case 28: $build = "Trade Office"; break;
|
||||
case 29: $build = "Great Barracks"; break;
|
||||
case 30: $build = "Great Stable"; break;
|
||||
case 31: $build = "City Wall"; break;
|
||||
case 32: $build = "Earth Wall"; break;
|
||||
case 33: $build = "Palisade"; break;
|
||||
case 34: $build = "Stonemason's Lodge"; break;
|
||||
case 35: $build = "Brewery"; break;
|
||||
case 36: $build = "Trapper"; break;
|
||||
case 37: $build = "Hero's Mansion"; break;
|
||||
case 38: $build = "Great Warehouse"; break;
|
||||
case 39: $build = "Great Granary"; break;
|
||||
case 40: $build = "Wonder of the World"; break;
|
||||
case 41: $build = "Horse Drinking Trough"; break;
|
||||
case 42: $build = "Great Workshop"; break;
|
||||
default: $build = "Error"; break;
|
||||
}
|
||||
return $build;
|
||||
}
|
||||
function LogOut()
|
||||
{
|
||||
$_SESSION['access'] = '';
|
||||
$_SESSION['id'] = '';
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
$funct = new funct;
|
||||
if($funct->CheckLogin()){
|
||||
if(isset($_GET['action']) && $_GET['action']){
|
||||
$funct->Act($_GET);
|
||||
}
|
||||
if(isset($_POST['action']) && $_POST['action']){
|
||||
$funct->Act2($_POST);
|
||||
}
|
||||
public function procResType($ref)
|
||||
{
|
||||
global $session;
|
||||
switch ($ref) {
|
||||
case 1:
|
||||
$build = "Woodcutter";
|
||||
break;
|
||||
case 2:
|
||||
$build = "Clay Pit";
|
||||
break;
|
||||
case 3:
|
||||
$build = "Iron Mine";
|
||||
break;
|
||||
case 4:
|
||||
$build = "Cropland";
|
||||
break;
|
||||
case 5:
|
||||
$build = "Sawmill";
|
||||
break;
|
||||
case 6:
|
||||
$build = "Brickyard";
|
||||
break;
|
||||
case 7:
|
||||
$build = "Iron Foundry";
|
||||
break;
|
||||
case 8:
|
||||
$build = "Grain Mill";
|
||||
break;
|
||||
case 9:
|
||||
$build = "Bakery";
|
||||
break;
|
||||
case 10:
|
||||
$build = "Warehouse";
|
||||
break;
|
||||
case 11:
|
||||
$build = "Granary";
|
||||
break;
|
||||
case 12:
|
||||
$build = "Blacksmith";
|
||||
break;
|
||||
case 13:
|
||||
$build = "Armoury";
|
||||
break;
|
||||
case 14:
|
||||
$build = "Tournament Square";
|
||||
break;
|
||||
case 15:
|
||||
$build = "Main Building";
|
||||
break;
|
||||
case 16:
|
||||
$build = "Rally Point";
|
||||
break;
|
||||
case 17:
|
||||
$build = "Marketplace";
|
||||
break;
|
||||
case 18:
|
||||
$build = "Embassy";
|
||||
break;
|
||||
case 19:
|
||||
$build = "Barracks";
|
||||
break;
|
||||
case 20:
|
||||
$build = "Stable";
|
||||
break;
|
||||
case 21:
|
||||
$build = "Workshop";
|
||||
break;
|
||||
case 22:
|
||||
$build = "Academy";
|
||||
break;
|
||||
case 23:
|
||||
$build = "Cranny";
|
||||
break;
|
||||
case 24:
|
||||
$build = "Town Hall";
|
||||
break;
|
||||
case 25:
|
||||
$build = "Residence";
|
||||
break;
|
||||
case 26:
|
||||
$build = "Palace";
|
||||
break;
|
||||
case 27:
|
||||
$build = "Treasury";
|
||||
break;
|
||||
case 28:
|
||||
$build = "Trade Office";
|
||||
break;
|
||||
case 29:
|
||||
$build = "Great Barracks";
|
||||
break;
|
||||
case 30:
|
||||
$build = "Great Stable";
|
||||
break;
|
||||
case 31:
|
||||
$build = "City Wall";
|
||||
break;
|
||||
case 32:
|
||||
$build = "Earth Wall";
|
||||
break;
|
||||
case 33:
|
||||
$build = "Palisade";
|
||||
break;
|
||||
case 34:
|
||||
$build = "Stonemason's Lodge";
|
||||
break;
|
||||
case 35:
|
||||
$build = "Brewery";
|
||||
break;
|
||||
case 36:
|
||||
$build = "Trapper";
|
||||
break;
|
||||
case 37:
|
||||
$build = "Hero's Mansion";
|
||||
break;
|
||||
case 38:
|
||||
$build = "Great Warehouse";
|
||||
break;
|
||||
case 39:
|
||||
$build = "Great Granary";
|
||||
break;
|
||||
case 40:
|
||||
$build = "Wonder of the World";
|
||||
break;
|
||||
case 41:
|
||||
$build = "Horse Drinking Trough";
|
||||
break;
|
||||
case 42:
|
||||
$build = "Great Workshop";
|
||||
break;
|
||||
default:
|
||||
$build = "Error";
|
||||
break;
|
||||
}
|
||||
return $build;
|
||||
}
|
||||
}
|
||||
if(isset($_POST['action']) && $_POST['action']=='login'){
|
||||
$funct->LogIN($_POST['name'],$_POST['pw']);
|
||||
;
|
||||
|
||||
$funct = new funct();
|
||||
if ($funct->CheckLogin()) {
|
||||
if (isset($_GET['action']) && $_GET['action']) {
|
||||
$funct->Act($_GET);
|
||||
}
|
||||
if (isset($_POST['action']) && $_POST['action']) {
|
||||
$funct->Act2($_POST);
|
||||
}
|
||||
}
|
||||
if (isset($_POST['action']) && $_POST['action'] == 'login') {
|
||||
$funct->LogIN($_POST['name'], $_POST['pw']);
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
class Artifacts{
|
||||
|
||||
/**
|
||||
* Gets the artifact informations in plain text
|
||||
*
|
||||
* @param int $artifact The artifact
|
||||
* @return array Returns the information of the artifacts
|
||||
*/
|
||||
|
||||
public static function getArtifactInfo($artifact){
|
||||
|
||||
$activationTime = 86400 / (SPEED == 2 ? 1.5 : (SPEED == 3 ? 2 : SPEED));
|
||||
$time = time();
|
||||
$nextEffect = "-";
|
||||
|
||||
if($artifact['size'] == 1 && $artifact['type'] != 11){
|
||||
$requiredLevel = 10;
|
||||
$effectInfluence = VILLAGE;
|
||||
}else{
|
||||
$requiredLevel = $artifact['type'] != 11 ? 20 : 10;
|
||||
$effectInfluence = ACCOUNT;
|
||||
}
|
||||
|
||||
if($artifact['owner'] == 3) $active = "-";
|
||||
elseif(!$artifact['active'] && $artifact['conquered'] < $time - $activationTime) $active = "<b>Can't be activated</b>";
|
||||
elseif (!$artifact['active']) $active = date("d.m.Y H:i:s", $artifact['conquered'] + $activationTime);
|
||||
else
|
||||
{
|
||||
$active = "<b>".ACTIVE."</b>";
|
||||
$nextEffect = date("d.m.Y H:i:s", $artifact['lastupdate'] + (86400 / (SPEED == 2 ? 1.5 : (SPEED == 3 ? 2 : SPEED))));
|
||||
}
|
||||
|
||||
//// Added by brainiac - thank you
|
||||
if ($artifact['type'] == 8)
|
||||
{
|
||||
$kind = $artifact['kind'];
|
||||
$effect = $artifact['effect2'];
|
||||
}else{
|
||||
$kind = $artifact['type'];
|
||||
$effect = $artifact['effect'];
|
||||
}
|
||||
|
||||
$artifactBadEffect = $artifact['type'] == 8 && $artifact['bad_effect'] == 1;
|
||||
switch($kind){
|
||||
case 1:
|
||||
$betterorbadder = $artifactBadEffect ? BUILDING_WEAKER : BUILDING_STRONGER;
|
||||
break;
|
||||
case 2:
|
||||
$betterorbadder = $artifactBadEffect ? TROOPS_SLOWEST : TROOPS_FASTER;
|
||||
break;
|
||||
case 3:
|
||||
$betterorbadder = $artifactBadEffect ? SPIES_DECRESE : SPIES_INCREASE;
|
||||
break;
|
||||
case 4:
|
||||
$betterorbadder = $artifactBadEffect ? CONSUME_HIGH : CONSUME_LESS;
|
||||
break;
|
||||
case 5:
|
||||
$betterorbadder = $artifactBadEffect ? TROOPS_MAKE_SLOWEST : TROOPS_MAKE_FASTER;
|
||||
break;
|
||||
case 6:
|
||||
$betterorbadder = $artifactBadEffect ? YOU_CONSTRUCT : YOU_CONSTRUCT;
|
||||
break;
|
||||
case 7:
|
||||
$betterorbadder = $artifactBadEffect ? CRANNY_DECRESE : CRANNY_INCREASED;
|
||||
break;
|
||||
case 8:
|
||||
$betterorbadder = $artifactBadEffect ? SPIES_INCREASE : SPIES_DECRESE;
|
||||
break;
|
||||
}
|
||||
$bonus = isset($betterorbadder) ? $betterorbadder." (<b>".str_replace(["(", ")"], "" , $effect)."</b>)" : (($kind == 11 && $artifact['active']) ? "<b>".WW_BUILDING_PLAN."</b>" : "<b>Not yet active</b>");
|
||||
|
||||
return ["requiredLevel" => $requiredLevel, "active" => $active,
|
||||
"bonus" => $bonus, "effectInfluence" => $effectInfluence,
|
||||
"nextEffect" => $nextEffect];
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -267,7 +267,9 @@ class Automation {
|
||||
if (isset($alliance)) {
|
||||
$database->deleteAlliance($alliance);
|
||||
}
|
||||
|
||||
$q = "UPDATE ".TB_PREFIX."artefacts where owner = ".(int) $need['uid']." SET del = 1";
|
||||
$database->query($q);
|
||||
|
||||
$q = "DELETE FROM ".TB_PREFIX."hero where uid = ".(int) $need['uid'];
|
||||
$database->query($q);
|
||||
|
||||
|
||||
+16
-1
@@ -7385,6 +7385,21 @@ References: User ID/Message ID, Mode
|
||||
return (isset(self::$artefactDataCache[$id.$mode][$size.$type]) ? self::$artefactDataCache[$id.$mode][$size.$type] : []);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete an artifact
|
||||
*
|
||||
* @param int $id The artifact ID
|
||||
* @return bool Return true if the query was successful, false otherwise
|
||||
*/
|
||||
|
||||
function deleteArtifact($id){
|
||||
list($id) = $this->escape_input((int) $id);
|
||||
|
||||
$q = "UPDATE " . TB_PREFIX . "artefacts WHERE id = $id SET del = 1";
|
||||
|
||||
return mysqli_query($this->dblink, $q);
|
||||
}
|
||||
|
||||
function villageHasArtefact($vref) {
|
||||
// this is a somewhat non-ideal, externally non-changeable way of caching
|
||||
// but since we're only ever going to be calling this from a single point of Automation,
|
||||
@@ -7482,7 +7497,7 @@ References: User ID/Message ID, Mode
|
||||
function getInactiveArtifacts($time){
|
||||
list($time) = $this->escape_input($time);
|
||||
|
||||
$q = "SELECT * FROM ".TB_PREFIX."artefacts WHERE active = 0 AND owner > 5 AND conquered <= $time ORDER BY conquered ASC, size ASC";
|
||||
$q = "SELECT * FROM ".TB_PREFIX."artefacts WHERE active = 0 AND owner > 5 AND conquered <= $time AND del = 0 ORDER BY conquered ASC, size ASC";
|
||||
$result = mysqli_query($this->dblink, $q);
|
||||
return $this->mysqli_fetch_all($result);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user