Skip to content

Instantly share code, notes, and snippets.

@megamaz
Created October 26, 2018 22:47
Show Gist options
  • Save megamaz/6eb2d00c5c9d8a6b7e6a36cc3478cb7c to your computer and use it in GitHub Desktop.
Save megamaz/6eb2d00c5c9d8a6b7e6a36cc3478cb7c to your computer and use it in GitHub Desktop.
import random
import time
battleHappen = False
card = [14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2]
player1 = input("What is player one's name? ")
player2 = input("What is player two's name? ")
print()
print("Hello " + player1 + " and " + player2 + ". Welcome to battle.")
print(player1 + " is the first player. They will start.")
print(player2 + " is the second player. They will play second.")
print()
print('''Here are the rules:
- You have to use the cards you have.
- Wait your turn to play.
- The player with the strongest card wins.
- each player has 12 cards.
- Jack is 11, Queen is 12, king is 13, and ace is 14.
- Medium font recomended.
''')
input("")
player1Cards = []
player2Cards = []
cardamount = 12
while cardamount != 0:
player1Cards.append(random.choice(card))
cardamount -= 1
cardamount = 12
while cardamount != 0:
player2Cards.append(random.choice(card))
cardamount -= 1
while True:
print("\n" * 100)
print(player1 + "'s turn; Make sure " + player2 + " is not looking.")
time.sleep(2)
print("\n" * 100)
print(player1 + "'s deck:")
print(player1Cards)
player1PLAY = int(input("Enter what you want to play. You will then pick a card."))
if player1PLAY not in player1Cards:
print("You did not play a card in your deck. a random card is picked.")
player1PLAY = random.choice(player1Cards)
player1Cards.append(random.choice(card))
else:
print(str(player1PLAY) + " is the card you will play.")
player1Cards.append(random.choice(card))
time.sleep(2)
print("\n" * 100)
print(player2 + "'s turn. Make sure " + player1 + " is not looking.")
time.sleep(2)
print("\n" * 100)
print(player2 + "'s deck:")
print(player2Cards)
player2PLAY = int(input("Enter what you want to play. You will then pick a card."))
if player2PLAY not in player2Cards:
print("You did not play a card in your deck. a random card is picked.")
player2PLAY = random.choice(player2Cards)
player2Cards.append(random.choice(card))
else:
print(str(player2PLAY) + " is the card you will play.")
player2Cards.append(random.choice(card))
time.sleep(2)
print("\n" * 100)
player1WIN = player2PLAY < player1PLAY
player2WIN = player1PLAY < player2PLAY
playerEQUAL = player1PLAY == player2PLAY
if player1WIN:
print(player1 + " has won! " + player2 + " had played " + str(player2PLAY) + ", and " + player1 + " had played " + str(player1PLAY) + ".")
print("These cards are added to their deck!")
player1Cards.append(player2PLAY)
player2Cards.remove(player2PLAY)
time.sleep(2)
print("\n" * 100)
elif player2WIN:
print(player2 + " has won! " + player1 + " had played " + str(player1PLAY) + ", and " + player2 + " had played " + str(player2PLAY) + ".")
print("These cards are added to their deck!")
player2Cards.append(player1PLAY)
player1Cards.remove(player1PLAY)
time.sleep(2)
print("\n" * 100)
elif playerEQUAL:
print("Nobody wins! It's a...")
time.sleep(1)
print("BATTLE!!!!")
print(player1 + " and " + player2 + " played: " + str(player1PLAY))
time.sleep(2)
if not battleHappen:
print("How does it work?")
print("When two cards are equal, they enter Battle mode.")
print("You then place a card that the enemy won't know about above it. It's the BET.")
print("What then happens is you place a card above it like normal. You try to win the bet.")
time.sleep(3)
battleHappen = True
print("Let's start it!")
time.sleep(0.5)
print("\n" * 100)
print(player1 + " will bet. Make sure " + player2 + " is not looking.")
time.sleep(2)
print("\n" * 100)
print(player1 + "'s deck:")
print(player1Cards)
player1BET = int(input("Enter what you want to play. You will then pick a card."))
if player1BET not in player1Cards:
print("You did not play a card in your deck. a random card is picked.")
player1BET = random.choice(player1Cards)
player1Cards.append(random.choice(card))
else:
print(str(player1BET) + " is the card you will bet.")
player1Cards.remove(player1BET)
player1Cards.append(random.choice(card))
print("\n" * 100)
print(player1 + ", what do you want to put to win the bet?")
print(player1Cards)
player1PLAY = int(input("Enter what you want to play. You will then pick a card."))
if player1PLAY not in player1Cards:
print("You did not play a card in your deck. a random card is picked.")
player1PLAY = random.choice(player1Cards)
player1Cards.append(random.choice(card))
else:
print(str(player1PLAY) + " is the card you will play.")
player1Cards.remove(player1PLAY)
player1Cards.append(random.choice(card))
time.sleep(2)
print(player2 + " will bet. Make sure " + player1 + " is not looking.")
time.sleep(2)
print("\n" * 100)
print(player2 + "'s deck:")
print(player2Cards)
player2BET = int(input("Enter what you want to play. You will then pick a card."))
if player2BET not in player1Cards:
print("You did not play a card in your deck. a random card is picked.")
player2BET = random.choice(player2Cards)
player2Cards.append(random.choice(card))
else:
print(str(player2BET) + " is the card you will bet.")
player2Cards.remove(player2BET)
player2Cards.append(random.choice(card))
print("\n" * 100)
print(player2 + ", what do you want to put to win the bet?")
print(player2Cards)
player2PLAY = int(input("Enter what you want to play. You will then pick a card."))
if player2PLAY not in player2Cards:
print("You did not play a card in your deck. a random card is picked.")
player2PLAY = random.choice(player2Cards)
player2Cards.append(random.choice(card))
else:
print(str(player2PLAY) + " is the card you will play.")
player2Cards.remove(player2PLAY)
player2Cards.append(random.choice(card))
time.sleep(2)
player1WIN = player2PLAY < player1PLAY
player2WIN = player1PLAY < player2PLAY
playerEQUAL = player1PLAY == player2PLAY
if player1WIN:
print(player1 + " wins! " + player1 + " had bet " + str(player1BET) + ", and won with a " + str(player1PLAY) + " against " + str(player2PLAY) + ". " + player2 + " had bet " + str(player2BET) + ".")
player1Cards.append(player2PLAY)
player1Cards.append(player2BET)
player2Cards.remove(player2PLAY)
player2Cards.remove(player2BET)
time.sleep(3)
print("\n" * 100)
elif player2WIN:
print(player2 + " wins! " + player2 + " had bet " + str(player2BET) + ", and won with a " + str(player2PLAY) + " against " + str(player1PLAY) + ". " + player1 + " had bet " + str(player1BET) + ".")
player2Cards.append(player1PLAY)
player2Cards.append(player1BET)
player1Cards.remove(player1PLAY)
player1Cards.remove(player1BET)
time.sleep(3)
print("\n" * 100)
breakLOOP = input("Do you want to keep playing? y/n ")
if breakLOOP == "n":
break
else:
print("Playing again!")
print("\n" * 100)
print("Loop broken.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment