diff --git a/GameEngine/Automation.php b/GameEngine/Automation.php
index 895d0927..f08f080d 100644
--- a/GameEngine/Automation.php
+++ b/GameEngine/Automation.php
@@ -169,6 +169,8 @@ class Automation {
$this->demolitionComplete();
}
$this->updateStore();
+ $this->delTradeRoute();
+ $this->TradeRoute();
if(!file_exists("GameEngine/Prevention/market.txt") or time()-filemtime("GameEngine/Prevention/market.txt")>10) {
$this->marketComplete();
}
@@ -528,9 +530,28 @@ class Automation {
$cp = $dataarray[($level+1)]['cp'];
return array($pop,$cp);
}
+
+ private function delTradeRoute() {
+ global $database;
+ $time = time();
+ $q = "DELETE from ".TB_PREFIX."route where timeleft < $time";
+ $database->query($q);
+ }
+
+ private function TradeRoute() {
+ global $database;
+ $time = time();
+ $q = "SELECT * FROM ".TB_PREFIX."route where timestamp < $time";
+ $dataarray = $database->query_return($q);
+ foreach($dataarray as $data) {
+ $targettribe = $database->getUserField($database->getVillageField($data['from'],"owner"),"tribe",0);
+ $this->sendResource2($data['wood'],$data['clay'],$data['iron'],$data['crop'],$data['from'],$data['wid'],$targettribe,$data['deliveries']);
+ $database->editTradeRoute($data['id'],"timestamp",86400,1);
+ }
+ }
private function marketComplete() {
- global $database,$generator;
+ global $database;
$ourFileHandle = @fopen("GameEngine/Prevention/market.txt", 'w');
@fclose($ourFileHandle);
$time = time();
@@ -2143,13 +2164,9 @@ $crannyimg = "
0){
- $unitssend_att_check=$unitssend_att.','.$data['t11'];
- }else{
- $unitssend_att_check=$unitssend_att;
- }
+ $unitssend_att= $unitssend_att1.','.$herosend_att;
$speeds = array();
@@ -2172,8 +2189,8 @@ $crannyimg = "
procDistanceTime($from,$to,min($speeds),1) + time();
$database->setMovementProc($data['moveid']);
$database->addMovement(4,$to['wref'],$from['wref'],$data['ref'],time(),$endtime);
-
- $data2 = ''.$from['owner'].','.$from['wref'].','.$to['owner'].','.$owntribe.','.$unitssend_att_check.'';
+ $peace = PEACE;
+ $data2 = ''.$from['owner'].','.$from['wref'].','.$to['owner'].','.$owntribe.','.$unitssend_att.','.$peace.'';
$database->addNotice($from['owner'],$to['wref'],$ownally,22,''.addslashes($from['name']).' attacks '.addslashes($to['name']).'',$data2,time());
$database->addNotice($to['owner'],$to['wref'],$targetally,22,''.addslashes($from['name']).' attacks '.addslashes($to['name']).'',$data2,time());
}
@@ -3049,7 +3066,7 @@ $crannyimg = "
modifyHero("lastupdate",time(),$hdata['heroid']);
}
- if ($hdata['experience'] > $hero_levels[$hdata['level']+1]) {
+ if ($hdata['experience'] > $hero_levels[$hdata['level']+1] && $hdata['level'] < 100) {
mysql_query("UPDATE " . TB_PREFIX ."hero SET level = level + 1 WHERE heroid = '".$hdata['heroid']."'");
mysql_query("UPDATE " . TB_PREFIX ."hero SET points = points + 5 WHERE heroid = '".$hdata['heroid']."'");
}
diff --git a/GameEngine/Database/db_MYSQL.php b/GameEngine/Database/db_MYSQL.php
index c0f9d1a0..cab861bf 100644
--- a/GameEngine/Database/db_MYSQL.php
+++ b/GameEngine/Database/db_MYSQL.php
@@ -565,13 +565,11 @@
}
function populateOasisUnitsHigh() {
- $q2 = "SELECT * FROM " . TB_PREFIX . "wdata where oasistype != 0";
- $result2 = mysql_query($q2, $this->connection);
- while($row = mysql_fetch_array($result2)) {
- $wid = $row['id'];
- $basearray = $this->getMInfo($wid);
- //each Troop is a Set for oasis type like mountains have rats spiders and snakes fields tigers elphants clay wolves so on stonger one more not so less
- switch($basearray['oasistype']) {
+ $q2 = "SELECT * FROM " . TB_PREFIX . "wdata where oasistype != 0";
+ $result2 = mysql_query($q2, $this->connection);
+ while($row = mysql_fetch_array($result2)) {
+ $wid = $row['id'];
+ switch($row['oasistype']) {
case 1:
case 2:
//+25% lumber per hour
@@ -1603,6 +1601,48 @@
$result = mysql_query($q, $this->connection);
return $this->mysql_fetch_all($result);
}
+
+ function createTradeRoute($uid,$wid,$from,$r1,$r2,$r3,$r4,$start,$deliveries,$merchant,$time) {
+ $x = "UPDATE " . TB_PREFIX . "users SET gold = gold - 2 WHERE id = ".$uid."";
+ mysql_query($x, $this->connection);
+ $timeleft = time()+604800;
+ $q = "INSERT into " . TB_PREFIX . "route values (0,$uid,$wid,$from,$r1,$r2,$r3,$r4,$start,$deliveries,$merchant,$time,$timeleft)";
+ return mysql_query($q, $this->connection);
+ }
+
+ function getTradeRoute($uid) {
+ $q = "SELECT * FROM " . TB_PREFIX . "route where uid = $uid ORDER BY timestamp ASC";
+ $result = mysql_query($q, $this->connection);
+ return $this->mysql_fetch_all($result);
+ }
+
+ function getTradeRoute2($id) {
+ $q = "SELECT * FROM " . TB_PREFIX . "route where id = $id";
+ $result = mysql_query($q, $this->connection) or die(mysql_error());
+ $dbarray = mysql_fetch_array($result);
+ return $dbarray;
+ }
+
+ function getTradeRouteUid($id) {
+ $q = "SELECT * FROM " . TB_PREFIX . "route where id = $id";
+ $result = mysql_query($q, $this->connection) or die(mysql_error());
+ $dbarray = mysql_fetch_array($result);
+ return $dbarray['uid'];
+ }
+
+ function editTradeRoute($id,$column,$value,$mode) {
+ if(!$mode){
+ $q = "UPDATE " . TB_PREFIX . "route set $column = $value where id = $id";
+ }else{
+ $q = "UPDATE " . TB_PREFIX . "route set $column = $column + $value where id = $id";
+ }
+ return mysql_query($q, $this->connection);
+ }
+
+ function deleteTradeRoute($id) {
+ $q = "DELETE FROM " . TB_PREFIX . "route where id = $id";
+ return mysql_query($q, $this->connection);
+ }
function addBuilding($wid, $field, $type, $loop, $time, $master, $level) {
$x = "UPDATE " . TB_PREFIX . "fdata SET f" . $field . "t=" . $type . " WHERE vref=" . $wid;
@@ -2720,7 +2760,7 @@
}
function getOwnArtefactInfoByType($vref, $type) {
- $q = "SELECT * FROM " . TB_PREFIX . "artefacts WHERE vref = $vref AND type = $type";
+ $q = "SELECT * FROM " . TB_PREFIX . "artefacts WHERE vref = $vref AND type = $type order by size";
$result = mysql_query($q, $this->connection);
return mysql_fetch_array($result);
}
@@ -2737,6 +2777,15 @@
return mysql_fetch_array($result);
}
+ function getOwnUniqueArtefactInfo2($id, $type, $size, $mode) {
+ if(!$mode){
+ $q = "SELECT * FROM " . TB_PREFIX . "artefacts WHERE owner = $id AND type = $type AND size=$size";
+ }else{
+ $q = "SELECT * FROM " . TB_PREFIX . "artefacts WHERE vref = $id AND type = $type AND size=$size";
+ }
+ return mysql_query($q, $this->connection);
+ }
+
function getArtefactInfo() {
$q = "SELECT * FROM " . TB_PREFIX . "artefacts WHERE id > 0";
$result = mysql_query($q, $this->connection);
diff --git a/GameEngine/Technology.php b/GameEngine/Technology.php
index a5b657c3..468af50c 100644
--- a/GameEngine/Technology.php
+++ b/GameEngine/Technology.php
@@ -401,7 +401,18 @@ class Technology {
// $unit = "hero";
// global $$unit;
// $dataarray = $$unit;
- $upkeep += $array['hero'] * 6;
+ $upkeep += $array['hero'] * 6;
+ $artefact = count($database->getOwnUniqueArtefactInfo2($session->uid,4,3,0));
+ $artefact1 = count($database->getOwnUniqueArtefactInfo2($vid,4,1,1));
+ $artefact2 = count($database->getOwnUniqueArtefactInfo2($session->uid,4,2,0));
+ if($artefact > 0){
+ $upkeep /= 2;
+ }else if($artefact1 > 1){
+ $upkeep /= 2;
+ }else if($artefact2 > 1){
+ $upkeep /= 4;
+ $upkeep *= 3;
+ }
return $upkeep;
}
diff --git a/Templates/Build/17_3.tpl b/Templates/Build/17_3.tpl
index 4b647b27..81cf171f 100644
--- a/Templates/Build/17_3.tpl
+++ b/Templates/Build/17_3.tpl
@@ -1,3 +1,4 @@
+gold > 2){ ?>
+
+At the Marketplace you can trade resources with other players. The higher its level, the more resources can be transported at the same time. +
+ +gold > 1){ +$routeaccess = 1; +include("17_create.tpl"); +}else if($_GET['action'] == 'editRoute' && isset($_GET['routeid']) && $_GET['routeid'] != ""){ +$traderoute = $database->getTradeRouteUid($_GET['routeid']); +if($traderoute == $session->uid){ +include("17_edit.tpl"); +} +}else{ +?> + +Trade route allows you to set up routes for your merchant that he will walk every day at a certain hour.
+Standard this holds on for 7 days, but you can extend it with 7 days for the cost of
2.
| + | description | +start | +Merchants | +time left | +No active trade route. | "; + }else{ +foreach($routes as $route){ +?> +
|---|---|---|---|---|
| + | +getMapCheck($route['wid']).">".$database->getVillageField($route['wid'],"name")."" +?> + | +9){ echo $route['start'];}else{ echo "0".$route['start'];} echo ":00"; ?> | ++ | + |
| + | ++ extend* + | edit + | delete + | |||
2
+