示例#1
0
文件: HitTest.php 项目: iannsp/phpwar
 /**
  * @test
  */
 public function play_to_Neutralize()
 {
     $scoreStrategy = array('Hit' => '\\Iannsp\\PhpWar\\Game\\Score\\Hit');
     $arenaLimits = new CartesianPoint(2, 2);
     $arena = new Arena($arenaLimits, $scoreStrategy);
     $this->assertCount(1, $arena->play('X', new Move(1, 1))->getWinners(), 'Win by empty position');
     $this->assertCount(1, $arena->play('Y', new Move(1, 1))->getNeutralizeds(), 'Neutralize X in position');
     $this->assertCount(1, $arena->play('Y', new Move(1, 1))->getWinners(), 'Win by neutrilized(empty) position');
     $this->assertCount(1, $arena->play('X', new Move(1, 1))->getNeutralizeds(), 'Neutralize Y in position');
     $feedback = $arena->play('Y', new Move(1, 1));
     $this->assertCount(1, $feedback->getWinners(), 'Win by neutrilized(empty) position');
     $this->assertCount(0, $feedback->getLosers(), 'No Losers');
     $this->assertCount(0, $feedback->getNeutralizeds(), 'No Neutralized');
 }
示例#2
0
 /**
  * @test
  */
 public function play_to_Lose()
 {
     $scoreStrategy = array('Hit' => '\\Iannsp\\PhpWar\\Game\\Score\\Neibor');
     $arenaLimits = new CartesianPoint(2, 2);
     $arena = new Arena($arenaLimits, $scoreStrategy);
     $this->assertCount(1, $arena->play('X', new Move(1, 1))->getWinners(), 'Win by empty position');
     $this->assertCount(1, $arena->play('Y', new Move(1, 1))->getWinners(), 'Win because has no Hit Rule');
     $this->assertCount(1, $arena->play('X', new Move(1, 1))->getWinners(), 'Win because has no Hit Rule');
     $this->assertCount(1, $arena->play('X', new Move(0, 1))->getWinners(), 'Win by empty position');
     $feedback = $arena->play('Y', new Move(0, 2));
     $this->assertCount(0, $feedback->getWinners(), '2 X neighbors made Y lose');
     $this->assertCount(1, $feedback->getLosers(), 'Lose the warrior');
     $this->assertCount(0, $feedback->getNeutralizeds(), 'No Neutralizeds');
 }