Пример #1
0
    def player(self) -> ba.Player:
        """The ba.Player associated with this Spaz.

        If the player no longer exists, raises an ba.PlayerNotFoundError.
        """
        if not self._player:
            raise ba.PlayerNotFoundError()
        return self._player
Пример #2
0
    def getplayer(self,
                  playertype: type[PlayerType],
                  doraise: bool = False) -> Optional[PlayerType]:
        """Get the ba.Player associated with this Spaz.

        By default this will return None if the Player no longer exists.
        If you are logically certain that the Player still exists, pass
        doraise=False to get a non-optional return type.
        """
        player: Any = self._player
        assert isinstance(player, playertype)
        if not player.exists() and doraise:
            raise ba.PlayerNotFoundError()
        return player if player.exists() else None