Merge branch 'map_generation' into 'master'

Map generation

Closes #5

See merge request ynerant/squirrel-battle!35
This commit is contained in:
2021-01-10 23:54:28 +01:00
11 changed files with 562 additions and 46 deletions

View File

@ -6,7 +6,7 @@ from random import randint
from typing import Dict, Optional, Tuple
from .items import Item
from ..interfaces import FightingEntity, InventoryHolder
from ..interfaces import FightingEntity, InventoryHolder, Tile
from ..translations import gettext as _
@ -108,9 +108,6 @@ class Player(InventoryHolder, FightingEntity):
self.charisma += 1
if self.level % 10 == 0 and self.critical < 95:
self.critical += (100 - self.charisma) // 30
# TODO Remove it, that's only for fun
self.map.spawn_random_entities(randint(3 * self.level,
10 * self.level))
def add_xp(self, xp: int) -> None:
"""
@ -140,6 +137,12 @@ class Player(InventoryHolder, FightingEntity):
return True
elif entity.is_item():
entity.hold(self)
tile = self.map.tiles[y][x]
if tile == Tile.DOOR and move_if_possible:
# Open door
self.map.tiles[y][x] = Tile.FLOOR
self.map.compute_visibility(y, x, self.vision)
return super().check_move(y, x, move_if_possible)
return super().check_move(y, x, move_if_possible)
def save_state(self) -> dict: