Skip to content

Commit 50f4b2d

Browse files
committed
Final QA updates
1 parent b147f3d commit 50f4b2d

File tree

5 files changed

+22
-23
lines changed

5 files changed

+22
-23
lines changed

top-python-game-engines/README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,11 @@ Alternately, you can use `pgzrun` to run both games:
8585
```
8686

8787
### Note
88-
Checkers like [flake8 are unaware](https://pygame-zero.readthedocs.io/en/latest/installation.html#for-flake8-pyflakes) of Pygame Zero's extra built-ins.
89-
That's why xou'll find `# noqa: F821` inline comments in `pygame_zero_basic.py` and `pygame_zero_game.py`.
90-
With the `# noqa` inline comments [flake8](https://flake8.pycqa.org/en/3.1.1/user/ignoring-errors.html#in-line-ignoring-errors) ignores the errors that these lines would cause.
88+
89+
Linters like [flake8 are unaware](https://pygame-zero.readthedocs.io/en/latest/installation.html#for-flake8-pyflakes) of Pygame Zero's extra built-ins.
90+
That's why you'll find `# noqa: F821` inline comments in `pygame_zero_basic.py` and `pygame_zero_game.py`.
91+
92+
With the `# noqa` inline comments [flake8](https://flake8.pycqa.org/en/3.1.1/user/ignoring-errors.html#in-line-ignoring-errors) ignores the linter errors that these lines would cause.
9193

9294
## Arcade
9395

top-python-game-engines/adventurelib/adventurelib_basic.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,9 @@ def go(direction: str):
117117
@adv.when("look")
118118
def look():
119119
"""Looks at the current room"""
120-
global current_room
121120

122121
# Describe the room
123-
adv.say(f"{current_room}")
122+
adv.say(current_room)
124123

125124
# List the contents
126125
for item in current_room.contents:
@@ -173,8 +172,6 @@ def use(item: str):
173172
item {str} -- Which item to use
174173
"""
175174

176-
global inventory
177-
178175
# First, do you have the item?
179176
obj = inventory.take(item)
180177
if not obj:

top-python-game-engines/adventurelib/adventurelib_game.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def look_at(item: str):
7171
if not obj:
7272
print(f"I can't find {item} anywhere.")
7373
else:
74-
print(f"You current have {item}.")
74+
print(f"You have {item}.")
7575
else:
7676
print(f"You see {item}.")
7777

@@ -96,7 +96,7 @@ def describe(item: str):
9696
if not obj:
9797
print(f"I can't find {item} anywhere.")
9898
else:
99-
print(f"You current have {obj.description}.")
99+
print(f"You have {obj.description}.")
100100
else:
101101
print(f"You see {obj.description}.")
102102

@@ -134,7 +134,7 @@ def eat(item: str):
134134
inventory.take(item)
135135

136136
else:
137-
print(f"How do propose we eat {obj.description}?")
137+
print(f"How do you propose we eat {obj.description}?")
138138

139139

140140
@adv.when("wear ITEM")
@@ -200,7 +200,7 @@ def yes_elder():
200200
offering, and use it well!
201201
"""
202202
)
203-
current_room.items.add(adventurelib_game_items.wooden_sword)
203+
inventory.add(adventurelib_game_items.wooden_sword)
204204
current_room.locked_exits["south"] = False
205205

206206

@@ -290,7 +290,7 @@ def fight_giant(character: str):
290290

291291
# Is the giant dead?
292292
if giant_hit_points <= 0:
293-
end_game(True)
293+
end_game(victory=True)
294294

295295
print_giant_condition()
296296
print()
@@ -310,7 +310,7 @@ def fight_giant(character: str):
310310

311311
# Is the player dead?
312312
if hit_points <= 0:
313-
end_game(False)
313+
end_game(victory=False)
314314

315315
print_player_condition()
316316
print()
@@ -485,8 +485,8 @@ def go(direction: str):
485485
# Clear the context if necessary
486486
current_context = adv.get_context()
487487
if current_context == "giant":
488-
print(
489-
"""You way is currently blocked.\
488+
adv.say(
489+
"""Your way is currently blocked.
490490
Or have you forgotten the giant you are fighting?"""
491491
)
492492
else:
@@ -504,7 +504,7 @@ def go(direction: str):
504504

505505

506506
# Define a prompt
507-
def my_prompt():
507+
def prompt():
508508
global current_room
509509

510510
# Get possible exits
@@ -516,10 +516,10 @@ def my_prompt():
516516
else:
517517
prompt_string = f"({current_room.title}) > "
518518

519-
return f"""({exits_string}) {prompt_string} """
519+
return f"""({exits_string}) {prompt_string}"""
520520

521521

522-
def my_no_command_matches(command: str):
522+
def no_command_matches(command: str):
523523
if adv.get_context() == "wizard.riddle":
524524
adv.say("That is not the correct answer. Begone!")
525525
adv.set_context(None)
@@ -544,10 +544,10 @@ def get_exits(room):
544544
adv.set_context(None)
545545

546546
# Set the prompt
547-
adv.prompt = my_prompt
547+
adv.prompt = prompt
548548

549549
# What happens with unknown commands
550-
adv.no_command_matches = my_no_command_matches
550+
adv.no_command_matches = no_command_matches
551551

552552
# Look at your starting room
553553
look()

top-python-game-engines/adventurelib/adventurelib_game_rooms.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ def __init__(self, description: str):
123123
side_path = GameArea(
124124
"""
125125
The path leads away from the fork to Dunhaven. Fresh tracks of
126-
something big, dragging something behind it, lead away to the east.
126+
something big, dragging something behind it, lead away to the south.
127127
"""
128128
)
129129
side_path.title = "Side path"

top-python-game-engines/pygame_zero/pygame_zero_game.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def add_coin():
4545
"""Adds a new coin to playfield, then
4646
schedules the next coin to be added
4747
"""
48-
global coin_list, coin_countdown
48+
global coin_countdown
4949

5050
# Create a new coin Actor at a random location
5151
new_coin = Actor( # noqa: F821
@@ -97,7 +97,7 @@ def update(delta_time: float):
9797
Arguments:
9898
delta_time {float} -- Time since the last frame
9999
"""
100-
global coin_list, score
100+
global score
101101

102102
# Update the player position
103103
player.center = player_position

0 commit comments

Comments
 (0)