Ejemplo n.º 1
0
 def test_reorderbattalions(self):
     p1 = HumanPlayers("Pepe", 35, "orange", [])
     c1 = Country('Europa del norte', p1)
     c1.changebattalions(3)
     c2 = Country('América central', p1)
     c2.changebattalions(7)
     p1.addconqueredcountry(c1)
     p2.addconqueredcountry(c1)
     playersExpected = [p1]
     game = Game()
     game.initplayers(playersExpected)
     game.reorderbattalions(p1, c2, c1, 5)
     self.assertEqual(8, c1.getbattalions())
     self.assertEqual(2, c2.getbattalions())
Ejemplo n.º 2
0
 def test_processresult(self):
     p1 = HumanPlayers("Pepe", initBattalions, "orange", [])
     p2 = HumanPlayers("Ana", initBattalions, "red", [])
     c1 = Country('Europa del norte', p1)
     c1.changebattalions(3)
     c2 = Country('América central', p2)
     c2.changebattalions(7)
     p1.addconqueredcountry(c1)
     p2.addconqueredcountry(c2)
     playersExpected = [p1, p2]
     game = Game()
     game.initplayers(playersExpected)
     rollResult = [0, -1]
     result = [rollResult, c1, c2]
     game.processresult(result)
     self.assertEqual(2, c1.getbattalions())
     self.assertEqual(6, c2.getbattalions())
     rollResult = [0, 0]
     result = [rollResult, c2, c1]
     game.processresult(result)
     self.assertEqual(1, c1.getbattalions())
     self.assertEqual(p2.isequal(c1.getconqueror()), True)
Ejemplo n.º 3
0
 def battalionstodefendok(self, defendingCountry, numBattalions):
     totalBattalions = Country.getbattalions(defendingCountry)
     if numBattalions > 0 and numBattalions <= 2 and (totalBattalions -
                                                      numBattalions) >= 0:
         return True
     return False
Ejemplo n.º 4
0
 def battalionstoattackok(self, attackingCountry, numBattalions):
     totalBattalions = Country.getbattalions(attackingCountry)
     if numBattalions > 0 and numBattalions <= 3 and (totalBattalions -
                                                      numBattalions) >= 1:
         return True
     return False