|
@@ -6,40 +6,77 @@ from cards import Card, shuffle
|
|
|
from option import OptionCode, Option
|
|
from option import OptionCode, Option
|
|
|
from player import Player, StateCode, ErrorCode
|
|
from player import Player, StateCode, ErrorCode
|
|
|
|
|
|
|
|
|
|
+all_colors = [Color.RED, Color.BLUE, Color.YELLOW, Color.GREEN]
|
|
|
|
|
|
|
|
class Game(object):
|
|
class Game(object):
|
|
|
"""description of class"""
|
|
"""description of class"""
|
|
|
|
|
|
|
|
- players: Dict[Color, Player]
|
|
|
|
|
|
|
+ players: List[Player]
|
|
|
current_player: Player
|
|
current_player: Player
|
|
|
current_dealer: Player
|
|
current_dealer: Player
|
|
|
stock: List[str]
|
|
stock: List[str]
|
|
|
number_of_cards: int
|
|
number_of_cards: int
|
|
|
|
|
|
|
|
- def __init__(self, players=None):
|
|
|
|
|
- if players is None:
|
|
|
|
|
- players = [
|
|
|
|
|
- Player(Color.RED, "Rood"),
|
|
|
|
|
- Player(Color.BLUE, "Blauw"),
|
|
|
|
|
- Player(Color.YELLOW, "Geel"),
|
|
|
|
|
- Player(Color.GREEN, "Groen")]
|
|
|
|
|
-
|
|
|
|
|
|
|
+ def __init__(self):
|
|
|
self.stock = []
|
|
self.stock = []
|
|
|
- random.seed()
|
|
|
|
|
self.number_of_cards = 0
|
|
self.number_of_cards = 0
|
|
|
|
|
+ self.players = []
|
|
|
|
|
+ self.current_player = None
|
|
|
|
|
+ self.current_dealer = None
|
|
|
|
|
+
|
|
|
|
|
+ def join_player(self, name):
|
|
|
|
|
+ player = Player(name=name)
|
|
|
|
|
+ self.players.append(player)
|
|
|
|
|
+ player.state = StateCode.PICK_COLOR
|
|
|
|
|
+ self.set_pick_color_state()
|
|
|
|
|
+ return player
|
|
|
|
|
+
|
|
|
|
|
+ def unjoin_player(self, player):
|
|
|
|
|
+ if player.color is None:
|
|
|
|
|
+ self.players.remove(player)
|
|
|
|
|
+ else:
|
|
|
|
|
+ player.name = None
|
|
|
|
|
+
|
|
|
|
|
+ self.set_pick_color_state()
|
|
|
|
|
+
|
|
|
|
|
+ def pick_color(self, player, color):
|
|
|
|
|
+ color_player = next((p for p in self.players if p.color == color), None)
|
|
|
|
|
+ if color_player is not None:
|
|
|
|
|
+ if color_player.name is None:
|
|
|
|
|
+ # reconnect, merge
|
|
|
|
|
+ player.merge_from(color_player)
|
|
|
|
|
+ self.players.remove(color_player)
|
|
|
|
|
+ else:
|
|
|
|
|
+ # error
|
|
|
|
|
+ player.message = f"Kleur {color} is al gekozen door een andere speler. " + player.message
|
|
|
|
|
+ player.set_error(ErrorCode.COLOR_ALREADY_CHOSEN, color=color)
|
|
|
|
|
+ return
|
|
|
|
|
+
|
|
|
|
|
+ player.color = color
|
|
|
|
|
+ self.set_pick_color_state()
|
|
|
|
|
|
|
|
- self.players = dict((player.color, player) for player in players)
|
|
|
|
|
|
|
|
|
|
- for player in self.players.values():
|
|
|
|
|
- player.options = [Option(OptionCode.DEAL, "Delen")]
|
|
|
|
|
- player.message = "Wie begint er met delen?"
|
|
|
|
|
- player.set_state(StateCode.FIRST_DEAL)
|
|
|
|
|
|
|
+ def set_pick_color_state(self):
|
|
|
|
|
+ used_colors = [player.color for player in self.players if player.color is not None and player.name is not None]
|
|
|
|
|
+ available_colors = [color for color in all_colors if color not in used_colors]
|
|
|
|
|
|
|
|
- def deal(self, player_color):
|
|
|
|
|
- player = self.players[player_color]
|
|
|
|
|
|
|
+ for player in self.players:
|
|
|
|
|
+ if player.state == StateCode.PICK_COLOR:
|
|
|
|
|
+ player.options = [Option(OptionCode.PICK_COLOR, str(color), color=color) for color in available_colors]
|
|
|
|
|
+ if len(used_colors) == 4 and player.color is not None:
|
|
|
|
|
+ player.options.append(Option(OptionCode.DEAL, "Delen"))
|
|
|
|
|
|
|
|
- self.current_player = player
|
|
|
|
|
- self.current_dealer = player
|
|
|
|
|
|
|
+ if player.color is None:
|
|
|
|
|
+ player.message = "Kies een kleur om mee te spelen"
|
|
|
|
|
+ else:
|
|
|
|
|
+ player.message = "Wie begint er met delen?"
|
|
|
|
|
+
|
|
|
|
|
+ player.set_others(self.players)
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ def deal(self, dealer):
|
|
|
|
|
+ self.current_player = dealer
|
|
|
|
|
+ self.current_dealer = dealer
|
|
|
|
|
|
|
|
if self.number_of_cards <= 2:
|
|
if self.number_of_cards <= 2:
|
|
|
self.stock = shuffle(2)
|
|
self.stock = shuffle(2)
|
|
@@ -47,193 +84,226 @@ class Game(object):
|
|
|
else:
|
|
else:
|
|
|
self.number_of_cards -= 1
|
|
self.number_of_cards -= 1
|
|
|
|
|
|
|
|
- for player in self.players.values():
|
|
|
|
|
- player.hand = self.stock[:self.number_of_cards]
|
|
|
|
|
- self.stock = self.stock[self.number_of_cards:]
|
|
|
|
|
- player.options = [Option(OptionCode.SWAP_CARD, card.denom, card=card) for card in player.hand]
|
|
|
|
|
- player.message = "Kies een kaart om te wisselen"
|
|
|
|
|
- player.set_state(StateCode.SWAP_CARD)
|
|
|
|
|
- player.selected_card = None
|
|
|
|
|
- player.card_is_changed = False
|
|
|
|
|
- player.passed = False
|
|
|
|
|
-
|
|
|
|
|
- return self.players
|
|
|
|
|
-
|
|
|
|
|
- def change_card(self, player_color, card):
|
|
|
|
|
- player = self.players[player_color]
|
|
|
|
|
-
|
|
|
|
|
|
|
+ for player in self.players:
|
|
|
|
|
+ if player.color is not None:
|
|
|
|
|
+ player.hand = self.stock[:self.number_of_cards]
|
|
|
|
|
+ self.stock = self.stock[self.number_of_cards:]
|
|
|
|
|
+ player.options = [Option(OptionCode.SWAP_CARD, card.denom, card=card) for card in player.hand]
|
|
|
|
|
+ player.message = "Kies een kaart om te wisselen"
|
|
|
|
|
+ player.state = StateCode.SWAP_CARD
|
|
|
|
|
+ player.swap_card = None
|
|
|
|
|
+ player.card_is_swapped = False
|
|
|
|
|
+ player.passed = False
|
|
|
|
|
+ player.set_current(dealer)
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ def swap_card(self, player, card):
|
|
|
|
|
+ if player.swap_card is not None:
|
|
|
|
|
+ player.hand.append(player.swap_card)
|
|
|
|
|
+ player.swap_card = None
|
|
|
|
|
+
|
|
|
player.hand.remove(card)
|
|
player.hand.remove(card)
|
|
|
partner = self.partner(player)
|
|
partner = self.partner(player)
|
|
|
|
|
|
|
|
- if partner.selected_card is None:
|
|
|
|
|
- player.selected_card = card
|
|
|
|
|
|
|
+ if partner.swap_card is None:
|
|
|
|
|
+ player.swap_card = card
|
|
|
player.message = "Wacht op je maat"
|
|
player.message = "Wacht op je maat"
|
|
|
- player.set_state(StateCode.SWAP_CARD_PARTNER)
|
|
|
|
|
- player.options = [Option(OptionCode.UNDO_CARD, "Terug")]
|
|
|
|
|
- return self.players
|
|
|
|
|
|
|
+ player.state = StateCode.SWAP_CARD
|
|
|
|
|
+ player.options = [Option(OptionCode.SWAP_CARD, card.denom, card=card) for card in player.hand]
|
|
|
|
|
+ player.options.append(Option(OptionCode.UNDO_CARD, "Terug"))
|
|
|
|
|
+ return
|
|
|
|
|
|
|
|
- player.hand.append(partner.selected_card)
|
|
|
|
|
- partner.selected_card = None
|
|
|
|
|
|
|
+ player.hand.append(partner.swap_card)
|
|
|
|
|
+ partner.swap_card = None
|
|
|
partner.hand.append(card)
|
|
partner.hand.append(card)
|
|
|
- player.card_is_changed = True
|
|
|
|
|
- partner.card_is_changed = True
|
|
|
|
|
|
|
+ player.card_is_swapped = True
|
|
|
|
|
+ partner.card_is_swapped = True
|
|
|
partner.options.clear()
|
|
partner.options.clear()
|
|
|
player.options.clear()
|
|
player.options.clear()
|
|
|
player.message = ""
|
|
player.message = ""
|
|
|
|
|
|
|
|
- if all(player.card_is_changed for player in self.players.values()):
|
|
|
|
|
|
|
+ if all(player.card_is_swapped for player in self.players if player.color is not None):
|
|
|
self.next_turn()
|
|
self.next_turn()
|
|
|
else:
|
|
else:
|
|
|
player.message = "Wacht op het andere team"
|
|
player.message = "Wacht op het andere team"
|
|
|
- player.set_state(StateCode.SWAP_CARD_OTHERS)
|
|
|
|
|
|
|
+ player.state = StateCode.SWAP_CARD_OTHERS
|
|
|
partner.message = "wacht op het andere team"
|
|
partner.message = "wacht op het andere team"
|
|
|
- partner.set_state(StateCode.SWAP_CARD_OTHERS)
|
|
|
|
|
|
|
+ partner.state = StateCode.SWAP_CARD_OTHERS
|
|
|
|
|
|
|
|
- return self.players
|
|
|
|
|
-
|
|
|
|
|
- def play_card(self, player_color, card):
|
|
|
|
|
- player = self.players[player_color]
|
|
|
|
|
|
|
|
|
|
|
|
+ def play_card(self, player, card):
|
|
|
|
|
+ if player.play_card is not None:
|
|
|
|
|
+ player.hand.append(player.play_card)
|
|
|
|
|
+ player.play_card = None
|
|
|
|
|
+
|
|
|
player.hand.remove(card)
|
|
player.hand.remove(card)
|
|
|
- player.selected_card = card
|
|
|
|
|
|
|
+ player.play_card = card
|
|
|
player.options = [Option(OptionCode.UNDO_CARD, "Terug"), Option(OptionCode.READY, "Klaar")]
|
|
player.options = [Option(OptionCode.UNDO_CARD, "Terug"), Option(OptionCode.READY, "Klaar")]
|
|
|
- player.message = f"Je speelt {card}"
|
|
|
|
|
- player.set_state(StateCode.PLAYING_CARD, card=card)
|
|
|
|
|
|
|
+ player.options.extend(Option(OptionCode.PLAY_CARD, card.denom, card=card) for card in self.current_player.hand)
|
|
|
|
|
+ player.message = f"Je speelt {card.denom}"
|
|
|
|
|
+ player.state = StateCode.PLAY_CARD
|
|
|
|
|
|
|
|
- for other in self.players.values():
|
|
|
|
|
|
|
+ for other in self.players:
|
|
|
if other.color != player.color:
|
|
if other.color != player.color:
|
|
|
- other.message = f"{player.name} speelt {card}"
|
|
|
|
|
- other.set_state(StateCode.PLAYING_CARD_OTHER, card=card, other_player_name=player.name)
|
|
|
|
|
|
|
+ other.message = f"{player.name} speelt een {card.denom}"
|
|
|
|
|
+ other.state = StateCode.PLAY_CARD_OTHER,
|
|
|
|
|
+ other.play_card = card
|
|
|
|
|
|
|
|
- return self.players
|
|
|
|
|
-
|
|
|
|
|
- def drop_cards(self, player_color):
|
|
|
|
|
- player = self.players[player_color]
|
|
|
|
|
|
|
|
|
|
|
|
+ def drop_cards(self, player):
|
|
|
player.hand = []
|
|
player.hand = []
|
|
|
player.options = []
|
|
player.options = []
|
|
|
player.passed = True
|
|
player.passed = True
|
|
|
|
|
+ player.play_card = None
|
|
|
self.next_turn()
|
|
self.next_turn()
|
|
|
|
|
|
|
|
- def ready(self, player_color):
|
|
|
|
|
- player = self.players[player_color]
|
|
|
|
|
|
|
|
|
|
|
|
+ def ready(self, player):
|
|
|
player.options.clear()
|
|
player.options.clear()
|
|
|
- player.selected_card = None
|
|
|
|
|
|
|
+ player.play_card = None
|
|
|
self.next_turn()
|
|
self.next_turn()
|
|
|
|
|
|
|
|
- return self.players
|
|
|
|
|
-
|
|
|
|
|
- def undo_card(self, player_color):
|
|
|
|
|
- player = self.players[player_color]
|
|
|
|
|
|
|
|
|
|
- player.hand.append(player.selected_card)
|
|
|
|
|
- player.selected_card = None
|
|
|
|
|
-
|
|
|
|
|
- if player.card_is_changed:
|
|
|
|
|
- self.turn()
|
|
|
|
|
- else:
|
|
|
|
|
|
|
+ def undo_card(self, player):
|
|
|
|
|
+ if player.swap_card is not None:
|
|
|
|
|
+ player.hand.append(player.swap_card)
|
|
|
|
|
+ player.swap_card = None
|
|
|
player.options = [Option(OptionCode.SWAP_CARD, card.denom, card=card) for card in player.hand]
|
|
player.options = [Option(OptionCode.SWAP_CARD, card.denom, card=card) for card in player.hand]
|
|
|
player.message = "Kies een kaart om te wisselen"
|
|
player.message = "Kies een kaart om te wisselen"
|
|
|
- player.set_state(StateCode.SWAP_CARD)
|
|
|
|
|
|
|
+ player.state = StateCode.SWAP_CARD
|
|
|
|
|
+ else:
|
|
|
|
|
+ player.hand.append(player.play_card)
|
|
|
|
|
+ player.play_card = None
|
|
|
|
|
+ self.turn()
|
|
|
|
|
|
|
|
- return self.players
|
|
|
|
|
|
|
|
|
|
def play_option(self, player, option):
|
|
def play_option(self, player, option):
|
|
|
- if option.code == OptionCode.DEAL:
|
|
|
|
|
- return self.deal(player.color)
|
|
|
|
|
|
|
+ if option.code == OptionCode.PICK_COLOR:
|
|
|
|
|
+ return self.pick_color(player, option.color)
|
|
|
|
|
+ elif option.code == OptionCode.DEAL:
|
|
|
|
|
+ return self.deal(player)
|
|
|
elif option.code == OptionCode.SWAP_CARD:
|
|
elif option.code == OptionCode.SWAP_CARD:
|
|
|
- return self.change_card(player.color, option.card)
|
|
|
|
|
|
|
+ return self.swap_card(player, option.card)
|
|
|
elif option.code == OptionCode.PLAY_CARD:
|
|
elif option.code == OptionCode.PLAY_CARD:
|
|
|
- return self.play_card(player.color, option.card)
|
|
|
|
|
|
|
+ return self.play_card(player, option.card)
|
|
|
elif option.code == OptionCode.READY:
|
|
elif option.code == OptionCode.READY:
|
|
|
- return self.ready(player.color)
|
|
|
|
|
|
|
+ return self.ready(player)
|
|
|
elif option.code == OptionCode.UNDO_CARD:
|
|
elif option.code == OptionCode.UNDO_CARD:
|
|
|
- return self.undo_card(player.color)
|
|
|
|
|
|
|
+ return self.undo_card(player)
|
|
|
elif option.code == OptionCode.PASS:
|
|
elif option.code == OptionCode.PASS:
|
|
|
- return self.drop_cards(player.color)
|
|
|
|
|
|
|
+ return self.drop_cards(player)
|
|
|
else:
|
|
else:
|
|
|
raise Exception(f"Unknown option {option.code}")
|
|
raise Exception(f"Unknown option {option.code}")
|
|
|
|
|
|
|
|
def next_player(self, player):
|
|
def next_player(self, player):
|
|
|
if player.color == Color.RED:
|
|
if player.color == Color.RED:
|
|
|
- return self.players[Color.BLUE]
|
|
|
|
|
|
|
+ color = Color.BLUE
|
|
|
elif player.color == Color.BLUE:
|
|
elif player.color == Color.BLUE:
|
|
|
- return self.players[Color.YELLOW]
|
|
|
|
|
|
|
+ color = Color.YELLOW
|
|
|
elif player.color == Color.YELLOW:
|
|
elif player.color == Color.YELLOW:
|
|
|
- return self.players[Color.GREEN]
|
|
|
|
|
|
|
+ color = Color.GREEN
|
|
|
elif player.color == Color.GREEN:
|
|
elif player.color == Color.GREEN:
|
|
|
- return self.players[Color.RED]
|
|
|
|
|
|
|
+ color = Color.RED
|
|
|
else:
|
|
else:
|
|
|
raise Exception(f"Unknown color {player.Color}")
|
|
raise Exception(f"Unknown color {player.Color}")
|
|
|
|
|
|
|
|
|
|
+ return next(player for player in self.players if player.color == color)
|
|
|
|
|
+
|
|
|
def next_turn(self):
|
|
def next_turn(self):
|
|
|
- if all(len(player.hand) == 0 for player in self.players.values()):
|
|
|
|
|
|
|
+ if all(len(player.hand) == 0 for player in self.players):
|
|
|
self.next_deal()
|
|
self.next_deal()
|
|
|
else:
|
|
else:
|
|
|
self.current_player = self.next_player(self.current_player)
|
|
self.current_player = self.next_player(self.current_player)
|
|
|
|
|
+ self.current_player.play_card = None
|
|
|
while len(self.current_player.hand) == 0:
|
|
while len(self.current_player.hand) == 0:
|
|
|
self.current_player = self.next_player(self.current_player)
|
|
self.current_player = self.next_player(self.current_player)
|
|
|
self.turn()
|
|
self.turn()
|
|
|
|
|
|
|
|
def next_deal(self):
|
|
def next_deal(self):
|
|
|
- self.current_player = self.next_player(self.current_dealer)
|
|
|
|
|
- self.current_player.options = [Option(OptionCode.DEAL, "Delen")]
|
|
|
|
|
- self.current_player.message = f"Jij bent aan de beurt om te delen."
|
|
|
|
|
- self.current_player.set_state(StateCode.DEAL)
|
|
|
|
|
|
|
+ dealer = self.next_player(self.current_dealer)
|
|
|
|
|
+ self.current_player = dealer
|
|
|
|
|
+ dealer.options = [Option(OptionCode.DEAL, "Delen")]
|
|
|
|
|
+ dealer.message = f"Jij bent aan de beurt om te delen."
|
|
|
|
|
+ dealer.state = StateCode.DEAL
|
|
|
|
|
|
|
|
- for player in self.players.values():
|
|
|
|
|
- if player.color != self.current_player.color:
|
|
|
|
|
- player.message = f"{self.current_player.name} is aan de beurt om te delen"
|
|
|
|
|
- player.set_state(StateCode.DEAL_OTHER, other_player_name=self.current_player.name)
|
|
|
|
|
|
|
+ for player in self.players:
|
|
|
|
|
+ player.set_current(dealer)
|
|
|
|
|
+ if player.color != dealer.color:
|
|
|
|
|
+ player.message = f"{dealer.name} is aan de beurt om te delen"
|
|
|
|
|
+ player.state= StateCode.DEAL_OTHER
|
|
|
|
|
|
|
|
- def turn(self):
|
|
|
|
|
- self.current_player.options = [Option(OptionCode.PLAY_CARD, card.denom, card=card) for card in self.current_player.hand]
|
|
|
|
|
- self.current_player.options.append(Option(OptionCode.PASS, "Pas"))
|
|
|
|
|
- self.current_player.message = "Kies een kaart om te spelen"
|
|
|
|
|
- self.current_player.set_state(StateCode.PLAY_CARD)
|
|
|
|
|
|
|
|
|
|
- for player in self.players.values():
|
|
|
|
|
|
|
+ def turn(self):
|
|
|
|
|
+ player = self.current_player
|
|
|
|
|
+ player.options = [Option(OptionCode.PLAY_CARD, card.denom, card=card) for card in player.hand]
|
|
|
|
|
+ player.options.append(Option(OptionCode.PASS, "Pas"))
|
|
|
|
|
+ player.message = "Kies een kaart om te spelen"
|
|
|
|
|
+ player.state = StateCode.PLAY_CARD
|
|
|
|
|
+ player.play_card = None
|
|
|
|
|
+
|
|
|
|
|
+ for player in self.players:
|
|
|
|
|
+ player.set_current(self.current_player)
|
|
|
if player.color != self.current_player.color:
|
|
if player.color != self.current_player.color:
|
|
|
player.message = f"{self.current_player.name} is aan de beurt"
|
|
player.message = f"{self.current_player.name} is aan de beurt"
|
|
|
- player.set_state(StateCode.PLAY_CARD_OTHER, other_player_name=self.current_player.name)
|
|
|
|
|
|
|
+ player.state = StateCode.PLAY_CARD_OTHER
|
|
|
|
|
+
|
|
|
|
|
|
|
|
def partner(self, player):
|
|
def partner(self, player):
|
|
|
if player.color == Color.RED:
|
|
if player.color == Color.RED:
|
|
|
- return self.players[Color.YELLOW]
|
|
|
|
|
|
|
+ color = Color.YELLOW
|
|
|
elif player.color == Color.BLUE:
|
|
elif player.color == Color.BLUE:
|
|
|
- return self.players[Color.GREEN]
|
|
|
|
|
|
|
+ color = Color.GREEN
|
|
|
elif player.color == Color.YELLOW:
|
|
elif player.color == Color.YELLOW:
|
|
|
- return self.players[Color.RED]
|
|
|
|
|
|
|
+ color = Color.RED
|
|
|
elif player.color == Color.GREEN:
|
|
elif player.color == Color.GREEN:
|
|
|
- return self.players[Color.BLUE]
|
|
|
|
|
|
|
+ color = Color.BLUE
|
|
|
else:
|
|
else:
|
|
|
raise Exception(f"Unknown color {player.Color}")
|
|
raise Exception(f"Unknown color {player.Color}")
|
|
|
|
|
|
|
|
|
|
+ return next(player for player in self.players if player.color == color)
|
|
|
|
|
+
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
if __name__ == "__main__":
|
|
|
game = Game()
|
|
game = Game()
|
|
|
-
|
|
|
|
|
- colors = [Color.BLUE, Color.YELLOW, Color.GREEN, Color.RED]
|
|
|
|
|
|
|
+ red = game.join_player("Rood")
|
|
|
|
|
+ blue = game.join_player("Blauw")
|
|
|
|
|
+ yellow = game.join_player("Geel")
|
|
|
|
|
+ green = game.join_player("Groen")
|
|
|
|
|
+ olive = game.join_player("Olijf")
|
|
|
|
|
+ players = [blue, yellow, green, red]
|
|
|
|
|
+ game.pick_color(red, Color.RED)
|
|
|
|
|
+ game.pick_color(blue, Color.BLUE)
|
|
|
|
|
+ game.pick_color(yellow, Color.YELLOW)
|
|
|
|
|
+ game.pick_color(green, Color.GREEN)
|
|
|
|
|
|
|
|
for round in range(2):
|
|
for round in range(2):
|
|
|
for deal in [6, 5, 4, 3, 2]:
|
|
for deal in [6, 5, 4, 3, 2]:
|
|
|
- color = colors[0]
|
|
|
|
|
- print(color)
|
|
|
|
|
- game.deal(color)
|
|
|
|
|
- game.change_card(Color.YELLOW, game.players[Color.YELLOW].hand[deal - 1])
|
|
|
|
|
- game.change_card(Color.RED, game.players[Color.RED].hand[1])
|
|
|
|
|
- game.change_card(Color.GREEN, game.players[Color.GREEN].hand[0])
|
|
|
|
|
- game.change_card(Color.BLUE, game.players[Color.BLUE].hand[-1])
|
|
|
|
|
|
|
+ player = players[0]
|
|
|
|
|
+ print(f"{player.name} deals {deal} cards")
|
|
|
|
|
+ game.deal(player)
|
|
|
|
|
|
|
|
- colors = colors[1:] + [colors[0]]
|
|
|
|
|
|
|
+ for player in game.players:
|
|
|
|
|
+ print(player.get_json(), end="\n\n")
|
|
|
|
|
|
|
|
- for turn in range(deal):
|
|
|
|
|
- for color in colors:
|
|
|
|
|
- game.play_card(color, game.players[color].hand[0])
|
|
|
|
|
- game.ready(color)
|
|
|
|
|
|
|
+ game.swap_card(yellow, yellow.hand[deal - 1])
|
|
|
|
|
+ game.swap_card(red, red.hand[1])
|
|
|
|
|
+ if round == 0:
|
|
|
|
|
+ game.swap_card(green, green.hand[0])
|
|
|
|
|
+ else:
|
|
|
|
|
+ game.swap_card(olive, olive.hand[0])
|
|
|
|
|
+ game.swap_card(blue, blue.hand[-1])
|
|
|
|
|
|
|
|
- for player in game.players.values():
|
|
|
|
|
- print(player.__dict__, end="\n\n")
|
|
|
|
|
|
|
+ players = players[1:] + players[:1]
|
|
|
|
|
|
|
|
- print([card.__dict__ for card in game.stock], end="\n\n")
|
|
|
|
|
|
|
+ for turn in range(deal):
|
|
|
|
|
+ for player in players:
|
|
|
|
|
+ card = player.hand[0]
|
|
|
|
|
+ game.play_card(player, card)
|
|
|
|
|
+ print(f"{player.name} plays {card.denom} of {card.suit}")
|
|
|
|
|
+ game.ready(player)
|
|
|
|
|
+
|
|
|
|
|
+ if round == 0:
|
|
|
|
|
+ print(green.get_json(), end="\n\n")
|
|
|
|
|
+ green.name = None
|
|
|
|
|
+ game.pick_color(olive, Color.GREEN)
|
|
|
|
|
+ players = [yellow, olive, red, blue]
|