Exemplo n.º 1
0
 def _topic_updater(self) -> None:
     try:
         game = minqlx.Game()
         topic = game_status_information(game)
         self.update_topics_on_relay_and_triggered_channels(topic)
     except minqlx.NonexistentGameError:
         pass
     finally:
         threading.Timer(self.discord_topic_update_interval,
                         self._topic_updater).start()
Exemplo n.º 2
0
def assert_game_addteamscore(team: str, score: int, _times: int = 1) -> None:
    """Verify that the score of the team was manipulated by the given amount.

    **The test needs to be set up via :func:`.setUp_game_in_warmup()` or :func:`.setup_game_in_progress()`
    before using this assertion.**

    **Make sure to use :func:`mockito.unstub()` after calling this assertion to avoid side effects spilling into the
    next test.**

    :param: team: the team for which the team score should have been manipualted
    :param: score: the amount that should have been added to the team's score. This may be negative or a matcher.
    :param: times: the amount of times the function addteamscore should have been called. (default: 1)
    """
    verify(minqlx.Game(), times=_times).addteamscore(team, score)
Exemplo n.º 3
0
def game_status_with_teams() -> str:
    try:
        game = minqlx.Game()
    except minqlx.NonexistentGameError:
        return "Currently no game running."

    ginfo = get_game_info(game)

    num_players = len(Plugin.players())
    max_players = game.maxclients

    maptitle = game.map_title if game.map_title else game.map
    gametype = game.type_short.upper()

    return f"{ginfo} on **{Plugin.clean_text(maptitle)}** ({gametype}) " \
           f"with **{num_players}/{max_players}** players. {player_data()}"
Exemplo n.º 4
0
    async def check_subscriptions(self):
        notification_actions = []
        game = None
        try:
            game = minqlx.Game()
        except minqlx.NonexistentGameError:
            pass

        if game is not None and game.map != self.last_notified_map:
            self.last_notified_map = game.map
            notification_actions.append(
                self.notify_map_change(self.last_notified_map))

        players = Plugin.players()
        new_players = [
            player for player in players
            if player.steam_id not in self.notified_steam_ids
        ]
        for player in new_players:
            notification_actions.append(self.notify_player_connected(player))
        self.notified_steam_ids = [player.steam_id for player in players]
        await asyncio.gather(*notification_actions)
Exemplo n.º 5
0
 def game(self):
     try:
         return minqlx.Game()
     except minqlx.NonexistentGameError:
         return None
Exemplo n.º 6
0
 def game(self):
     """A Game instance."""
     try:
         return minqlx.Game()
     except minqlx.NonexistentGameError:
         return None
Exemplo n.º 7
0
 def change_map(cls, new_map, factory=None):
     if not factory:
         minqlx.Game().map = new_map
     else:
         minqlx.console_command("map {} {}".format(new_map, factory))
Exemplo n.º 8
0
 def shuffle(cls):
     minqlx.Game().shuffle()
Exemplo n.º 9
0
 def teamsize(cls, size):
     minqlx.Game().teamsize = size
Exemplo n.º 10
0
 def change_map(cls, new_map: str, factory: str = None) -> None:
     if not factory:
         minqlx.Game().map = new_map
     else:
         minqlx.console_command(f"map {new_map} {factory}")
Exemplo n.º 11
0
 def shuffle(cls) -> None:
     minqlx.Game().shuffle()
Exemplo n.º 12
0
 def teamsize(cls, size: int) -> None:
     minqlx.Game().teamsize = size