コード例 #1
0
 def test_movebattalions2(self):
     player = HumanPlayers("Pepe", 38, "orange", [])
     origCountry = Country("Europa del norte", player)
     destCountry = Country("Europa del sur", player)
     player.addconqueredcountry(origCountry)
     player.addconqueredcountry(destCountry)
     origCountry.changebattalions(5)
     numBattalions = 4
     expected = True
     self.assertEqual(
         expected,
         player.movebattalions(origCountry, destCountry, numBattalions))
コード例 #2
0
 def test_usedbattalions(self):
     paux = HumanPlayers("Pepe", 35, "orange", [])
     country1 = Country("Europa del sur", paux)
     country2 = Country("Francia", paux)
     country3 = Country("Italia", paux)
     country1.changebattalions(7)
     country2.changebattalions(1)
     country3.changebattalions(5)
     paux.addconqueredcountry(country1)
     paux.addconqueredcountry(country2)
     paux.addconqueredcountry(country3)
     self.assertEqual(paux.getusedbattalions(), 13)
コード例 #3
0
ファイル: GameRulesTest.py プロジェクト: SGjorge/Risk-ISI
 def test_movebattalions2(self):
     player = HumanPlayers("Pepe", 5, "orange", [])
     origCountry = Country("Europa del norte", player)
     destCountry = Country("Europa del sur", player)
     player.addconqueredcountry(origCountry)
     player.addconqueredcountry(destCountry)
     origCountry.changebattalions(5)
     numBattalions = 5
     expected = False  #Numero tropas incorrecto
     self.assertEqual(
         expected,
         GameRules.movebattalions(player, origCountry, destCountry,
                                  numBattalions))
コード例 #4
0
ファイル: GameRulesTest.py プロジェクト: SGjorge/Risk-ISI
 def test_movebattalions1(self):
     player = HumanPlayers("Pepe", 10, "Orange", [])
     origCountry = Country("Europa del norte", player)
     origCountry.changebattalions(10)
     player.addconqueredcountry(origCountry)
     destCountry = Country("Europa del sur", player)
     player.addconqueredcountry(destCountry)
     numBattalions = 5
     expected = True  #vecinos directos
     self.assertEqual(
         expected,
         GameRules.movebattalions(player, origCountry, destCountry,
                                  numBattalions))
コード例 #5
0
ファイル: GameTest.py プロジェクト: SGjorge/Risk-ISI
 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())
コード例 #6
0
ファイル: GameRulesTest.py プロジェクト: SGjorge/Risk-ISI
 def test_movebattalions3(self):
     player = HumanPlayers("Pepe", 38, "orange", [])
     origCountry = Country("Europa del norte", player)
     otherCountry = Country("Europa del sur", player)
     player.addconqueredcountry(origCountry)
     player.addconqueredcountry(otherCountry)
     origCountry.changebattalions(5)
     player2 = HumanPlayers("Nerea", 38, "red", [])
     destCountry = Country("Islandia", player2)
     numBattalions = 1
     expected = False  #no son vecinos ni hay camino
     self.assertEqual(
         expected,
         GameRules.movebattalions(player, origCountry, destCountry,
                                  numBattalions))
コード例 #7
0
 def test_distributebattalions(self):
     paux = HumanPlayers("Pepe", 35, "orange", [])
     country1 = Country("Europa del sur", paux)
     country2 = Country("Francia", paux)
     country3 = Country("Italia", paux)
     country1.changebattalions(7)
     country2.changebattalions(1)
     country3.changebattalions(5)
     paux.addconqueredcountry(country1)
     paux.addconqueredcountry(country2)
     paux.addconqueredcountry(country3)
     paux.distributebatallions()
     self.assertEqual(paux.getusedbattalions(), 35)
     conqueredCountries = paux.getconqueredcountries()
     self.assertEqual(conqueredCountries[0].tostring(),
                      "Europa del sur 15:Pepe 35 orange")
     self.assertEqual(conqueredCountries[1].tostring(),
                      "Francia 8:Pepe 35 orange")
     self.assertEqual(conqueredCountries[2].tostring(),
                      "Italia 12:Pepe 35 orange")
コード例 #8
0
ファイル: GameTest.py プロジェクト: SGjorge/Risk-ISI
 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)
コード例 #9
0
ファイル: GameRulesTest.py プロジェクト: SGjorge/Risk-ISI
 def test_movebattalions5(self):
     player = HumanPlayers("Pepe", 38, "orange", [])
     origCountry = Country("Europa del norte", player)
     otherCountry = Country("Europa del sur", player)
     anotherCountry = Country("África del norte", player)
     destCountry = Country("Brasil", player)
     player.addconqueredcountry(origCountry)
     player.addconqueredcountry(otherCountry)
     player.addconqueredcountry(anotherCountry)
     player.addconqueredcountry(destCountry)
     origCountry.changebattalions(5)
     numBattalions = 1
     expected = True  #hay camino entre vecinos
     self.assertEqual(
         expected,
         GameRules.movebattalions(player, origCountry, destCountry,
                                  numBattalions))
コード例 #10
0
 def test_removeconqueredcountry(self):
     paux = HumanPlayers("Pepe", 35, "orange", [])
     c1 = Country("Europa del sur", paux)
     c2 = Country("Francia", paux)
     c3 = Country("Italia", paux)
     paux.addconqueredcountry(c1)
     conqueredCountries = paux.getconqueredcountries()
     paux.addconqueredcountry(c2)
     conqueredCountries = paux.getconqueredcountries()
     paux.addconqueredcountry(c3)
     conqueredCountries = paux.getconqueredcountries()
     paux.removeconqueredcountry(c2)
     conqueredCountries = paux.getconqueredcountries()
     self.assertEqual(c1.isequal(conqueredCountries[0]), True)
     self.assertEqual(c3.isequal(conqueredCountries[1]), True)