Ejemplo n.º 1
0
 def test_move(self, unit):
     map = Map([self.grass, self.water], [unit])
     gc = GameControl(map)
     grass_x, grass_y = self.grass.get_coordinates()
     assert gc._can_unit_move(unit, grass_x, grass_y)
     water_x, water_y = self.water.get_coordinates()
     assert not gc._can_unit_move(unit, water_x, water_y)
Ejemplo n.º 2
0
def test_move_unit(unit):
    map = Map([Grass(14, 14), Grass(15, 15)], [unit])
    gc = GameControl(map)
    gc.move_unit(unit, MOVE_POSITION_X, MOVE_POSITION_Y)
    assert unit.x == MOVE_POSITION_X and unit.y == MOVE_POSITION_Y
Ejemplo n.º 3
0
from mainclass.map import Map
from grounds.playable.grass import Grass
from grounds.unplayable.water import Water
from units.melee.horseman import Hourseman
from units.melee.swordsman import Swordsman
from units.range.archer import Archer
from units.range.catapult import Catapult
from control.game_control import GameControl


grass_list = [Grass(0, 0, 't'), Grass(0, 1, 'r'), Grass(0, 2, 'r'),
              Grass(1, 0, 't'), Grass(1, 1, 't'), Grass(1, 2, 't'),
              Water(2, 0, 't'), Grass(2, 1, 't'), Grass(2, 2, 't'),
              Water(3, 0, 't'), Water(3, 1, 't'), Water(3, 2, 't')]
swordsman = Swordsman(0, 2, 2)
print(swordsman)
archer = Archer(0, 0, 1)
print(archer)

catapult = Catapult(1, 1, 2)
print(catapult)
hourseman = Hourseman(2, 2, 1)
print(hourseman)
unit_list = [swordsman, archer, catapult, hourseman]
map = Map(grass_list, unit_list)
gc = GameControl(map)
print(archer.get_coordinates() == (0, 0))
Ejemplo n.º 4
0
 def test_swordsman(self, test_x, test_y, answer):
     map = Map(list(), [self.swordsman])
     gc = GameControl(map)
     can_move = gc._can_unit_move(self.swordsman, test_x, test_y)
     assert answer == can_move
Ejemplo n.º 5
0
 def test_catapult(self, test_x, test_y, answer):
     map = Map(list(), [self.catapult])
     gc = GameControl(map)
     can_move = gc._can_unit_move(self.catapult, test_x, test_y)
     assert answer == can_move
Ejemplo n.º 6
0
 def test_archer(self, test_x, test_y, answer):
     map = Map(list(), [self.archer])
     gc = GameControl(map)
     can_move = gc._can_unit_move(self.archer, test_x, test_y)
     assert answer == can_move
Ejemplo n.º 7
0
 def test_to_unit(self, unit):
     map = Map(list(), [self.archer, unit])
     gc = GameControl(map)
     target_x, target_y = self.archer.get_coordinates()
     assert not gc._can_unit_move(unit, target_x, target_y)