Advertisement
logancberrypie

big cardo boy

Sep 7th, 2016
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.89 KB | None | 0 0
  1. from random import randint
  2. from tkinter import *
  3.  
  4.  
  5. """******
  6. Task 3
  7. ******"""
  8.  
  9. """*************************************
  10. Part 1 changes:
  11.  
  12. Fixed errors
  13. allowed acceptance of lower case letters
  14. *************************************"""
  15.  
  16. ###create a list of play options
  17. ##t = ["rock", "paper", "scissors"]
  18. ##
  19. ###assign a random play to the computer
  20. ##computer = t[randint(0,2)]
  21. ##
  22. ###set player to Falsea
  23. ##player = False
  24. ##
  25. ##while player == False:
  26. ###set player to True
  27. ## player = input("Rock, Paper, Scissors?").lower()
  28. ## if player == computer:
  29. ## print("Tie!")
  30. ## elif player == "rock":
  31. ## print("You win!", player, "smashes", computer)
  32. ## elif player == "paper":
  33. ## if computer == "scissors":
  34. ## print("You lose!", computer, "cut", player)
  35. ## else:
  36. ## print("You win!", player, "covers", computer)
  37. ## elif player == "scissors":
  38. ## if computer == "rock":
  39. ## print("You lose...", computer, "smashes", player)
  40. ## else:
  41. ## print("You win!", player, "cut", computer)
  42. ## else:
  43. ## print("That's not a valid play. Check your spelling!")
  44. ## #player was set to True, but we want it to be False so the loop continues
  45. ## player = False
  46. ## computer = t[randint(0,2)]
  47.  
  48.  
  49. """
  50. Part 2 additions :
  51. Added equation based decisions
  52. Added Spock , Lizard and magical eLF
  53. Added GUI
  54. """
  55.  
  56.  
  57.  
  58. def check(player , computer):
  59. if selection[player] == computer:
  60. print("Tie")
  61. elif computer == selection[(player-1)%6] or computer == selection[(player+2)%6]:
  62. print("You win!",selection[player],"beats",computer)
  63. else:
  64. print("You lose!",computer,"beats",selection[player])
  65.  
  66. def main(player):
  67. value = selection.index(player)
  68. computer = selection[randint(0,5)]
  69. check(value , computer)
  70.  
  71. def GUI():
  72. window = Tk()
  73. window.title("Rock , paper , sissors , spock , lizard , eLF")
  74.  
  75. label = Label(window,text="Click on Rock , paper , Scissors , Spock , Lizard or magical eLF")
  76. label.pack()
  77.  
  78. topframe = Frame(window)
  79. topframe.pack(side=TOP)
  80.  
  81. rock = Button(window, text="Rock", fg="red",command= lambda: main("rock"))
  82. paper = Button(window, text="paper", fg="blue",command= lambda: main("paper"))
  83. scissor = Button(window, text="scissor", fg="green",command= lambda: main("scissors"))
  84. spock = Button(window, text="Spock", fg="purple",command= lambda: main("spock"))
  85. lizard =Button(window, text="lizard", fg="yellow",command= lambda: main("lizard"))
  86. eLF = Button(window, text="eLF", fg="aqua",command= lambda: main("eLF"))
  87.  
  88. rock.pack(side=TOP)
  89. paper.pack(side=TOP)
  90. scissor.pack(side=TOP)
  91. spock.pack(side=TOP)
  92. lizard.pack(side=TOP)
  93. eLF.pack(side=TOP)
  94.  
  95. window.mainloop()
  96.  
  97.  
  98. #Globals
  99. selection = ["rock","paper","scissors","spock","lizard","eLF"]
  100.  
  101.  
  102. GUI()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement