summaryrefslogtreecommitdiff
path: root/Varty's Cardy v1.py
blob: 3ef90af827aac69b2ef85d0251849b2f6d565970 (plain)
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
103
import random

players = 6
cards = []
place = random.randrange(players)
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):
    # print(cards)
    if i == place:
        if i != players-1: 
            if cards[i+1] != 13:
                print("Your turn!")
                choice = bool(int(input("Do you want to swap with the player after you (0 - No, 1 - Yes): ")))
                if choice:
                    (cards[i], cards[i+1]) = (cards[i+1], cards[i])
                    print(f"Card swapped! Current card: {cards[i]}")
                else:
                    print("Card saved! ")
            else:
                print("Your turn, but you can't swap ~")
        else:
            if cards[0] != 13:
                print("Your turn!")
                choice = bool(int(input("Do you want to swap with the player after you (0 - No, 1 - Yes): ")))
                if choice:
                    (cards[i], cards[0]) = (cards[0], cards[i])
                    print(f"Card swapped! Current card: {cards[0]}")
                else:
                    print("Card saved! ")
            else:
                print("Your turn, but you can't swap ~")
    else:
        if i != players-1:
            if cards[i+1] != 13:
                level = random.randrange(3, 9)
                if cards[i] >= level:
                    print(f"Player {i+1} decided not to swap their card ...")
                else:
                    (cards[i], cards[i+1]) = (cards[i+1], cards[i])
                    if i+1 == place:
                        print(f"Player {i+1} swapped with you! Current card: {cards[i+1]}")
                    else:
                        print(f"Player {i+1} decided to swap with Player {i+2} ...")
            else:
                print(f"Player {i+1} can't swap ~ ")
        else:
            if cards[0] != 13: 
                level = random.randrange(3, 9)
                if cards[i] >= level:
                    print(f"Player {i+1} decided not to swap their card ...")
                else:
                    (cards[i], cards[0]) = (cards[0], cards[i])
                    if 0 == place:
                        print(f"Player {i+1} swapped with you! Current card: {cards[0]}")
                    else:
                        print(f"Player {i+1} decided to swap with Player 1 ...")
            else:
                print(f"Player {i+1} can't swap ~ ")

if place == 0:
    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 ...")

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]}")