Esempio n. 1
0
    def initial_roll(self, inout):
        while True:
            max_roll = 0
            max_player = None
            same_roll = 1
            for player_ in self.players:
                roll = util.roll_two_dice()
                inout.tell("{} rolls {}\n".format(player_, roll))
                if roll > max_roll:
                    max_roll = roll
                    max_player = player_
                    same_roll = 1
                elif roll == max_roll:
                    same_roll += 1

            if same_roll > 1:
                inout.tell("%d people rolled the same thing" % same_roll +
                           ", so we'll try again\n")
                continue
            else:
                break

        inout.tell("{} goes first".format(max_player))
        self.current_player = max_player

        # Set the player iteration to the correct position
        while self.get_next_player() != self.current_player:
            pass
Esempio n. 2
0
    def initial_roll(self, inout):
        while True:
            max_roll = 0
            max_player = None
            same_roll = 1
            for player_ in self.players:
                roll = util.roll_two_dice()
                inout.tell("{} rolls {}\n".format(player_, roll))
                if roll > max_roll:
                    max_roll = roll
                    max_player = player_
                    same_roll = 1
                elif roll == max_roll:
                    same_roll += 1

            if same_roll > 1:
                inout.tell("%d people rolled the same thing" % same_roll
                    + ", so we'll try again\n")
                continue
            else:
                break

        inout.tell("{} goes first".format(max_player))
        self.current_player = max_player

        # Set the player iteration to the correct position
        while self.get_next_player() != self.current_player:
            pass
Esempio n. 3
0
    def roll_dice(self, inout):
        roll = util.roll_two_dice()
        inout.tell("roll is {}\n".format(roll))

        # XXX: This num_doubles thing sucks....

        go_again = False

        if self.current_player.in_jail:
            # If we are in jail, our roll goes to trying to get us out.  Only
            # doubles lets this happen
            if not roll.is_doubles():
                inout.tell("Sorry, that doesn't get you out\n")
                self.current_player.jailbreak_failure(inout)
            else:
                inout.tell("Double roll gets you out.\n")
                self.current_player.jailbreak_success()
        else:
            # If we are not in jail and we roll doubles, this player gets to go
            # again.
            if roll.is_doubles():
                go_again = True
                self.current_player.num_doubles += 1
            else:
                self.current_player.num_double = 0

        # If you roll doubles 3 times, its off to jail for you
        if self.current_player.num_doubles >= 3:
            self.current_player.num_doubles = 0
            go_again = False
            inout.tell("That's 3 doubles.  You go to jail\n")
            self.board.advance_player_to(inout, self.current_player,
                                         self.board.jail_tile)

        # We check jail state again to catch the case where the player got out
        # of or into jail on this turn.
        if not self.current_player.in_jail:
            self.board.advance_player_by_roll(inout, self.current_player, roll)

        # advance to the next person's turn
        if not go_again:
            self.current_player = self.get_next_player()
        else:
            inout.tell("{} rolled doubles.  Goes again\n".format(
                self.current_player.name))
Esempio n. 4
0
    def roll_dice(self, inout):
        roll = util.roll_two_dice()
        inout.tell("roll is {}\n".format(roll))

        # XXX: This num_doubles thing sucks....

        go_again = False

        if self.current_player.in_jail:
            # If we are in jail, our roll goes to trying to get us out.  Only
            # doubles lets this happen
            if not roll.is_doubles():
                inout.tell("Sorry, that doesn't get you out\n")
                self.current_player.jailbreak_failure(inout)
            else:
                inout.tell("Double roll gets you out.\n")
                self.current_player.jailbreak_success()
        else:
            # If we are not in jail and we roll doubles, this player gets to go
            # again.
            if roll.is_doubles():
                go_again = True
                self.current_player.num_doubles += 1
            else:
                self.current_player.num_double = 0

        # If you roll doubles 3 times, its off to jail for you
        if self.current_player.num_doubles >= 3:
            self.current_player.num_doubles = 0
            go_again = False
            inout.tell("That's 3 doubles.  You go to jail\n")
            self.board.advance_player_to(
                inout, self.current_player, self.board.jail_tile)

        # We check jail state again to catch the case where the player got out
        # of or into jail on this turn.
        if not self.current_player.in_jail:
            self.board.advance_player_by_roll(inout, self.current_player, roll)

        # advance to the next person's turn
        if not go_again:
            self.current_player = self.get_next_player()
        else:
            inout.tell("{} rolled doubles.  Goes again\n"
                .format(self.current_player.name))