Exemplo n.º 1
0
 def test_can_not_mark_dot_in_already_marked_cell(self):
     field = Field.Field(5, 5)
     player = Player(1, field)
     another = Player(2, field)
     field.mark_dot(0, 0, player)
     field.mark_dot(0, 0, another)
     self.assertEqual(field.field_array[0][0].owner, player)
Exemplo n.º 2
0
 def test_can_not_mark_at_the_edge(self):
     field = Field.Field(5, 5)
     player = Player(1, field)
     field.mark_dot(-1, -1, player)
     field.mark_dot(5, 5, player)
     field.mark_dot(-1, 5, player)
     field.mark_dot(5, -1, player)
     self.assertTrue(is_empty(field))
Exemplo n.º 3
0
 def test_belongs(self):
     field = Field.Field(5, 5)
     player = Player(1, field)
     field.mark_dot(0, 1, player)  # _x
     field.mark_dot(1, 0, player)  # xzx
     field.mark_dot(2, 1, player)  # _x
     field.mark_dot(1, 2, player)  #
     actually = field.field_array[1][1].belongs_smb()
     self.assertFalse(actually)
Exemplo n.º 4
0
 def test_cell_marked_as_occupied_staggered_layout_with_empty(self):
     field = Field.Field(3, 3)
     occupier = Player(1, field)
     field.mark_dot(0, 1, occupier)  # _x
     field.mark_dot(1, 0, occupier)  # xzx
     field.mark_dot(2, 1, occupier)  # _x
     field.mark_dot(1, 2, occupier)  #
     Cycles.find_occupied_dots(field)
     self.assertEqual(field.field_array[1][1].occupier, occupier)
Exemplo n.º 5
0
 def test_occupied_cell_marked_as_occupied(self):
     field = Field.Field(5, 5)
     occupier = Player(1, field)
     field.mark_dot(0, 1, occupier)  # _x
     field.mark_dot(1, 0, occupier)  # xzx
     field.mark_dot(2, 1, occupier)  # _x
     field.mark_dot(1, 2, occupier)  #
     Cycles.find_occupied_dots(field)
     self.assertEqual(field.field_array[1][1].occupier, occupier)
Exemplo n.º 6
0
 def __init__(self, ui, configurator, server):
     self.quit_flag = False
     self.ui = ui
     self.field = Field.Field(ui.width, ui.height, ui)
     self.configurator = configurator
     self.players = configurator.get_players(ui)
     self.server = server
     self.should_act = 0
     self.interrupted = False
Exemplo n.º 7
0
 def test_can_not_mark_dot_inside_others_occupied_area(self):
     field = Field.Field(5, 5)
     player = Player(1, field)
     field.mark_dot(0, 1, player)  # _x
     field.mark_dot(1, 0, player)  # xzx
     field.mark_dot(2, 1, player)  # _x
     field.mark_dot(1, 2, player)  #
     Cycles.find_occupied_dots(field)
     success = field.mark_dot(1, 1, Player(2, field))
     self.assertFalse(success)
Exemplo n.º 8
0
 def test_can_mark_dot_inside_its_own_occupied_area(self):
     field = Field.Field(5, 5)
     player = Player(1, field)
     field.mark_dot(0, 1, player)  # _x
     field.mark_dot(1, 0, player)  # xzx
     field.mark_dot(2, 1, player)  # _x
     field.mark_dot(1, 2, player)  #
     Cycles.find_occupied_dots(field)
     success = field.mark_dot(1, 1, player)
     self.assertTrue(success)
Exemplo n.º 9
0
 def test_dot_inside_occupied_area(self):
     field = Field.Field(5, 5)
     player = Player(1, field)
     field.mark_dot(0, 1, player)  # _x
     field.mark_dot(1, 0, player)  # xzx
     field.mark_dot(2, 1, player)  # _x
     field.mark_dot(1, 2, player)  #
     Cycles.find_occupied_dots(field)
     occ_b_enm = field.field_array[1][1].occupied_by_enemy()
     self.assertTrue(occ_b_enm)
Exemplo n.º 10
0
 def test_dot_outside_occupied_area_do_not_contact_with_area(self):
     field = Field.Field(6, 6)
     player = Player(1, field)
     field.mark_dot(0, 1, player)  # _x___z
     field.mark_dot(1, 0, player)  # x_x
     field.mark_dot(2, 1, player)  # _x
     field.mark_dot(1, 2, player)  #
     _ = Cycles.find_occupied_dots(field)
     not_occ = field.field_array[5][0].occupied_by_enemy()
     self.assertFalse(not_occ)
Exemplo n.º 11
0
    def test_cell_marked_as_occupied_staggered_layout_with_enemy(self):
        field = Field.Field(3, 3)
        player_x = Player(1, field)
        player_z = Player(2, field)
        field.mark_dot(0, 1, player_z)  # xzx
        field.mark_dot(1, 0, player_z)  # zxz
        field.mark_dot(2, 1, player_z)  # xzx
        field.mark_dot(1, 2, player_z)  #

        field.mark_dot(0, 0, player_x)
        field.mark_dot(0, 2, player_x)
        field.mark_dot(2, 2, player_x)
        field.mark_dot(2, 0, player_x)
        field.mark_dot(1, 1, player_x)

        Cycles.find_occupied_dots(field)
        self.assertEqual(field.field_array[1][1].occupier, player_z)
Exemplo n.º 12
0
 def test_can_mark_dot(self):
     field = Field.Field(5, 5)
     player = Player(1, field)
     field.mark_dot(2, 3, player)
     self.assertEqual(field.field_array[2][3].owner, player)