diff --git a/GameEngine/Automation.php b/GameEngine/Automation.php index 6df61b30..bc413b18 100644 --- a/GameEngine/Automation.php +++ b/GameEngine/Automation.php @@ -150,6 +150,7 @@ class Automation { $this->oasisResoucesProduce(); $this->pruneResource(); $this->pruneOResource(); + $this->checkWWAttacks(); if(!file_exists("GameEngine/Prevention/culturepoints.txt") or time()-filemtime("GameEngine/Prevention/culturepoints.txt")>10) { $this->culturePoints(); } @@ -527,8 +528,9 @@ class Automation { } // by SlimShady95 aka Manuel Mannhardt < manuel_mannhardt@web.de > - private function startNatarAttack($level, $vid) { - global $database; + private function startNatarAttack($level, $vid) { + global $database; + // bad, but should work :D // I took the data from my first ww (first .org world) // todo: get the algo from the real travian with the 100 biggest @@ -556,7 +558,7 @@ class Automation { 25 => array( array(6004, 5977, 7400, 7277, 23, 0), - array(152, 499, 220, 58, 37) + array(152, 0, 499, 220, 58, 37) ), 30 => array( @@ -649,7 +651,7 @@ class Automation { array(872, 0, 3025, 1338, 317, 208) ) ); - + // select the troops^^ if (isset($troops[$level])) { @@ -659,18 +661,37 @@ class Automation { { return false; } - + // get the capital village from the natars $query = mysql_query('SELECT `wref` FROM `' . TB_PREFIX . 'vdata` WHERE `owner` = 3 and `capital` = 1 LIMIT 1') or die(mysql_error()); $row = mysql_fetch_assoc($query); - + // start the attacks $endtime = time() + round((60 * 60 * 24) / SPEED); + + // -.- + mysql_query('INSERT INTO `' . TB_PREFIX . 'ww_attacks` (`vid`, `attack_time`) VALUES (' . $vid . ', ' . $endtime . ')'); + mysql_query('INSERT INTO `' . TB_PREFIX . 'ww_attacks` (`vid`, `attack_time`) VALUES (' . $vid . ', ' . ($endtime + 1) . ')'); + + // wave 1 $ref = $database->addAttack($row['wref'], 0, $units[0][0], $units[0][1], 0, $units[0][2], $units[0][3], $units[0][4], $units[0][5], 0, 0, 0, 3, 0, 0, 0, 0, 20, 20, 0, 20, 20, 20, 20); $database->addMovement(3, $row['wref'], $vid, $ref, time(), $endtime); - - $ref2 = $database->addAttack($row['wref'], 0, $units[1][0], $units[1][1], 0, $units[1][2], $units[1][3], $units[1][4], $units[1][5], 0, 0, 0, 3, 40, 0, 0, 0, 20, 20, 0, 20, 20, 20, 20); - $database->addMovement(3, $row['wref'], $vid, $ref2, time(), $endtime + 1); + + // wave 2 + $ref2 = $database->addAttack($row['wref'], 0, $units[1][0], $units[1][1], 0, $units[1][2], $units[1][3], $units[1][4], $units[1][5], 0, 0, 0, 3, 40, 0, 0, 0, 20, 20, 0, 20, 20, 20, 20, array('vid' => $vid, 'endtime' => ($endtime + 1))); + $database->addMovement(3, $row['wref'], $vid, $ref2, time(), $endtime + 1); + } + + private function checkWWAttacks() { + $query = mysql_query('SELECT * FROM `' . TB_PREFIX . 'ww_attacks` WHERE `attack_time` <= ' . time()); + while ($row = mysql_fetch_assoc($query)) + { + // fix for destroyed wws + $query2 = mysql_query('UPDATE `' . TB_PREFIX . 'fdata` SET `f90t` = 40 WHERE `vref` = ' . $row['vid']); + + // delete the attack + $query3 = mysql_query('DELETE FROM `' . TB_PREFIX . 'ww_attacks` WHERE `vid` = ' . $row['vid'] . ' AND `attack_time` = ' . $row['attack_time']); + } } private function getPop($tid,$level) { diff --git a/Templates/Ranking/ww.tpl b/Templates/Ranking/ww.tpl index f3834b90..728f6daa 100644 --- a/Templates/Ranking/ww.tpl +++ b/Templates/Ranking/ww.tpl @@ -1,53 +1,52 @@ - - - - - - - - - - - - - - - - - getAlliance($row[alliance]); - ?> - - - - - - - - - - \ No newline at end of file + +
- Wonder of the world -
PlayerNameAllianceLevel
.getMapCheck($row['vref'])."\">"; - ?> - - -
+ + + + + + + + + + + + + + + getAlliance($row[alliance]); + $query = @mysql_query('SELECT * FROM `' . TB_PREFIX . 'ww_attacks` WHERE `vid` = ' . $row['vref'] . ' ORDER BY `attack_time` ASC LIMIT 1'); + $row2 = @mysql_fetch_assoc($query); + ?> + + + + + + + + + + + + + \ No newline at end of file diff --git a/install/data/sql.sql b/install/data/sql.sql index b8c21747..7aa83657 100644 --- a/install/data/sql.sql +++ b/install/data/sql.sql @@ -1437,4 +1437,24 @@ CREATE TABLE IF NOT EXISTS `%PREFIX%password` ( `used` tinyint(1) NOT NULL DEFAULT '0', `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`uid`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 ; \ No newline at end of file +) ENGINE=MyISAM DEFAULT CHARSET=utf8 ; + +-- +-- Dumping data for table `%prefix%password` +-- + +-- -------------------------------------------------------- +-- +-- Table structure for table `%prefix%ww_attacks` +-- + +CREATE TABLE IF NOT EXISTS `%PREFIX%ww_attacks` ( + `vid` int(25) NOT NULL, + `attack_time` int(25) NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8 ; + +-- +-- Dumping data for table `%prefix%password` +-- + +-- -------------------------------------------------------- \ No newline at end of file
Wonder of the world
PlayerNameAllianceLevel
.getMapCheck($row['vref']) . "\">"; ?>