def use_jail_card(self): if not self.jail_cards: raise game.MonopolyUsageError("Player doesn't have jail card") if not self.in_jail: raise game.MonopolyUsageError("Player isn't in jail") self.jail_cards -= 1 self.jailbreak_success()
def pay_for_jail(self, inout): if not self.in_jail: raise game.MonopolyUsageError("Player isn't in jail") # Price for jail is $50 self.pay(inout, 50) self.jailbreak_success()
def jailbreak_failure(self, inout): if not self.in_jail: raise game.MonopolyUsageError("Player isn't in jail") self.turns_in_jail += 1 if self.turns_in_jail > 3: inout.tell("It's your third turn and you didn't roll doubles. " "You have to pay $50\n") # We are now out of tries to get out of jail, so we have to pay $50 self.pay(inout, 50) self.turns_in_jail = 0
def resign_to(self, other_player): if self == other_player: raise game.MonopolyUsageError("Player can't resign to himself") # XXX: what to do when resigning when in debt? assert self.money >= 0 other_player.award(self.money) self.money = 0 for holding in self.holdings: holding.owner = other_player other_player.add_to_holdings(holding) self.holdings = [] other_player.jail_cards += self.jail_cards self.jail_cards = 0 self.game.player_resign(self)
def jailbreak_success(self): if not self.in_jail: raise game.MonopolyUsageError("Player isn't in jail") self.turns_in_jail = 0
def jail(self): if self.in_jail: raise game.MonopolyUsageError("Player is already in jail") self.turns_in_jail = 1
def place_house(self, inout, player): raise game.MonopolyUsageError("Can't place a house on a utility")