/**
  */
 public function testInvalidOpponentMoves()
 {
     // the parser
     $inputParser = new \Mastercoding\Conquest\Command\Parser\Parser();
     // bot test
     $this->setExpectedException('\\Mastercoding\\Conquest\\Command\\Parser\\GenericException');
     $command = $inputParser->parse('opponent_moves blal');
 }
Пример #2
0
 public function testStartingArmies()
 {
     // the parser
     $inputParser = new \Mastercoding\Conquest\Command\Parser\Parser();
     // bot test
     $command = $inputParser->parse('settings starting_armies 25');
     $this->assertInstanceOf('\\Mastercoding\\Conquest\\Command\\Settings\\StartingArmies', $command);
     // name
     $this->assertEquals(25, $command->getAmount());
 }
Пример #3
0
 public function testAttackTransfer()
 {
     // the parser
     $inputParser = new \Mastercoding\Conquest\Command\Parser\Parser();
     // bot test
     $command = $inputParser->parse('go attack/transfer 1000');
     $this->assertInstanceOf('\\Mastercoding\\Conquest\\Command\\Go\\AttackTransfer', $command);
     // timeout
     $this->assertEquals('1000', $command->getTimeout());
 }
 public function testPick()
 {
     // the parser
     $inputParser = new \Mastercoding\Conquest\Command\Parser\Parser();
     // bot test
     $command = $inputParser->parse('pick_starting_regions 2000 1 7 12 13 18 15 24');
     $this->assertInstanceOf('\\Mastercoding\\Conquest\\Command\\StartingRegions\\Pick', $command);
     // timeout
     $this->assertEquals('2000', $command->getTimeout());
     // region ids
     $this->assertEquals(array(1, 7, 12, 13, 18, 15, 24), $command->getRegionIds());
 }
Пример #5
0
 public function setup()
 {
     // bot
     $map = new \Mastercoding\Conquest\Object\Map();
     $eventDispatcher = new \Symfony\Component\EventDispatcher\EventDispatcher();
     $bot = new \Mastercoding\Conquest\Bot\SimpleBot($map, $eventDispatcher);
     $commandParser = new \Mastercoding\Conquest\Command\Parser\Parser();
     $setupCommands = file(dirname(__FILE__) . '/../setup.txt');
     // process
     foreach ($setupCommands as $line) {
         $command = $commandParser->parse($line);
         $bot->processCommand($command);
     }
     $this->map = $bot->getMap();
 }
Пример #6
0
 public function testNeighbors()
 {
     // the parser
     $inputParser = new \Mastercoding\Conquest\Command\Parser\Parser();
     // bot test
     $command = $inputParser->parse('setup_map neighbors 1 2,3,4 2 3 4 5');
     $this->assertInstanceOf('\\Mastercoding\\Conquest\\Command\\SetupMap\\Neighbors', $command);
     // region connections
     $regions = array(1 => array(2, 3, 4), 2 => array(1, 3), 3 => array(1, 2), 4 => array(1, 5), 5 => array(4));
     $neighbors = $command->getNeighbors();
     foreach ($regions as $regionId => $neighborIds) {
         $this->assertEquals(count($neighborIds), count($neighbors[$regionId]));
         $this->assertEquals($neighborIds, $neighbors[$regionId]);
     }
 }
Пример #7
0
 public function testUpdate()
 {
     // the parser
     $inputParser = new \Mastercoding\Conquest\Command\Parser\Parser();
     // bot test
     $command = $inputParser->parse('update_map 13 player1 2 24 player1 2 33 player1 2 11 neutral 4');
     $this->assertInstanceOf('\\Mastercoding\\Conquest\\Command\\UpdateMap\\Update', $command);
     // timeout
     $updates = array();
     $updates[] = array('regionId' => 13, 'owner' => 'player1', 'armies' => 2);
     $updates[] = array('regionId' => 24, 'owner' => 'player1', 'armies' => 2);
     $updates[] = array('regionId' => 33, 'owner' => 'player1', 'armies' => 2);
     $updates[] = array('regionId' => 11, 'owner' => 'neutral', 'armies' => 4);
     // region ids
     $this->assertEquals($updates, $command->getUpdates());
 }
Пример #8
0
 /**
  * @depends testUpdateMap
  */
 public function testOpponentMoves(\Mastercoding\Conquest\Object\Map $map)
 {
     $commandParser = new \Mastercoding\Conquest\Command\Parser\Parser();
     $lastUpdateCommand = $commandParser->parse('update_map 1 player1 4');
     $this->mapUpdater->updateMap($map, $lastUpdateCommand);
     // opponent moves
     $opponentMovesCommand = $commandParser->parse('opponent_moves player2 attack/transfer 42 1 3 player2 attack/transfer 42 2 5');
     // update
     $this->mapUpdater->uppateOpponentMoves($map, $opponentMovesCommand, $lastUpdateCommand);
     // verify
     $this->assertEquals('player1', $map->getRegionById(1)->getOwner()->getName());
     $this->assertEquals(4, $map->getRegionById(1)->getArmies());
     $this->assertEquals('player2', $map->getRegionById(2)->getOwner()->getName());
     $this->assertEquals(5, $map->getRegionById(2)->getArmies());
 }