mirror of
https://github.com/Shadowss/TravianZ.git
synced 2026-06-28 00:24:23 +00:00
Distance calculation optimization and bug fixing
-Removed a lot of redundant code and put into a function +Fixed a bug that permitted to found a new village in already founded village +Fixed a bug that permitted to found in an oasis +Fixed a bug that permitted to hack the time you need to found a new village +Fixed a bug that permitted to found a new village to an inexistent one
This commit is contained in:
+26
-147
@@ -343,7 +343,7 @@ class Automation {
|
||||
}
|
||||
|
||||
private function clearDeleting() {
|
||||
global $autoprefix;
|
||||
global $autoprefix, $units;
|
||||
if(file_exists($autoprefix."GameEngine/Prevention/cleardeleting.txt")) {
|
||||
unlink($autoprefix."GameEngine/Prevention/cleardeleting.txt");
|
||||
}
|
||||
@@ -435,10 +435,9 @@ class Automation {
|
||||
|
||||
foreach($enforcement as $enforce) {
|
||||
$time = microtime(true);
|
||||
$fromcoor = $database->getCoor($enforce['vref']);
|
||||
$tocoor = $database->getCoor($enforce['from']);
|
||||
$targettribe = $database->getUserField($database->getVillageField($enforce['from'],"owner"),"tribe",0);
|
||||
$time2 = $this->procDistanceTime($tocoor,$fromcoor,$targettribe,0);
|
||||
$targetOwner = $database->getVillageField($enforce['from'], "owner");
|
||||
$targettribe = $database->getUserField($targetOwner, "tribe", 0);
|
||||
$time2 = $units->getWalkingTroopsTime($enforce['from'], $enforce['vref'], $targetOwner, $targettribe, $enforce, 1);
|
||||
$start = 10*($targettribe-1);
|
||||
for($i=1;$i<11;$i++){
|
||||
$unit = $start + $i;
|
||||
@@ -942,7 +941,7 @@ class Automation {
|
||||
}
|
||||
|
||||
private function marketComplete() {
|
||||
global $database, $autoprefix;
|
||||
global $database, $autoprefix, $units;
|
||||
if(file_exists($autoprefix."GameEngine/Prevention/market.txt")) {
|
||||
unlink($autoprefix."GameEngine/Prevention/market.txt");
|
||||
}
|
||||
@@ -972,10 +971,8 @@ class Automation {
|
||||
$database->addNotice($from['owner'],$to['wref'],$ownally,$sort_type,''.addslashes($from['name']).' send resources to '.addslashes($to['name']).'',''.$from['owner'].','.$from['wref'].','.$data['wood'].','.$data['clay'].','.$data['iron'].','.$data['crop'].'',$data['endtime']);
|
||||
}
|
||||
$database->modifyResource($data['to'],$data['wood'],$data['clay'],$data['iron'],$data['crop'],1);
|
||||
$tocoor = $database->getCoor($data['from']);
|
||||
$fromcoor = $database->getCoor($data['to']);
|
||||
$targettribe = $userData_to["tribe"];
|
||||
$endtime = $this->procDistanceTime($tocoor,$fromcoor,$targettribe,0) + $data['endtime'];
|
||||
$endtime = $units->getWalkingTroopsTime($data['from'], $data['to'], 0, 0, [$targettribe], 0) + $data['endtime'];
|
||||
$database->addMovement(2,$data['to'],$data['from'],$data['merchant'],time(),$endtime,$data['send'],$data['wood'],$data['clay'],$data['iron'],$data['crop']);
|
||||
$database->setMovementProc($data['moveid']);
|
||||
}
|
||||
@@ -1006,7 +1003,7 @@ class Automation {
|
||||
}
|
||||
|
||||
private function sendResource2($wtrans, $ctrans, $itrans, $crtrans, $from, $to, $tribe, $send) {
|
||||
global $bid17,$bid28,$database,$generator,$logging;
|
||||
global $bid17, $bid28, $database, $units;
|
||||
|
||||
$availableWood = $database->getWoodAvailable($from);
|
||||
$availableClay = $database->getClayAvailable($from);
|
||||
@@ -1033,12 +1030,9 @@ class Automation {
|
||||
$resource = array($wtrans,$ctrans,$itrans,$crtrans);
|
||||
$reqMerc = ceil((array_sum($resource)-0.1)/$maxcarry2);
|
||||
|
||||
if($merchantAvail2 != 0 && $reqMerc <= $merchantAvail2) {
|
||||
$coor = $database->getCoor($to);
|
||||
$coor2 = $database->getCoor($from);
|
||||
|
||||
if($merchantAvail2 != 0 && $reqMerc <= $merchantAvail2) {
|
||||
if($database->getVillageState($to)) {
|
||||
$timetaken = $generator->procDistanceTime($coor,$coor2,$tribe,0);
|
||||
$timetaken = $units->getWalkingTroopsTime($from, $to, 0, 0, [$tribe], 0);
|
||||
$res = $resource[0]+$resource[1]+$resource[2]+$resource[3];
|
||||
if($res!=0){
|
||||
$reference = $database->sendResource($resource[0],$resource[1],$resource[2],$resource[3],$reqMerc,0);
|
||||
@@ -1587,7 +1581,7 @@ class Automation {
|
||||
//impossible to attack or scout NATAR Capital Village
|
||||
if ($NatarCapital)
|
||||
{
|
||||
for($i=1;$i<=11;$i++) ${'traped'.$i} = $data['t'.$i];
|
||||
for($i = 1; $i <= 11; $i++) ${'traped'.$i} = $data['t'.$i];
|
||||
}
|
||||
elseif(empty($scout))
|
||||
{
|
||||
@@ -1757,7 +1751,7 @@ class Automation {
|
||||
if (isset($battlepart['casualties_attacker']) && isset($battlepart['casualties_attacker'][$i]) && $battlepart['casualties_attacker'][$i] <= 0) {
|
||||
${'dead'.$i} = 0;
|
||||
} else if (isset($data['t'.$i]) && isset($battlepart['casualties_attacker']) && isset($battlepart['casualties_attacker'][$i]) && $battlepart['casualties_attacker'][$i] > $data['t'.$i]) {
|
||||
${'dead'.$i}=$data['t'.$i];
|
||||
${'dead'.$i} = $data['t'.$i];
|
||||
} else {
|
||||
${'dead'.$i} = (isset($battlepart['casualties_attacker']) && isset($battlepart['casualties_attacker'][$i]) ? $battlepart['casualties_attacker'][$i] : 0);
|
||||
}
|
||||
@@ -2178,48 +2172,20 @@ class Automation {
|
||||
}
|
||||
}
|
||||
|
||||
//work out time of return
|
||||
$start = ($owntribe-1)*10+1;
|
||||
$end = ($owntribe*10);
|
||||
|
||||
$unitspeeds = array(6,5,7,16,14,10,4,3,4,5,
|
||||
7,7,6,9,10,9,4,3,4,5,
|
||||
7,6,17,19,16,13,4,3,4,5,
|
||||
7,7,6,9,10,9,4,3,4,5,
|
||||
7,7,6,9,10,9,4,3,4,5);
|
||||
|
||||
$speeds = array();
|
||||
|
||||
//find slowest unit.
|
||||
for($i=1;$i<=10;$i++)
|
||||
{
|
||||
if ($data['t'.$i] > $battlepart['casualties_attacker'][$i]) {
|
||||
if($unitarray) { reset($unitarray); }
|
||||
$unitarray = $GLOBALS["u".(($owntribe-1)*10+$i)];
|
||||
$speeds[] = $unitarray['speed'];
|
||||
}
|
||||
}
|
||||
if ($herosend_att>0){
|
||||
$hero_unit = $database->getHeroField($from['owner'], 'unit');
|
||||
$speeds[] = $GLOBALS['u'.$hero_unit]['speed'];
|
||||
}
|
||||
|
||||
// Data for when troops return.
|
||||
|
||||
//catapults look :D
|
||||
$info_cat = $info_chief = $info_ram = $info_hero = ",";
|
||||
//check to see if can destroy village
|
||||
if (count($varray) != 1 && $to['capital'] != 1 && !$database->villageHasArtefact($DefenderWref)) {
|
||||
$can_destroy=1;
|
||||
} else {
|
||||
$can_destroy=0;
|
||||
$can_destroy = 1;
|
||||
}
|
||||
else $can_destroy = 0;
|
||||
|
||||
if($isoasis == 0)
|
||||
{
|
||||
if ($type=='3')
|
||||
if ($type == 3)
|
||||
{
|
||||
if (($data['t7']-$traped7)>0){
|
||||
if (($data['t7'] - $traped7) > 0){
|
||||
$newLevel = $battle->CalculateNewBuildingLevel($battlepart['rams']['moral'], $battlepart['rams']['updown'], $walllevel, $battlepart['rams']['realAttackers'], $data['t7']);
|
||||
if (isset($empty)){
|
||||
$info_ram = "".$ram_pic.",There is no wall to destroy.";
|
||||
@@ -2241,11 +2207,8 @@ class Automation {
|
||||
|
||||
// village has been destroyed
|
||||
if ($pop <= 0) {
|
||||
if ($can_destroy==1) {
|
||||
$info_cat = "".$catp_pic.", Village already destroyed.";
|
||||
} else {
|
||||
$info_cat = "".$catp_pic.", Village can\'t be destroyed.";
|
||||
}
|
||||
if ($can_destroy == 1) $info_cat = "".$catp_pic.", Village already destroyed.";
|
||||
else $info_cat = "".$catp_pic.", Village can\'t be destroyed.";
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2395,7 +2358,7 @@ class Automation {
|
||||
|
||||
//chiefing village
|
||||
//there are senators
|
||||
if(($data['t9']-$dead9-$traped9)>0 && $isoasis==0){
|
||||
if(($data['t9']- $dead9- $traped9) > 0 && $isoasis == 0){
|
||||
if ($type=='3') {
|
||||
|
||||
$palacelevel = $database->getResourceLevel($from['wref']);
|
||||
@@ -2601,7 +2564,7 @@ class Automation {
|
||||
$database->setVillageField($data['from'],$exp,$value);
|
||||
|
||||
//remove oasis related to village
|
||||
$units->returnTroops($data['to'],1);
|
||||
$units->returnTroops($data['to'], 1);
|
||||
$chiefing_village = 1;
|
||||
|
||||
//Remove trade routes related to village
|
||||
@@ -2791,33 +2754,9 @@ class Automation {
|
||||
$neutral = ($neutralarray[0]['alli1'] > 0 && $neutralarray[0]['alli2'] > 0 && $p_alliance > 0) && ($neutralarray[0]['alli1'] == $ownally || $neutralarray[0]['alli2'] == $ownally) && ($ownally != $p_alliance && $ownally && $p_alliance);
|
||||
|
||||
if($p_alliance == $ownally || $friend || $neutral){
|
||||
$p_tribe = $database->getUserField($p_owner,"tribe",0);
|
||||
$p_tribe = $database->getUserField($p_owner, "tribe", 0);
|
||||
|
||||
$p_eigen = $database->getCoor($prisoner['wref']);
|
||||
$p_from = array('x'=>$p_eigen['x'], 'y'=>$p_eigen['y']);
|
||||
$p_ander = $database->getCoor($prisoner['from']);
|
||||
$p_to = array('x'=>$p_ander['x'], 'y'=>$p_ander['y']);
|
||||
$p_tribe = $database->getUserField($p_owner,"tribe",0);
|
||||
|
||||
$p_speeds = array();
|
||||
|
||||
//find slowest unit.
|
||||
for($i = 1; $i <= 10; $i++){
|
||||
if ($prisoner['t'.$i]){
|
||||
if(!empty($prisoner['t'.$i]) && $prisoner['t'.$i] > 0){
|
||||
if($p_unitarray) { reset($p_unitarray); }
|
||||
$p_unitarray = $GLOBALS["u".(($p_tribe-1)*10+$i)];
|
||||
$p_speeds[] = $p_unitarray['speed'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($prisoner['t11'] > 0){
|
||||
$p_hero_unit = $database->getHeroField($p_owner, 'unit');
|
||||
$p_speeds[] = $GLOBALS['u'.$p_hero_unit]['speed'];
|
||||
}
|
||||
|
||||
$troopsTime = $this->procDistanceTime($p_to, $p_from, min($p_speeds), 1);
|
||||
$troopsTime = $units->getWalkingTroopsTime($prisoner['from'], $prisoner['wref'], $p_owner, $p_tribe, $prisoner, 1, 't');
|
||||
$p_time = $database->getArtifactsValueInfluence($p_owner, $prisoner['from'], 2, $troopsTime);
|
||||
|
||||
$p_reference = $database->addAttack($prisoner['from'],$prisoner['t1'],$prisoner['t2'],$prisoner['t3'],$prisoner['t4'],$prisoner['t5'],$prisoner['t6'],$prisoner['t7'],$prisoner['t8'],$prisoner['t9'],$prisoner['t10'],$prisoner['t11'],3,0,0,0,0,0,0,0,0,0,0,0);
|
||||
@@ -2880,7 +2819,9 @@ class Automation {
|
||||
// If the dead units not equal the ammount sent they will return and report
|
||||
if($totalsend_att - ($totaldead_att + (isset($totaltraped_att) ? $totaltraped_att : 0)) > 0)
|
||||
{
|
||||
$troopsTime = $this->procDistanceTime($from, $to, min($speeds), 1);
|
||||
$returningTroops = [];
|
||||
for($i = 1; $i <= 11; $i++) $returningTroops['t'.$i] = $data['t'.$i] - ${'traped'.$i} - ${'dead'.$i};
|
||||
$troopsTime = $units->getWalkingTroopsTime($from['wref'], $to['wref'], $from['owner'], $owntribe, $returningTroops, 1, 't');
|
||||
$endtime = $database->getArtifactsValueInfluence($from['owner'], $from['wref'], 2, $troopsTime);
|
||||
$endtime += $AttackArrivalTime;
|
||||
if($type == 1) {
|
||||
@@ -2960,25 +2901,8 @@ class Automation {
|
||||
$unitssend_att1 = ''.$data['t1'].','.$data['t2'].','.$data['t3'].','.$data['t4'].','.$data['t5'].','.$data['t6'].','.$data['t7'].','.$data['t8'].','.$data['t9'].','.$data['t10'].'';
|
||||
$herosend_att = $data['t11'];
|
||||
$unitssend_att= $unitssend_att1.','.$herosend_att;
|
||||
|
||||
$speeds = [];
|
||||
|
||||
//find slowest unit.
|
||||
//TODO: Needs to be made as a function
|
||||
for($i = 1; $i <= 10; $i++)
|
||||
{
|
||||
if ($data['t'.$i] > 0) {
|
||||
$unitarray = $GLOBALS["u".(($owntribe-1)*10+$i)];
|
||||
$speeds[] = $unitarray['speed'];
|
||||
}
|
||||
}
|
||||
|
||||
if ($herosend_att > 0){
|
||||
$hero_unit = $database->getHeroField($from['owner'], 'unit');
|
||||
$speeds[] = $GLOBALS['u'.$hero_unit]['speed'];
|
||||
}
|
||||
|
||||
$troopsTime = $this->procDistanceTime($from, $to, min($speeds), 1);
|
||||
|
||||
$troopsTime = $units->getWalkingTroopsTime($from['wref'], $to['wref'], $from['owner'], $owntribe, $data, 1, 't');
|
||||
$endtime = $database->getArtifactsValueInfluence($from['owner'], $from['wref'], 2, $troopsTime);
|
||||
$endtime += $AttackArrivalTime;
|
||||
|
||||
@@ -4209,51 +4133,6 @@ class Automation {
|
||||
}
|
||||
}
|
||||
|
||||
public function procDistanceTime($coor,$thiscoor,$ref,$mode) {
|
||||
global $bid14,$database,$generator;
|
||||
$resarray = $database->getResourceLevel($generator->getBaseID($coor['x'],$coor['y']));
|
||||
$xdistance = ABS($thiscoor['x'] - $coor['x']);
|
||||
if($xdistance > WORLD_MAX) {
|
||||
$xdistance = (2*WORLD_MAX+1) - $xdistance;
|
||||
}
|
||||
$ydistance = ABS($thiscoor['y'] - $coor['y']);
|
||||
if($ydistance > WORLD_MAX) {
|
||||
$ydistance = (2*WORLD_MAX+1) - $ydistance;
|
||||
}
|
||||
$distance = SQRT(POW($xdistance,2)+POW($ydistance,2));
|
||||
if(!$mode) {
|
||||
if($ref == 1) {
|
||||
$speed = 16;
|
||||
}
|
||||
else if($ref == 2) {
|
||||
$speed = 12;
|
||||
}
|
||||
else if($ref == 3) {
|
||||
$speed = 24;
|
||||
}
|
||||
else if($ref == 300) {
|
||||
$speed = 5;
|
||||
}
|
||||
else {
|
||||
$speed = 1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$speed = $ref;
|
||||
if($this->getsort_typeLevel(14,$resarray) != 0 && $distance >= TS_THRESHOLD) {
|
||||
$speed = $speed * ($bid14[$this->getsort_typeLevel(14,$resarray)]['attri']/100) ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if($speed!=0){
|
||||
return round(($distance/$speed) * 3600 / INCREASE_SPEED);
|
||||
}else{
|
||||
return round($distance * 3600 / INCREASE_SPEED);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private function getsort_typeLevel($tid,$resarray) {
|
||||
global $village;
|
||||
|
||||
|
||||
+13
-26
@@ -35,8 +35,8 @@ class MyGenerator {
|
||||
return substr($encode,0,$length);
|
||||
}
|
||||
|
||||
public function procDistanceTime($coor,$thiscoor,$ref,$mode) {
|
||||
global $bid28,$bid14,$building;
|
||||
public function procDistanceTime($coor, $thiscoor, $ref, $mode) {
|
||||
global $bid28, $bid14, $building;
|
||||
$xdistance = ABS($thiscoor['x'] - $coor['x']);
|
||||
if($xdistance > WORLD_MAX) {
|
||||
$xdistance = (2 * WORLD_MAX + 1) - $xdistance;
|
||||
@@ -46,34 +46,21 @@ class MyGenerator {
|
||||
$ydistance = (2 * WORLD_MAX + 1) - $ydistance;
|
||||
}
|
||||
$distance = SQRT(POW($xdistance,2)+POW($ydistance,2));
|
||||
if(!$mode) {
|
||||
if($ref == 1) {
|
||||
$speed = 16;
|
||||
}
|
||||
else if($ref == 2) {
|
||||
$speed = 12;
|
||||
}
|
||||
else if($ref == 3) {
|
||||
$speed = 24;
|
||||
}
|
||||
else if($ref == 300) {
|
||||
$speed = 5;
|
||||
}
|
||||
else {
|
||||
$speed = 1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(!$mode){
|
||||
if($ref == 1) $speed = 16;
|
||||
else if($ref == 2) $speed = 12;
|
||||
else if($ref == 3) $speed = 24;
|
||||
else if($ref == 300) $speed = 5;
|
||||
else $speed = 1;
|
||||
}else{
|
||||
$speed = $ref;
|
||||
if($building->getTypeLevel(14) != 0 && $distance >= TS_THRESHOLD) {
|
||||
$speed = $speed * ($bid14[$building->gettypeLevel(14)]['attri']/100) ;
|
||||
$speed *= ($bid14[$building->gettypeLevel(14)]['attri'] / 100) ;
|
||||
}
|
||||
}
|
||||
if($speed!=0){
|
||||
return round(($distance/$speed) * 3600 / INCREASE_SPEED);
|
||||
}else{
|
||||
return round($distance * 3600 / INCREASE_SPEED);
|
||||
}
|
||||
|
||||
if($speed != 0) return round(($distance / $speed) * 3600 / INCREASE_SPEED);
|
||||
else return round($distance * 3600 / INCREASE_SPEED);
|
||||
}
|
||||
|
||||
public function getTimeFormat($time) {
|
||||
|
||||
@@ -123,7 +123,7 @@ class Market
|
||||
$coor = $database->getCoor($id);
|
||||
if($database->getVillageState($id))
|
||||
{
|
||||
$timetaken = $generator->procDistanceTime($coor,$village->coor,$session->tribe,0);
|
||||
$timetaken = $generator->procDistanceTime($coor, $village->coor, $session->tribe, 0);
|
||||
$res = $resource[0]+$resource[1]+$resource[2]+$resource[3];
|
||||
if($res!=0)
|
||||
{
|
||||
@@ -308,7 +308,7 @@ class Market
|
||||
foreach($displayarray as $value)
|
||||
{
|
||||
$targetcoor = $database->getCoor($value['vref']);
|
||||
$duration = $generator->procDistanceTime($targetcoor,$village->coor,$session->tribe,0);
|
||||
$duration = $generator->procDistanceTime($targetcoor, $village->coor, $session->tribe, 0);
|
||||
if($duration <= ($value['maxtime'] * 3600) || $value['maxtime'] == 0)
|
||||
{
|
||||
$value['duration'] = $duration;
|
||||
|
||||
+108
-148
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
use App\Database\IDbConnection;
|
||||
|
||||
#################################################################################
|
||||
## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- ##
|
||||
## --------------------------------------------------------------------------- ##
|
||||
@@ -67,7 +69,7 @@ class Units {
|
||||
}
|
||||
|
||||
case "5":
|
||||
if (isset($post['a'])&& $post['a']== "new"){
|
||||
if (isset($post['a']) && $post['a']== "new"){
|
||||
$this->Settlers($post);
|
||||
}else{
|
||||
$post = $this->loadUnits($post);
|
||||
@@ -217,7 +219,7 @@ class Units {
|
||||
// another variable that will define the flag is raised and is being sent and the type of shipping
|
||||
$villageName = $database->getVillageField($id,'name');
|
||||
$speed= 300;
|
||||
$timetaken = $generator->procDistanceTime($coor,$village->coor,INCREASE_SPEED,1);
|
||||
$timetaken = $generator->procDistanceTime($coor, $village->coor, INCREASE_SPEED, 1);
|
||||
array_push($post, "$id", "$villageName", "$villageOwner","$timetaken");
|
||||
return $post;
|
||||
|
||||
@@ -232,7 +234,7 @@ class Units {
|
||||
} else if (isset($id)) {
|
||||
$villageName = $database->getOasisField($id,"name");
|
||||
$speed= 300;
|
||||
$timetaken = $generator->procDistanceTime($coor,$village->coor,INCREASE_SPEED,1);
|
||||
$timetaken = $generator->procDistanceTime($coor, $village->coor, INCREASE_SPEED, 1);
|
||||
array_push($post, "$id", "$villageName", "2","$timetaken");
|
||||
return $post;
|
||||
|
||||
@@ -241,7 +243,7 @@ class Units {
|
||||
|
||||
}
|
||||
|
||||
public function returnTroops($wref,$mode=0) {
|
||||
public function returnTroops($wref, $mode = 0) {
|
||||
global $database;
|
||||
if (!$mode) {
|
||||
$getenforce=$database->getEnforceVillage($wref,0);
|
||||
@@ -263,38 +265,9 @@ class Units {
|
||||
private function processReturnTroops($enforce) {
|
||||
global $database, $generator;
|
||||
$to = $database->getVillage($enforce['from']);
|
||||
$Gtribe = ($tribe = $database->getUserField($to['owner'], 'tribe',0)) == 1 ? "" : $tribe - 1;
|
||||
|
||||
$start = ($database->getUserField($to['owner'], 'tribe', 0) - 1) * 10 + 1;
|
||||
$end = ($database->getUserField($to['owner'] ,'tribe', 0) * 10);
|
||||
|
||||
$from = $database->getVillage($enforce['from']);
|
||||
$fromcoor = $database->getCoor($enforce['from']);
|
||||
$tocoor = $database->getCoor($enforce['vref']);
|
||||
$fromCor = ['x' => $tocoor['x'], 'y' => $tocoor['y']];
|
||||
$toCor = ['x' => $fromcoor['x'], 'y' => $fromcoor['y']];
|
||||
|
||||
$speeds = [];
|
||||
|
||||
//find slowest unit.
|
||||
for($i = $start; $i <= $end; $i++){
|
||||
$tribe = $database->getUserField($to['owner'], 'tribe', 0);
|
||||
|
||||
if(intval($enforce['u'.$i]) > 0){
|
||||
if($unitarray) { reset($unitarray); }
|
||||
$unitarray = $GLOBALS["u".$i];
|
||||
$speeds[] = $unitarray['speed'];
|
||||
}else{
|
||||
$enforce['u'.$i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if(intval($enforce['hero']) > 0){
|
||||
$hero_unit = $database->getHeroField($from['owner'], 'unit');
|
||||
$speeds[] = $GLOBALS['u'.$hero_unit]['speed'];
|
||||
}
|
||||
else $enforce['hero'] = 0;
|
||||
|
||||
$troopsTime = $generator->procDistanceTime($fromCor, $toCor, min($speeds), $enforce['from']);
|
||||
$troopsTime = $this->getWalkingTroopsTime($enforce['from'], $enforce['vref'], $to['owner'], $tribe, $enforce, 1);
|
||||
$time = $database->getArtifactsValueInfluence($from['owner'], $enforce['from'], 2, $troopsTime);
|
||||
|
||||
$reference = $database->addAttack($enforce['from'], $enforce['u'.$start], $enforce['u'.($start + 1)], $enforce['u'.($start + 2)], $enforce['u'.($start + 3)], $enforce['u'.($start + 4)], $enforce['u'.($start + 5)], $enforce['u'.($start + 6)], $enforce['u'.($start + 7)], $enforce['u'.($start + 8)], $enforce['u'.($start + 9)], $enforce['hero'], 2, 0, 0, 0, 0);
|
||||
@@ -345,7 +318,7 @@ class Units {
|
||||
|
||||
$database->modifyUnit(
|
||||
$village->wid,
|
||||
array(
|
||||
[
|
||||
$u . "1",
|
||||
$u . "2",
|
||||
$u . "3",
|
||||
@@ -357,8 +330,8 @@ class Units {
|
||||
$u . "9",
|
||||
$u . $session->tribe . "0",
|
||||
"hero"
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
$data['u1'],
|
||||
$data['u2'],
|
||||
$data['u3'],
|
||||
@@ -370,37 +343,11 @@ class Units {
|
||||
$data['u9'],
|
||||
$data['u10'],
|
||||
$data['u11']
|
||||
),
|
||||
array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
|
||||
],
|
||||
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
|
||||
);
|
||||
|
||||
$fromcoor = $database->getCoor( $village->wid );
|
||||
$from = ['x' => $fromcoor['x'], 'y' => $fromcoor['y']];
|
||||
$tocoor = $database->getCoor( $data['to_vid'] );
|
||||
$to = ['x' => $tocoor['x'], 'y' => $tocoor['y']];
|
||||
$speeds = [];
|
||||
|
||||
//find slowest unit.
|
||||
for ($i = 1; $i <= 10; $i ++) {
|
||||
if (isset( $data['u'.$i] ) ) {
|
||||
if (!empty($data['u'.$i]) && $data['u'.$i] > 0) {
|
||||
if ($unitarray) {
|
||||
reset($unitarray);
|
||||
}
|
||||
$unitarray = $GLOBALS["u".(($session->tribe - 1) * 10 + $i)];
|
||||
$speeds[] = $unitarray['speed'];
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isset($data['u11'])) {
|
||||
if (!empty($data['u11']) && $data['u11'] > 0) {
|
||||
$heroarray = $database->getHero( $session->uid);
|
||||
$herodata = $GLOBALS['u'.$heroarray[0]['unit']];
|
||||
$speeds[] = $herodata['speed'];
|
||||
}
|
||||
}
|
||||
|
||||
$troopsTime = $generator->procDistanceTime($from, $to, min($speeds), 1);
|
||||
$troopsTime = $this->getWalkingTroopsTime($village->wid, $data['to_vid'], $session->uid, $session->tribe, $data, 1, 'u');
|
||||
$time = $database->getArtifactsValueInfluence($session->uid, $village->wid, 2, $troopsTime);
|
||||
|
||||
// Check if have WW owner have artefact Rivals great confusion or Artefact of the unique fool with that effect
|
||||
@@ -510,12 +457,12 @@ class Units {
|
||||
if ( isset( $post[ 't' . $i ] ) ) {
|
||||
if ( $i != 10 ) {
|
||||
if ( $post[ 't' . $i ] > $enforce[ 'u' . $Gtribe . $i ] ) {
|
||||
$form->addError( "error", "You can't send more units than you have" );
|
||||
$form->addError( "error", "You can't send back more units than you have" );
|
||||
break;
|
||||
}
|
||||
|
||||
if ( $post[ 't' . $i ] < 0 ) {
|
||||
$form->addError( "error", "You can't send negative units." );
|
||||
$form->addError( "error", "You can't send back negative units." );
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -525,11 +472,11 @@ class Units {
|
||||
}
|
||||
if ( isset( $post['t11'] ) ) {
|
||||
if ( $post['t11'] > $enforce['hero'] ) {
|
||||
$form->addError( "error", "You can't send more units than you have" );
|
||||
$form->addError( "error", "You can't send back more units than you have" );
|
||||
}
|
||||
|
||||
if ( $post['t11'] < 0 ) {
|
||||
$form->addError( "error", "You can't send negative units." );
|
||||
$form->addError( "error", "You can't send back negative units." );
|
||||
}
|
||||
} else {
|
||||
$post['t11'] = '0';
|
||||
@@ -543,8 +490,9 @@ class Units {
|
||||
} else {
|
||||
|
||||
//change units
|
||||
$start = ( $database->getUserField( $to['owner'], 'tribe', 0 ) - 1 ) * 10 + 1;
|
||||
$end = ( $database->getUserField( $to['owner'], 'tribe', 0 ) * 10 );
|
||||
$tribe = $database->getUserField($to['owner'], 'tribe', 0);
|
||||
$start = ($tribe - 1 ) * 10 + 1;
|
||||
$end = $tribe * 10 ;
|
||||
|
||||
$units = [];
|
||||
$amounts = [];
|
||||
@@ -562,48 +510,15 @@ class Units {
|
||||
$amounts[] = $post['t11'];
|
||||
$modes[] = 0;
|
||||
|
||||
$database->modifyEnforce( $post['ckey'], $units, $amounts, $modes );
|
||||
$j ++;
|
||||
//get cord
|
||||
$from = $database->getVillage( $enforce['from'] );
|
||||
$fromcoor = $database->getCoor( $enforce['from'] );
|
||||
$tocoor = $database->getCoor( $enforce['vref'] );
|
||||
$fromCor = array( 'x' => $tocoor['x'], 'y' => $tocoor['y'] );
|
||||
$toCor = array( 'x' => $fromcoor['x'], 'y' => $fromcoor['y'] );
|
||||
|
||||
$speeds = array();
|
||||
|
||||
//find slowest unit.
|
||||
for ( $i = 1; $i <= 10; $i ++ ) {
|
||||
if ( isset( $post[ 't' . $i ] ) ) {
|
||||
if ( $post[ 't' . $i ] != '' && $post[ 't' . $i ] > 0 ) {
|
||||
if ( $unitarray ) {
|
||||
reset( $unitarray );
|
||||
}
|
||||
$unitarray = $GLOBALS[ "u" . ( ( $session->tribe - 1 ) * 10 + $i ) ];
|
||||
$speeds[] = $unitarray['speed'];
|
||||
} else {
|
||||
$post[ 't' . $i . '' ] = '0';
|
||||
}
|
||||
} else {
|
||||
$post[ 't' . $i . '' ] = '0';
|
||||
}
|
||||
}
|
||||
if ( isset( $post['t11'] ) ) {
|
||||
if ( $post['t11'] != '' && $post['t11'] > 0 ) {
|
||||
$hero_unit = $database->getHeroField($from['owner'], 'unit');
|
||||
$speeds[] = $GLOBALS[ 'u' . $hero_unit ]['speed'];
|
||||
}
|
||||
else $post['t11'] = 0;
|
||||
}
|
||||
else $post['t11'] = 0;
|
||||
|
||||
$troopsTime = $generator->procDistanceTime($fromCor, $toCor, min($speeds), 1);
|
||||
$database->modifyEnforce($post['ckey'], $units, $amounts, $modes);
|
||||
$j++;
|
||||
|
||||
$troopsTime = $this->getWalkingTroopsTime($enforce['from'], $enforce['vref'], $to['owner'], $tribe, $post, 1, 't');
|
||||
$time = $database->getArtifactsValueInfluence($session->uid, $village->wid, 2, $troopsTime);
|
||||
|
||||
$reference = $database->addAttack( $enforce['from'], $post['t1'], $post['t2'], $post['t3'], $post['t4'], $post['t5'], $post['t6'], $post['t7'], $post['t8'], $post['t9'], $post['t10'], $post['t11'], 2, 0, 0, 0, 0 );
|
||||
$database->addMovement( 4, $village->wid, $enforce['from'], $reference, time(), ( $time + time() ) );
|
||||
$technology->checkReinf( $post['ckey'], false );
|
||||
$reference = $database->addAttack($enforce['from'], $post['t1'], $post['t2'], $post['t3'], $post['t4'], $post['t5'], $post['t6'], $post['t7'], $post['t8'], $post['t9'], $post['t10'], $post['t11'], 2, 0, 0, 0, 0 );
|
||||
$database->addMovement(4, $village->wid, $enforce['from'], $reference, time(), ($time + time()));
|
||||
$technology->checkReinf($post['ckey'], false );
|
||||
|
||||
header( "Location: build.php?id=39&refresh=1" );
|
||||
exit;
|
||||
@@ -626,48 +541,34 @@ class Units {
|
||||
|
||||
public function Settlers($post) {
|
||||
global $form, $database, $village, $session;
|
||||
//-- Prevent user from founding a new village if there are not enough settlers
|
||||
//-- fix by AL-Kateb
|
||||
$tempunits = $database->getUnit($village->coor['id']);
|
||||
$settler_key = "u" . $session->userinfo['tribe'] . "0";
|
||||
$settlers = (int)$tempunits[$settler_key];
|
||||
if($settlers < 3){
|
||||
header("location: dorf1.php");
|
||||
exit;
|
||||
}
|
||||
//--
|
||||
|
||||
if ( $session->access != BANNED ) {
|
||||
$mode = CP;
|
||||
$total = count( $database->getProfileVillages( $session->uid ) );
|
||||
$need_cps = ${'cp' . $mode}[ $total + 1 ];
|
||||
$cps = $session->cp;
|
||||
$rallypoint = $database->getResourceLevel( $village->wid );
|
||||
if ( $rallypoint['f39'] > 0 ) {
|
||||
if ( $cps >= $need_cps ) {
|
||||
$unit = ( $session->tribe * 10 );
|
||||
$database->modifyResource( $village->wid, 750, 750, 750, 750, 0 );
|
||||
$database->modifyUnit( $village->wid, array( $unit ), array( 3 ), array( 0 ) );
|
||||
$database->addMovement( 5, $village->wid, $post['s'], 0, time(), time() + $post['timestamp'] );
|
||||
header( "Location: build.php?id=39" );
|
||||
exit;
|
||||
if ($session->access != BANNED) {
|
||||
$mode = CP;
|
||||
$total = count($database->getProfileVillages($session->uid));
|
||||
$need_cps = ${'cp'.$mode}[$total + 1];
|
||||
$cps = $session->cp;
|
||||
$rallypoint = $database->getResourceLevel($village->wid);
|
||||
|
||||
if ( $form->returnErrors() > 0 ) {
|
||||
$_SESSION['errorarray'] = $form->getErrors();
|
||||
$_SESSION['valuearray'] = $_POST;
|
||||
header( "Location: a2b.php" );
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
header( "Location: build.php?id=39" );
|
||||
exit;
|
||||
//-- Prevent user from founding a new village if there are not enough settlers or the player put an invalid village ID or an already occupied one
|
||||
//-- fix by AL-Kateb - Semplified and additions by iopietro
|
||||
if ($rallypoint['f39'] > 0 && $village->unitarray['u'.$session->tribe.'0'] >= 3 && isset($post['s']) && ($newvillage = $database->getMInfo($post['s']))['id'] > 0 && $newvillage['occupied'] == 0 && $newvillage['oasistype'] == 0) {
|
||||
if ($cps >= $need_cps) {
|
||||
$troopsTime = $this->getWalkingTroopsTime($village->wid, $newvillage['id'], 0, 0, [300], 0);
|
||||
$time = $database->getArtifactsValueInfluence($session->uid, $village->wid, 2, $troopsTime);
|
||||
|
||||
$unit = ($session->tribe * 10);
|
||||
$database->modifyResource($village->wid, 750, 750, 750, 750, 0);
|
||||
$database->modifyUnit($village->wid, [$unit], [3], [0]);
|
||||
$database->addMovement(5, $village->wid, $post['s'], 0, time(), time() + $time);
|
||||
}
|
||||
header("Location: build.php?id=39");
|
||||
exit;
|
||||
} else {
|
||||
header( "Location: dorf1.php" );
|
||||
header("Location: dorf1.php");
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
header( "Location: banned.php" );
|
||||
header("Location: banned.php");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
@@ -773,6 +674,65 @@ class Units {
|
||||
return $heroes;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get how much time troops spend to walk from a village to another
|
||||
*
|
||||
* @param int $from The start village ID
|
||||
* @param int $to The target village ID
|
||||
* @param int $owner The owner of the troops
|
||||
* @param int $tribe The tribe of the owner's troops
|
||||
* @param array $unitArray The array containing troops count if mode is 0, otherwise it'll contains the troop speed
|
||||
* @param int $mode How the time should be calculated
|
||||
* @return int Returns the time troops take to walk from a village to another
|
||||
*/
|
||||
|
||||
public function getWalkingTroopsTime($from, $to, $owner, $tribe, $unitArray, $mode, $unit = ""){
|
||||
global $generator, $database;
|
||||
|
||||
$fromCoor = $database->getCoor($from);
|
||||
$toCoor = $database->getCoor($to);
|
||||
$fromCor = ['x' => $fromCoor['x'], 'y' => $fromCoor['y']];
|
||||
$toCor = ['x' => $toCoor['x'], 'y' => $toCoor['y']];
|
||||
|
||||
if(!$mode) return $generator->procDistanceTime($fromCor, $toCor, $unitArray[0], $mode);
|
||||
|
||||
$start = ($tribe - 1) * 10 + 1;
|
||||
$end = $tribe * 10;
|
||||
|
||||
$speeds = [];
|
||||
|
||||
//Find slowest unit
|
||||
if(!empty($unit)){
|
||||
for($i = 1; $i <= 11; $i++){
|
||||
if(isset($unitArray[$unit.$i]) && $unitArray[$unit.$i] > 0) $unitArray[$i - 1] = $unitArray[$unit.$i];
|
||||
else $unitArray[$i - 1] = 0;
|
||||
}
|
||||
}else{
|
||||
for($i = $start; $i <= $end; $i++){
|
||||
if(isset($unitArray['u'.$i]) && $unitArray['u'.$i] > 0) $unitArray[$i - $start] = $unitArray['u'.$i];
|
||||
else $unitArray[$i - $start] = 0;
|
||||
}
|
||||
|
||||
if(isset($unitArray['hero']) && $unitArray['hero'] > 0){
|
||||
$unitArray[10] = $unitArray['hero'];
|
||||
}
|
||||
else $unitArray[10] = 0;
|
||||
}
|
||||
|
||||
for($i = 0; $i <= 9; $i++){
|
||||
if(isset($unitArray[$i]) && $unitArray[$i] > 0){
|
||||
$speeds[] = $GLOBALS['u'.($i + $start)]['speed'];
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($unitArray[10]) && $unitArray[10] > 0){
|
||||
$heroUnit = $database->getHeroField($owner, 'unit');
|
||||
$speeds[] = $GLOBALS['u'.$heroUnit]['speed'];
|
||||
}
|
||||
|
||||
return $generator->procDistanceTime($fromCor, $toCor, min($speeds), $mode);
|
||||
}
|
||||
};
|
||||
|
||||
$units = new Units;
|
||||
|
||||
@@ -78,14 +78,14 @@ if(isset($_POST['ft'])=='check' && (($_POST['send3'] > 1 && $_POST['send3'] <= 3
|
||||
$getvilowner = $database->getVillageField($getwref, "owner");
|
||||
$getvilcoor['y'] = $_POST['y'];
|
||||
$getvilcoor['x'] = $_POST['x'];
|
||||
$time = $generator->procDistanceTime($getvilcoor,$village->coor,$session->tribe,0);
|
||||
$time = $generator->procDistanceTime($getvilcoor, $village->coor, $session->tribe, 0);
|
||||
}
|
||||
else if(!empty($_POST['dname'])){
|
||||
$getwref = $database->getVillageByName($_POST['dname']);
|
||||
$getvilcoor = $database->getCoor($getwref);
|
||||
$getvilname = $database->getVillageField($getwref, "name");
|
||||
$getvilowner = $database->getVillageField($getwref, "owner");
|
||||
$time = $generator->procDistanceTime($getvilcoor,$village->coor,$session->tribe,0);
|
||||
$time = $generator->procDistanceTime($getvilcoor, $village->coor, $session->tribe, 0);
|
||||
}
|
||||
?>
|
||||
<td><a href="karte.php?d=<?php echo $getwref; ?>&c=<?php echo $generator->getMapCheck($getwref); ?>"><?php echo $getvilname; ?>(<?php echo $getvilcoor['x']; ?>|<?php echo $getvilcoor['y']; ?>)<span class="clear"></span></a></td>
|
||||
|
||||
@@ -283,35 +283,8 @@ $end = $tribe * 10;
|
||||
|
||||
|
||||
|
||||
<?php
|
||||
$speeds = [];
|
||||
$scout = 1;
|
||||
|
||||
//find slowest unit.
|
||||
for($i = 1; $i <= 11; $i++)
|
||||
{
|
||||
if (isset($process['t'.$i]))
|
||||
{
|
||||
if(!empty($process['t'.$i]) && $process['t'.$i] > 0)
|
||||
{
|
||||
if ($i < 11) $speeds[] = ${'u'.(($session->tribe-1) * 10 + $i)}['speed'];
|
||||
else
|
||||
{
|
||||
$hero_unit = $database->getHeroField($uid, 'unit');
|
||||
$speeds[] = ${'u'.$hero_unit}['speed'];
|
||||
}
|
||||
if($i != 4) $scout = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($scout) $process['c'] = 1;
|
||||
|
||||
$ownVillage = $database->getCoor($village->wid);
|
||||
$from = ['x' => $ownVillage['x'], 'y' => $ownVillage['y']];
|
||||
$to = ['x' => $coor['x'], 'y' => $coor['y']];
|
||||
|
||||
$troopsTime = $generator->procDistanceTime($from, $to, min($speeds), 1);
|
||||
<?php
|
||||
$troopsTime = $units->getWalkingTroopsTime($village->wid, $process[0], $session->uid, $session->tribe, $process, 1, 't');
|
||||
$time = $database->getArtifactsValueInfluence($session->uid, $village->wid, 2, $troopsTime);
|
||||
?>
|
||||
|
||||
|
||||
+12
-19
@@ -1,25 +1,19 @@
|
||||
<?php
|
||||
//-- Prevent user from founding a new village if there are not enough settlers or the player put an invalid village ID or an already occupied one
|
||||
//-- fix by AL-Kateb - Semplified and additions by iopietro
|
||||
if(($settlers = $village->unitarray['u'.$session->tribe.'0']) < 3 || !isset($_GET['id']) || ($newvillage = $database->getMInfo($_GET['id']))['id'] == 0 || $newvillage['occupied'] > 0 || $newvillage['oasistype'] > 0){
|
||||
header("location: dorf1.php");
|
||||
exit;
|
||||
}
|
||||
//--
|
||||
$wood = round($village->awood);
|
||||
$clay = round($village->aclay);
|
||||
$iron = round($village->airon);
|
||||
$crop = round($village->acrop);
|
||||
$founder = $database->getVillage($village->wid);
|
||||
$newvillage = $database->getMInfo($_GET['id']);
|
||||
$eigen = $database->getCoor($village->wid);
|
||||
$from = array('x'=>$eigen['x'], 'y'=>$eigen['y']);
|
||||
$to = array('x'=>$newvillage['x'], 'y'=>$newvillage['y']);
|
||||
|
||||
$troopsTime = $generator->procDistanceTime($from, $to, 300, 0);
|
||||
$troopsTime = $units->getWalkingTroopsTime($village->wid, $newvillage['id'], 0, 0, [300], 0);
|
||||
$time = $database->getArtifactsValueInfluence($session->uid, $village->wid, 2, $troopsTime);
|
||||
|
||||
//-- Prevent user from founding a new village if there are not enough settlers
|
||||
//-- fix by AL-Kateb - Semplified by iopietro
|
||||
if($village->unitarray['u'.$session->tribe.'0'] < 3){
|
||||
header("location: dorf1.php");
|
||||
exit;
|
||||
}
|
||||
//--
|
||||
|
||||
echo '<pre>';
|
||||
echo '</pre>';
|
||||
?>
|
||||
@@ -29,23 +23,22 @@ echo '</pre>';
|
||||
<input type="hidden" name="c" value="5" />
|
||||
<input type="hidden" name="s" value="<?php echo $_GET['id']; ?>" />
|
||||
<input type="hidden" name="id" value="39" />
|
||||
<input type="hidden" name="timestamp" value="<?php echo $time; ?>" />
|
||||
<table class="troop_details" cellpadding="1" cellspacing="1">
|
||||
<thead>
|
||||
<tr>
|
||||
<td class="role"><a href="karte.php?d=<?php echo (isset($founder['0']) ? $founder['0'] : ''); ?>&c=<?php echo $generator->getMapCheck((isset($founder['0']) ? $founder['0'] : '')); ?>"><?php echo $session->username; ?></a></td><td colspan="10"><a href="karte.php?d=<?php echo $newvillage['id']; ?>&c=<?php echo $generator->getMapCheck($newvillage['0']) ?>">Found new village (<?php echo $newvillage['x']; ?>|<?php echo $newvillage['y']; ?>)</a></td>
|
||||
<td class="role"><a href="spieler.php?uid=<?php echo $session->uid; ?>"><?php echo $session->username; ?></a></td><td colspan="10"><a href="karte.php?d=<?php echo $newvillage['id']; ?>&c=<?php echo $generator->getMapCheck($newvillage[0]) ?>">Found new village (<?php echo $newvillage['x']; ?>|<?php echo $newvillage['y']; ?>)</a></td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="units">
|
||||
<tr>
|
||||
<th> </th>
|
||||
<?php for($i=($session->tribe-1)*10+1;$i<=$session->tribe*10;$i++) {
|
||||
<?php for($i = ($session->tribe-1) * 10 + 1; $i <= $session->tribe * 10; $i++) {
|
||||
echo "<td><img src=\"img/x.gif\" class=\"unit u".$i."\" title=\"".$technology->getUnitName($i)."\" alt=\"".$technology->getUnitName($i)."\" /></td>";
|
||||
} ?>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Troops</th>
|
||||
<?php for($i=1;$i<=9;$i++) {
|
||||
<?php for($i = 1;$i <= 9; $i++) {
|
||||
echo "<td class=\"none\">0</td>";
|
||||
}
|
||||
|
||||
@@ -76,7 +69,7 @@ echo '</pre>';
|
||||
</table>
|
||||
<p class="btn">
|
||||
<?php
|
||||
if ($wood>749 && $clay>749 && $iron>749 && $crop>749) {
|
||||
if ($wood >= 750 && $clay >= 750 && $iron >= 750 && $crop >= 750) {
|
||||
?>
|
||||
<input type="image" value="ok" name="s1" id="btn_ok" class="dynamic_img" alt="OK" src="img/x.gif" onclick="this.disabled=true;this.form.submit();"/>
|
||||
<?php
|
||||
|
||||
@@ -3,9 +3,6 @@ $to = $database->getVillage($enforce['from']);
|
||||
$fromcoor = $database->getCoor($enforce['from']);
|
||||
$tocoor = $database->getCoor($enforce['vref']);
|
||||
|
||||
$fromCor = ['x'=>$tocoor['x'], 'y'=>$tocoor['y']];
|
||||
$toCor = ['x'=>$fromcoor['x'], 'y'=>$fromcoor['y']];
|
||||
|
||||
$att_tribe = $database->getUserField($to['owner'],'tribe',0);
|
||||
$start = ($att_tribe - 1) * 10 + 1;
|
||||
$end = $att_tribe * 10;
|
||||
@@ -124,28 +121,7 @@ $end = $att_tribe * 10;
|
||||
<th>Arrived:</th>
|
||||
|
||||
<?php
|
||||
$speeds = [];
|
||||
//find slowest unit.
|
||||
for($i = $start; $i <= $end; $i++)
|
||||
{
|
||||
if (isset($enforce['u'.$i]))
|
||||
{
|
||||
if(!empty($enforce['u'.$i]) && $enforce['u'.$i] > 0)
|
||||
{
|
||||
$speeds[] = ${'u'.$i}['speed'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($enforce['hero']>0){
|
||||
$qh = "SELECT unit FROM ".TB_PREFIX."hero WHERE uid = ".(int) $to['owner']." AND dead = 0";
|
||||
$resulth = mysqli_query($database->dblink,$qh);
|
||||
$hero_f=mysqli_fetch_array($resulth);
|
||||
$hero_unit=$hero_f['unit'];
|
||||
$speeds[] = $GLOBALS['u'.$hero_unit]['speed'];
|
||||
}
|
||||
|
||||
$troopsTime = $generator->procDistanceTime($fromCor, $toCor, min($speeds), 1);
|
||||
$troopsTime = $units->getWalkingTroopsTime($enforce['from'], $enforce['vref'], $to['owner'], $att_tribe, $enforce, 1);
|
||||
$time = $database->getArtifactsValueInfluence($session->uid, $village->wid, 2, $troopsTime);
|
||||
?>
|
||||
|
||||
|
||||
@@ -60,33 +60,8 @@
|
||||
$id = $database->addA2b( $ckey, $time_now, $wref, $t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10, $t11, 4 );
|
||||
|
||||
$data = $database->getA2b( $ckey, $time_now );
|
||||
|
||||
$eigen = $database->getCoor( $getFLData['wref'] );
|
||||
$from = array( 'x' => $eigen['x'], 'y' => $eigen['y'] );
|
||||
|
||||
$ander = $database->getCoor( $data['to_vid'] );
|
||||
$to = array( 'x' => $ander['x'], 'y' => $ander['y'] );
|
||||
|
||||
$start = ( $tribe - 1 ) * 10 + 1;
|
||||
$end = ( $tribe * 10 );
|
||||
|
||||
$speeds = array();
|
||||
$scout = 1;
|
||||
|
||||
//find slowest unit.
|
||||
for ( $i = 1; $i <= 10; $i ++ ) {
|
||||
if ( $data[ 'u' . $i ] ) {
|
||||
if ( $data[ 'u' . $i ] != '' && $data[ 'u' . $i ] > 0 ) {
|
||||
if ( $unitarray ) {
|
||||
reset( $unitarray );
|
||||
}
|
||||
$unitarray = $GLOBALS[ "u" . ( ( $tribe - 1 ) * 10 + $i ) ];
|
||||
$speeds[] = $unitarray['speed'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$troopsTime = $generator->procDistanceTime($from, $to, min($speeds), 1);
|
||||
$troopsTime = $units->getWalkingTroopsTime($getFLData['wref'], $data['to_vid'], $session->uid, $session->tribe, $data, 1, 'u');
|
||||
$time = $database->getArtifactsValueInfluence($getFLData['owner'], $getFLData['wref'], 2, $troopsTime);
|
||||
|
||||
$ctar1 = $ctar2 = 0;
|
||||
@@ -114,8 +89,8 @@
|
||||
$amounts[] = $data['u11'];
|
||||
$modes[] = 0;
|
||||
|
||||
$database->modifyUnit( $getFLData['wref'], $units, $amounts, $modes );
|
||||
$database->addMovement( 3, $getFLData['wref'], $data['to_vid'], $reference, time(), ( $time + time() ) );
|
||||
$database->modifyUnit($getFLData['wref'], $units, $amounts, $modes);
|
||||
$database->addMovement(3, $getFLData['wref'], $data['to_vid'], $reference, time(), ($time + time()));
|
||||
|
||||
// prevent re-use of the same attack via re-POSTing the same data
|
||||
$database->remA2b( $id );
|
||||
|
||||
+31
-2
@@ -10,7 +10,36 @@
|
||||
#################################################################################
|
||||
|
||||
|
||||
$txt="";
|
||||
$txt="Construction plans
|
||||
|
||||
|
||||
|
||||
Countless days have passed since the first battles upon the walls of the cursed villages of the Dread Natars, many armies of both the free ones and the Natarian empire struggled and died before the walls of the many strongholds from which the Natars had once ruled all creation. Now with the dust settled and a relative calm having settled in, armies began to count their losses and collect their dead, the stench of combat still lingering in the night air, a smell of a slaughter unforgettable in its extent and brutality yet soon to be dwarfed by yet others. The largest armies of the free ones and the Dread Natars were marshalling for yet another renewed assault upon the coveted former strongholds of the Natarian Empire.
|
||||
|
||||
Soon scouts arrived telling of a most awesome sight and a chilling reminder, a dread army of an unfathomable size had been spotted marshalling at the end of the world, the Natarian capital, a force so great and unstoppable that the dust from their march would choke off all light, a force so brutal and ruthless that it would crush all hope. The free people knew that they had to race now, race against time and the endless hordes of the Natarian Empire to raise a Wonder of the World to restore the world to peace and vanquish the Natarian threat.
|
||||
|
||||
But to raise such a great Wonder would be no easy task, one would need construction plans created in the distant past, plans of such an arcane nature that even the very wisest of sages knew not their contents or locations.
|
||||
|
||||
Tens of thousands of scouts roamed across all existence searching in vain for these mystical plans, looking in all places but the dreaded Natarian Capital, yet could not find them. Today however, they return bearing good news, they return baring the locations of the plans, hidden by the armies of the Natars inside secret strongholds constructed to be hidden from the eyes of man.
|
||||
|
||||
Now begins the final stretch, when the greatest armies of the Free people and the Natars will clash across the world for the fate of all that lies under heaven. This is the war that will echo across the eons, this is your war, and here you shall etch your name across history, here you shall become legend.
|
||||
|
||||
|
||||
Facts:
|
||||
To steal one, the following things must happen:
|
||||
You must attack the village (NO Raid!)
|
||||
WIN the Attack
|
||||
Destroy the treasury
|
||||
An empty treasury lvl 10 MUST be in the village where that attack came from
|
||||
Have a hero in an attack
|
||||
|
||||
If not, the next attack on that village, winning with a hero and empty treasury will take the building plan.
|
||||
|
||||
To build a WW, you must own a plan yourself (you = the WW village owner) from lvl 0 to 50, from 51 to 100 you need an additional plan in your alliance! Two plans in the WW village account would not work!
|
||||
|
||||
The construction plans are conquerable immediately when they appear to the server.
|
||||
|
||||
There will be a countdown in game, showing the exact time of the release, 5 days prior to the launch. ";
|
||||
|
||||
//bbcode = html code
|
||||
$txt = preg_replace("/\[b\]/is",'<b>', $txt);
|
||||
@@ -23,4 +52,4 @@ $txt = preg_replace("/\[\/u\]/is",'</u>', $txt);
|
||||
//nl2br = enter
|
||||
echo nl2br($txt);
|
||||
|
||||
?>
|
||||
?>
|
||||
@@ -175,34 +175,9 @@ if(isset($_GET['o'])) {
|
||||
$prisoner = $database->getPrisonersByID($delprisoners);
|
||||
if($prisoner['wref'] == $village->wid){
|
||||
$p_owner = $database->getVillageField($prisoner['from'],"owner");
|
||||
$p_eigen = $database->getCoor($prisoner['wref']);
|
||||
$p_from = array('x'=>$p_eigen['x'], 'y'=>$p_eigen['y']);
|
||||
$p_ander = $database->getCoor($prisoner['from']);
|
||||
$p_to = array('x'=>$p_ander['x'], 'y'=>$p_ander['y']);
|
||||
$p_tribe = $database->getUserField($p_owner,"tribe",0);
|
||||
|
||||
$p_speeds = array();
|
||||
|
||||
//find slowest unit.
|
||||
for($i=1;$i<=10;$i++){
|
||||
if ($prisoner['t'.$i]){
|
||||
if($prisoner['t'.$i] != '' && $prisoner['t'.$i] > 0){
|
||||
if($p_unitarray) { reset($p_unitarray); }
|
||||
$p_unitarray = $GLOBALS["u".(($p_tribe-1)*10+$i)];
|
||||
$p_speeds[] = $p_unitarray['speed'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($prisoner['t11']>0){
|
||||
$p_qh = "SELECT unit FROM ".TB_PREFIX."hero WHERE uid = ".(int) $p_owner." AND dead = 0";
|
||||
$p_resulth = mysqli_query($database->dblink,$p_qh);
|
||||
$p_hero_f=mysqli_fetch_array($p_resulth);
|
||||
$p_hero_unit=$p_hero_f['unit'];
|
||||
$p_speeds[] = $GLOBALS['u'.$p_hero_unit]['speed'];
|
||||
}
|
||||
|
||||
$troopsTime = $automation->procDistanceTime($p_to, $p_from, min($p_speeds), 1);
|
||||
$troopsTime = $units->getWalkingTroopsTime($prisoner['from'], $prisoner['wref'], $p_owner, $p_tribe, $prisoner, 1, 't');
|
||||
$p_time = $database->getArtifactsValueInfluence($p_owner, $prisoner['from'], 2, $troopsTime);
|
||||
|
||||
$p_reference = $database->addAttack($prisoner['from'],$prisoner['t1'],$prisoner['t2'],$prisoner['t3'],$prisoner['t4'],$prisoner['t5'],$prisoner['t6'],$prisoner['t7'],$prisoner['t8'],$prisoner['t9'],$prisoner['t10'],$prisoner['t11'],3,0,0,0,0,0,0,0,0,0,0,0);
|
||||
|
||||
Reference in New Issue
Block a user