Repository navigation
Expand file tree
/
Copy pathJankenPython.py
More file actions
102 lines (86 loc) · 2.81 KB
/
Copy pathJankenPython.py
File metadata and controls
102 lines (86 loc) · 2.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
import random
Aleat = 0
win = 0
lose = 0
draw = 0
choise = ""
hand = 0
def choiseHand():
global hand
hand = int(input("1 = PEDRA / 2 = PAPEL / 3 = TESOURA: "))
validaHand()
def validaChoice():
global choise
if choise == "s":
choiseHand()
elif choise == "n":
print("Obrigado por jogar Janken-Python!")
else:
print("Opção inválida.")
options()
def options():
global choise
choise = input("Deseja jogar de novo? s / n ").lower()
validaChoice()
def battle():
global win, lose, draw, hand
Aleat = random.randint(1, 3)
if Aleat == 1 and hand == 1: # Batalha - PEDRA
draw = draw + 1
print("\nPedra x Pedra: Deu empate!")
print(f"\nSeu placar: {win} Vitórias | {lose} Derrotas | {draw} Empates.")
options()
if Aleat == 2 and hand == 1:
lose = lose + 1
print("\nPedra x Papel: Você perdeu!")
print(f"\nSeu placar: {win} Vitórias | {lose} Derrotas | {draw} Empates.")
options()
if Aleat == 3 and hand == 1:
win = win + 1
print("\nPedra x Tesoura: Você venceu!")
print(f"\nSeu placar: {win} Vitórias | {lose} Derrotas | {draw} Empates.")
options()
if Aleat == 1 and hand == 2: # Batalha - PAPEL
win = win + 1
print("\nPapel x Pedra: Você venceu!")
print(f"\nSeu placar: {win} Vitórias | {lose} Derrotas | {draw} Empates.")
options()
if Aleat == 2 and hand == 2:
draw = draw + 1
print("\nPapel x Papel: Deu empate!")
print(f"\nSeu placar: {win} Vitórias | {lose} Derrotas | {draw} Empates.")
options()
if Aleat == 3 and hand == 2:
lose = lose + 1
print("\nPapel x Tesoura: Você perdeu!")
print(f"\nSeu placar: {win} Vitórias | {lose} Derrotas | {draw} Empates.")
options()
if Aleat == 1 and hand == 3: # Batalha -TESOURA
lose = lose + 1
print("\nTesoura x Pedra: Você perdeu!")
print(f"\nSeu placar: {win} Vitórias | {lose} Derrotas | {draw} Empates.")
options()
if Aleat == 2 and hand == 3:
win = win + 1
print("\nTesoura x Papel: Você Venceu!")
print(f"\nSeu placar: {win} Vitórias | {lose} Derrotas | {draw} Empates.")
options()
if Aleat == 3 and hand == 3:
draw = draw + 1
print("\nTesoura x Tesoura: Deu empate!")
print(f"\nSeu placar: {win} Vitórias | {lose} Derrotas | {draw} Empates.")
options()
def numInes():
global hand
print("Opção inválida!")
hand = int(input("1 = PEDRA / 2 = PAPEL / 3 = TESOURA "))
validaHand()
def validaHand():
global hand
if hand >= 1 and hand <= 3:
battle()
else:
numInes()
print("Bem-vindo(a) ao Janken-Python! Escolha sua mão!")
hand = int(input("1 = PEDRA / 2 = PAPEL / 3 = TESOURA: "))
validaHand()