import random
class Poker:
color = ['♠', '♥', '♣', '♦']
numb = ['2', 'A', 'K', 'Q', 'J', '10', '9', '8', '7', '6', '5', '4', '3']
poker = ['joker', 'JOKER']
for x in numb:
for y in color:
poker.append(y + x)
def __init__(self):
self.player1 = []
self.player2 = []
self.player3 = []
self.base = []
def shuffle(self):
self.base = random.choices(Poker.poker, k=3)
self.player1 = random.choices(list(set(Poker.poker) - set(self.base)), k=17)
self.player2 = random.choices(list(set(Poker.poker) - set(self.base) - set(self.player1)), k=17)
self.player3 = list(set(Poker.poker) - set(self.base) - set(self.player1) - set(self.player2))
self.base.sort(key=lambda x: Poker.poker.index(x))
self.player1.sort(key=lambda x: Poker.poker.index(x))
self.player2.sort(key=lambda x: Poker.poker.index(x))
self.player3.sort(key=lambda x: Poker.poker.index(x))
def deal(self):
print(f'底牌:({self.base}),玩家1:({self.player1}),玩家2:({self.player2}),玩家3:({self.player3})')
game = Poker()
game.shuffle()
game.deal()
扑克
最新推荐文章于 2024-08-28 18:57:30 发布