Ballistica Logo

baclassic package

Submodules

baclassic.macmusicapp module

Music playback functionality using the Mac Music (formerly iTunes) app.

class baclassic.macmusicapp.MacMusicAppMusicPlayer[source]

Bases: MusicPlayer

A music-player that utilizes the macOS Music.app for playback.

Allows selecting playlists as entries.

get_playlists(callback: Callable) None[source]

Asynchronously fetch the list of available iTunes playlists.

on_app_shutdown() None[source]

Called on final app shutdown.

on_play(entry: Any) None[source]

Called when a new song/playlist/etc should be played.

on_select_entry(callback: Callable[[Any], None], current_entry: Any, selection_target_name: str) bauiv1.MainWindow[source]

Present a GUI to select an entry.

The callback should be called with a valid entry or None to signify that the default soundtrack should be used..

on_set_volume(volume: float) None[source]

Called when the volume should be changed.

on_stop() None[source]

Called when the music should stop.

baclassic.osmusic module

Music playback using OS functionality exposed through the C++ layer.

class baclassic.osmusic.OSMusicPlayer[source]

Bases: MusicPlayer

Music player that talks to internal C++ layer for functionality.

(internal)

classmethod get_valid_music_file_extensions() list[str][source]

Return file extensions for types playable on this device.

on_app_shutdown() None[source]

Called on final app shutdown.

on_play(entry: Any) None[source]

Called when a new song/playlist/etc should be played.

on_select_entry(callback: Callable[[Any], None], current_entry: Any, selection_target_name: str) bauiv1.MainWindow[source]

Present a GUI to select an entry.

The callback should be called with a valid entry or None to signify that the default soundtrack should be used..

on_set_volume(volume: float) None[source]

Called when the volume should be changed.

on_stop() None[source]

Called when the music should stop.

Module contents

Components for the classic BombSquad experience.

This package/feature-set contains functionality related to the classic BombSquad experience. Note that much legacy BombSquad code is still a bit tangled and thus this feature-set is largely inseperable from scenev1 and uiv1. Future feature-sets will be designed in a more modular way.

class baclassic.Achievement(name: str, icon_name: str, icon_color: tuple[float, float, float], level_name: str, *, award: int, hard_mode_only: bool = False)

Bases: object

Represents attributes and state for an individual achievement.

Category: App Classes

announce_completion(sound: bool = True) None[source]

Kick off an announcement for this achievement’s completion.

property complete: bool

Whether this Achievement is currently complete.

create_display(x: float, y: float, delay: float, *, outdelay: float | None = None, color: Sequence[float] | None = None, style: str = 'post_game') list[bascenev1.Actor][source]

Create a display for the Achievement.

Shows the Achievement icon, name, and description.

property description: Lstr

Get a babase.Lstr for the Achievement’s brief description.

property description_complete: Lstr

Get a babase.Lstr for the Achievement’s description when complete.

property description_full: Lstr

Get a babase.Lstr for the Achievement’s full description.

property description_full_complete: Lstr

Get a babase.Lstr for the Achievement’s full desc. when completed.

property display_name: Lstr

Return a babase.Lstr for this Achievement’s name.

get_award_chest_type() ClassicChestAppearance[source]

Return the type of chest given for this achievement.

get_icon_color(complete: bool) Sequence[float][source]

Return the color tint for this Achievement’s icon.

get_icon_texture(complete: bool) Texture[source]

Return the icon texture to display for this achievement

get_icon_ui_texture(complete: bool) Texture[source]

Return the icon texture to display for this achievement

property hard_mode_only: bool

Whether this Achievement is only unlockable in hard-mode.

property level_name: str

The name of the level this achievement applies to.

property name: str

The name of this achievement.

property power_ranking_value: int

Get the power-ranking award value for this achievement.

set_complete(complete: bool = True) None[source]

Set an achievement’s completed state.

note this only sets local state; use a transaction to actually award achievements.

show_completion_banner(sound: bool = True) None[source]

Create the banner/sound for an acquired achievement announcement.

class baclassic.AchievementSubsystem

Bases: object

Subsystem for achievement handling.

Category: App Classes

Access the single shared instance of this class at ‘ba.app.ach’.

achievements_for_coop_level(level_name: str) list[Achievement][source]

Given a level name, return achievements available for it.

award_local_achievement(achname: str) None[source]

For non-game-based achievements such as controller-connection.

display_achievement_banner(achname: str) None[source]

Display a completion banner for an achievement.

(internal)

Used for server-driven achievements.

get_achievement(name: str) Achievement[source]

Return an Achievement by name.

set_completed_achievements(achs: Sequence[str]) None[source]

Set the current state of completed achievements.

(internal)

All achievements not included here will be set incomplete.

class baclassic.ChestAppearanceDisplayInfo(texclosed: str, texclosedtint: str, texopen: str, texopentint: str, color: tuple[float, float, float], tint: tuple[float, float, float], tint2: tuple[float, float, float])

Bases: object

Info about how to locally display chest appearances.

color: tuple[float, float, float]
texclosed: str
texclosedtint: str
texopen: str
texopentint: str
tint: tuple[float, float, float]
tint2: tuple[float, float, float]
class baclassic.ClassicAppMode

Bases: AppMode

AppMode for the classic BombSquad experience.

classmethod get_app_experience() AppExperience[source]

Return the overall experience provided by this mode.

handle_intent(intent: AppIntent) None[source]

Handle an intent.

on_activate() None[source]

Called when the mode is being activated.

on_app_active_changed() None[source]

Called when ba*.app.active changes while this mode is active.

The app-mode may want to take action such as pausing a running game in such cases.

on_deactivate() None[source]

Called when the mode is being deactivated.

class baclassic.ClassicAppSubsystem

Bases: AppSubsystem

Subsystem for classic functionality in the app.

The single shared instance of this app can be accessed at babase.app.classic. Note that it is possible for babase.app.classic to be None if the classic package is not present, and code should handle that case gracefully.

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

Bases: Enum

Influences behavior when playing music.

Category: Enums

REGULAR = 'regular'
TEST = 'test'

(internal)

add_coop_practice_level(level: Level) None[source]

Adds an individual level to the ‘practice’ section in Co-op.

add_main_menu_close_callback(call: Callable[[], Any]) None[source]

(internal)

static basic_client_ui_button_label_str(label: bacommon.bs.BasicClientUI.ButtonLabel) babase.Lstr[source]

Given a client-ui label, return an Lstr.

create_in_game_tournament_prize_image(entry: dict[str, Any], index: int, position: tuple[float, float]) None[source]

Given a tournament entry, return strings for its prize levels.

device_menu_press(device_id: int | None) None[source]

(internal)

game_begin_analytics() None[source]

(internal)

get_foreground_host_activity() Activity | None[source]

(internal)

get_foreground_host_session() Session | None[source]

(internal)

get_game_port() int[source]

(internal)

get_input_device_config(inputdevice: InputDevice, default: bool) tuple[dict, str][source]

Given an input device, return its config dict in the app config.

The dict will be created if it does not exist.

get_input_device_map_hash(inputdevice: InputDevice) str[source]

Given an input device, return hash based on its raw input values.

get_input_device_mapped_value(device: bascenev1.InputDevice, name: str, default: bool = False) Any[source]

Return a mapped value for an input device.

This checks the user config and falls back to default values where available.

get_main_menu_session() type[Session][source]

(internal)

get_next_tip() str[source]

Returns the next tip to be displayed.

get_player_colors() list[tuple[float, float, float]][source]

Return user-selectable player colors.

get_player_profile_colors(profilename: str | None, profiles: dict[str, dict[str, Any]] | None = None) tuple[tuple[float, float, float], tuple[float, float, float]][source]

Given a profile, return colors for them.

get_player_profile_icon(profilename: str) str[source]

Given a profile name, returns an icon string for it.

(non-account profiles only)

get_tournament_prize_strings(entry: dict[str, Any], include_tickets: bool) list[str][source]

Given a tournament entry, return strings for its prize levels.

getcampaign(name: str) Campaign[source]

Return a campaign by name.

getmaps(playtype: str) list[str][source]

Return a list of bascenev1.Map types supporting a playtype str.

Category: Asset Functions

Maps supporting a given playtype must provide a particular set of features and lend themselves to a certain style of play.

Play Types:

‘melee’

General fighting map. Has one or more ‘spawn’ locations.

‘team_flag’

For games such as Capture The Flag where each team spawns by a flag. Has two or more ‘spawn’ locations, each with a corresponding ‘flag’ location (based on index).

‘single_flag’

For games such as King of the Hill or Keep Away where multiple teams are fighting over a single flag. Has two or more ‘spawn’ locations and 1 ‘flag_default’ location.

‘conquest’

For games such as Conquest where flags are spread throughout the map - has 2+ ‘flag’ locations, 2+ ‘spawn_by_flag’ locations.

‘king_of_the_hill’ - has 2+ ‘spawn’ locations,

1+ ‘flag_default’ locations, and 1+ ‘powerup_spawn’ locations

‘hockey’

For hockey games. Has two ‘goal’ locations, corresponding ‘spawn’ locations, and one ‘flag_default’ location (for where puck spawns)

‘football’

For football games. Has two ‘goal’ locations, corresponding ‘spawn’ locations, and one ‘flag_default’ location (for where flag/ball/etc. spawns)

‘race’

For racing games where players much touch each region in order. Has two or more ‘race_point’ locations.

invoke_main_menu_ui() None[source]

Bring up main menu ui.

is_game_unlocked(game: str) bool[source]

Is a particular game unlocked?

classmethod json_prep(data: Any) Any[source]

Return a json-friendly version of the provided data.

This converts any tuples to lists and any bytes to strings (interpreted as utf-8, ignoring errors). Logs errors (just once) if any data is modified/discarded/unsupported.

launch_coop_game(game: str, force: bool = False, args: dict | None = None) bool[source]

High level way to launch a local co-op session.

property legacy_user_agent_string: str

String containing various bits of info about OS/device/etc.

master_server_v1_get(request: str, data: dict[str, Any], callback: MasterServerCallback | None = None, response_type: MasterServerResponseType = MasterServerResponseType.JSON) None[source]

Make a call to the master server via a http GET.

master_server_v1_post(request: str, data: dict[str, Any], callback: MasterServerCallback | None = None, response_type: MasterServerResponseType = MasterServerResponseType.JSON) None[source]

Make a call to the master server via a http POST.

on_app_loading() None[source]

Called when the app reaches the loading state.

Note that subsystems created after the app switches to the loading state will not receive this callback. Subsystems created by plugins are an example of this.

on_app_shutdown() None[source]

Called when the app begins shutting down.

on_app_suspend() None[source]

Called when the app enters the suspended state.

on_app_unsuspend() None[source]

Called when the app exits the suspended state.

party_icon_activate(origin: Sequence[float]) None[source]

(internal)

pause() None[source]

Pause the game due to a user request or menu popping up.

If there’s a foreground host-activity that says it’s pausable, tell it to pause. Note: we now no longer pause if there are connected clients.

property platform: str

Name of the current platform.

Examples are: ‘mac’, ‘windows’, android’.

preload_map_preview_media() None[source]

Preload media needed for map preview UIs.

Category: Asset Functions

profile_browser_window(transition: str = 'in_right', origin_widget: Widget | None = None, selected_profile: str | None = None) None[source]

(internal)

quit_window(quit_type: QuitType) None[source]

(internal)

required_purchase_for_game(game: str) str | None[source]

Return which purchase (if any) is required for a game.

resume() None[source]

Resume the game due to a user request or menu closing.

If there’s a foreground host-activity that’s currently paused, tell it to resume.

return_to_main_menu_session_gracefully(reset_ui: bool = True) None[source]

Attempt to cleanly get back to the main menu.

static run_bs_client_effects(effects: list[bacommon.bs.ClientEffect]) None[source]

Run client effects sent from the master server.

run_cpu_benchmark() None[source]

Kick off a benchmark to test cpu speeds.

run_media_reload_benchmark() None[source]

Kick off a benchmark to test media reloading speeds.

run_stress_test(*, playlist_type: str = 'Random', playlist_name: str = '__default__', player_count: int = 8, round_duration: int = 30, attract_mode: bool = False) None[source]

Run a stress test.

save_ui_state() None[source]

Store our current place in the UI.

scene_v1_protocol_version() int[source]

(internal)

server_dialog(delay: float, data: dict[str, Any]) None[source]

(internal)

set_master_server_source(source: int) None[source]

(internal)

set_tournament_prize_image(entry: dict[str, Any], index: int, image: bauiv1.Widget) None[source]

Given a tournament entry, return strings for its prize levels.

show_url_window(address: str) None[source]

(internal)

property subplatform: str

String for subplatform.

Can be empty. For the ‘android’ platform, subplatform may be ‘google’, ‘amazon’, etc.

tournament_entry_window(tournament_id: str, *, tournament_activity: bascenev1.Activity | None = None, position: tuple[float, float] = (0.0, 0.0), delegate: Any = None, scale: float | None = None, offset: tuple[float, float] = (0.0, 0.0), on_close_call: Callable[[], Any] | None = None) None[source]

(internal)

v2_upgrade_window(login_name: str, code: str) None[source]

(internal)

value_test(arg: str, change: float | None = None, absolute: float | None = None) float[source]

(internal)

baclassic.show_display_item(itemwrapper: DisplayItemWrapper, parent: Widget, pos: tuple[float, float], width: float) None

Create ui to depict a display-item.