Most of my game works fine other than the if statements, it always prints "You win!" never does it print "You Lose". Maybe I'm using my if statements wrong, but I don't know where I'm wrong, and I'm pretty new to python too so yeah. Also I'm using import for my project, since I've never used it before.
This is the code that generates cards for user and comp
#Generator that generates the cards for YOU and COMP
n = 0
helper = 0
n2 = 0
helper2 = 0
cards = ["Fire 1", "Fire 2", "Fire 3", "Water 1", "Water 2", "Water 3", "Thunder 1", "Thunder 2", "Thunder 3"]
userDeck = ["", "", "", ""]
compDeck = ["", "", "", ""]
while n < 4:
import random
cardNum = random.randint(0, 8)
userDeck[helper] = cards[cardNum]
n = n + 1
helper = helper + 1
while n2 < 4:
import random
cardNum = random.randint(0, 8)
compDeck[helper2] = cards[cardNum]
n2 = n2 + 1
helper2 = helper2 + 1
This is the main code
#Card Game
#Core Mechanics - Card Jitsu
#Cards - Elements(Fire,Water,Thunder) and Value(1,2,3)
#Fire > Thunder, Thunder > Water, Water > Fire
#If the same cards are played then the one with higher value wins
#Make a random number generator to generate the Comp's Cards and Your Cards
print("Welcome to Card Game! Type PLAY to continue!")
start = input()
from cardGen import compDeck
from cardGen import userDeck
import random
compCardNum = random.randint(0, 3)
if start == "PLAY": #Still in progress!
print("This game is a luck based game, it's basically a copy of Rock-Paper-Scissors.Fire > Thunder, Thunder > Water, Water > Fire. Let's play now!")
print("Your deck contains", userDeck[0], userDeck[1], userDeck[2], userDeck[3])
user = int(input("Pick a number (0 for 1st card, 1 for next card, and so on): "))
print("You picked", userDeck[user])
print("Comp picked", compDeck[compCardNum])
curCard = userDeck[user]
if curCard in userDeck:
if curCard == "Thunder 1" or "Thunder 2" or "Thunder 3" and compDeck[compCardNum] == "Water 1" or "Water 2" or "Water 3":
print("You win!")
userDeck.pop(user)
elif curCard == "Fire 1" or "Fire 2" or "Fire 3" and compDeck[compCardNum] == "Thunder 1" or "Thunder 2" or "Thunder 3":
print("You win!")
userDeck.pop(user)
elif curCard == "Water 1" or "Water 2" or "Water 3" and compDeck[compCardNum] == "Fire 1" or "Fire 2" or "Fire 3":
print("You win!")
userDeck.pop(user)
elif curCard == "Water 1" or "Water 2" or "Water 3" and compDeck[compCardNum] == "Thunder 1" or "Thunder 2" or "Thunder 3":
print("You lost!")
userDeck.pop(user)
elif curCard == "Fire 1" or "Fire 2" or "Fire 3" and compDeck[compCardNum] == "Water 1" or "Water 2" or "Water 3":
print("You lost!")
userDeck.pop(user)
elif curCard == "Thunder 1" or "Thunder 2" or "Thunder 3" and compDeck[compCardNum] == "Fire 1" or "Fire 2" or "Fire 3":
print("You lost!")
userDeck.pop(user)
else: print("Tie")
else : print(":/")
Any fixes?
Aucun commentaire:
Enregistrer un commentaire