Next-Dining-The-Video-Game/main.py
2023-01-15 19:06:02 -05:00

177 lines
7.2 KiB
Python

import time
import random
# Initializing variables
player_name = ""
player_hunger = 90
player_health = 50
player_inventory = []
player_location = "lobby"
chef_angry = False
chef_names = ["Soup Nazi", "Halloween Lady", "Good Evening Lady"]
def sprint(s):
for c in s:
print(c, end="", flush=True)
time.sleep(0.025)
print()
# Function to display player's current status
def display_status():
sprint("Name: " + player_name)
sprint("Hunger: " + str(player_hunger))
sprint("Health: " + str(player_health))
sprint("Inventory: " + str(player_inventory))
sprint("Location: " + player_location)
# Function to move player to a new location
def move_location(new_location):
global player_location
player_location = new_location
sprint("You are now in the " + new_location)
# Function to handle player's interactions with chefs
def interact_with_chef():
global chef_angry, player_hunger, player_health, player_inventory
chef_name = random.choice(chef_names)
sprint("You approach " + chef_name + " in the kitchen.")
sprint("What would you like to do? (speak, steal, run)")
action = input()
if action == "speak":
sprint("You ask " + chef_name + " for some food. They glare at you and refuse to give you any.")
chef_angry = True
elif action == "steal":
if "stealth" in player_inventory:
sprint("You use your stealth skills to sneak some food from the kitchen without " + chef_name + " noticing.")
player_hunger -= 25
sprint("You successfully steal some food and your hunger is now at " + str(player_hunger) + ".")
sprint("You gained a stir fry!")
player_inventory.append("stir fry")
else:
sprint("You try to steal some food from the kitchen, but " + chef_name + " catches you.")
sprint("They are furious and call security to escort you out of the building.")
move_location("outside")
player_health -= 25
elif action == "run":
sprint("You quickly run away from " + chef_name + " before they can react.")
else:
sprint("Invalid action. Please try again.")
interact_with_chef()
# Function to handle player's interactions with vending machines
def interact_with_vending_machine():
global player_hunger, player_health, player_inventory
sprint("You approach a vending machine.")
sprint("What would you like to do? (buy, hack)")
action = input()
if action == "buy":
sprint("You insert some money and select your desired snack.")
player_hunger -= 15
sprint("You successfully buy a snack and your hunger is now at " + str(player_hunger) + ".")
elif action == "hack":
if "hacking" in player_inventory:
sprint("You use your hacking skills to hack the vending machine and get a free snack.")
player_hunger -= 25
sprint("You successfully hack the vending machine and your hunger is now at " + str(player_hunger) + ".")
sprint("Additionally, you gained stealth!")
player_inventory.append("stealth")
else:
sprint("You try to hack the vending machine, but you are unsuccessful.")
sprint("A security guard approaches and asks you to leave the building.")
move_location("outside")
player_health -= 10
else:
sprint("Invalid action. Please try again.")
interact_with_vending_machine()
# Function to handle player's interactions with other students
def interact_with_student():
global player_hunger, player_health, player_inventory
student_name = "John" # name of student is randomly generated
sprint("You approach " + student_name + " in the dining hall.")
sprint("What would you like to do? (speak, learn, trade)")
action = input()
if action == "speak":
sprint("You strike up a conversation with " + student_name + " and learn some valuable information about the dining hall.")
player_hunger += 5
elif action == "learn":
sprint(student_name + " teaches you how to hack.")
player_hunger += 5
player_inventory.append("hacking")
elif action == "trade":
sprint("You ask " + student_name + " if they would like to trade items.")
student_item = "extra meal ticket" # item student has is randomly generated
sprint(student_name + " has an " + student_item + " and is willing to trade it for one of your items.")
if player_inventory:
sprint("Your current inventory: " + str(player_inventory))
sprint("What item would you like to trade?")
trade_item = input()
if trade_item in player_inventory:
if trade_item == "stir fry":
player_inventory.remove(trade_item)
player_inventory.append(student_item)
sprint("You successfully trade your " + trade_item + " for " + student_name + "'s " + student_item + ".")
else:
sprint(student_name + " doesn't like your item.")
else:
sprint("You do not have that item in your inventory.")
else:
sprint("You do not have any items to trade.")
else:
sprint("Invalid action. Please try again.")
interact_with_student()
# Main game loop
def play_game():
global player_name, player_hunger, player_health, player_inventory
# Introduction
sprint("Welcome to Next Dining: The Video Game!")
sprint("What is your name?")
player_name = input()
display_status()
# Gameplay
while player_health > 0 and player_hunger <= 100:
sprint("What would you like to do? (move, interact, check status)")
action = input()
if action == "move":
sprint("Where would you like to go? (kitchen, dining hall, vending room, outside)")
new_location = input()
move_location(new_location)
elif action == "interact":
if player_location == "kitchen":
interact_with_chef()
elif player_location == "vending room":
interact_with_vending_machine()
elif player_location == "dining hall":
interact_with_student()
else:
sprint("There is nothing to interact with in this location.")
elif action == "check status":
display_status()
else:
sprint("Invalid action. Please try again.")
# Hunger and health decrement
player_hunger += 5
if chef_angry:
player_health -= 10
# Check for game over
if player_health <= 0:
sprint("Your health has reached zero. Game over.")
break
elif player_hunger >= 100:
sprint("You have died of starvation. Game over.")
break
elif player_location == "outside":
sprint("You have been kicked out of the building and cannot continue playing.")
break
# End game message
sprint("Thank you for playing Next Dining: The Video Game! Better luck next time.")
if "extra meal ticket" in player_inventory:
sprint("Congratulations! You won!")
break
play_game()