Created
September 17, 2016 21:51
-
-
Save JerzySpendel/4c03da7bf59dd2306d3c4efc4006f42a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
PAPER, ROCK, SCISSORS = 1, 2, 3 | |
def show_menu(): | |
print('1. Wcisnij 1 żeby rozpocząć grę') | |
print('2. Wciśnij 2, aby zakończyć') | |
print() | |
return int(input()) | |
def attack_option(): | |
print('1. Wpisz 1, aby wybrać papier') | |
print('2. Wpisz 2, aby wybrać kamień') | |
print('3. Wpisz 3, aby wybrać nożyce') | |
return int(input()) | |
def won(choice): | |
bot_choice = random.choice([x for x in range(1, 3+1)]) | |
if choice == PAPER: | |
return bot_choice == ROCK | |
elif choice == ROCK: | |
return bot_choice == SCISSORS | |
elif choice == SCISSORS: | |
return bot_choice == PAPER | |
def game(): | |
wins = 0 | |
for _ in range(3): | |
choice = attack_option() | |
if not won(choice): | |
print('Tę rundę przegrałeś') | |
else: | |
print('Tę rundę wygrałeś!') | |
wins += 1 | |
if wins != 2: | |
print('Przegrałeś grę') | |
else: | |
print('Wygrałeś grę!') | |
while True: | |
decision = show_menu() | |
if decision == 1: | |
game() | |
else: | |
break | |
print('Gra zakończona') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment