Advertisement
VinColo

Python Healthy Shopping Game

Aug 29th, 2013
1,274
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.07 KB | None | 0 0
  1. from sys import exit
  2. from ext_links import *
  3. from game_messages import *
  4.  
  5. init_hscore = 100
  6. final_score = 0
  7.  
  8. # Beginning. Proceed or quit game.
  9. def start():
  10.     print "Your shopping habits will either help you live longer or they will help you die sooner. No kidding! Wanna find out which one of the two in your case?", yn
  11.    
  12.     find_out = raw_input(select).upper()
  13.    
  14.     if find_out == "YES":
  15.         print "\nGreat! Let's go shopping... but first..."
  16.         print "Think of this as a personal health deposit account at the Health Bank..."
  17.         print "Your starting Health Score is: %d" % init_hscore
  18.         print "So, here is the situation..."
  19.         inner_outer()
  20.     else:
  21.         out("No prob. May be next time.")
  22.  
  23.  
  24. # Choose shopping from inner or outer isles
  25. def inner_outer():
  26.     print "You enter the grocery store. You have to choose between the 'inner' or 'outer' isles. Which isles do you choose?"
  27.    
  28.     init_isle = raw_input(select).lower()
  29.    
  30.     if init_isle == "inner":
  31.         inner()
  32.     elif init_isle == "outer":
  33.         outer()
  34.     else:
  35.         print not_sure
  36.         inner_outer()
  37.        
  38.  
  39. # Define inner isles and the four subcategories.       
  40. def inner():
  41.     print "Okay. You are about to do some shopping from the inner isles of the store!"
  42.     print "There are four main sections. Choose which section you want to go to first."
  43.     print "Your choices are: \n\n\t cereal \n\t snacks and chips \n\t peanut butter \n\t sports drinks\n"
  44.    
  45.     inner_choice = raw_input(select).lower()
  46.    
  47.     if inner_choice == "cereal":
  48.         new_hscore = init_hscore - 5
  49.         print "NOTE: Shopping from the 'cereal' isle is not a good idea. \nYou just lost 5 points from your Health Score. \nYour new Health Score is %d!" % new_hscore
  50.         print cereal_url
  51.         again()
  52.     elif inner_choice == "snacks and chips":
  53.         new_hscore = init_hscore - 5
  54.         print "NOTE: Shopping from the 'snacks and chips' isle is not a good idea. \nYou just lost 5 points from your Health Score. \nYour new Health Score is %d!" % new_hscore
  55.         print snack_url
  56.         again()
  57.     elif inner_choice == "peanut butter":
  58.         new_hscore = init_hscore - 5
  59.         print "NOTE: Shopping from the 'peanut butter' isle is not a good idea. \nYou just lost 5 points from your Health Score. \nYour new Health Score is %d!" % new_hscore
  60.         print peanut_url
  61.         again()
  62.     elif inner_choice == "sports drinks":
  63.         new_hscore = init_hscore - 5
  64.         print "NOTE: Shopping from the 'sports drinks' isle is not a good idea. \nYou just lost 5 points from your Health Score. \nYour new Health Score is %d!" % new_hscore
  65.         print gatorade_url
  66.         again()
  67.     else:
  68.         print not_sure
  69.         inner()
  70.        
  71.  
  72. # Define outer isles and the three subcategories.          
  73. def outer():
  74.     print "You are about to shop from the outer isles of the store!"
  75.     print "There are three main sections. Choose which section you want \nto go to first."
  76.     print "Your choices are: \n\n\t produce \n\t dairy \n\t meat \n"
  77.    
  78.     outer_choice = raw_input(select).lower()
  79.    
  80.     if outer_choice == "produce":
  81.         new_hscore = init_hscore + 5
  82.         print "Awesome! Shopping from the 'produce' isle is a great idea. \nYou just added 5 points to your Health Score. \nYour new Health Score is %d!" % new_hscore
  83.         print poduce_url
  84.         again()
  85.     elif outer_choice == "dairy":
  86.         new_hscore = init_hscore + 2
  87.         print "Alright. Shopping from the 'dairy' isle is a good idea. \nYou just added 2 points to your Health Score. \nYour new Health Score is %d!" % new_hscore
  88.         print dairy_url
  89.         again()
  90.     elif outer_choice == "meat":
  91.         new_hscore = init_hscore + 2
  92.         print "Not bad! Shopping from the 'meat' isle could be a good idea. \nYou just added 2 points to your Health Score. \nYour new Health Score is %d!" % new_hscore
  93.         print meat_url
  94.         again()
  95.     else:
  96.         print not_sure
  97.         outer()
  98.  
  99.  
  100.  
  101. # Define a function for quitting the game      
  102. def out(why):
  103.     print why, "Your final Health Score is: %d" % final_score
  104.     print "Good bye!"
  105.     exit(0)
  106.    
  107.  
  108. # Define a function for going back to choosing from inner or outer isles 'inner_outer()'   
  109. def again():
  110.     print "Want to continue shopping?", yn
  111.     go_again = raw_input(select).upper()
  112.    
  113.     if go_again == "YES":
  114.         inner_outer()
  115.     else:
  116.         out("No prob.")
  117.    
  118.  
  119. # Initiate the game
  120. start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement