Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from random import choice
- # Globals
- health = 5
- food_pounds = 500
- miles_to_go = 2000
- cur_month = 3
- cur_day = 1
- game_over = False
- months_with_31_days = [3, 5, 7, 8, 10, 12]
- def add_day():
- global cur_month, cur_day, miles_to_go, food_pounds, health
- if cur_day == 31 or (cur_day == 30 and cur_month not in months_with_31_days):
- cur_month += 1
- cur_day = 1
- else:
- cur_day += 1
- food_pounds -= 5
- if food_pounds < 0:
- print('GAME OVER')
- print('You lost! You had nothing to eat and starved to death!')
- status()
- exit()
- print('You ate 5 lbs of food. Food remaining: ' + str(food_pounds))
- if choice(range(14)) == 0:
- health -= 1
- print('You got sick and lost one health! Your health is now: ' + str(health) + 'hp')
- if health <= 0:
- print('GAME OVER')
- print('You lost! Your health dropped below 1!')
- status()
- exit()
- print('It is now %d/%d' % (cur_month, cur_day))
- if (cur_month, cur_day) == (12, 31):
- print('GAME OVER')
- if miles_to_go > 0:
- print('You lost! You did not make it before 12/31!')
- else:
- print('You won! You survived the Oregon Trail!')
- miles_to_go = 0
- status()
- exit()
- def travel():
- global miles_to_go
- miles_to_go -= choice(range(30, 61))
- for i in range(choice(range(3, 8))):
- add_day()
- if miles_to_go <= 0:
- print('You won! You survived the Oregon Trail!')
- miles_to_go = 0
- status()
- if miles_to_go <= 0:
- exit()
- def rest():
- global health
- if health < 5:
- for i in range(choice(range(2, 6))):
- add_day()
- health += 1
- print('Your health increases by 1 up to ' + str(health))
- else:
- print('Your health is already maxed out and there is no time to waste!')
- def hunt():
- global food_pounds
- food_pounds += 100
- for i in range(choice(range(2, 6))):
- add_day()
- print('You had a good hunt and your food stores increase by 100 up to ' + str(food_pounds))
- def status():
- print(name + ', your current status is:')
- print('-Today is ' + str(cur_month) + '/' + str(cur_day))
- print('-Food: ' + str(food_pounds) + ' pounds')
- print('-Health: ' + str(health))
- print('-Distance traveled: ' + str(2000 - miles_to_go) + ' miles')
- print(' You still have ' + str(miles_to_go) + ' miles to go before you reach Oregon.')
- def help():
- print('Commands: travel, rest, hunt, status, help, quit')
- def quit():
- print('You gave up on your dreams to make it to Oregon!')
- status()
- exit()
- def take_action(command):
- if command == 'travel':
- travel()
- elif command == 'rest':
- rest()
- elif command == 'hunt':
- hunt()
- elif command == 'status':
- status()
- elif command == 'help':
- help()
- elif command == 'quit':
- quit()
- name = input('What is your name? ')
- while True:
- print('\nWhat do you want to do? (Type "help" to list commands)')
- command = input('>')
- take_action(command)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement