mirror of
https://github.com/Shadowss/TravianZ.git
synced 2026-07-15 09:06:08 +00:00
more fixes
This commit is contained in:
+45
-13
@@ -946,6 +946,41 @@ class Automation {
|
||||
$toF = $database->getVillage($data['to']);
|
||||
$fromF = $database->getVillage($data['from']);
|
||||
|
||||
$DefenderUnit = array();
|
||||
$DefenderUnit = $database->getUnit($data['to']);
|
||||
$evasion = $database->getVillageField($data['to'],"evasion");
|
||||
$maxevasion = $database->getUserField($DefenderID,"maxevasion",0);
|
||||
$gold = $database->getUserField($DefenderID,"gold",0);
|
||||
$playerunit = ($targettribe-1)*10;
|
||||
$cannotsend = 0;
|
||||
$movements = $database->getMovement("34",$data['to'],1);
|
||||
for($y=0;$y < count($movements);$y++){
|
||||
$returntime = $units[$y]['endtime']-time();
|
||||
if($units[$y]['sort_type'] == 4 && $units[$y]['from'] != 0 && $returntime <= 10){
|
||||
$cannotsend = 1;
|
||||
}
|
||||
}
|
||||
if($evasion == 1 && $maxevasion > 0 && $gold > 1 && $cannotsend == 0){
|
||||
$totaltroops = 0;
|
||||
for($i=1;$i<=10;$i++){
|
||||
$playerunit += $i;
|
||||
$data['u'.$i] = $DefenderUnit['u'.$playerunit];
|
||||
$database->modifyUnit($data['to'],array($playerunit),array($DefenderUnit['u'.$playerunit]),array(0));
|
||||
$playerunit -= $i;
|
||||
$totaltroops += $data['u'.$i];
|
||||
}
|
||||
$data['u11'] = $DefenderUnit['hero'];
|
||||
$totaltroops += $data['u11'];
|
||||
if($totaltroops > 0){
|
||||
$database->modifyUnit($data['to'],array("hero"),array($DefenderUnit['hero']),array(0));
|
||||
$attackid = $database->addAttack($data['to'],$data['u1'],$data['u2'],$data['u3'],$data['u4'],$data['u5'],$data['u6'],$data['u7'],$data['u8'],$data['u9'],$data['u10'],$data['u11'],4,0,0,0,0,0,0,0,0,0,0,0);
|
||||
$database->addMovement(4,0,$data['to'],$attackid,time(),time()+(180/EVASION_SPEED));
|
||||
$newgold = $gold-2;
|
||||
$newmaxevasion = $maxevasion-1;
|
||||
$database->updateUserField($DefenderID, "gold", $newgold, 1);
|
||||
$database->updateUserField($DefenderID, "maxevasion", $newmaxevasion, 1);
|
||||
}
|
||||
}
|
||||
//get defence units
|
||||
$Defender = array(); $rom = $ger = $gal = $nat = $natar = 0;
|
||||
$Defender = $database->getUnit($data['to']);
|
||||
@@ -2571,7 +2606,8 @@ $crannyimg = "<img src=\"".GP_LOCATE."img/g/g23.gif\" height=\"20\" width=\"15\"
|
||||
,$troopsdead8
|
||||
,$troopsdead9
|
||||
,$troopsdead10
|
||||
,$troopsdead11);
|
||||
,$troopsdead11
|
||||
,$DefenderUnit);
|
||||
|
||||
#################################################
|
||||
|
||||
@@ -3227,25 +3263,21 @@ $crannyimg = "<img src=\"".GP_LOCATE."img/g/g23.gif\" height=\"20\" width=\"15\"
|
||||
$ourFileHandle = fopen("GameEngine/Prevention/training.txt", 'w');
|
||||
fclose($ourFileHandle);
|
||||
$trainlist = $database->getTrainingList();
|
||||
if(count($trainlist) > 0) {
|
||||
foreach($trainlist as $train) {
|
||||
$database->updateTraining($train['id'],0);
|
||||
$trained = 0;
|
||||
|
||||
$timepast = $train['timestamp'] - $time;
|
||||
$trained = $timepast-($train['amt']-1)*$train['eachtime'];
|
||||
if(count($trainlist) > 0){
|
||||
foreach($trainlist as $train){
|
||||
$timepast = $train['timestamp2'] - $time;
|
||||
$pop = $train['pop'];
|
||||
if($trained <= 0){
|
||||
if($timepast <= 0 && $train['amt'] > 0) {
|
||||
if($train['unit']>60 && $train['unit']!=99){
|
||||
$database->modifyUnit($train['vref'],array($train['unit']-60),array(1),array(1));
|
||||
}else{
|
||||
$database->modifyUnit($train['vref'],array($train['unit']),array(1),array(1));
|
||||
}
|
||||
$database->updateTraining($train['id'],1);
|
||||
$database->updateTraining($train['id'],1,$train['eachtime']);
|
||||
}
|
||||
if($train['amt'] == 0){
|
||||
$database->trainUnit($train['id'],0,0,0,0,1,1);
|
||||
}
|
||||
if($timepast < 0) {
|
||||
$database->trainUnit($train['id'],0,0,0,0,1,1);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(file_exists("GameEngine/Prevention/training.txt")) {
|
||||
|
||||
@@ -2061,6 +2061,9 @@
|
||||
case 7:
|
||||
$q = "SELECT * FROM " . TB_PREFIX . "movement where " . TB_PREFIX . "movement." . $where . " = $village and sort_type = 4 and ref = 0 and proc = 0 ORDER BY endtime ASC";
|
||||
break;
|
||||
case 8:
|
||||
$q = "SELECT * FROM " . TB_PREFIX . "movement, " . TB_PREFIX . "attacks where " . TB_PREFIX . "movement." . $where . " = $village and " . TB_PREFIX . "movement.ref = " . TB_PREFIX . "attacks.id and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 4 OR " . TB_PREFIX . "movement." . $where . " = $village and sort_type = 4 and ref = 0 and proc = 0 ORDER BY endtime ASC";
|
||||
break;
|
||||
case 34:
|
||||
$q = "SELECT * FROM " . TB_PREFIX . "movement, " . TB_PREFIX . "attacks where " . TB_PREFIX . "movement." . $where . " = $village and " . TB_PREFIX . "movement.ref = " . TB_PREFIX . "attacks.id and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 3 or " . TB_PREFIX . "movement." . $where . " = $village and " . TB_PREFIX . "movement.ref = " . TB_PREFIX . "attacks.id and " . TB_PREFIX . "movement.proc = 0 and " . TB_PREFIX . "movement.sort_type = 4 ORDER BY endtime ASC";
|
||||
break;
|
||||
@@ -2159,6 +2162,31 @@
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
function getUnitsNumber($vid) {
|
||||
$q = "SELECT * from " . TB_PREFIX . "units where vref = $vid";
|
||||
$result = mysql_query($q, $this->connection);
|
||||
$dbarray = mysql_fetch_assoc($result);
|
||||
$totalunits = 0;
|
||||
$movingunits = $this->getVillageMovement($vid);
|
||||
for($i=1;$i<=50;$i++){
|
||||
$totalunits += $dbarray['u'.$i];
|
||||
}
|
||||
$totalunits += $dbarray['hero'];
|
||||
$movingunits = $this->getVillageMovement($vid);
|
||||
$reinforcingunits = $this->getEnforceArray($vid,1);
|
||||
$owner = $this->getVillageField($vid,"owner");
|
||||
$ownertribe = $this->getUserField($owner,"tribe",0);
|
||||
$start = ($ownertribe-1)*10+1;
|
||||
$end = ($ownertribe*10);
|
||||
for($i=$start;$i<=$end;$i++){
|
||||
$totalunits += $movingunits['u'.$i];
|
||||
$totalunits += $reinforcingunits['u'.$i];
|
||||
}
|
||||
$totalunits += $movingunits['hero'];
|
||||
$totalunits += $reinforcingunits['hero'];
|
||||
return $totalunits;
|
||||
}
|
||||
|
||||
function getHero($uid=0,$all=0) {
|
||||
if ($all) {
|
||||
@@ -2295,7 +2323,7 @@
|
||||
$now = time();
|
||||
|
||||
$uid = $this->getVillageField($vid, "owner");
|
||||
|
||||
$oldeach = $each;
|
||||
$artefact = count($this->getOwnUniqueArtefactInfo2($uid,5,3,0));
|
||||
$artefact1 = count($this->getOwnUniqueArtefactInfo2($vid,5,1,1));
|
||||
$artefact2 = count($this->getOwnUniqueArtefactInfo2($uid,5,2,0));
|
||||
@@ -2315,18 +2343,25 @@
|
||||
$each = round($each);
|
||||
}
|
||||
if($each == 0){ $each = 1; }
|
||||
$time2 = $now+$each;
|
||||
if(count($queued) > 0) {
|
||||
$time += $queued[count($queued) - 1]['timestamp'] - $now;
|
||||
$time2 += $queued[count($queued) - 1]['timestamp'] - $now;
|
||||
}
|
||||
$q = "INSERT INTO " . TB_PREFIX . "training values (0,$vid,$unit,$amt,$pop,$time,$each)";
|
||||
if($queued[count($queued) - 1]['unit'] == $unit){
|
||||
$time = $amt*$oldeach;
|
||||
$q = "UPDATE " . TB_PREFIX . "training SET amt = amt + $amt, timestamp = timestamp + $time WHERE id = ".$queued[count($queued) - 1]['id']."";
|
||||
}else{
|
||||
$q = "INSERT INTO " . TB_PREFIX . "training values (0,$vid,$unit,$amt,$pop,$time,$each,$time2)";
|
||||
}
|
||||
} else {
|
||||
$q = "DELETE FROM " . TB_PREFIX . "training where id = $vid";
|
||||
}
|
||||
return mysql_query($q, $this->connection);
|
||||
}
|
||||
|
||||
function updateTraining($id, $trained) {
|
||||
$q = "UPDATE " . TB_PREFIX . "training set amt = amt - $trained where id = $id";
|
||||
function updateTraining($id, $trained, $each) {
|
||||
$q = "UPDATE " . TB_PREFIX . "training set amt = amt - $trained,timestamp2 = timestamp2 + $each where id = $id";
|
||||
return mysql_query($q, $this->connection);
|
||||
}
|
||||
|
||||
@@ -3084,6 +3119,8 @@
|
||||
return $casualties;
|
||||
}
|
||||
|
||||
//end general statistics
|
||||
|
||||
function addFriend($uid, $column, $friend) {
|
||||
$q = "UPDATE " . TB_PREFIX . "users SET $column = $friend WHERE id = $uid";
|
||||
return mysql_query($q, $this->connection);
|
||||
@@ -3113,8 +3150,17 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function setVillageEvasion($vid) {
|
||||
$village = $this->getVillage($vid);
|
||||
if($village['evasion'] == 0){
|
||||
$q = "UPDATE " . TB_PREFIX . "vdata SET evasion = 1 WHERE wref = $vid";
|
||||
}else{
|
||||
$q = "UPDATE " . TB_PREFIX . "vdata SET evasion = 0 WHERE wref = $vid";
|
||||
}
|
||||
return mysql_query($q, $this->connection);
|
||||
}
|
||||
}
|
||||
;
|
||||
|
||||
|
||||
@@ -420,7 +420,6 @@ class Technology {
|
||||
$upkeep /= 4;
|
||||
$upkeep = round($upkeep);
|
||||
$upkeep *= 3;
|
||||
$upkeep = round($upkeep);
|
||||
}
|
||||
return $upkeep;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user