Example #1
0
def get_winners_menu(player):
    """Return a sorted menu of all winners."""
    menu = PagedMenu(title=menu_strings['Winners:Title'])
    if not winners_database:
        menu.description = menu_strings['Winners:None']
        return menu

    winners = sorted(
        winners_database,
        key=lambda key: (
            winners_database[key].wins,
            -winners_database[key].time_stamp,
        ),
        reverse=True,
    )
    for rank, unique_id in enumerate(winners, 1):
        instance = winners_database[unique_id]
        menu.append(
            ListOption(
                choice_index=rank,
                text='{name} [{wins}]'.format(
                    name=instance.name,
                    wins=instance.wins
                ),
                value=unique_id,
                highlight=player.uniqueid == unique_id,
                selectable=False,
            )
        )
    return menu
Example #2
0
def send_leaders_menu(index):
    """Send the leaders menu to the player."""
    menu = PagedMenu(title=menu_strings['Leader:Current'])
    language = Player(index).language
    if GunGameStatus.MATCH is GunGameMatchStatus.WARMUP:
        menu.append(menu_strings['Warmup'])
    elif GunGameStatus.MATCH is not GunGameMatchStatus.ACTIVE:
        menu.append(menu_strings['Inactive'])
    elif gg_plugin_manager.is_team_game:
        menu.append(menu_strings['Leader:Team'])
        leader_level = max(team_levels.values())
        teams = [
            team_names[num] for num, level in team_levels.items()
            if level == leader_level
        ]
        weapon = weapon_order_manager.active[leader_level].weapon

        if len(teams) == len(team_levels):
            if len(teams) > 2:
                message = menu_strings['Leader:Team:All'].get_string(
                    language=language,
                    level=leader_level,
                    weapon=weapon,
                )
            else:
                message = menu_strings['Leader:Team:Tied'].get_string(
                    language=language,
                    level=leader_level,
                    weapon=weapon,
                )
        elif len(teams) > 1:
            message = menu_strings['Leader:Team:Multiple'].get_string(
                language=language,
                level=leader_level,
                weapon=weapon,
            )
            message += f'\n\t* {", ".join(teams)}'
        else:
            message = menu_strings['Leader:Team:Current'].get_string(
                language=language,
                team=teams[0],
                level=leader_level,
                weapon=weapon,
            )
        menu.append(StarOption(message))
    elif leader_manager.current_leaders is None:
        menu.append(menu_strings['Leader:None'])
    else:
        level = leader_manager.leader_level
        menu.description = menu_strings['Leader:Level'].get_string(
            language=language,
            level=level,
            weapon=weapon_order_manager.active[level].weapon,
        )
        for userid in leader_manager.current_leaders:
            menu.append(StarOption(player_dictionary[userid].name))
    menu.send(index)