summaryrefslogtreecommitdiff
path: root/Varty's Cardy v1.py
diff options
context:
space:
mode:
authorAlbert Tan <albert@Alberts-MacBook-Air.local>2022-10-11 13:35:52 +0800
committerAlbert Tan <albert@Alberts-MacBook-Air.local>2022-10-11 13:35:52 +0800
commit37a52d95eb357980e6559f7039e33b947517d45b (patch)
tree094b5ff935626df64d77eff76d4e573ba50eca9c /Varty's Cardy v1.py
downloadcardy-master.tar.gz
cardy-master.zip
Diffstat (limited to 'Varty's Cardy v1.py')
-rw-r--r--Varty's Cardy v1.py103
1 files changed, 103 insertions, 0 deletions
diff --git a/Varty's Cardy v1.py b/Varty's Cardy v1.py
new file mode 100644
index 0000000..3ef90af
--- /dev/null
+++ b/Varty's Cardy v1.py
@@ -0,0 +1,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]}")