Repository navigation
Expand file tree
/
Copy pathrock_paper_scissors.py
More file actions
68 lines (66 loc) · 2.43 KB
/
Copy pathrock_paper_scissors.py
File metadata and controls
68 lines (66 loc) · 2.43 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
import random
from pick import pick
def rock_paper_scissors(player: str, stdscr):
return_table = []
win = 0 # When user finds the great number
user_point = 0
while win == 0:
ia_point = 0
while user_point < 3 and ia_point < 3:
user_movement = 0
ia_movement = 0
ia_movement = random.choice([1, 2, 3])
choice = ["rock", "paper", "scissors"]
title = f"""Which movement want you to do ?\n
1 - rock
2 - paper
3 - scissors"""
options = [1, 2 ,3]
user_movement = pick(options, title, screen=stdscr)
stdscr.refresh()
user_movement = user_movement[0]
if user_movement in (1, 2, 3):
stdscr.refresh()
if ia_movement == user_movement:
stdscr.addstr(7, 0, "No winner")
stdscr.refresh()
stdscr.getch()
if ia_movement < user_movement:
if ia_movement == 1 and user_movement == 3:
stdscr.addstr(7, 0, "you lose")
stdscr.getch()
ia_point += 1
else:
stdscr.addstr(7, 0, "you win")
stdscr.getch()
user_point += 1
elif user_movement < ia_movement:
if ia_movement == 3 and user_movement == 1:
stdscr.addstr(7, 0, "You win")
stdscr.getch()
user_point += 1
else:
stdscr.addstr(7, 0, "you lose")
stdscr.getch()
ia_point += 1
if ia_point > 2:
win = -1
break
if user_point > 2:
win = 1
break
stdscr.addstr(8, 0, f"You : {user_point} IA : {ia_point}")
stdscr.getch()
else:
stdscr.addstr(
5,
0,
"Please type '1' for rock or '2' for paper or '3' for scissors ",
)
stdscr.refresh()
stdscr.getch()
return_table.append(win)
return_table.append(user_point)
return_table.append(player)
return_table.append("shifoumi")
return return_table