Пример #1
0
 def test_algo_attack(self):
     #el que va a atacar
     playerAuxAtak = IAPlayers("Eva", 35, "orange", [])
     countryA1 = Country("Europa del norte", playerAuxAtak)
     countryA1.changebattalions(6)
     playerAuxAtak.addconqueredcountry(countryA1)
     countryA2 = Country("Europa del sur", playerAuxAtak)
     countryA2.changebattalions(8)
     playerAuxAtak.addconqueredcountry(countryA2)
     countryA3 = Country("África del norte", playerAuxAtak)
     countryA3.changebattalions(6)
     playerAuxAtak.addconqueredcountry(countryA3)
     #necesito tener un jugador al que atacar
     playerAuxDeff = IAPlayers("Nerea", 35, "blue", [])
     countryA4 = Country("Egipto", playerAuxDeff)
     countryA4.changebattalions(3)
     playerAuxDeff.addconqueredcountry(countryA4)
     countryA5 = Country("Europa occidental", playerAuxDeff)
     countryA5.changebattalions(2)
     playerAuxDeff.addconqueredcountry(countryA5)
     players = [playerAuxAtak, playerAuxDeff]
     players = ArrayPlayers().orderplayers(players, playerAuxAtak)
     expected = True
     out = playerAuxAtak.algoattack(playerAuxAtak, players)
     self.assertEqual(out, expected)
Пример #2
0
 def test_deffend_IA(self):
     playerAux = IAPlayers("Pepe", 35, "orange", [])
     countryAux = Country("Europa del norte", playerAux)
     countryAux.changebattalions(6)
     playerAux.addconqueredcountry(countryAux)
     deffended = playerAux.deffend("Europa del norte")
     expectedCountry = "Europa del norte"
     self.assertEqual(expectedCountry, deffended[0])
Пример #3
0
    def test_attack_IA_2(self):
        playerAux = IAPlayers("Pepe", 35, "orange", [])
        countryAux = Country("Europa del sur", playerAux)
        countryAux.changebattalions(6)
        playerAux.addconqueredcountry(countryAux)
        expectedOrigin = "Europa del sur"
        expectedDestiny = "Europa del norte"
        attacked = playerAux.attack("Europa del sur", "Europa del norte")

        self.assertEqual(expectedOrigin, attacked[0])
        self.assertEqual(expectedDestiny, attacked[1])
Пример #4
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))
Пример #5
0
 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))
Пример #6
0
 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))
Пример #7
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())
Пример #8
0
 def test_movebattalions4(self):
     player = HumanPlayers("Pepe", 38, "orange", [])
     origCountry = Country("Europa del norte", player)
     otherCountry = Country("Europa del sur", player)
     destCountry = Country("África del norte", player)
     player.addconqueredcountry(origCountry)
     player.addconqueredcountry(otherCountry)
     player.addconqueredcountry(destCountry)
     origCountry.changebattalions(5)
     numBattalions = 1
     expected = True  #no vecinos directos pero sí hay camino
     self.assertEqual(
         expected,
         GameRules.movebattalions(player, origCountry, destCountry,
                                  numBattalions))
Пример #9
0
 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))
Пример #10
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)
Пример #11
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)
Пример #12
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")
Пример #13
0
 def test_are2battalionstoattackok(self):
     pAux = Players("Pepe", 0, "orange", [])
     country = Country("Islandia", pAux)
     country.changebattalions(25)  #25 battalions
     expected = True
     self.assertEqual(expected, GameRules.battalionstoattackok(country, 2))
Пример #14
0
 def test_are0battalionstodefendok(self):
     pAux = Players("Pepe", 0, "orange", [])
     country = Country("Groenlandia", pAux)
     country.changebattalions(1)  #1 battalion
     expected = False
     self.assertEqual(expected, GameRules.battalionstodefendok(country, 0))
Пример #15
0
 def test_is1battaliontodefendok(self):
     pAux = Players("Pepe", 0, "orange", [])
     country = Country("Groenlandia", pAux)
     country.changebattalions(4)  #4 battalions
     expected = True
     self.assertEqual(expected, GameRules.battalionstodefendok(country, 1))