Fix global var bug

This commit is contained in:
Anthony Wang 2023-01-15 19:06:02 -05:00
parent 37a70d73dc
commit 9dcb86f9f9
Signed by: a
GPG key ID: 42A5B952E6DD8D38

View file

@ -123,7 +123,7 @@ def interact_with_student():
# Main game loop # Main game loop
def play_game(): def play_game():
global player_hunger, player_health, player_inventory global player_name, player_hunger, player_health, player_inventory
# Introduction # Introduction
sprint("Welcome to Next Dining: The Video Game!") sprint("Welcome to Next Dining: The Video Game!")
sprint("What is your name?") sprint("What is your name?")
@ -151,12 +151,12 @@ def play_game():
display_status() display_status()
else: else:
sprint("Invalid action. Please try again.") sprint("Invalid action. Please try again.")
# Hunger and health decrement # Hunger and health decrement
player_hunger += 5 player_hunger += 5
if chef_angry: if chef_angry:
player_health -= 10 player_health -= 10
# Check for game over # Check for game over
if player_health <= 0: if player_health <= 0:
sprint("Your health has reached zero. Game over.") sprint("Your health has reached zero. Game over.")