Ballistica Logo

bacommon package

Subpackages

Submodules

bacommon.app module

Common high level values/functionality related to apps.

class bacommon.app.AppArchitecture(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

Processor architecture the App is running on.

ARM = 'arm'
ARM64 = 'arm64'
X86 = 'x86'
X86_64 = 'x86_64'
class bacommon.app.AppExperience(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

A particular experience that can be provided by a Ballistica app.

This is one metric used to isolate different playerbases from each other where there might be no technical barriers doing so. For example, a casual one-hand-playable phone game and an augmented reality tabletop game may both use the same scene-versions and networking-protocols and whatnot, but it would make no sense to allow players of one to join servers of the other. AppExperience can be used to keep these player bases separate.

Generally a single Ballistica app targets a single AppExperience. This is not a technical requirement, however. A single app may support multiple experiences, or there may be multiple apps targeting one experience. Cloud components such as leagues are generally associated with an AppExperience so that they are only visible to client apps designed for that play style.

EMPTY = 'empty'
MELEE = 'melee'
REMOTE = 'remote'
class bacommon.app.AppInstanceInfo(interface_idiom: AppInterfaceIdiom, locale: str, device: str | None)[source]

Bases: object

General info about an individual running app.

architecture

alias of Annotated[AppArchitecture]

device: str | None
engine_build

alias of Annotated[int]

engine_version

alias of Annotated[str]

interface_idiom: AppInterfaceIdiom
locale: str
name

alias of Annotated[str]

os_version

alias of Annotated[str | None]

platform

alias of Annotated[AppPlatform]

variant

alias of Annotated[AppVariant]

class bacommon.app.AppInterfaceIdiom(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

A general form-factor or method of experiencing a Ballistica app.

Note that it is possible for a running app to switch idioms (for instance if a mobile device or computer is connected to a TV).

DESKTOP = 'desktop'
PHONE = 'phone'
TABLET = 'tablet'
TV = 'tv'
XR = 'xr'
class bacommon.app.AppPlatform(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

Overall platform a Ballistica build is targeting.

Each distinct flavor of an app has a unique combination of AppPlatform and AppVariant. Generally platform describes a set of hardware, while variant describes a destination or purpose for the build.

ANDROID = 'android'
IOS = 'ios'
LINUX = 'linux'
MAC = 'mac'
TVOS = 'tvos'
WINDOWS = 'windows'
class bacommon.app.AppVariant(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

A unique Ballistica build type within a single platform.

Each distinct flavor of an app has a unique combination of AppPlatform and AppVariant. Generally platform describes a set of hardware, while variant describes a destination or purpose for the build.

AMAZON_APPSTORE = 'amazon_appstore'
APP_STORE = 'app_store'
ARCADE = 'arcade'
DEMO = 'demo'
EPIC_GAMES_STORE = 'epic_games_store'
GENERIC = 'generic'
GOOGLE_PLAY = 'google_play'
META = 'meta'
STEAM = 'steam'
TEST = 'test'
WINDOWS_STORE = 'windows_store'

bacommon.assets module

Functionality related to cloud based assets.

class bacommon.assets.AssetPackageBuildState(in_progress_builds: list[str] = <factory>, initial_build_count: int = 0, error: str | None = None)[source]

Bases: object

Contains info about an in-progress asset cloud build.

error: str | None = None
in_progress_builds: list[str]
initial_build_count: int = 0
class bacommon.assets.AssetPackageFlavor(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

Flavors for asset package outputs for different platforms/etc.

DESKTOP = 'desktop'
MOBILE = 'mobile'
class bacommon.assets.AssetPackageFlavorManifest(cloudfiles: dict[str, str] = <factory>)[source]

Bases: object

A manifest of asset info for a specific flavor of an asset package.

cloudfiles: dict[str, str]
class bacommon.assets.AssetType(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

Types for individual assets within a package.

COLLISION_MESH = 'collision_mesh'
CUBE_TEXTURE = 'cube_texture'
DATA = 'data'
MESH = 'mesh'
SOUND = 'sound'
TEXTURE = 'texture'

bacommon.bacloud module

Functionality related to the bacloud tool.

class bacommon.bacloud.RequestData(command: str, token: str | None, payload: dict, tzoffset: float, isatty: bool)[source]

Bases: object

Request sent to bacloud server.

command: str
isatty: bool
payload: dict
token: str | None
tzoffset: float
class bacommon.bacloud.ResponseData(message: str | None = None, message_end: str = '\n', error: str | None = None, delay_seconds: float = 0.0, login: str | None = None, logout: bool = False, dir_manifest: str | None = None, uploads: tuple[list[str], str, dict] | None = None, uploads_inline: list[str] | None = None, deletes: list[str] | None = None, downloads_inline: dict[str, str] | None = None, dir_prune_empty: str | None = None, open_url: str | None = None, input_prompt: tuple[str, bool] | None = None, end_message: str | None = None, end_message_end: str = '\n', end_command: tuple[str, dict] | None = None)[source]

Bases: object

Response sent from the bacloud server to the client.

message

If present, client should print this message before any other response processing (including error handling) occurs.

Type:

str | None

message_end

end arg for message print() call.

Type:

str

error

If present, client should abort with this error message.

Type:

str | None

delay_seconds

How long to wait before proceeding with remaining response (can be useful when waiting for server progress in a loop).

Type:

float

login

If present, a token that should be stored client-side and passed with subsequent commands.

Type:

str | None

logout

If True, any existing client-side token should be discarded.

Type:

bool

dir_manifest

If present, client should generate a manifest of this dir. It should be added to end_command args as ‘manifest’.

Type:

str | None

uploads

If present, client should upload the requested files (arg1) individually to a server command (arg2) with provided args (arg3).

Type:

tuple[list[str], str, dict] | None

uploads_inline

If present, a list of pathnames that should be base64 gzipped and uploaded to an ‘uploads_inline’ dict in end_command args. This should be limited to relatively small files.

Type:

list[str] | None

deletes

If present, file paths that should be deleted on the client.

Type:

list[str] | None

downloads_inline

If present, pathnames mapped to base64 gzipped data to be written to the client. This should only be used for relatively small files as they are all included inline as part of the response.

Type:

dict[str, str] | None

dir_prune_empty

If present, all empty dirs under this one should be removed.

Type:

str | None

open_url

If present, url to display to the user.

Type:

str | None

input_prompt

If present, a line of input is read and placed into end_command args as ‘input’. The first value is the prompt printed before reading and the second is whether it should be read as a password (without echoing to the terminal).

Type:

tuple[str, bool] | None

end_message

If present, a message that should be printed after all other response processing is done.

Type:

str | None

end_message_end

end arg for end_message print() call.

Type:

str

end_command

If present, this command is run with these args at the end of response processing.

Type:

tuple[str, dict] | None

delay_seconds: float = 0.0
deletes: list[str] | None = None
dir_manifest: str | None = None
dir_prune_empty: str | None = None
downloads_inline: dict[str, str] | None = None
end_command: tuple[str, dict] | None = None
end_message: str | None = None
end_message_end: str = '\n'
error: str | None = None
input_prompt: tuple[str, bool] | None = None
login: str | None = None
logout: bool = False
message: str | None = None
message_end: str = '\n'
open_url: str | None = None
uploads: tuple[list[str], str, dict] | None = None
uploads_inline: list[str] | None = None

bacommon.build module

Functionality related to game builds.

class bacommon.build.BuildInfoSet(builds: Annotated[list[Entry], IOAttrs('builds')] = <factory>)[source]

Bases: object

Set of build infos.

class Entry(filename: str, size: int, version: str, build_number: int, checksum: str, createtime: datetime)[source]

Bases: object

Info about a particular app build.

build_number: int
checksum: str
createtime: datetime
filename: str
size: int
version: str
builds: Annotated[list[Entry], IOAttrs('builds')]

bacommon.cloud module

Functionality related to cloud functionality.

class bacommon.cloud.LoginProxyCompleteMessage(proxyid: str)[source]

Bases: Message

Just so you know, we’re done with this proxy.

proxyid: str
class bacommon.cloud.LoginProxyRequestMessage[source]

Bases: Message

Request send to the cloud to ask for a login-proxy.

classmethod get_response_types() list[type[Response] | None][source]

Return all Response types this Message can return when sent.

The default implementation specifies a None return type.

class bacommon.cloud.LoginProxyRequestResponse(url: str, url_overlay: str, proxyid: str, proxykey: str)[source]

Bases: Response

Response to a request for a login proxy.

proxyid: str
proxykey: str
url: str
url_overlay: str
class bacommon.cloud.LoginProxyStateQueryMessage(proxyid: str, proxykey: str)[source]

Bases: Message

Soo.. how is that login proxy going?

classmethod get_response_types() list[type[Response] | None][source]

Return all Response types this Message can return when sent.

The default implementation specifies a None return type.

proxyid: str
proxykey: str
class bacommon.cloud.LoginProxyStateQueryResponse(state: Annotated[State, IOAttrs('s')], credentials: Annotated[str | None, IOAttrs('tk')])[source]

Bases: Response

Here’s the info on that login-proxy you asked about, boss.

class State(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

States a login-proxy can be in.

FAIL = 'fail'
SUCCESS = 'success'
WAITING = 'waiting'
credentials: Annotated[str | None, IOAttrs('tk')]
state: Annotated[State, IOAttrs('s')]
class bacommon.cloud.ManageAccountMessage[source]

Bases: Message

Message asking for a manage-account url.

classmethod get_response_types() list[type[Response] | None][source]

Return all Response types this Message can return when sent.

The default implementation specifies a None return type.

class bacommon.cloud.ManageAccountResponse(url: str | None)[source]

Bases: Response

Here’s that sign-in result you asked for, boss.

url: str | None
class bacommon.cloud.MerchAvailabilityMessage[source]

Bases: Message

Can we show merch link?

classmethod get_response_types() list[type[Response] | None][source]

Return all Response types this Message can return when sent.

The default implementation specifies a None return type.

class bacommon.cloud.MerchAvailabilityResponse(url: str | None)[source]

Bases: Response

About that merch…

url: str | None
class bacommon.cloud.PingMessage[source]

Bases: Message

Standard ping.

classmethod get_response_types() list[type[Response] | None][source]

Return all Response types this Message can return when sent.

The default implementation specifies a None return type.

class bacommon.cloud.PingResponse[source]

Bases: Response

pong.

class bacommon.cloud.SendInfoMessage(description: str)[source]

Bases: Message

User is using the send-info function

description: str
classmethod get_response_types() list[type[Response] | None][source]

Return all Response types this Message can return when sent.

The default implementation specifies a None return type.

class bacommon.cloud.SendInfoResponse(handled: bool, message: str | None = None, legacy_code: str | None = None)[source]

Bases: Response

Response to sending into the server.

handled: bool
legacy_code: str | None = None
message: str | None = None
class bacommon.cloud.SignInMessage(login_type: LoginType, sign_in_token: str, description: str, apptime: float)[source]

Bases: Message

Can I sign in please?

apptime: float
description: str
classmethod get_response_types() list[type[Response] | None][source]

Return all Response types this Message can return when sent.

The default implementation specifies a None return type.

login_type: LoginType
sign_in_token: str
class bacommon.cloud.SignInResponse(credentials: str | None)[source]

Bases: Response

Here’s that sign-in result you asked for, boss.

credentials: str | None
class bacommon.cloud.TestMessage(testfoo: int)[source]

Bases: Message

Can I get some of that workspace action?

classmethod get_response_types() list[type[Response] | None][source]

Return all Response types this Message can return when sent.

The default implementation specifies a None return type.

testfoo: int
class bacommon.cloud.TestResponse(testfoo: int)[source]

Bases: Response

Here’s that workspace you asked for, boss.

testfoo: int
class bacommon.cloud.WorkspaceFetchMessage(workspaceid: str, state: WorkspaceFetchState)[source]

Bases: Message

Can I get some of that workspace action?

classmethod get_response_types() list[type[Response] | None][source]

Return all Response types this Message can return when sent.

The default implementation specifies a None return type.

state: WorkspaceFetchState
workspaceid: str
class bacommon.cloud.WorkspaceFetchResponse(state: ~bacommon.cloud.WorkspaceFetchState, deletes: list[str] = <factory>, downloads_inline: dict[str, bytes] = <factory>, done: bool = False)[source]

Bases: Response

Here’s that workspace you asked for, boss.

deletes: list[str]
done: bool = False
downloads_inline: dict[str, bytes]
state: WorkspaceFetchState
class bacommon.cloud.WorkspaceFetchState(manifest: DirectoryManifest, iteration: int = 0, total_deletes: int = 0, total_downloads: int = 0, total_up_to_date: int | None = None)[source]

Bases: object

Common state data for a workspace fetch.

iteration: int = 0
manifest: DirectoryManifest
total_deletes: int = 0
total_downloads: int = 0
total_up_to_date: int | None = None

bacommon.login module

Functionality related to cloud based assets.

class bacommon.login.LoginType(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

Types of logins available.

EMAIL = 'email'
GAME_CENTER = 'game_center'
GPGS = 'gpgs'
property displayname: str

Human readable name for this value.

bacommon.net module

Network related data and functionality.

class bacommon.net.PrivateHostingConfig(session_type: str = 'ffa', playlist_name: str = 'Unknown', randomize: bool = False, tutorial: bool = False, custom_team_names: tuple[str, str] | None = None, custom_team_colors: tuple[tuple[float, float, float], tuple[float, float, float]] | None = None, playlist: list[dict[str, Any]] | None = None, exit_minutes: float = 120.0, exit_minutes_unclean: float = 180.0, exit_minutes_idle: float = 10.0)[source]

Bases: object

Config provided when hosting a private party.

custom_team_colors: tuple[tuple[float, float, float], tuple[float, float, float]] | None = None
custom_team_names: tuple[str, str] | None = None
exit_minutes: float = 120.0
exit_minutes_idle: float = 10.0
exit_minutes_unclean: float = 180.0
playlist: list[dict[str, Any]] | None = None
playlist_name: str = 'Unknown'
randomize: bool = False
session_type: str = 'ffa'
tutorial: bool = False
class bacommon.net.PrivateHostingState(unavailable_error: str | None = None, party_code: str | None = None, tickets_to_host_now: int = 0, minutes_until_free_host: float | None = None, free_host_minutes_remaining: float | None = None)[source]

Bases: object

Combined state of whether we’re hosting, whether we can, etc.

free_host_minutes_remaining: float | None = None
minutes_until_free_host: float | None = None
party_code: str | None = None
tickets_to_host_now: int = 0
unavailable_error: str | None = None
class bacommon.net.PrivatePartyConnectResult(error: str | None = None, address4: str | None = None, address6: str | None = None, port: int | None = None, password: str | None = None)[source]

Bases: object

Info about a server we get back when connecting.

address4: str | None = None
address6: str | None = None
error: str | None = None
password: str | None = None
port: int | None = None
class bacommon.net.ServerNodeEntry(zone: str, latlong: tuple[float, float] | None, address: str, port: int)[source]

Bases: object

Information about a specific server.

address: str
latlong: tuple[float, float] | None
port: int
zone: str
class bacommon.net.ServerNodeQueryResponse(time: ~datetime.datetime, latlong: tuple[float, float] | None, ping_per_dist: float, max_dist: float, debug_log_seconds: float | None = None, error: str | None = None, servers: list[~bacommon.net.ServerNodeEntry] = <factory>)[source]

Bases: object

A response to a query about server-nodes.

debug_log_seconds: float | None = None
error: str | None = None
latlong: tuple[float, float] | None
max_dist: float
ping_per_dist: float
servers: list[ServerNodeEntry]
time: datetime

bacommon.servermanager module

Functionality related to the server manager script.

class bacommon.servermanager.ChatMessageCommand(message: str, clients: list[int] | None)[source]

Bases: ServerCommand

Chat message from the server.

clients: list[int] | None
message: str
class bacommon.servermanager.ClientListCommand[source]

Bases: ServerCommand

Print a list of clients.

class bacommon.servermanager.KickCommand(client_id: int, ban_time: int | None)[source]

Bases: ServerCommand

Kick a client.

ban_time: int | None
client_id: int
class bacommon.servermanager.ScreenMessageCommand(message: str, color: tuple[float, float, float] | None, clients: list[int] | None)[source]

Bases: ServerCommand

Screen-message from the server.

clients: list[int] | None
color: tuple[float, float, float] | None
message: str
class bacommon.servermanager.ServerCommand[source]

Bases: object

Base class for commands that can be sent to the server.

class bacommon.servermanager.ServerConfig(party_name: str = 'FFA', party_is_public: bool = True, authenticate_clients: bool = True, admins: list[str] = <factory>, enable_default_kick_voting: bool = True, public_ipv4_address: str | None = None, public_ipv6_address: str | None = None, port: int = 43210, max_party_size: int = 6, session_max_players_override: int | None = None, session_type: str = 'ffa', playlist_code: int | None = None, playlist_inline: list[dict[str, ~typing.Any]] | None = None, playlist_shuffle: bool = True, auto_balance_teams: bool = True, coop_campaign: str = 'Easy', coop_level: str = 'Onslaught Training', enable_telnet: bool = False, teams_series_length: int = 7, ffa_series_length: int = 24, stats_url: str | None = None, clean_exit_minutes: float | None = None, unclean_exit_minutes: float | None = None, idle_exit_minutes: float | None = None, show_tutorial: bool = False, team_names: tuple[str, str] | None = None, team_colors: tuple[tuple[float, float, float], tuple[float, float, float]] | None = None, enable_queue: bool = True, protocol_version: int | None = None, stress_test_players: int | None = None, player_rejoin_cooldown: float = 10.0)[source]

Bases: object

Configuration for the server manager app (<appname>_server).

admins: list[str]
authenticate_clients: bool = True
auto_balance_teams: bool = True
clean_exit_minutes: float | None = None
coop_campaign: str = 'Easy'
coop_level: str = 'Onslaught Training'
enable_default_kick_voting: bool = True
enable_queue: bool = True
enable_telnet: bool = False
ffa_series_length: int = 24
idle_exit_minutes: float | None = None
max_party_size: int = 6
party_is_public: bool = True
party_name: str = 'FFA'
player_rejoin_cooldown: float = 10.0
playlist_code: int | None = None
playlist_inline: list[dict[str, Any]] | None = None
playlist_shuffle: bool = True
port: int = 43210
protocol_version: int | None = None
public_ipv4_address: str | None = None
public_ipv6_address: str | None = None
session_max_players_override: int | None = None
session_type: str = 'ffa'
show_tutorial: bool = False
stats_url: str | None = None
stress_test_players: int | None = None
team_colors: tuple[tuple[float, float, float], tuple[float, float, float]] | None = None
team_names: tuple[str, str] | None = None
teams_series_length: int = 7
unclean_exit_minutes: float | None = None
class bacommon.servermanager.ShutdownCommand(reason: ShutdownReason, immediate: bool)[source]

Bases: ServerCommand

Tells the server to shut down.

immediate: bool
reason: ShutdownReason
class bacommon.servermanager.ShutdownReason(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

Reason a server is shutting down.

NONE = 'none'
RESTARTING = 'restarting'
class bacommon.servermanager.StartServerModeCommand(config: ServerConfig)[source]

Bases: ServerCommand

Tells the app to switch into ‘server’ mode.

config: ServerConfig

bacommon.transfer module

Functionality related to transferring files/data.

class bacommon.transfer.DirectoryManifest(files: dict[str, DirectoryManifestFile], exists: bool)[source]

Bases: object

Contains a summary of files in a directory.

classmethod create_from_disk(path: Path) DirectoryManifest[source]

Create a manifest from a directory on disk.

exists: bool
files: dict[str, DirectoryManifestFile]
validate() None[source]

Log any odd data in the manifest; for debugging.

class bacommon.transfer.DirectoryManifestFile(hash_sha256: str, size: int)[source]

Bases: object

Describes a file in a manifest.

hash_sha256: str
size: int

Module contents

Functionality and data common to ballistica client and server components.