Skip to content
This repository was archived by the owner on Jul 2, 2024. It is now read-only.

Commit 004bb60

Browse files
committed
WKT: updated engine documentation
Signed-off-by: Serhii Horodilov <sgorodil@gmail.com>
1 parent 51f2365 commit 004bb60

File tree

1 file changed

+26
-4
lines changed

1 file changed

+26
-4
lines changed

src/wtk/engine.py

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
"""
2+
***********
23
Game engine
4+
***********
5+
6+
The game engine implements core functions:
7+
8+
.. autofunction:: get_player_name
9+
10+
.. autofunction:: play
311
412
"""
513

@@ -15,7 +23,15 @@
1523

1624

1725
def get_player_name() -> str:
18-
"""Return a player's name from the user prompt"""
26+
"""
27+
Return a player's name from the user prompt
28+
29+
A validation process is performed as well. The player name cannot be
30+
an empty string.
31+
32+
:return: a player defined name
33+
34+
"""
1935

2036
player_name: str = ""
2137

@@ -26,7 +42,14 @@ def get_player_name() -> str:
2642

2743

2844
def play() -> None:
29-
"""Play the game"""
45+
"""
46+
Run the game
47+
48+
The function initializes player and enemy instances.
49+
After that it runs the game process in an endless loop.
50+
Once the player is defeated - it stops the execution.
51+
52+
"""
3053

3154
player_name = get_player_name()
3255
player = Player(player_name)
@@ -40,9 +63,8 @@ def play() -> None:
4063
logger.info(exc)
4164
enemy = Enemy(enemy.level + 1)
4265
except GameOver as exc:
43-
msg_score_points = f"SCORE POINTS: {player.score}"
4466
logger.info(exc)
45-
logger.info(msg_score_points)
67+
logger.info("SCORE POINTS: %s", player.score)
4668
break
4769

4870

0 commit comments

Comments
 (0)