From 37a52d95eb357980e6559f7039e33b947517d45b Mon Sep 17 00:00:00 2001 From: Albert Tan Date: Tue, 11 Oct 2022 13:35:52 +0800 Subject: a --- .DS_Store | Bin 0 -> 6148 bytes Varty's Cardy v1.py | 103 ++++++++++++++++++++++++++++++++++++++++ Varty's Cardy v2.py | 87 ++++++++++++++++++++++++++++++++++ Varty's Cardy v3.py | 134 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 324 insertions(+) create mode 100644 .DS_Store create mode 100644 Varty's Cardy v1.py create mode 100644 Varty's Cardy v2.py create mode 100644 Varty's Cardy v3.py diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..9f5e415 Binary files /dev/null and b/.DS_Store differ 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]}") diff --git a/Varty's Cardy v2.py b/Varty's Cardy v2.py new file mode 100644 index 0000000..67d3166 --- /dev/null +++ b/Varty's Cardy v2.py @@ -0,0 +1,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]}") diff --git a/Varty's Cardy v3.py b/Varty's Cardy v3.py new file mode 100644 index 0000000..b94752d --- /dev/null +++ b/Varty's Cardy v3.py @@ -0,0 +1,134 @@ +import random +import time + +players = int(input("Amount of players: ")) +cards = [] +place = random.randrange(players) +allcards = [] + +def generate(): + for i in [u"\u2660", u"\u2665", u"\u2663", u"\u2666"]: + for j in range(1, 14): + allcards.append([i, j]) + +def getinput(question, start, stop): + try: + i = int(input(question)) + while start > i or stop <= i: + print("Invalid Input") + i = int(input(question)) + except TypeError: + print("Invalid Input") + +def newcard(): + output = random.choice(allcards) + allcards.pop(allcards.index(output)) + return output + +def action(player): + time.sleep(0.5) + playercontrol = player == place + if player == players - 1: + nxtplayer = 0 + else: + nxtplayer = player + 1 + if player == 0: + if cards[0][1] == 13: + if playercontrol: + print("★ ★ ★ ★ ★ ★ ★ ★ ★ ★\nYour turn, but you can't give up your King ~\n★ ★ ★ ★ ★ ★ ★ ★ ★ ★") + else: + print(f"Player {player+1} can't give up their King ~") + elif 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] = newcard() + print(f" ↓ ↓ ↓ ↓\nCurrent card: {cards[0][0]} {cards[0][1]}\n ↑ ↑ ↑ ↑") + else: + print("Card saved! ") + else: + level = random.randrange(3, 9) + if cards[0][1] >= level: + print("Player 1 decides not to change their card ...") + else: + cards[0] = newcard() + print("Player 1 decides to change their card ...") + elif cards[player][1] == 13: + if playercontrol: + print("★ ★ ★ ★ ★ ★ ★ ★ ★ ★\nYour turn, but you can't give up your King ~\n★ ★ ★ ★ ★ ★ ★ ★ ★ ★") + else: + print(f"Player {player+1} can't give up their King ~") + elif cards[nxtplayer][1] == 13: + if playercontrol: + print("★ ★ ★ ★ ★ ★ ★ ★ ★ ★\nYour turn, but you can't swap ~\n★ ★ ★ ★ ★ ★ ★ ★ ★ ★") + else: + print(f"Player {player+1} can't swap ~") + elif playercontrol: + print("★ ★ ★ ★ ★ ★ ★ ★ ★ ★\nYour 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! \n ↓ ↓ ↓ ↓\nCurrent card: {cards[player][0]} {cards[player][1]}\n ↑ ↑ ↑ ↑\n★ ★ ★ ★ ★ ★ ★ ★ ★ ★") + else: + print("Card saved! \n★ ★ ★ ★ ★ ★ ★ ★ ★ ★") + else: + level = random.randrange(3, 9) + if cards[i][1] >= level: + print(f"Player {player+1} decides not to swap their card ...") + else: + (cards[player], cards[nxtplayer]) = (cards[nxtplayer], cards[player]) + if nxtplayer == place: + print(f"Player {player+1} swaps with you! \n ↓ ↓ ↓ ↓\nCurrent card: {cards[nxtplayer][0]} {cards[nxtplayer][1]}\n ↑ ↑ ↑ ↑") + else: + print(f"Player {player+1} decides to swap with Player {nxtplayer+1} ...") + + +generate() +print(f"You are in place: {place+1}") + +for i in range(players): + cards.append(newcard()) + if cards[i][1] == 13: + print(f"Player in place {i+1} gets the King of {cards[i][0]}! ") + +print(f" ↓ ↓ ↓ ↓\nYour card is: {cards[place][0]} {cards[place][1]}\n ↑ ↑ ↑ ↑") +if cards[place][1] == 13: + print("You get a King! ") +print("- - - - - - - - - -") + +for i in range(1, players): + action(i) + +action(0) + +time.sleep(0.5) + +print("- - - - - - - - - -") + +lowest = 13 +losers = [] +multiple = False +for i in range(players): + if cards[i][1] < lowest: + losers = [i] + lowest = cards[i][1] + multiple = False + elif cards[i][1] == lowest: + losers.append(i) + multiple = True + +if multiple: + print("The losers are:", end=" ") + for i in losers: + print(f"Player {i+1}", end=" ") + print() +else: + print(f"The loser is: Player {losers[0]+1}") + +if place in losers: + print("You lose! \n- - - - - - - - - -") +else: + print("You win! \n- - - - - - - - - -") + +for i in range(players): + print(f"Player {i+1}'s card: {cards[i][0]} {cards[i][1]}") -- cgit v1.2.3