From 01cdea6edcbf6e48a2ef61a1d1523dd999bea5b2 Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Sun, 10 Jan 2021 21:57:51 +0100 Subject: [PATCH] Don't spawn random entities on each level anymore --- squirrelbattle/entities/player.py | 3 --- squirrelbattle/game.py | 1 - squirrelbattle/interfaces.py | 16 ---------------- 3 files changed, 20 deletions(-) diff --git a/squirrelbattle/entities/player.py b/squirrelbattle/entities/player.py index 615dfd5..81a0c55 100644 --- a/squirrelbattle/entities/player.py +++ b/squirrelbattle/entities/player.py @@ -71,9 +71,6 @@ class Player(InventoryHolder, FightingEntity): self.max_xp = self.level * 10 self.health = self.maxhealth self.strength = self.strength + 1 - # TODO Remove it, that's only fun - self.map.spawn_random_entities(randint(3 * self.level, - 10 * self.level)) def add_xp(self, xp: int) -> None: """ diff --git a/squirrelbattle/game.py b/squirrelbattle/game.py index fb10404..87317e0 100644 --- a/squirrelbattle/game.py +++ b/squirrelbattle/game.py @@ -61,7 +61,6 @@ class Game: self.player = Player() self.map.add_entity(self.player) self.player.move(self.map.start_y, self.map.start_x) - self.map.spawn_random_entities(randint(3, 10)) self.inventory_menu.update_player(self.player) @property diff --git a/squirrelbattle/interfaces.py b/squirrelbattle/interfaces.py index e9b2407..6e3065c 100644 --- a/squirrelbattle/interfaces.py +++ b/squirrelbattle/interfaces.py @@ -180,22 +180,6 @@ class Map: return "\n".join("".join(tile.char(pack) for tile in line) for line in self.tiles) - def spawn_random_entities(self, count: int) -> None: - """ - Puts randomly {count} entities on the map, only on empty ground tiles. - """ - for _ignored in range(count): - y, x = 0, 0 - while True: - y, x = randint(0, self.height - 1), randint(0, self.width - 1) - tile = self.tiles[y][x] - if tile.can_walk(): - break - entity = choices(Entity.get_all_entity_classes(), - weights=Entity.get_weights(), k=1)[0]() - entity.move(y, x) - self.add_entity(entity) - def compute_visibility(self, y: int, x: int, max_range: int) -> None: """ Sets the visible tiles to be the ones visible by an entity at point