rps-game.py 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. import random
  2. print("Wellcome to the Rock-Paper-Scissors Game")
  3. rock = '''
  4. _______
  5. ---' ____)
  6. (_____)
  7. (_____)
  8. (____)
  9. ---.__(___)
  10. '''
  11. paper = '''
  12. _______
  13. ---' ____)____
  14. ______)
  15. _______)
  16. _______)
  17. ---.__________)
  18. '''
  19. scissors = '''
  20. _______
  21. ---' ____)____
  22. ______)
  23. __________)
  24. (____)
  25. ---.__(___)
  26. '''
  27. signs = [rock, paper, scissors]
  28. def res_print(res):
  29. if res == "win":
  30. print("==== You win! ====\n")
  31. elif res == "lose":
  32. print("==== Computer wins ====\n")
  33. elif res == "draw":
  34. print("==== It's a draw ====\n")
  35. else:
  36. print("Something went wrong! End of the game")
  37. def game():
  38. comp_choise = random.randint(0, 2)
  39. while True:
  40. your_choise = int(input("Choose you destiny. Rock - 0, papper - 1, scissors - 2: "))
  41. if your_choise >= 0 and your_choise <= 2:
  42. break
  43. print("Your chose: \n" + signs[your_choise])
  44. print("Computer chose: \n" + signs[comp_choise])
  45. if comp_choise == your_choise:
  46. res_print("draw")
  47. else:
  48. if comp_choise == 0:
  49. if your_choise == 1:
  50. res_print("win")
  51. else:
  52. res_print("lose")
  53. elif comp_choise == 1:
  54. if your_choise == 0:
  55. res_print("lose")
  56. else:
  57. res_print("win")
  58. else:
  59. if your_choise == 0:
  60. res_print("win")
  61. else:
  62. res_print("lose")
  63. game()
  64. while True:
  65. if input("Play again? Y/N: ").lower() == "y":
  66. game()
  67. else:
  68. break