我正在寻找一些关于一个简单的纸牌游戏的帮助。前提是:一副牌中洗牌的30张牌,每副牌的颜色为红色、蓝色和黄色,每副牌的数字为1-10
2名玩家从这副牌堆的顶部收到一张牌
某些颜色会胜过另一种颜色
获胜者将得到两张扑克牌
这个过程会重复,直到牌堆中没有矿石卡。在
我的问题是,一旦第一次出牌结束,我就想不出一种方法来抽新牌。我的代码会调用已经玩过的牌(这会导致错误)。有没有什么有效的方法可以让我在使用代码的同时抽到新卡?谢谢。在import random
Deck = ['R1', 'R2', 'R3', 'R4', 'R5', 'R6', 'R7', 'R8', 'R9', 'R10', 'Y1', 'Y2', 'Y3', 'Y4', 'Y5', 'Y6', 'Y7', 'Y8', 'Y9', 'Y10', 'B1', 'B2', 'B3', 'B4', 'B5', 'B6', 'B7', 'B8', 'B9', 'B10']
random.shuffle(Deck)
print(Deck)
Player1Card = Deck[0]
print("Player One, Your Card Is {0}" .format(Deck[0]))
Player2Card = Deck[1]
print("Player Two, Your Card Is {0}" .format(Deck[1]))
PlayerOneScore = 0
PlayerTwoScore = 0
GameCount = 0
PlayerOneCardList = list()
PlayerTwoCardList = list()
1 < 2
2 < 3
3 < 4
4 < 5
5 < 6
7 < 8
8 < 9
9 < 10
while GameCount == 0:
if "R" in Player1Card and "B" in Player2Card:
print("Player One Wins")
PlayerOneScore = PlayerOneScore+2
print("Player One, your score is {0} and Player Two, your score is {1}" . format(PlayerOneScore, PlayerTwoScore))
PlayerOneCardList.append(Player1Card)
PlayerOneCardList.append(Player2Card)
print("Player 1, These Are Your Currently Held Cards:")
print(PlayerOneCardList)
print("Player 2, These Are Your Currently Held Cards:")
print(PlayerTwoCardList)
Deck.remove(Player1Card)
Deck.remove(Player2Card)
elif "R" in Player2Card and "B" in Player1Card:
print("Player Two Wins")
PlayerTwoScore = PlayerTwoScore+2
print("Player One, your score is {0} and Player Two, your score is {1}" . format(PlayerOneScore, PlayerTwoScore))
elif "B" in Player1Card and "Y" in Player2Card:
print("Player One Wins")
PlayerOneScore = PlayerOneScore+2
print("Player One, your score is {0} and Player Two, your score is {1}" . format(PlayerOneScore, PlayerTwoScore))
elif "B" in Player2Card and "Y" in Player1Card:
print("Player Two Wins")
PlayerTwoScore = PlayerTwoScore+2
print("Player One, your score is {0} and Player Two, your score is {1}" . format(PlayerOneScore, PlayerTwoScore))
elif "Y" in Player1Card and "R" in Player2Card:
print("Player One Wins")
PlayerOneScore = PlayerOneScore+2
print("Player One, your score is {0} and Player Two, your score is {1}" . format(PlayerOneScore, PlayerTwoScore))
elif "Y" in Player2Card and "R" in Player1Card:
print("Player Two Wins")
PlayerTwoScore = PlayerTwoScore+2
print("Player One, your score is {0} and Player Two, your score is {1}" . format(PlayerOneScore, PlayerTwoScore))
elif "Y" in Player1Card and "Y" in Player2Card:
if Player1Card > Player2Card:
print("Player One Wins")
PlayerOneScore = PlayerOneScore+2
print("Player One, your score is {0} and Player Two, your score is {1}" . format(PlayerOneScore, PlayerTwoScore))
elif Player1Card < Player2Card:
print("Player Two Wins")
PlayerTwoScore = PlayerTwoScore+2
print("Player One, your score is {0} and Player Two, your score is {1}" . format(PlayerOneScore, PlayerTwoScore))
elif "B" in Player1Card and "B" in Player2Card:
if Player1Card > Player2Card:
print("Player One Wins")
PlayerOneScore = PlayerOneScore+2
print("Player One, your score is {0} and Player Two, your score is {1}" . format(PlayerOneScore, PlayerTwoScore))
elif Player1Card < Player2Card:
print("Player Two Wins")
PlayerTwoScore = PlayerTwoScore+2
print("Player One, your score is {0} and Player Two, your score is {1}" . format(PlayerOneScore, PlayerTwoScore))
elif "R" in Player1Card and "R" in Player2Card:
if Player1Card > Player2Card:
print("Player One Wins")
PlayerOneScore = PlayerOneScore+2
print("Player One, your score is {0} and Player Two, your score is {1}" . format(PlayerOneScore, PlayerTwoScore))
elif Player1Card < Player2Card:
print("Player Two Wins")
PlayerTwoScore = PlayerTwoScore+2
print("Player One, your score is {0} and Player Two, your score is {1}" . format(PlayerOneScore, PlayerTwoScore))
if PlayerOneScore + PlayerTwoScore == 30:
if PlayerOneScore > PlayerTwoScore:
print("Player One Wins")
print("The game is over")
gamecount = 1
elif PlayerTwoScore > PlayerOneScore:
print("Player Two Wins")
print("The game is over")
gamecount = 1
else:
gamecont1 = input("Would you like to continue the game Y for yes or N for no?")
if gamecont1 == "Y" or "y":
gamecont = 0
else:
gamecont = 1