Ejemplo n.º 1
0
    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()
Ejemplo n.º 2
0
    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()
Ejemplo n.º 3
0
    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
Ejemplo n.º 4
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)
Ejemplo n.º 5
0
    def jailbreak_success(self):
        if not self.in_jail:
            raise game.MonopolyUsageError("Player isn't in jail")

        self.turns_in_jail = 0
Ejemplo n.º 6
0
    def jail(self):
        if self.in_jail:
            raise game.MonopolyUsageError("Player is already in jail")

        self.turns_in_jail = 1
Ejemplo n.º 7
0
 def place_house(self, inout, player):
     raise game.MonopolyUsageError("Can't place a house on a utility")