Example #1
0
 def on_activate(self, players: list, card_owner_ind: int,
                 active_player_ind: int, state):
     from app import write_message
     players[card_owner_ind].wallet += 1
     write_message(
         f"Player {card_owner_ind + 1} received 1 coin from the bank",
         state)
Example #2
0
 def on_activate(self, players: list, card_owner_ind: int,
                 active_player_ind: int, state):
     from app import write_message
     total = 2 if players[card_owner_ind].landmarks['Shopping Mall'][
         0] else 1
     players[card_owner_ind].wallet += total
     write_message(
         f"Player {card_owner_ind + 1} received {total} coin{'s' if total == 2 else ''} from the bank",
         state)
Example #3
0
 def on_activate(self, players: list, card_owner_ind: int,
                 active_player_ind: int, state):
     from app import write_message
     if players[active_player_ind].wallet > 0:
         total = min(
             players[active_player_ind].wallet, 2
         ) if players[card_owner_ind].landmarks['Shopping Mall'][0] else 1
         players[active_player_ind].wallet -= total
         players[card_owner_ind].wallet += total
         write_message(
             f"Player {card_owner_ind + 1} received {total} coin{'s' if total == 2 else ''} from Player "
             f"{active_player_ind + 1}", state)
Example #4
0
    def on_activate(self, players: list, card_owner_ind: int,
                    active_player_ind: int, state):
        from app import write_message
        total = min(players[active_player_ind].wallet, 3) if players[card_owner_ind].landmarks['Shopping Mall'][0] \
            else min(players[active_player_ind].wallet, 2)
        players[card_owner_ind].wallet += total
        players[active_player_ind].wallet -= total

        if total:
            write_message(
                f"Player {card_owner_ind + 1} received {total} coins from Player {active_player_ind + 1}",
                state)
Example #5
0
    def on_activate(self, players: list, card_owner_ind: int,
                    active_player_ind: int, state):
        from app import write_message
        for card in players[card_owner_ind].cards:
            total = 0
            if card().symbol == 'cog':
                total += (3 * players[card_owner_ind].cards[card])

            players[card_owner_ind].wallet += total
            if total:
                write_message(
                    f"Player {card_owner_ind + 1} received {total} coins from the bank",
                    state)
Example #6
0
    def on_activate(self, players: list, card_owner_ind: int,
                    active_player_ind: int, state):
        from app import write_message
        # loop through the other players
        for ind in range(len(players) - 1):
            player_ind = (ind + active_player_ind + 1) % 4

            total = min(players[player_ind].wallet, 2)
            players[card_owner_ind].wallet += total
            players[player_ind].wallet -= total

            if total:
                write_message(
                    f"Player {card_owner_ind + 1} received {total} coins from Player {player_ind + 1}",
                    state)
Example #7
0
    def on_activate(self, players: list, card_owner_ind: int,
                    active_player_ind: int, state):
        from app import write_message, get_input
        valid_player_nums = {
            "1": 0,
            "one": 0,
            "2": 1,
            "two": 1,
            "3": 2,
            "three": 2,
            "4": 3,
            "four": 3
        }

        while True:
            write_message(f"What player do you want to take 5 coins from?",
                          state)
            choice = get_input(state)

            # check it's a valid response
            if choice.lower() in valid_player_nums and valid_player_nums[
                    choice.lower()] < len(players):
                ind = valid_player_nums[choice.lower()]

                total = min(players[ind].wallet, 5)
                players[card_owner_ind].wallet += total
                players[ind].wallet -= total

                if total:
                    write_message(
                        f"Player {card_owner_ind + 1} received {total} coins from Player {ind + 1}",
                        state)
                break

            else:
                write_message(
                    f"Choice of '{choice}' is not valid, please write a number from 1 to {len(players)}",
                    state)
Example #8
0
    def on_activate(self, players: list, card_owner_ind: int,
                    active_player_ind: int, state):
        from app import write_message, get_input, establishment_str_to_obj
        valid_player_nums = {
            "1": 0,
            "one": 0,
            "2": 1,
            "two": 1,
            "3": 2,
            "three": 2,
            "4": 3,
            "four": 3
        }

        while True:
            write_message(
                f"What player do you want to take an establishment from?",
                state)
            choice = get_input(state)

            # check it's a valid response
            if choice.lower() in valid_player_nums and valid_player_nums[
                    choice.lower()] < len(players):
                ind = valid_player_nums[choice.lower()]
                valid_establishments = []

                for card in players[ind].cards:
                    if players[ind].cards[card] > 0:
                        card_obj = card()
                        if card_obj.symbol != "tower":
                            valid_establishments.append(card_obj.name)

                while True:
                    write_message(
                        f"What non-tower establishment do you want to take?",
                        state)
                    choice = get_input(state)

                    # check it's a valid response
                    if choice.lower() in valid_establishments:
                        card_obj = establishment_str_to_obj(choice)

                        players[card_owner_ind].cards[type(card_obj)] += 1
                        players[ind].cards[type(card_obj)] -= 1

                        write_message(
                            f"Player {card_owner_ind + 1} received a {choice} from Player {ind + 1}",
                            state)
                        break

                    else:
                        write_message(
                            f"Player {ind + 1} does not have a '{choice}' or you cannot take it, please choose again",
                            state)

                break

            else:
                write_message(
                    f"Choice of '{choice}' is not valid, please write a number from 1 to {len(players)}",
                    state)