Exemplo n.º 1
0
 public function testAttackTransfer()
 {
     $move = new \Mastercoding\Conquest\Move\AttackTransfer();
     $move->setPlayerName('test');
     $move->addAttackTransfer(1, 3, 3);
     $move->addAttackTransfer(1, 4, 2);
     // output
     $this->assertEquals('test attack/transfer 1 3 3,test attack/transfer 1 4 2', $move->toString());
 }
Exemplo n.º 2
0
 /**
  * @inheritDoc
  */
 public static function create($components)
 {
     // set timeout
     $moves = new self();
     // no moves?
     if (count($components) == 1) {
         return $moves;
     }
     for ($i = 1; $i < count($components);) {
         switch ($components[$i + 1]) {
             case 'place_armies':
                 $placeArmiesMove = new \Mastercoding\Conquest\Move\PlaceArmies();
                 $placeArmiesMove->setPlayerName($components[$i]);
                 $placeArmiesMove->addPlaceArmies($components[$i + 2], $components[$i + 3]);
                 $moves->addMove($placeArmiesMove);
                 $i += 4;
                 break;
             case 'attack/transfer':
                 $attackTransferMove = new \Mastercoding\Conquest\Move\AttackTransfer();
                 $attackTransferMove->setPlayerName($components[$i]);
                 $attackTransferMove->addAttackTransfer($components[$i + 2], $components[$i + 3], $components[$i + 4]);
                 $moves->addMove($attackTransferMove);
                 $i += 5;
                 break;
             default:
                 throw new \Mastercoding\Conquest\Command\Parser\GenericException('Invalid opponent moves');
         }
     }
     return $moves;
 }