def __init__(self): from pyGBot.Plugins.games.fluxxfiles.deck import FluxxDeck self.started = False self.finished = False self.debug = False self.deck = FluxxDeck() self.rule_pile = RulePile(self) self.draw_discard = DrawDiscard(self) self.players = [] self.turn = 0 self.current_goal = None self.game = self self.reverse_played = False self.another_turn_played = False
def __init__(self): from pyGBot.Plugins.games.fluxxfiles.deck import FluxxDeck self.started = False self.finished = False self.debug = False self.deck = FluxxDeck() self.rule_pile = RulePile(self) self.draw_discard = DrawDiscard(self) self.players = [] self.turn = 0 self.current_goal = None self.game = self self.reverse_played = False self.another_turn_played = False
class FluxxGame(object): is_removable = False def __init__(self): from pyGBot.Plugins.games.fluxxfiles.deck import FluxxDeck self.started = False self.finished = False self.debug = False self.deck = FluxxDeck() self.rule_pile = RulePile(self) self.draw_discard = DrawDiscard(self) self.players = [] self.turn = 0 self.current_goal = None self.game = self self.reverse_played = False self.another_turn_played = False def add_player(self, player): player.game = self self.players.append(player) def deal(self): # Set the basic rules card (R_BASIC) on the board. self.rule_pile.receive(self.deck.find_card("R_BASIC")) # Give all our undealt cards (every card except R_BASIC) # to the draw pile. self.draw_discard.draw_pile.receive(self.deck.undealt_cards) self.draw_discard.draw_pile.shuffle() for player in self.players: player.hand = FluxxHand() # Deal 3 cards to each player. self.draw_discard.deal(self.players, 3) self.post_deal_hook() def start_game(self): # Deal to our players. self.started = True self.deal() self.player.start_turn() @property def current_player(self): return self.players[self.turn] def get_player(self, player=None, modifier=1): num_players = len(self.players) if player is None: turn = self.turn else: try: # player is a player obj turn = self.players.index(player) except ValueError: # player is an index turn = player turn += modifier if turn < 0: return turn+num_players elif turn >= num_players: return turn-num_players return turn def next_player(self, player=None): return self.get_player(player, self.rule_pile.turn_order) def prev_player(self, player=None): return self.get_player(player, -self.rule_pile.turn_order) def next_turn(self): num_players = len(self.players) # Check if reverse order was just played, and if there's only two people if not ((self.reverse_played and num_players == 2) or self.another_turn_played): self.turn = self.next_player() self.players[self.turn].start_turn() self.reverse_played = False # Turn off reverse_played self.another_turn_played = False # Turn off another_turn_played def draw_cards(self, num_cards): # Utility function for us. return self.draw_discard.draw(num_cards) def discard(self, cards): # Utility function for us. print "Discarding %r" % cards self.draw_discard.discard(cards) @property def player(self): return self.players[self.turn] def post_deal_hook(self): pass
import re from pyGBot import log from pyGBot.BasePlugin import BasePlugin from pyGBot.Plugins.games.fluxxfiles.fluxx import FluxxPlayer, FluxxGame from pyGBot.Plugins.games.fluxxfiles.game import pretty_print_list, pp_index from pyGBot.Plugins.games.fluxxfiles.deck import FluxxDeck # IRC formatting BOLD = '\x02' # Bold UNDERLINE = '\x1F' # Underline REV_VIDEO = '\x16' # Reverse Video # Used for looking up card descriptions. dummy_deck = FluxxDeck() YES_NO_RESPONSE = '(yes|true|no|false|0|1)' class FluxxIRCGame(FluxxGame): def post_deal_hook(self): for p in self.players: p.output("You got: %s" % pp_index(p.hand)) class FluxxIRCUser(FluxxPlayer): _halt_game = None def __init__(self, name, plugin):
class FluxxGame(object): is_removable = False def __init__(self): from pyGBot.Plugins.games.fluxxfiles.deck import FluxxDeck self.started = False self.finished = False self.debug = False self.deck = FluxxDeck() self.rule_pile = RulePile(self) self.draw_discard = DrawDiscard(self) self.players = [] self.turn = 0 self.current_goal = None self.game = self self.reverse_played = False self.another_turn_played = False def add_player(self, player): player.game = self self.players.append(player) def deal(self): # Set the basic rules card (R_BASIC) on the board. self.rule_pile.receive(self.deck.find_card("R_BASIC")) # Give all our undealt cards (every card except R_BASIC) # to the draw pile. self.draw_discard.draw_pile.receive(self.deck.undealt_cards) self.draw_discard.draw_pile.shuffle() for player in self.players: player.hand = FluxxHand() # Deal 3 cards to each player. self.draw_discard.deal(self.players, 3) self.post_deal_hook() def start_game(self): # Deal to our players. self.started = True self.deal() self.player.start_turn() @property def current_player(self): return self.players[self.turn] def get_player(self, player=None, modifier=1): num_players = len(self.players) if player is None: turn = self.turn else: try: # player is a player obj turn = self.players.index(player) except ValueError: # player is an index turn = player turn += modifier if turn < 0: return turn+num_players elif turn >= num_players: return turn-num_players return turn def next_player(self, player=None): return self.get_player(player, self.rule_pile.turn_order) def prev_player(self, player=None): return self.get_player(player, -self.rule_pile.turn_order) def next_turn(self): num_players = len(self.players) # Check if reverse order was just played, and if there's only two people if not ((self.reverse_played and num_players == 2) or self.another_turn_played): self.turn = self.next_player() self.players[self.turn].start_turn() self.reverse_played = False # Turn off reverse_played self.another_turn_played = False # Turn off another_turn_played def draw_cards(self, num_cards): # Utility function for us. return self.draw_discard.draw(num_cards) def discard(self, cards): # Utility function for us. print "Discarding %r" % cards self.draw_discard.discard(cards) @property def player(self): return self.players[self.turn] def post_deal_hook(self): pass