diff --git a/GameEngine/Automation.php b/GameEngine/Automation.php
index cc876139..95a70bfd 100755
--- a/GameEngine/Automation.php
+++ b/GameEngine/Automation.php
@@ -2165,14 +2165,13 @@ class Automation {
}
}
} else {
- global $form;
if ($heroxp == 0) $xp=" no XP from the battle.";
else $xp=" gained ".$heroxp." XP from the battle.";
$artifact = reset($database->getOwnArtefactInfo($data['to']));
if (!empty($artifact)) {
if ($type == 3) {
- if ($database->canClaimArtifact($data['from'], $artifact['vref'], $artifact['size'], $artifact['type'])) {
+ if (empty($artifactError = $database->canClaimArtifact($data['from'], $artifact['vref'], $artifact['size'], $artifact['type']))) {
$database->claimArtefact($data['from'], $data['to'], $database->getVillageField($data['from'], "owner"));
$info_hero = $hero_pic.",Your hero is carrying home the artifact ".$artifact['name']." and".$xp;
@@ -2182,7 +2181,7 @@ class Automation {
$info_hero .= " The village has been destroyed.";
}
}
- else $info_hero = $hero_pic.",".$form->getError("error").$xp;
+ else $info_hero = $hero_pic.",".$artifactError.$xp;
}
else $info_hero = $hero_pic.",Your hero could not claim an artifact during raid".$xp;
}
diff --git a/GameEngine/Database.php b/GameEngine/Database.php
index bd1f966b..424b11ad 100755
--- a/GameEngine/Database.php
+++ b/GameEngine/Database.php
@@ -4741,7 +4741,7 @@ References: User ID/Message ID, Mode
*/
public function checkAllianceEmbassiesStatus($userData, $demolition = false, $use_cache = true) {
// TODO: refactor this and break it into more smaler methods
- global $session;
+ //global $session;
if ($userData['alliance']) {
// check whether this player is an alliance owner
@@ -4760,9 +4760,9 @@ References: User ID/Message ID, Mode
// unset the alliance in session, if we're evicting
// currently logged-in player
- if ($session->uid == $userData['id']) {
- $_SESSION['alliance_user'] = 0;
- }
+ //if ($session->uid == $userData['id']) {
+ // $_SESSION['alliance_user'] = 0;
+ //}
// notify them via in-game messaging, if we come from a demolition,
// otherwise return a result which can be used in battle reports
@@ -6130,7 +6130,7 @@ References: User ID/Message ID, Mode
function trainUnit($vid, $unit, $amt, $pop, $each, $mode) {
list($vid, $unit, $amt, $pop, $each, $mode) = $this->escape_input((int) $vid, (int) $unit, (int) $amt, (int) $pop, (int) $each, $mode);
- global $village, $building, $session, $technology;
+ global $technology;
if(!$mode) {
$barracks = [1, 2, 3, 11, 12, 13, 14, 21, 22, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44];
@@ -7532,23 +7532,17 @@ References: User ID/Message ID, Mode
// no need to cache this method
public function canClaimArtifact($from, $vref, $size, $type) {
- list($size,$type) = $this->escape_input((int) $size,(int) $type);
-
- //fix by Ronix
- global $form;
+ list($size, $type) = $this->escape_input((int) $size, (int) $type);
$artifact = $this->getOwnArtefactInfo($from);
- if (!empty($artifact)) {
- $form->addError("error", "Treasury is full. Your hero could not claim the artefact");
- return false;
- }
+ if (!empty($artifact)) return "Treasury is full. Your hero could not claim the artefact";
$uid = $this->getVillageField($from, "owner");
$vuid = $this->getVillageField($vref, "owner");
$artifact = $this->getOwnArtifactsSum($uid);
- if ( $artifact['totals'] < 3 || $uid == $vuid) {
+ if ($artifact['totals'] < 3 || $uid == $vuid) {
$DefenderFields = $this->getResourceLevel( $vref );
$defcanclaim = true;
@@ -7557,8 +7551,7 @@ References: User ID/Message ID, Mode
$defTresuaryLevel = $DefenderFields['f'.$i];
if ($defTresuaryLevel > 0) {
$defcanclaim = false;
- $form->addError("error", "Treasury has not been destroyed. Your hero could not claim the artefact");
- return false;
+ return "Treasury has not been destroyed. Your hero could not claim the artefact";
}
else $defcanclaim = true;
}
@@ -7575,20 +7568,15 @@ References: User ID/Message ID, Mode
}
if(($artifact['great'] > 0 || $artifact['unique'] > 0) && $size > 1 && $uid != $vuid) {
- $form->addError( "error", "Max num. of great/unique artefacts. Your hero could not claim the artefact" );
- return false;
+ return "Max num. of great/unique artefacts. Your hero could not claim the artefact";
}
if(($size == 1 && ($villageartifact || $accountartifact)) || (($size == 2 || $size == 3) && $accountartifact)) {
- return true;
- } else {
- $form->addError("error", "Your level treasury is low. Your hero could not claim the artefact");
- return false;
+ return "";
}
- } else {
- $form->addError("error", "Max num. of artefacts. Your hero could not claim the artefact");
- return false;
- }
+ else return "Your level treasury is low. Your hero could not claim the artefact";
+ }
+ else return "Max num. of artefacts. Your hero could not claim the artefact";
}
// no need to cache this method
@@ -7728,7 +7716,7 @@ References: User ID/Message ID, Mode
}
function getCropProdstarv($wref, $use_cache = true) {
- global $bid4, $bid8, $bid9, $sesion, $technology;
+ global $bid4, $bid8, $bid9, $technology;
// first of all, check if we should be using cache and whether the field
// required is already cached
@@ -7841,27 +7829,27 @@ References: User ID/Message ID, Mode
// no need to cache this method
function checkFriends($uid) {
list($uid) = $this->escape_input($uid);
-
global $session;
- $user = $this->getUserArray( $uid, 1 );
- for ( $i = 0; $i <= 19; $i ++ ) {
- if ( $user[ 'friend' . $i ] == 0 && $user[ 'friend' . $i . 'wait' ] == 0 ) {
- for ( $j = $i + 1; $j <= 19; $j ++ ) {
- $k = $j - 1;
- if ( $user[ 'friend' . $j ] != 0 ) {
- $friend = $this->getUserField( $uid, "friend" . $j, 0 );
- $this->addFriend( $uid, "friend" . $k, $friend );
- $this->deleteFriend( $uid, "friend" . $j );
- }
-
- if ( $user[ 'friend' . $j . 'wait' ] == 0 ) {
- $friendwait = $this->getUserField( $uid, "friend" . $j . "wait", 0 );
- $this->addFriend( $session->uid, "friend" . $k . "wait", $friendwait );
- $this->deleteFriend( $uid, "friend" . $j . "wait" );
- }
- }
- }
- }
+
+ $user = $this->getUserArray($uid, 1);
+ for($i = 0; $i <= 19; $i++){
+ if($user['friend'.$i] == 0 && $user['friend'.$i.'wait'] == 0){
+ for($j = $i + 1; $j <= 19; $j++){
+ $k = $j - 1;
+ if($user['friend'.$j] != 0){
+ $friend = $this->getUserField($uid, "friend".$j, 0);
+ $this->addFriend($uid, "friend".$k, $friend);
+ $this->deleteFriend($uid, "friend".$j);
+ }
+
+ if($user['friend'.$j.'wait'] == 0){
+ $friendwait = $this->getUserField($uid, "friend".$j."wait", 0);
+ $this->addFriend($session->uid, "friend".$k."wait", $friendwait);
+ $this->deleteFriend($uid, "friend".$j."wait");
+ }
+ }
+ }
+ }
}
function setVillageEvasion($vid) {
diff --git a/GameEngine/Form.php b/GameEngine/Form.php
index 3af3f75f..00a64981 100755
--- a/GameEngine/Form.php
+++ b/GameEngine/Form.php
@@ -24,9 +24,7 @@ class Form {
unset($_SESSION['errorarray']);
unset($_SESSION['valuearray']);
}
- else {
- $this->errorcount = 0;
- }
+ else $this->errorcount = 0;
}
public function addError($field,$error) {
@@ -38,18 +36,14 @@ class Form {
if(array_key_exists($field,$this->errorarray)) {
return $this->errorarray[$field];
}
- else {
- return "";
- }
+ else return "";
}
public function getValue($field) {
if(array_key_exists($field,$this->valuearray)) {
return $this->valuearray[$field];
}
- else {
- return "";
- }
+ else return "";
}
public function setValue($field, $value) {
@@ -60,18 +54,14 @@ class Form {
if(array_key_exists($field,$this->valuearray) && $this->valuearray[$field] != $cookie) {
return $this->valuearray[$field];
}
- else {
- return $cookie;
- }
+ else return $cookie;
}
public function getRadio($field,$value) {
if(array_key_exists($field,$this->valuearray) && $this->valuearray[$field] == $value) {
return "checked";
}
- else {
- return "";
- }
+ else return "";
}
public function returnErrors() {