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
|
import random
players = int(input("Amount of players: "))
cards = []
place = random.randrange(players)
def action(player):
playercontrol = player == place
if player == players - 1:
nxtplayer = 0
else:
nxtplayer = player + 1
if player == 0:
if playercontrol:
print("You have a chance to choose another card! ")
choice = bool(int(input("Do you want to continue? (0 - No, 1 - Yes): ")))
if choice:
cards[0] = random.randrange(1, 14)
print(f"Current card: {cards[0]}")
else:
print("Card saved! ")
else:
level = random.randrange(3, 9)
if cards[0] >= level:
print("Player 1 decided not to change their card ...")
else:
cards[0] = random.randrange(1, 14)
print("Player 1 decided to change their card ...")
elif cards[nxtplayer] == 13:
if playercontrol:
print("Your turn, but you can't swap ~")
else:
print(f"Player {player+1} can't swap ~")
elif playercontrol:
print("Your turn!")
choice = bool(int(input("Do you want to swap with the player after you (0 - No, 1 - Yes): ")))
if choice:
(cards[player], cards[nxtplayer]) = (cards[nxtplayer], cards[player])
print(f"Card swapped! Current card: {cards[player]}")
else:
print("Card saved! ")
else:
level = random.randrange(3, 9)
if cards[i] >= level:
print(f"Player {player+1} decided not to swap their card ...")
else:
(cards[player], cards[nxtplayer]) = (cards[nxtplayer], cards[player])
if nxtplayer == place:
print(f"Player {player+1} swapped with you! Current card: {cards[nxtplayer]}")
else:
print(f"Player {player+1} decided to swap with Player {nxtplayer+1} ...")
print(f"You are in place: {place+1}")
for i in range(players):
cards.append(random.randrange(1, 14))
if cards[i] == 13:
print(f"Player in place {i+1} gets a King! ")
print(f"Your card is: {cards[place]}")
for i in range(1, players):
action(i)
action(0)
lowest = 13
losers = []
for i in range(players):
if cards[i] < lowest:
losers = [i]
lowest = cards[i]
elif cards[i] == lowest:
losers.append(i)
for i in losers:
print(f"Player {i+1}", end=" ")
print("lost! ")
if place in losers:
print("You lost! ")
else:
print("You won! ")
for i in range(players):
print(f"Player {i+1}'s card: {cards[i]}")
|