游戏可以运行

This commit is contained in:
2026-05-24 08:10:22 +08:00
commit 035b2f7af9
28 changed files with 4222 additions and 0 deletions

26
card_game/deck.py Normal file
View File

@@ -0,0 +1,26 @@
"""Deck class: build, shuffle, draw."""
import random
from card_game.card import Card
class Deck:
def __init__(self):
self.cards = []
self.draw_pile = []
def build(self, card_id_list):
self.cards = [Card(cid) for cid in card_id_list]
self.draw_pile = list(self.cards)
random.shuffle(self.draw_pile)
def draw(self):
if not self.draw_pile:
return None
return self.draw_pile.pop()
def is_empty(self):
return len(self.draw_pile) == 0
def remaining(self):
return len(self.draw_pile)