Fixed grammar, unified the docstring's format and added documentation to some classes that did not have any. Closes #32.

This commit is contained in:
eichhornchen
2020-12-13 21:29:25 +01:00
parent 3f62fbaa2b
commit 646e0063be
24 changed files with 254 additions and 170 deletions

View File

@ -14,7 +14,7 @@ from .translations import gettext as _, Translator
class Menu:
"""
A Menu object is the logical representation of a menu in the game
A Menu object is the logical representation of a menu in the game.
"""
values: list
@ -23,26 +23,26 @@ class Menu:
def go_up(self) -> None:
"""
Moves the pointer of the menu on the previous value
Moves the pointer of the menu on the previous value.
"""
self.position = max(0, self.position - 1)
def go_down(self) -> None:
"""
Moves the pointer of the menu on the next value
Moves the pointer of the menu on the next value.
"""
self.position = min(len(self.values) - 1, self.position + 1)
def validate(self) -> Any:
"""
Selects the value that is pointed by the menu pointer
Selects the value that is pointed by the menu pointer.
"""
return self.values[self.position]
class MainMenuValues(Enum):
"""
Values of the main menu
Values of the main menu.
"""
START = "New game"
RESUME = "Resume"
@ -57,14 +57,14 @@ class MainMenuValues(Enum):
class MainMenu(Menu):
"""
A special instance of a menu : the main menu
A special instance of a menu : the main menu.
"""
values = [e for e in MainMenuValues]
class SettingsMenu(Menu):
"""
A special instance of a menu : the settings menu
A special instance of a menu : the settings menu.
"""
waiting_for_key: bool = False
@ -75,7 +75,7 @@ class SettingsMenu(Menu):
def handle_key_pressed(self, key: Optional[KeyValues], raw_key: str,
game: Any) -> None:
"""
In the setting menu, we van select a setting and change it
In the setting menu, we can select a setting and change it.
"""
if not self.waiting_for_key:
# Navigate normally through the menu.
@ -121,22 +121,40 @@ class SettingsMenu(Menu):
class InventoryMenu(Menu):
"""
A special instance of a menu : the menu for the inventory of the player.
"""
player: Player
def update_player(self, player: Player) -> None:
"""
Updates the player.
"""
self.player = player
@property
def values(self) -> list:
"""
Returns the values of the menu.
"""
return self.player.inventory
class StoreMenu(Menu):
"""
A special instance of a menu : the menu for the inventory of a merchant.
"""
merchant: Merchant
def update_merchant(self, merchant: Merchant) -> None:
"""
Updates the merchant.
"""
self.merchant = merchant
@property
def values(self) -> list:
"""
Returns the values of the menu.
"""
return self.merchant.inventory