Пример #1
0
 def test_score_despawn_chance(self):
     world_map.TARGET_NUM_SCORE_LOCATIONS_PER_AVATAR = 0
     grid = self._generate_grid()
     grid[Location(0, 1)].generates_score = True
     map = WorldMap(grid)
     map.update(1)
     self.assertIn(grid[Location(0, 1)], map.score_cells())
     self.assertEqual(len(list(map.score_cells())), 1)
Пример #2
0
    def test_scores_added(self):
        world_map.TARGET_NUM_SCORE_LOCATIONS_PER_AVATAR = 1
        map = WorldMap(self._generate_grid())
        map.update(1)
        self.assertEqual(len(list(map.score_cells())), 1)

        map.update(2)
        self.assertEqual(len(list(map.score_cells())), 2)
Пример #3
0
 def test_scores_not_added_when_at_target(self):
     world_map.TARGET_NUM_SCORE_LOCATIONS_PER_AVATAR = 1
     grid = self._generate_grid()
     grid[Location(0, 1)].generates_score = True
     map = WorldMap(grid)
     map.update(1)
     self.assertEqual(len(list(map.score_cells())), 1)
     self.assertIn(grid[Location(0, 1)], map.score_cells())
Пример #4
0
    def test_scores_added(self):
        self.settings['TARGET_NUM_SCORE_LOCATIONS_PER_AVATAR'] = 1
        world_map = WorldMap(self._generate_grid(), self.settings)
        world_map.update(1)
        self.assertEqual(len(list(world_map.score_cells())), 1)

        world_map.update(2)
        self.assertEqual(len(list(world_map.score_cells())), 2)
Пример #5
0
 def test_scores_removed(self):
     world_map.SCORE_DESPAWN_CHANCE = 1
     grid = self._generate_grid()
     grid[0][1].generates_score = True
     map = WorldMap(grid)
     map.reconstruct_interactive_state(1)
     self.assertEqual(len(list(map.score_cells())), 0)
Пример #6
0
 def test_score_cells(self):
     cells = self._generate_cells()
     cells[0]["interactable"] = {"type": "score"}
     cells[8]["interactable"] = {"type": "score"}
     map = WorldMap(cells)
     self.assertLocationsEqual(map.score_cells(),
                               (Location(-1, -1), Location(1, 1)))
Пример #7
0
 def test_score_cells(self):
     cells = self._generate_cells()
     cells[0]['generates_score'] = True
     cells[5]['generates_score'] = True
     map = WorldMap(cells)
     self.assertLocationsEqual(map.score_cells(),
                               (Location(-1, -1), Location(0, 1)))
Пример #8
0
 def test_not_enough_score_space(self):
     world_map.TARGET_NUM_SCORE_LOCATIONS_PER_AVATAR = 1
     grid = self._generate_grid(1)
     grid = [[MockCell(avatar='avatar')]]
     map = WorldMap(grid)
     map.reconstruct_interactive_state(1)
     self.assertEqual(len(list(map.score_cells())), 0)
Пример #9
0
 def test_not_enough_score_space(self):
     world_map.TARGET_NUM_SCORE_LOCATIONS_PER_AVATAR = 1
     grid = self._generate_grid(1)
     grid = [[MockCell(avatar='avatar')]]
     map = WorldMap(grid)
     map.reconstruct_interactive_state(1)
     self.assertEqual(len(list(map.score_cells())), 0)
Пример #10
0
 def test_no_score_cells_generated_if_no_suitable_cells(self):
     world_map.TARGET_NUM_SCORE_LOCATIONS_PER_AVATAR = 1
     grid = self._generate_grid(1, 1)
     grid[Location(0, 0)].avatar = 'avatar'
     map = WorldMap(grid)
     map.update(1)
     self.assertEqual(len(list(map.score_cells())), 0)
Пример #11
0
 def test_not_enough_score_space(self):
     self.settings['TARGET_NUM_SCORE_LOCATIONS_PER_AVATAR'] = 1
     grid = self._generate_grid(1, 1)
     grid[Location(0, 0)].avatar = 'avatar'
     world_map = WorldMap(grid, self.settings)
     world_map.update(1)
     self.assertEqual(len(list(world_map.score_cells())), 0)
Пример #12
0
 def test_scores_removed(self):
     world_map.SCORE_DESPAWN_CHANCE = 1
     grid = self._generate_grid()
     grid[0][1].generates_score = True
     map = WorldMap(grid)
     map.reconstruct_interactive_state(1)
     self.assertEqual(len(list(map.score_cells())), 0)
Пример #13
0
 def test_scores_removed(self):
     world_map.SCORE_DESPAWN_CHANCE = 1
     grid = self._generate_grid()
     grid[Location(0, 1)].generates_score = True
     map = WorldMap(grid)
     map.update(1)
     self.assertEqual(len(list(map.score_cells())), 0)
Пример #14
0
 def test_scores_removed(self):
     self.settings['SCORE_DESPAWN_CHANCE'] = 1
     grid = self._generate_grid()
     grid[Location(0, 1)].generates_score = True
     world_map = WorldMap(grid, self.settings)
     world_map.update(1)
     self.assertEqual(len(list(world_map.score_cells())), 0)
Пример #15
0
 def test_scores_not_added_when_at_target(self):
     world_map.TARGET_NUM_SCORE_LOCATIONS_PER_AVATAR = 1
     grid = self._generate_grid()
     grid[0][1].generates_score = True
     map = WorldMap(grid)
     map.reconstruct_interactive_state(1)
     self.assertEqual(len(list(map.score_cells())), 1)
     self.assertIn(grid[0][1], map.score_cells())
Пример #16
0
 def test_score_despawn_chance(self):
     world_map.TARGET_NUM_SCORE_LOCATIONS_PER_AVATAR = 0
     grid = self._generate_grid()
     grid[0][1].generates_score = True
     map = WorldMap(grid)
     map.reconstruct_interactive_state(1)
     self.assertIn(grid[0][1], map.score_cells())
     self.assertEqual(len(list(map.score_cells())), 1)
Пример #17
0
 def test_score_despawn_chance(self):
     world_map.TARGET_NUM_SCORE_LOCATIONS_PER_AVATAR = 0
     grid = self._generate_grid()
     grid[0][1].generates_score = True
     map = WorldMap(grid)
     map.reconstruct_interactive_state(1)
     self.assertIn(grid[0][1], map.score_cells())
     self.assertEqual(len(list(map.score_cells())), 1)
Пример #18
0
 def test_scores_not_added_when_at_target(self):
     world_map.TARGET_NUM_SCORE_LOCATIONS_PER_AVATAR = 1
     grid = self._generate_grid()
     grid[0][1].generates_score = True
     map = WorldMap(grid)
     map.reconstruct_interactive_state(1)
     self.assertEqual(len(list(map.score_cells())), 1)
     self.assertIn(grid[0][1], map.score_cells())
Пример #19
0
 def test_score_cells(self):
     score_cell1 = MockCell(generates_score=True)
     score_cell2 = MockCell(generates_score=True)
     no_score_cell = MockCell()
     grid = self._grid_from_list([[score_cell1, no_score_cell], [no_score_cell, score_cell2]])
     map = WorldMap(grid)
     cells = list(map.score_cells())
     self.assertIn(score_cell1, cells)
     self.assertIn(score_cell2, cells)
     self.assertEqual(len(cells), 2, "Non-scoring cells present")
Пример #20
0
    def test_get_all_score_locations(self):
        score_cell = MockCell()
        score_cell.interactable = ScoreLocation(score_cell)
        grid = self._grid_from_list([[score_cell, MockCell()],
                                     [MockCell(), MockCell()]])
        world_map = WorldMap(grid, self.settings)
        score_list = list(world_map.score_cells())

        self.assertEqual(len(score_list), 1)
        self.assertTrue(isinstance(score_list[0].interactable, ScoreLocation))
Пример #21
0
 def test_score_cells(self):
     score_cell1 = MockCell()
     score_cell1.interactable = ScoreLocation(score_cell1)
     score_cell2 = MockCell()
     score_cell2.interactable = ScoreLocation(score_cell2)
     no_score_cell = MockCell()
     grid = self._grid_from_list([[score_cell1, no_score_cell],
                                  [no_score_cell, score_cell2]])
     world_map = WorldMap(grid, self.settings)
     cells = list(world_map.score_cells())
     self.assertIn(score_cell1, cells)
     self.assertIn(score_cell2, cells)
     self.assertEqual(len(cells), 2, "Non-scoring cells present")
Пример #22
0
 def test_score_cells(self):
     cells = self._generate_cells()
     cells[0]["interactable"] = {"score_location": 5}
     cells[5]["interactable"] = {"score_location": 5}
     map = WorldMap(cells)
     self.assertLocationsEqual(map.score_cells(), (Location(-1, -1), Location(0, 1)))
Пример #23
0
 def test_score_cells(self):
     cells = self._generate_cells()
     cells[0]['generates_score'] = True
     cells[5]['generates_score'] = True
     map = WorldMap(cells)
     self.assertLocationsEqual(map.score_cells(), (Location(-1, -1), Location(0, 1)))