def test_get_all_pickup_locations(self): pickup_cell = MockCell() pickup_cell.interactable = HealthPickup(pickup_cell) grid = self._grid_from_list([[pickup_cell, MockCell()], [MockCell(), MockCell()]]) world_map = WorldMap(grid, self.settings) pickup_list = list(world_map.pickup_cells()) self.assertEqual(len(pickup_list), 1) self.assertTrue(isinstance(pickup_list[0].interactable, ALL_PICKUPS))
async def test_health_effect_is_capped_at_HEALTH_RESTORE_MAX(self, loop): """ Make sure health cannot go above the maximum cap. Avatar health begins at 5hp, so every pickup in the 96-HEALTH_RESTORE_MAX range would cause it to go above HEALTH_RESTORE_MAX, until the initial health changes. """ avatar = self.game.avatar_manager.get_avatar(1) avatar.health = 97 self.cell.interactable = HealthPickup(self.cell) await self.game.simulation_runner.run_single_turn( self.game.avatar_manager.get_player_id_to_serialized_action()) assert self.cell.avatar == self.game.avatar_manager.get_avatar(1) assert self.cell.avatar.health == AVATAR_HEALTH_MAX
async def test_health_pickups_and_effects_apply_default(self, loop): """ HealthPickups without any parameter provided. """ self.cell.interactable = HealthPickup(self.cell) assert self.cell.interactable.serialize() == { "type": "health", "location": {"x": self.cell.location.x, "y": self.cell.location.y}, } await self.game.simulation_runner.run_single_turn( self.game.turn_collector.collected_turn_actions ) assert self.cell.avatar == self.game.avatar_manager.get_avatar(1) assert self.cell.avatar.health == self.initial_health + HEALTH_RESTORE_DEFAULT
def test_health_pickups_and_effects_apply_default(self): """ HealthPickups without any parameter provided. """ self.cell.interactable = HealthPickup(self.cell) self.assertEqual( self.cell.interactable.serialize(), { "type": "health", "location": { "x": self.cell.location.x, "y": self.cell.location.y }, }, ) self.loop.run_until_complete( self.game.simulation_runner.run_single_turn( self.game.avatar_manager.get_player_id_to_serialized_action())) self.assertEqual(self.cell.avatar, self.game.avatar_manager.get_avatar(1)) self.assertEqual(self.cell.avatar.health, self.initial_health + HEALTH_RESTORE_DEFAULT)