Added documentation on a lot of classes and functions (and removed some files I commited by mistake)
This commit is contained in:
committed by
Yohann D'ANELLO
parent
41d1696c9b
commit
8f932604f6
@ -12,6 +12,9 @@ from typing import Callable
|
||||
|
||||
|
||||
class Game:
|
||||
"""
|
||||
The game object controls all actions in the game.
|
||||
"""
|
||||
map: Map
|
||||
player: Player
|
||||
# display_actions is a display interface set by the bootstrapper
|
||||
@ -43,8 +46,8 @@ class Game:
|
||||
def run(self, screen: Any) -> None:
|
||||
"""
|
||||
Main infinite loop.
|
||||
We wait for a player action, then we do what that should be done
|
||||
when the given key got pressed.
|
||||
We wait for the player's action, then we do what that should be done
|
||||
when the given key gets pressed.
|
||||
"""
|
||||
while True: # pragma no cover
|
||||
screen.clear()
|
||||
@ -70,7 +73,7 @@ class Game:
|
||||
|
||||
def handle_key_pressed_play(self, key: KeyValues) -> None:
|
||||
"""
|
||||
In play mode, arrows or zqsd should move the main character.
|
||||
In play mode, arrows or zqsd move the main character.
|
||||
"""
|
||||
if key == KeyValues.UP:
|
||||
if self.player.move_up():
|
||||
@ -108,15 +111,16 @@ class Game:
|
||||
elif option == menus.MainMenuValues.EXIT:
|
||||
sys.exit(0)
|
||||
|
||||
def game_to_str(self) -> str:
|
||||
d = dict()
|
||||
d["Map"] = game.map
|
||||
d["Player"] = game.player
|
||||
|
||||
def save_state(self) -> dict():
|
||||
"""
|
||||
Saves the game to a dictionnary
|
||||
"""
|
||||
return self.map.save_state()
|
||||
|
||||
def load_state(self, d: dict) -> None:
|
||||
"""
|
||||
Loads the game from a dictionnary
|
||||
"""
|
||||
self.map.load_state(d)
|
||||
|
||||
def load_game(self) -> None:
|
||||
@ -129,7 +133,7 @@ class Game:
|
||||
|
||||
def save_game(self) -> None:
|
||||
"""
|
||||
Save the game to a file
|
||||
Saves the game to a file
|
||||
"""
|
||||
with open("save.json", "w") as f:
|
||||
f.write(json.dumps(self.save_state()))
|
||||
|
Reference in New Issue
Block a user