2022-01-02 17:50:33 +00:00
|
|
|
from __future__ import annotations
|
|
|
|
from typing import TYPE_CHECKING
|
2022-01-02 15:23:25 +00:00
|
|
|
|
|
|
|
from tcod.context import Context
|
|
|
|
from tcod.console import Console
|
|
|
|
from tcod.map import compute_fov
|
|
|
|
|
|
|
|
from input_handlers import EventHandler
|
|
|
|
|
2022-01-02 17:50:33 +00:00
|
|
|
if TYPE_CHECKING:
|
|
|
|
from entity import Entity
|
|
|
|
from game_map import GameMap
|
|
|
|
|
2022-01-02 15:23:25 +00:00
|
|
|
|
|
|
|
class Engine:
|
2022-01-02 17:50:33 +00:00
|
|
|
game_map: GameMap
|
|
|
|
|
|
|
|
def __init__(self, player: Entity):
|
|
|
|
self.event_handler: EventHandler = EventHandler(self)
|
2022-01-02 15:23:25 +00:00
|
|
|
self.player = player
|
|
|
|
|
2022-01-02 17:19:43 +00:00
|
|
|
def handle_enemy_turns(self) -> None:
|
|
|
|
for entity in self.game_map.entities - {self.player}:
|
|
|
|
print(f'the {entity.name} wonders when it will move')
|
|
|
|
|
2022-01-02 15:23:25 +00:00
|
|
|
def update_fov(self) -> None:
|
|
|
|
self.game_map.visible[:] = compute_fov(
|
|
|
|
self.game_map.tiles["transparent"],
|
|
|
|
(self.player.x, self.player.y),
|
|
|
|
radius=8,
|
|
|
|
)
|
|
|
|
self.game_map.explored |= self.game_map.visible
|
|
|
|
|
|
|
|
def render(self, console: Console, context: Context) -> None:
|
|
|
|
self.game_map.render(console)
|
|
|
|
|
|
|
|
context.present(console)
|
2022-01-02 17:19:43 +00:00
|
|
|
console.clear()
|