Complete part 10
This commit is contained in:
parent
5d0915b82b
commit
5f8a8c674d
@ -7,7 +7,7 @@ from entity import Actor, Item
|
||||
player = Actor(
|
||||
char="@",
|
||||
color=(255, 255, 255),
|
||||
name="PLayer",
|
||||
name="Player",
|
||||
ai_cls=HostileEnemy,
|
||||
fighter=Fighter(hp=30, defense=2, power=5),
|
||||
inventory=Inventory(capacity=26),
|
||||
|
@ -1,5 +1,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
|
||||
from typing import overload, Callable, Optional, Tuple, TYPE_CHECKING, Union
|
||||
|
||||
import tcod.event
|
||||
@ -432,9 +434,18 @@ class MainGameEventHandler(EventHandler):
|
||||
|
||||
|
||||
class GameOverEventHandler(EventHandler):
|
||||
def on_quit(self) -> None:
|
||||
"""Handle exiting out of a finished game."""
|
||||
if os.path.exists("savegame.sav"):
|
||||
os.remove("savegame.sav") # Deletes the active save file.
|
||||
raise exceptions.QuitWithoutSaving() # Avoid saving a finished game.
|
||||
|
||||
def ev_quit(self, event: tcod.event.Quit) -> None:
|
||||
self.on_quit()
|
||||
|
||||
def ev_keydown(self, event: tcod.event.KeyDown) -> None:
|
||||
if event.sym == tcod.event.K_ESCAPE:
|
||||
raise SystemExit()
|
||||
self.on_quit()
|
||||
|
||||
|
||||
CURSOR_Y_KEYS = {
|
||||
|
Loading…
Reference in New Issue
Block a user