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

Commit 71a07a5

Browse files
committed
Fixed #45
Added docstrings to "settings" module. Updated `Enemy.__init__` documentation to avoid misunderstanding of `health` attribute. Applied minor changes to game overview section in "challenge" document. Signed-off-by: Serhii Horodilov <sgorodil@gmail.com>
1 parent 0dffa6d commit 71a07a5

File tree

3 files changed

+77
-36
lines changed

3 files changed

+77
-36
lines changed

src/wtk/challenge.rst

Lines changed: 21 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22
Wizards, Thieves and Knights
33
###############################################################################
44

5-
"Wizards, Thieves and Knights" (WTK) game is a "Paper, Rock and Scissors" clone
6-
but in a fantasy setting. It comes with a simple command line interface where
7-
the use must type in his or her choice. The enemy is controlled by the script.
8-
The player's goal is to gain as many score points, as it possible.
5+
"Wizards, Thieves and Knights" (:abbr:`WTK (Wizards, Thieves and Knights)`)
6+
game is a "Paper, Rock and Scissors" clone but in a fantasy setting. It comes
7+
with a simple command line interface where the use must type in his or her
8+
choice. The enemy is controlled by the script. The player's goal is to gain
9+
as many score points, as it possible.
910

1011
*****************
1112
Code organization
@@ -118,29 +119,22 @@ Settings module contains constants values for the game.
118119

119120
For example,
120121

121-
.. py:data:: INITIAL_PLAYER_NAME
122-
123-
Initial health meter value for a player instance
124-
125-
:type: int
126-
127-
.. py:data:: INITIAL_ENEMY_LEVEL
128-
129-
Indicates the level to initialize the first enemy instance.
130-
131-
:type: int
132-
133-
.. py:data:: SCORE_SUCCESS_ATTACK
134-
135-
Set the score value to assign when an attack is successful
136-
137-
:type: int
138-
139-
.. py:data:: SCORE_ENEMY_DOWN
140-
141-
Set the score value to assign when an enemy is defeated
142-
143-
:type: int
122+
.. autodata:: wtk.settings.INITIAL_PLAYER_HEALTH
123+
:no-value:
124+
.. autodata:: wtk.settings.INITIAL_ENEMY_LEVEL
125+
:no-value:
126+
.. autodata:: wtk.settings.SCORE_SUCCESS_ATTACK
127+
:no-value:
128+
.. autodata:: wtk.settings.SCORE_ENEMY_DOWN
129+
:no-value:
130+
131+
You may also define messages with this module, for example:
132+
133+
.. autodata:: wtk.settings.MSG_SUCCESS_ATTACK
134+
.. autodata:: wtk.settings.MSG_SUCCESS_DEFENCE
135+
.. autodata:: wtk.settings.MSG_FAILURE_ATTACK
136+
.. autodata:: wtk.settings.MSG_FAILURE_DEFENCE
137+
.. autodata:: wtk.settings.MSG_DRAW
144138

145139
******
146140
Engine

src/wtk/models.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ def __init__(self, level: int = settings.INITIAL_ENEMY_LEVEL) -> None:
4949
"""
5050
Initialize instance
5151
52+
Health value is equal to the level value.
53+
5254
:param level: an enemy's level indicator
5355
:type level: int
5456

src/wtk/settings.py

Lines changed: 54 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,61 @@
77
GAME_TITLE = "KNIGHT, THIEFS AND WIZARDS GAME"
88

99
# initial settings
10-
INITIAL_PLAYER_HEALTH = 5
11-
INITIAL_ENEMY_LEVEL = 1
10+
INITIAL_PLAYER_HEALTH: int = 5
11+
"""
12+
Initial player health value
13+
14+
:type INITIAL_PLAYER_HEALTH: int
15+
"""
16+
INITIAL_ENEMY_LEVEL: int = 1
17+
"""
18+
Initial enemy level value
19+
20+
:type INITIAL_ENEMY_LEVEL: int
21+
"""
1222

1323
# score assignment options
14-
SCORE_SUCCESS_ATTACK = 1
15-
SCORE_ENEMY_DOWN = 5
24+
SCORE_SUCCESS_ATTACK: int = 1
25+
"""
26+
Score points value to assign when player's attack is successful
27+
28+
:type SCORE_SUCCESS_ATTACK: int
29+
"""
30+
SCORE_ENEMY_DOWN: int = 5
31+
"""
32+
Score points value to assign when enemy is defeated
33+
34+
:type SCORE_ENEMY_DOWN: int
35+
"""
1636

1737
# messages
18-
MSG_SUCCESS_ATTACK = "YOUR ATTACK IS SUCCESSFUL!"
19-
MSG_SUCCESS_DEFENCE = "YOUR DEFENCE IS SUCCESSFUL!"
20-
MSG_FAILURE_ATTACK = "YOUR ATTACK IS FAILED!"
21-
MSG_FAILURE_DEFENCE = "YOUR DEFENCE HAS BEEN BREACHED!"
22-
MSG_DRAW = "IT'S A DRAW!"
38+
MSG_SUCCESS_ATTACK: str = "YOUR ATTACK IS SUCCESSFUL!"
39+
"""
40+
Successful attack message
41+
42+
:type MSG_SUCCESS_ATTACK: str
43+
"""
44+
MSG_SUCCESS_DEFENCE: str = "YOUR DEFENCE IS SUCCESSFUL!"
45+
"""
46+
Successful defence message
47+
48+
:type MSG_SUCCESS_DEFENCE: str
49+
"""
50+
MSG_FAILURE_ATTACK: str = "YOUR ATTACK IS FAILED!"
51+
"""
52+
Failed attack message
53+
54+
:type MSG_FAILURE_ATTACK: str
55+
"""
56+
MSG_FAILURE_DEFENCE: str = "YOUR DEFENCE HAS BEEN BREACHED!"
57+
"""
58+
Failed defence message
59+
60+
:type MSG_FAILURE_DEFENCE: str
61+
"""
62+
MSG_DRAW: str = "IT'S A DRAW!"
63+
"""
64+
Draw fight message
65+
66+
:type MSG_DRAW: str
67+
"""

0 commit comments

Comments
 (0)