bacommon.bs package

Functionality related to bombsquad classic.

class bacommon.bs.BasicCloudDialog(components: list[BasicCloudDialogComponent], interaction_style: InteractionStyle = InteractionStyle.BUTTON_POSITIVE, button_label_positive: ButtonLabel = ButtonLabel.OK, button_label_negative: ButtonLabel = ButtonLabel.CANCEL)[source]

Bases: CloudDialog

A basic UI for the client.

class ButtonLabel(*values)[source]

Bases: Enum

Distinct button labels we support.

ACCEPT = 'ac'
APPLY = 'a'
CANCEL = 'c'
CLAIM = 'cl'
DECLINE = 'dn'
DISCARD = 'd'
IGNORE = 'ig'
OK = 'o'
UNKNOWN = 'u'
class InteractionStyle(*values)[source]

Bases: Enum

Overall interaction styles we support.

BUTTON_POSITIVE = 'p'
BUTTON_POSITIVE_NEGATIVE = 'pn'
UNKNOWN = 'u'
button_label_negative: ButtonLabel = 'c'
button_label_positive: ButtonLabel = 'o'
components: list[BasicCloudDialogComponent]
contains_unknown_elements() bool[source]

Whether something within us is an unknown type or enum.

classmethod get_type_id() CloudDialogTypeID[source]

Return the type-id for this subclass.

interaction_style: InteractionStyle = 'p'
class bacommon.bs.BasicCloudDialogBsClassicTourneyResult(tournament_id: str, game: str, players: int, rank: int, trophy: str | None, prizes: list[DisplayItemWrapper])[source]

Bases: BasicCloudDialogComponent

Show info about a classic tourney.

game: str
classmethod get_type_id() BasicCloudDialogComponentTypeID[source]

Return the type-id for this subclass.

players: int
prizes: list[DisplayItemWrapper]
rank: int
tournament_id: str
trophy: str | None
class bacommon.bs.BasicCloudDialogComponent[source]

Bases: IOMultiType[BasicCloudDialogComponentTypeID]

Top level class for our multitype.

classmethod get_type(type_id: BasicCloudDialogComponentTypeID) type[BasicCloudDialogComponent][source]

Return the subclass for each of our type-ids.

classmethod get_type_id() BasicCloudDialogComponentTypeID[source]

Return the type-id for this subclass.

classmethod get_unknown_type_fallback() BasicCloudDialogComponent[source]

Return a fallback object in cases of unrecognized types.

This can allow newer data to remain readable in older environments. Use caution with this option, however, as it effectively modifies data.

Bases: BasicCloudDialogComponent

Show a link in the inbox message.

classmethod get_type_id() BasicCloudDialogComponentTypeID[source]

Return the type-id for this subclass.

label: str
spacing_bottom: float = 0.0
spacing_top: float = 0.0
subs: list[str]
url: str
class bacommon.bs.BasicCloudDialogComponentText(text: str, subs: list[str] = <factory>, scale: float = 1.0, color: tuple[float, float, float, float] = (1.0, 1.0, 1.0, 1.0), spacing_top: float = 0.0, spacing_bottom: float = 0.0)[source]

Bases: BasicCloudDialogComponent

Show some text in the inbox message.

color: tuple[float, float, float, float] = (1.0, 1.0, 1.0, 1.0)
classmethod get_type_id() BasicCloudDialogComponentTypeID[source]

Return the type-id for this subclass.

scale: float = 1.0
spacing_bottom: float = 0.0
spacing_top: float = 0.0
subs: list[str]
text: str
class bacommon.bs.BasicCloudDialogComponentTypeID(*values)[source]

Bases: Enum

Type ID for each of our subclasses.

BS_CLASSIC_TOURNEY_RESULT = 'ct'
DISPLAY_ITEMS = 'di'
EXPIRE_TIME = 'd'
TEXT = 't'
UNKNOWN = 'u'
class bacommon.bs.BasicCloudDialogComponentUnknown[source]

Bases: BasicCloudDialogComponent

An unknown basic client component type.

In practice these should never show up since the master-server generates these on the fly for the client and so should not send clients one they can’t digest.

classmethod get_type_id() BasicCloudDialogComponentTypeID[source]

Return the type-id for this subclass.

class bacommon.bs.BasicCloudDialogDisplayItems(items: list[DisplayItemWrapper], width: float = 100.0, spacing_top: float = 0.0, spacing_bottom: float = 0.0)[source]

Bases: BasicCloudDialogComponent

Show some display-items.

classmethod get_type_id() BasicCloudDialogComponentTypeID[source]

Return the type-id for this subclass.

items: list[DisplayItemWrapper]
spacing_bottom: float = 0.0
spacing_top: float = 0.0
width: float = 100.0
class bacommon.bs.BasicCloudDialogExpireTime(time: datetime, spacing_top: float = 0.0, spacing_bottom: float = 0.0)[source]

Bases: BasicCloudDialogComponent

Show expire-time.

classmethod get_type_id() BasicCloudDialogComponentTypeID[source]

Return the type-id for this subclass.

spacing_bottom: float = 0.0
spacing_top: float = 0.0
time: datetime
class bacommon.bs.ChestActionMessage(action: Action, token_payment: int, chest_id: str)[source]

Bases: Message

Request action about a chest.

class Action(*values)[source]

Bases: Enum

Types of actions we can request.

AD = 'ad'
UNLOCK = 'u'
action: Action
chest_id: 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.

token_payment: int
class bacommon.bs.ChestActionResponse(tokens_charged: int = 0, contents: list[~bacommon.bs._displayitem.DisplayItemWrapper] | None = None, prizeindex: int = 0, error: str | None = None, warning: str | None = None, success_msg: str | None = None, effects: list[~bacommon.bs._clienteffect.ClientEffect] = <factory>)[source]

Bases: Response

Here’s the results of that action you asked for, boss.

contents: list[DisplayItemWrapper] | None = None
effects: list[ClientEffect]
error: str | None = None
prizeindex: int = 0
success_msg: str | None = None
tokens_charged: int = 0
warning: str | None = None
class bacommon.bs.ChestDisplayItem(appearance: ClassicChestAppearance)[source]

Bases: DisplayItem

Display a chest.

appearance: ClassicChestAppearance
get_description() tuple[str, list[tuple[str, str]]][source]

Return a string description and subs for the item.

These decriptions are baked into the DisplayItemWrapper and should be accessed from there when available. This allows clients to give descriptions even for newer display items they don’t recognize.

classmethod get_type_id() DisplayItemTypeID[source]

Return the type-id for this subclass.

class bacommon.bs.ChestInfoMessage(chest_id: str)[source]

Bases: Message

Request info about a chest.

chest_id: 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.bs.ChestInfoResponse(chest: Chest | None, user_tokens: int | None)[source]

Bases: Response

Here’s that chest info you asked for, boss.

class Chest(appearance: ClassicChestAppearance, unlock_tokens: int, unlock_time: datetime.datetime, prizesets: list[PrizeSet], ad_allow: bool)[source]

Bases: object

A lovely chest.

class PrizeSet(weight: float, contents: list[DisplayItemWrapper])[source]

Bases: object

A possible set of prizes for this chest.

contents: list[DisplayItemWrapper]
weight: float
ad_allow: bool
appearance: ClassicChestAppearance
prizesets: list[PrizeSet]
unlock_time: datetime.datetime
unlock_tokens: int
chest: Chest | None
user_tokens: int | None
class bacommon.bs.ClassicAccountLiveData(tickets: int, tokens: int, gold_pass: bool, remove_ads: bool, achievements: int, achievements_total: int, league_type: LeagueType | None, league_num: int | None, league_rank: int | None, level: int, xp: int, xpmax: int, inbox_count: int, inbox_count_is_max: bool, inbox_contains_prize: bool, chests: dict[str, Chest], purchases_state: str | None, flags: set[Flag])[source]

Bases: object

Live account data fed to the client in the bs classic app mode.

class Chest(appearance: ClassicChestAppearance, create_time: datetime, unlock_time: datetime, unlock_tokens: int, ad_allow_time: datetime | None)[source]

Bases: object

A lovely chest.

ad_allow_time: datetime | None
appearance: ClassicChestAppearance
create_time: datetime
unlock_time: datetime
unlock_tokens: int
class Flag(*values)[source]

Bases: Enum

Flags set for our account.

ASK_FOR_REVIEW = 'r'
class LeagueType(*values)[source]

Bases: Enum

Type of league we are in.

BRONZE = 'b'
DIAMOND = 'd'
GOLD = 'g'
SILVER = 's'
achievements: int
achievements_total: int
chests: dict[str, Chest]
flags: set[Flag]
gold_pass: bool
inbox_contains_prize: bool
inbox_count: int
inbox_count_is_max: bool
league_num: int | None
league_rank: int | None
league_type: LeagueType | None
level: int
purchases_state: str | None
remove_ads: bool
tickets: int
tokens: int
xp: int
xpmax: int
class bacommon.bs.ClassicChestAppearance(*values)[source]

Bases: Enum

Appearances bombsquad classic chests can have.

DEFAULT = 'd'
L1 = 'l1'
L2 = 'l2'
L3 = 'l3'
L4 = 'l4'
L5 = 'l5'
L6 = 'l6'
UNKNOWN = 'u'
property pretty_name: str

Pretty name for the chest in English.

class bacommon.bs.ClientEffect[source]

Bases: IOMultiType[ClientEffectTypeID]

Something that can happen on the client.

This can include screen messages, sounds, visual effects, etc.

classmethod get_type(type_id: ClientEffectTypeID) type[ClientEffect][source]

Return the subclass for each of our type-ids.

classmethod get_type_id() ClientEffectTypeID[source]

Return the type-id for this subclass.

classmethod get_unknown_type_fallback() ClientEffect[source]

Return a fallback object in cases of unrecognized types.

This can allow newer data to remain readable in older environments. Use caution with this option, however, as it effectively modifies data.

class bacommon.bs.ClientEffectChestWaitTimeAnimation(chestid: str, duration: float, startvalue: datetime, endvalue: datetime)[source]

Bases: ClientEffect

Animate chest wait time changing.

chestid: str
duration: float
endvalue: datetime
classmethod get_type_id() ClientEffectTypeID[source]

Return the type-id for this subclass.

startvalue: datetime
class bacommon.bs.ClientEffectDelay(seconds: float)[source]

Bases: ClientEffect

Delay effect processing.

classmethod get_type_id() ClientEffectTypeID[source]

Return the type-id for this subclass.

seconds: float
class bacommon.bs.ClientEffectScreenMessage(message: str, subs: list[str] = <factory>, color: tuple[float, float, float] = (1.0, 1.0, 1.0))[source]

Bases: ClientEffect

Display a screen-message.

color: tuple[float, float, float] = (1.0, 1.0, 1.0)
classmethod get_type_id() ClientEffectTypeID[source]

Return the type-id for this subclass.

message: str
subs: list[str]
class bacommon.bs.ClientEffectSound(sound: Sound, volume: float = 1.0)[source]

Bases: ClientEffect

Play a sound.

class Sound(*values)[source]

Bases: Enum

Sounds that can be made alongside the message.

CASH_REGISTER = 'c'
ERROR = 'e'
GUN_COCKING = 'g'
POWER_DOWN = 'p'
UNKNOWN = 'u'
classmethod get_type_id() ClientEffectTypeID[source]

Return the type-id for this subclass.

sound: Sound
volume: float = 1.0
class bacommon.bs.ClientEffectTicketsAnimation(duration: float, startvalue: int, endvalue: int)[source]

Bases: ClientEffect

Animate tickets count.

duration: float
endvalue: int
classmethod get_type_id() ClientEffectTypeID[source]

Return the type-id for this subclass.

startvalue: int
class bacommon.bs.ClientEffectTokensAnimation(duration: float, startvalue: int, endvalue: int)[source]

Bases: ClientEffect

Animate tokens count.

duration: float
endvalue: int
classmethod get_type_id() ClientEffectTypeID[source]

Return the type-id for this subclass.

startvalue: int
class bacommon.bs.ClientEffectTypeID(*values)[source]

Bases: Enum

Type ID for each of our subclasses.

CHEST_WAIT_TIME_ANIMATION = 't'
DELAY = 'd'
SCREEN_MESSAGE = 'm'
SOUND = 's'
TICKETS_ANIMATION = 'ta'
TOKENS_ANIMATION = 'toa'
UNKNOWN = 'u'
class bacommon.bs.ClientEffectUnknown[source]

Bases: ClientEffect

Fallback substitute for types we don’t recognize.

classmethod get_type_id() ClientEffectTypeID[source]

Return the type-id for this subclass.

class bacommon.bs.CloudDialog[source]

Bases: IOMultiType[CloudDialogTypeID]

Small self-contained ui bit provided by the cloud.

These take care of updating and/or dismissing themselves based on user input. Useful for things such as inbox messages. For more complex UI construction, look at CloudUI.

classmethod get_type(type_id: CloudDialogTypeID) type[CloudDialog][source]

Return the subclass for each of our type-ids.

classmethod get_type_id() CloudDialogTypeID[source]

Return the type-id for this subclass.

classmethod get_unknown_type_fallback() CloudDialog[source]

Return a fallback object in cases of unrecognized types.

This can allow newer data to remain readable in older environments. Use caution with this option, however, as it effectively modifies data.

class bacommon.bs.CloudDialogAction(*values)[source]

Bases: Enum

Types of actions we can run.

BUTTON_PRESS_NEGATIVE = 'n'
BUTTON_PRESS_POSITIVE = 'p'
class bacommon.bs.CloudDialogActionMessage(id: str, action: CloudDialogAction)[source]

Bases: Message

Do something to a client ui.

action: CloudDialogAction
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.

id: str
class bacommon.bs.CloudDialogActionResponse(error_type: ErrorType | None, error_message: str | None, effects: list[ClientEffect])[source]

Bases: Response

Did something to that inbox entry, boss.

class ErrorType(*values)[source]

Bases: Enum

Types of errors that may have occurred.

EXPIRED = 'e'
INTERNAL = 'i'
UNKNOWN = 'u'
effects: list[ClientEffect]
error_message: str | None
error_type: ErrorType | None
class bacommon.bs.CloudDialogTypeID(*values)[source]

Bases: Enum

Type ID for each of our subclasses.

BASIC = 'b'
UNKNOWN = 'u'
class bacommon.bs.CloudDialogWrapper(id: str, createtime: datetime, ui: CloudDialog)[source]

Bases: object

Wrapper for a CloudDialog and its common data.

createtime: datetime
id: str
ui: CloudDialog
class bacommon.bs.CloudUI[source]

Bases: IOMultiType[CloudUITypeID]

UI defined by the cloud.

Conceptually similar to a basic html page, except using app UI.

classmethod get_type(type_id: CloudUITypeID) type[CloudUI][source]

Return the subclass for each of our type-ids.

classmethod get_type_id() CloudUITypeID[source]

Return the type-id for this subclass.

classmethod get_unknown_type_fallback() CloudUI[source]

Return a fallback object in cases of unrecognized types.

This can allow newer data to remain readable in older environments. Use caution with this option, however, as it effectively modifies data.

class bacommon.bs.CloudUITypeID(*values)[source]

Bases: Enum

Type ID for each of our subclasses.

UNKNOWN = 'u'
V1 = 'v1'
class bacommon.bs.DisplayItem[source]

Bases: IOMultiType[DisplayItemTypeID]

Some amount of something that can be shown or described.

Used to depict chest contents, inventory, rewards, etc.

get_description() tuple[str, list[tuple[str, str]]][source]

Return a string description and subs for the item.

These decriptions are baked into the DisplayItemWrapper and should be accessed from there when available. This allows clients to give descriptions even for newer display items they don’t recognize.

classmethod get_type(type_id: DisplayItemTypeID) type[DisplayItem][source]

Return the subclass for each of our type-ids.

classmethod get_type_id() DisplayItemTypeID[source]

Return the type-id for this subclass.

classmethod get_unknown_type_fallback() DisplayItem[source]

Return a fallback object in cases of unrecognized types.

This can allow newer data to remain readable in older environments. Use caution with this option, however, as it effectively modifies data.

class bacommon.bs.DisplayItemTypeID(*values)[source]

Bases: Enum

Type ID for each of our subclasses.

CHEST = 'c'
TEST = 's'
TICKETS = 't'
TOKENS = 'k'
UNKNOWN = 'u'
class bacommon.bs.DisplayItemWrapper(item: DisplayItem, description: str, description_subs: list[str] | None)[source]

Bases: object

Wraps a DisplayItem and common info.

description: str
description_subs: list[str] | None
classmethod for_display_item(item: DisplayItem) DisplayItemWrapper[source]

Convenience method to wrap a DisplayItem.

item: DisplayItem
class bacommon.bs.GetClassicPurchasesMessage[source]

Bases: Message

Asking for current account’s classic purchases.

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.bs.GetClassicPurchasesResponse(purchases: set[str])[source]

Bases: Response

Here’s those classic purchases ya asked for boss.

purchases: set[str]
class bacommon.bs.GlobalProfileCheckMessage(name: str)[source]

Bases: Message

Is this global profile name available?

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.

name: str
class bacommon.bs.GlobalProfileCheckResponse(available: bool, ticket_cost: int)[source]

Bases: Response

Here’s that profile check ya asked for boss.

available: bool
ticket_cost: int
class bacommon.bs.InboxRequestMessage[source]

Bases: Message

Message requesting our inbox.

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.bs.InboxRequestResponse(wrappers: list[CloudDialogWrapper], error: str | None = None)[source]

Bases: Response

Here’s that inbox contents you asked for, boss.

error: str | None = None
wrappers: list[CloudDialogWrapper]
class bacommon.bs.LegacyRequest(request: str, request_type: str, user_agent_string: str, data: str)[source]

Bases: Message

A generic request for the legacy master server.

data: 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.

request: str
request_type: str
user_agent_string: str
class bacommon.bs.LegacyResponse(data: str | None, zipped: bool)[source]

Bases: Response

Response for generic legacy request.

data: str | None
zipped: bool
class bacommon.bs.PrivatePartyMessage(need_datacode: bool)[source]

Bases: Message

Message asking about info we need for private-party UI.

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.

need_datacode: bool
class bacommon.bs.PrivatePartyResponse(success: bool, tokens: int, gold_pass: bool, datacode: str | None)[source]

Bases: Response

Here’s that private party UI info you asked for, boss.

datacode: str | None
gold_pass: bool
success: bool
tokens: int
class bacommon.bs.ScoreSubmitMessage(score_token: str)[source]

Bases: Message

Let the server know we got some score in something.

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.

score_token: str
class bacommon.bs.ScoreSubmitResponse(effects: list[ClientEffect])[source]

Bases: Response

Did something to that inbox entry, boss.

effects: list[ClientEffect]
class bacommon.bs.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.bs.SendInfoResponse(handled: bool, message: str | None = None, effects: list[~bacommon.bs._clienteffect.ClientEffect] = <factory>, legacy_code: str | None = None)[source]

Bases: Response

Response to sending info to the server.

effects: list[ClientEffect]
handled: bool
legacy_code: str | None = None
message: str | None = None
class bacommon.bs.TestDisplayItem[source]

Bases: DisplayItem

Fills usable space for a display-item - good for calibration.

get_description() tuple[str, list[tuple[str, str]]][source]

Return a string description and subs for the item.

These decriptions are baked into the DisplayItemWrapper and should be accessed from there when available. This allows clients to give descriptions even for newer display items they don’t recognize.

classmethod get_type_id() DisplayItemTypeID[source]

Return the type-id for this subclass.

class bacommon.bs.TicketsDisplayItem(count: int)[source]

Bases: DisplayItem

Some amount of tickets.

count: int
get_description() tuple[str, list[tuple[str, str]]][source]

Return a string description and subs for the item.

These decriptions are baked into the DisplayItemWrapper and should be accessed from there when available. This allows clients to give descriptions even for newer display items they don’t recognize.

classmethod get_type_id() DisplayItemTypeID[source]

Return the type-id for this subclass.

class bacommon.bs.TokensDisplayItem(count: int)[source]

Bases: DisplayItem

Some amount of tokens.

count: int
get_description() tuple[str, list[tuple[str, str]]][source]

Return a string description and subs for the item.

These decriptions are baked into the DisplayItemWrapper and should be accessed from there when available. This allows clients to give descriptions even for newer display items they don’t recognize.

classmethod get_type_id() DisplayItemTypeID[source]

Return the type-id for this subclass.

class bacommon.bs.UnknownCloudDialog[source]

Bases: CloudDialog

Fallback type for unrecognized entries.

classmethod get_type_id() CloudDialogTypeID[source]

Return the type-id for this subclass.

class bacommon.bs.UnknownDisplayItem[source]

Bases: DisplayItem

Something we don’t know how to display.

get_description() tuple[str, list[tuple[str, str]]][source]

Return a string description and subs for the item.

These decriptions are baked into the DisplayItemWrapper and should be accessed from there when available. This allows clients to give descriptions even for newer display items they don’t recognize.

classmethod get_type_id() DisplayItemTypeID[source]

Return the type-id for this subclass.