def explosion(self, origin_tile: TileModel): FileImporter.play_music(EXPLOSION_SOUND, 1) logger.info(f"Explosion occurred on {origin_tile}") game_state = GameStateModel.instance() tile_sprite = GameBoard.instance().grid.grid[origin_tile.column][ origin_tile.row] tile_sprite.explosion = True for direction, obstacle in origin_tile.adjacent_edge_objects.items(): # fire does not move to the neighbouring tile # damaging wall present along the tile if isinstance( obstacle, WallModel ) and obstacle.wall_status != WallStatusEnum.DESTROYED: obstacle.inflict_damage() game_state.damage = game_state.damage + 1 # fire does not move to the neighbouring tile # removing door that borders the tile elif isinstance(obstacle, DoorModel): obstacle.destroy_door() # fire can move to the neighbouring tile # if the neighbouring tile is on fire, a shockwave is created # else it is just set on fire. else: nb_tile = origin_tile.get_tile_in_direction(direction) if not isinstance(nb_tile, NullModel): if nb_tile.space_status == SpaceStatusEnum.FIRE: self.shockwave(nb_tile, direction) else: nb_tile.space_status = SpaceStatusEnum.FIRE
def execute(self, *args, **kwargs): logger.info("Executing Fire Deck Gun Event") self.game: GameStateModel = GameStateModel.instance() if isinstance(self.target_tile, NullModel): self._set_target_tile() self.target_tile.space_status = SpaceStatusEnum.SAFE FileImporter.play_music(SPLASH_SOUND, 1) tile_sprite = GameBoard.instance().grid.grid[self.target_tile.column][ self.target_tile.row] tile_sprite.fire_deck_gun = True directions = ["North", "East", "West", "South"] for dirn in directions: has_obstacle = self.target_tile.has_obstacle_in_direction(dirn) obstacle = self.target_tile.get_obstacle_in_direction(dirn) # If there is no obstacle in the given direction or there is an # open door, set the status of the space in that direction to Safe. if not has_obstacle or (isinstance(obstacle, DoorModel) and obstacle.door_status == DoorStatusEnum.OPEN)\ or (isinstance(obstacle, WallModel) and obstacle.wall_status == WallStatusEnum.DESTROYED): nb_tile: TileModel = self.target_tile.get_tile_in_direction( dirn) nb_tile.space_status = SpaceStatusEnum.SAFE tile_sprite = GameBoard.instance().grid.grid[nb_tile.column][ nb_tile.row] tile_sprite.fire_deck_gun = True if self.player.role == PlayerRoleEnum.DRIVER: self.player.ap = self.player.ap - 2 else: self.player.ap = self.player.ap - 4