Advertisement
daichan21

baseballDone.py

Nov 25th, 2014
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 6.42 KB | None | 0 0
  1. import time
  2. import random
  3. import math
  4.  
  5. scoreCounter = 0
  6. theZone = [' '] * 10
  7.  
  8. def twp(string, typewriterN):
  9.     listOfString = list(string)
  10.     indexOfString = list(range(len(listOfString)))
  11.     j = 0
  12.     while j < len(listOfString):
  13.         print(listOfString[j], end='')
  14.         j = j+1
  15.         time.sleep(1/typewriterN)
  16.  
  17. def cfnp(string, confusingN):
  18.     listOfString = list(string)
  19.     indexOfString = list(range(len(listOfString)))
  20.     while len(listOfString) >= 1:
  21.         k = random.randint(0, len(listOfString)-1)
  22.         print(listOfString[k], end='')
  23.         del listOfString[k]
  24.         time.sleep(1/confusingN)
  25.  
  26. def happyEnding():
  27.     twp("Bernard Marx decides that you are fit enough to be a part of the World State.\n", 30)
  28.     twp("Congratulations! You've managed to achieve the impossible.\n", 15)
  29.     twp("Thank you for playing Brave New World by D. Zhang\n", 10)
  30.     twp("THE END", 5)
  31.  
  32. def sadEnding():
  33.     twp("Bernard Marx decides that you are not fit enough to be a part of the World State.\n", 30)
  34.     twp("You have been defeated by destiny.\n", 15)
  35.     twp("Thank you for playing Brave New World by D. Zhang\n", 10)
  36.     twp("THE END", 5)
  37.  
  38. def strikeZone(board):
  39.    
  40.     print('   |   |')
  41.     print(' ' + board[7] + ' | ' + board[8] + ' | ' + board[9])
  42.     print(' 1 | 2 | 3')
  43.     print('-----------')
  44.     print(' 4 | 5 | 6')
  45.     print(' ' + board[4] + ' | ' + board[5] + ' | ' + board[6])
  46.     print('   |   |')
  47.     print('-----------')
  48.     print(' 7 | 8 | 9')
  49.     print(' ' + board[1] + ' | ' + board[2] + ' | ' + board[3])
  50.     print('   |   |')
  51.  
  52. twp("""
  53. ######  #######    #    ####### #     #
  54. #     # #         # #      #    #     #
  55. #     # #        #   #     #    #     #
  56. #     # #####   #     #    #    #######
  57. #     # #       #######    #    #     #
  58. #     # #       #     #    #    #     #
  59. ######  ####### #     #    #    #     #
  60.                                        
  61. ######     #     #####  ####### ######     #    #       #      
  62. #     #   # #   #     # #       #     #   # #   #       #      
  63. #     #  #   #  #       #       #     #  #   #  #       #      
  64. ######  #     #  #####  #####   ######  #     # #       #      
  65. #     # #######       # #       #     # ####### #       #      
  66. #     # #     # #     # #       #     # #     # #       #      
  67. ######  #     #  #####  ####### ######  #     # ####### ####### by D. Zhang
  68. """, 1000)
  69.  
  70. twp("BERNARD MARX: 'Congratulations, you survived!'\n", 35)
  71. twp("'Now it's time for your next quest, baseball! \n", 35)
  72. cfnp("TEST 2 - PHYSICAL CAPABILITIES   LOCATION: DODGER STADIUM, LOS ANGELES, WORLD STATE\n", 30)
  73. twp("TEST 2 - PHYSICAL CAPABILITIES   LOCATION: DODGER STADIUM, LOS ANGELES, WORLD STATE\n", 15)
  74.  
  75. def baseballLegit():
  76.     twp("Please select difficulty: rookie, easy, hard, insane.\n", 15)
  77.     difficultyChooser = input()
  78.     twp("Difficulty " + difficultyChooser + " registered.\n", 10)
  79.     twp("Initializing Strike Zone..........................\n", 5)
  80.     twp("Loading...........................................\n", 10)
  81.        
  82.     twp("Press Enter to start your quest. \n", 30)
  83.     varEmpty6 = input()
  84.  
  85.     twp("Please choose your bat: Pine, aluminum, iron, Major League\n", 10)
  86.     bat = input()
  87.     twp("You pick up a " + bat + " bat, and proceed to the stadium.\n", 10)
  88.    
  89.  
  90.     strikeZone(theZone)
  91.  
  92.     twp("BERNARD MARX: 'Let's have some fun. I will be the pitcher and you will be the batter.\n'", 35)
  93.     twp("Here's the strike zone. You see that each part of the Zone has a number on it.\n", 35)
  94.     twp("As batter, you can pick 2 parts of the zone you are aiming at hitting.\n", 35)
  95.     twp("You also have the choice of letting the electromagnetic computer decide for you.\n", 35)
  96.     twp("Don't worry. The computer algorithm is purely random.\n", 35)
  97.     twp("Do you want to hit for yourself or let the computer hit for you?\n", 20)
  98.  
  99.     twp("Choose A if you want to hit the ball yourself. Choose B for automatic control.\n", 35)
  100.     howToHit = input()
  101.     while howToHit == 'B':
  102.           twp("The game is currently under testing. This function is not yet available.\n", 35)
  103.           howToHit = input("Press A please.")
  104.     else:
  105.         strikeCount = 0
  106.         while strikeCount < 3:
  107.             twp("\nPlease select your first number between 1 and 9:\t", 30)
  108.  
  109.             firstChoice = input()
  110.  
  111.             twp("\nPlease select your second number between 1 and 9:\t", 30)
  112.  
  113.             secondChoice = input()
  114.  
  115.             pitcherNumber = random.randint(1, 9)
  116.             ballBank = ['75 mph curveball', '50 mph eephus', '99 mph 4 seamer fastball', '88 mph backdoor slider', '62 mph knuckleball', '105 mph flameball!!', '30 mph little league pitch']
  117.             ballType = random.choice(ballBank)
  118.             twp("Bernard Marx winds up on the mound...\n", 27)
  119.             time.sleep(0.75)
  120.             twp("he stretches...\n", 23)
  121.             time.sleep(0.85)
  122.             twp("and pitches a " + ballType + " that flies toward...\n", 15)
  123.             time.sleep(1)
  124.             twp(str(pitcherNumber) + " part of the strike zone!", 10)
  125.  
  126.             if firstChoice == str(pitcherNumber):
  127.                 twp("And you aim carefully, and swing the bat with all your might!\n",15)
  128.                 twp("IT'S A HOMERUN!\n", 5)
  129.                 happyEnding()
  130.                 break
  131.             elif secondChoice == str(pitcherNumber):
  132.                 twp("And you aim carefully, and swing the bat with all your might!\n",15)
  133.                 twp("IT'S A HOMERUN!\n", 5)
  134.                 happyEnding()
  135.                 break
  136.             else:
  137.                 strikeCount = strikeCount + 1
  138.                 if strikeCount == 3:
  139.                     twp("\nThat is a really nasty pitch. It's impossible to locate. You miss terribly again.\n", 15)
  140.                     twp("That's the 3rd strike, and you are out. YOU LOSE.\n", 10)
  141.                     sadEnding()
  142.                     break
  143.                 else:
  144.                     twp("\nYou try to locate the tricky pitch, but you miss it by inches. STRIKE!\n", 15)
  145.                     twp("Strike count: " + str(strikeCount), 19)
  146.  
  147.        
  148.  
  149. def replayAgain():
  150.     twp("\nWould you like to play again?", 20)
  151.     playAgain = input()
  152.     if playAgain == 'Yes' or playAgain == 'yes':
  153.         baseballLegit()
  154.     else:
  155.         twp("\nThank you for playing!", 20)
  156.    
  157. varEmpty3 = input('Press Enter Key to Continue.\n \n \n \n')
  158.  
  159.  
  160.  
  161. baseballLegit()
  162. replayAgain()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement