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

Commit 63d3c3e

Browse files
committed
WTK: general documentation updates
Signed-off-by: Serhii Horodilov <sgorodil@gmail.com>
1 parent 1605903 commit 63d3c3e

File tree

5 files changed

+44
-121
lines changed

5 files changed

+44
-121
lines changed

src/wtk/challenge.rst

Lines changed: 44 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
###############################################################################
2-
WIZARDS, THIEFS AND KNIGHTS GAME
2+
Wizards, Thiefs and Knights
33
###############################################################################
44

55
"Wizards, Thiefs and Knights" (WTK) game is a "Paper, Rock and Scissors" clone,
@@ -8,7 +8,7 @@ the use must type in his or her choice. The enemy is controlled by the script.
88
The player's goal is to gain as many score points, as it possible.
99

1010
*****************
11-
Code Organization
11+
Code organization
1212
*****************
1313

1414
Use separate modules to maintain your code base. For example:
@@ -22,13 +22,13 @@ Use separate modules to maintain your code base. For example:
2222
|-- settings.py
2323

2424
******************************
25-
General Playground Description
25+
General playground description
2626
******************************
2727

2828
The game process is divided into rounds. Each round consists of **attack** and
2929
**defence** stages. Rounds are repeated, until player is defeated.
3030

31-
Fight Rules
31+
Fight rules
3232
===========
3333

3434
It's simple...
@@ -37,7 +37,7 @@ It's simple...
3737
- **Thief** beats **Wizard**
3838
- **Wizard** beats **Knight**
3939

40-
Attack Stage
40+
Attack stage
4141
============
4242

4343
Player selects the choice to attack from **knight**, **thief** or **wizard**,
@@ -53,7 +53,7 @@ In case enemy is defeated:
5353
- player gains some extra score points
5454
- next defence stage is skipped, and player attacks again
5555

56-
Defence Stage
56+
Defence stage
5757
=============
5858

5959
Player selects the choice to defend from **knight**, **thief** or **wizard**,
@@ -71,100 +71,76 @@ If player is defeated:
7171
Exceptions
7272
**********
7373

74-
Enemy Down
74+
Enemy down
7575
==========
7676

7777
This is an exceptional scenario when enemy is defeated. A custom exception
7878
``EnemyDown`` should be used to track these cases. Exception should provide
7979
the details on the enemy's instance, especially its level.
8080

81-
Game Over
81+
.. autoclass:: wtk.exceptions.EnemyDown
82+
83+
Game over
8284
=========
8385

8486
This is an exceptional scenario when player is defeated. A custom exception
8587
``GameOver`` should be used to track these cases. Exception should provide
8688
the details on the player's instance, especially its score points.
8789

90+
.. autoclass:: wtk.exceptions.GameOver
91+
8892
******
8993
Models
9094
******
9195

9296
Enemy
9397
=====
9498

95-
Represents the playing enemy-bot. All choices made by this model are random.
96-
The model should implement methods:
99+
.. autoclass:: wtk.models.Enemy
100+
:members: decrease_health, select_attack, select_defence
101+
:special-members: __init__
97102

98-
:``__init__``:
99-
Initialize enemy instance. Initializer should receive one argument of
100-
integer type - ``level: int``. Health points value should be set equal
101-
to level value.
103+
You are free to implement other methods you like, if needed.
102104

103-
:``descrease_health``:
104-
Method decreases the health points value by 1 (one). If this value becomes
105-
less that 1 (one) the ``EnemyDown`` exception is raised.
105+
Player
106+
======
106107

107-
:``select_attack``:
108-
Return a random attack choice from valid choices.
108+
.. autoclass:: wtk.models.Player
109+
:members: decrease_health, select_attack, select_defence,
110+
fight, attack, defence
111+
:special-members: __init__
109112

110-
:``select_defence``:
111-
Return a random defence choice from valid choices.
113+
********
114+
Settings
115+
********
112116

113-
You are free to implement other methods you like, if needed.
117+
Settings module contains constants values for the game.
114118

115-
Player
116-
======
119+
For example,
117120

118-
This model is controlled by the user. It represents a playing user. All choices
119-
are controlled by the user. The model should implement methods:
121+
.. py:data:: INITIAL_PLAYER_NAME
120122
121-
:``__init__``:
122-
Initialize player instance. Initializer should receive player's name as
123-
an argument - ``name: str``. Health points are to be set from settings.
124-
Score points should be initialized with 0 (zero).
123+
Initial health meter value for a player instance
125124

126-
:``decrease_health``:
127-
Method decreases the health points value by 1 (one). If this value becomes
128-
less that 1 (one) the ``GameOver`` exception is raised.
125+
:type: int
129126

130-
:``select_attack``:
131-
Return a fight choice made by the user. Performs choice validation.
127+
.. py:data:: INITIAL_ENEMY_LEVEL
132128
133-
:``select_defence``:
134-
Return a fight choice made by the user. Performs choice validation.
129+
Indicates the level to initialize the first enemy instance.
135130

136-
:``fight``:
137-
Static method to perform a fight. Takes two arguments representing attack
138-
and defence choices. Performs fight result calculation and return it back.
131+
:type: int
139132

140-
:``attack``:
141-
Perform attack on an enemy instance. This method takes an enemy instance as
142-
an argument. After that, it takes attack choice from the player model and
143-
the defence choice from an enemy model. After fight result calculation
144-
required operation are to be performed (decrease enemy health, assign
145-
score points etc.). Based on fight result should print out a message:
133+
.. py:data:: SCORE_SUCCESS_ATTACK
146134
147-
- ``"YOUR ATTACK IS SUCCESSFUL!"``
148-
- ``"YOUR ATTACK IS FAILED!"``
149-
- ``IT'S A DRAW!"``
135+
Set the score value to assign when an attack is successful
150136

151-
:``defence``:
152-
Perform defence from an enemy attack. This method takes an enemy instance
153-
as an argument. After that, it takes defence choice from the player model
154-
and the attack choice from an enemy model. After fight result calculation
155-
required operation are to be performed (decrease player health). Based on
156-
fight result should print out a message:
137+
:type: int
157138

158-
- ``"YOUR DEFENCE IS SUCCESSFUL!"``
159-
- ``"YOUR DEFENCE IS FAILED!"``
160-
- ``IT'S A DRAW!"``
139+
.. py:data:: SCORE_ENEMY_DOWN
161140
162-
********
163-
Settings
164-
********
141+
Set the score value to assign when an enemy is defeated
165142

166-
**settings.py** module contains constants values for the game (e.g.
167-
``INITIAL_PLAYER_HEALTH = 5``).
143+
:type: int
168144

169145
******
170146
Engine
@@ -182,6 +158,8 @@ Asks the user to type in his or her name and return it back.
182158
Leading and trailing whitespaces are to be trimmed.
183159
Name should contain at least one character.
184160

161+
.. autofunction:: wtk.engine.get_player_name
162+
185163
Play
186164
====
187165

@@ -194,6 +172,8 @@ terminal.
194172
``KeyboardInterrupt`` should be handled as well - it's behavior is similar
195173
to "Game Over" event, but "game over" message should be omitted.
196174

175+
.. autofunction:: wtk.engine.play
176+
197177
*********************
198178
Optional Enhancements
199179
*********************
@@ -205,3 +185,4 @@ Optional Enhancements
205185
AVAILABLE MENU CHOICES: PLAY, SCORES, EXIT
206186
TYPE YOUR CHOICE HERE:
207187

188+
#. Store score table to the database instead of using text file.

src/wtk/engine.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
11
"""
2-
***********
32
Game engine
4-
***********
5-
6-
The game engine implements core functions:
7-
8-
.. autofunction:: get_player_name
9-
10-
.. autofunction:: play
113
124
"""
135

src/wtk/exceptions.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
"""
2-
**************
32
Game exception
4-
**************
5-
6-
.. autoclass:: EnemyDown
7-
8-
.. autoclass:: GameOver
93
104
"""
115

src/wtk/models.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,5 @@
11
"""
2-
***********
32
Game models
4-
***********
5-
6-
Enemy
7-
=====
8-
9-
.. autoclass:: Enemy
10-
:members: decrease_health, select_attack, select_defence
11-
:special_members: __init__
12-
13-
Player
14-
======
15-
16-
.. autoclass:: Player
17-
:members: decrease_health, select_attack, select_defence, attack, defence
18-
:special_members: __init__
193
204
"""
215

src/wtk/settings.py

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,5 @@
11
"""
2-
*************
32
Game settings
4-
*************
5-
6-
This module contains game settings and constants.
7-
8-
.. py:data: INITIAL_PLAYER_NAME
9-
10-
Initial health meter value for a player instance
11-
12-
:type: int
13-
14-
.. py:data: INITIAL_ENEMY_LEVEL
15-
16-
Indicates the level to initialize the first enemy instance.
17-
18-
:type: int
19-
20-
.. py:data: SCORE_SUCCESS_ATTACK
21-
22-
Set the score value to assign when an attack is successful
23-
24-
:type: int
25-
26-
.. py:data: SCORE_ENEMY_DOWN
27-
28-
Set the score value to assign when an enemy is defeated
29-
30-
:type: int
313
324
"""
335

0 commit comments

Comments
 (0)