updated dummymodules, fixed afk check
Some checks failed
CI / run_server_binary (push) Has been cancelled

This commit is contained in:
Ayush Saini 2025-09-07 23:46:31 +05:30
parent 8640706f30
commit 528209e18c
8 changed files with 339 additions and 146 deletions

View file

@ -56,7 +56,7 @@ def filter_chat_message(msg: str, client_id: int) -> str | None:
return handlechat.filter_chat_message(msg, client_id)
# ba_meta export babse.Plugin
# ba_meta export babase.Plugin
class modSetup(babase.Plugin):
def on_app_running(self):
"""Runs when app is launched."""
@ -384,7 +384,7 @@ def on_access_check_response(self, data):
if data is not None:
addr = data['address']
port = data['port']
if settings["ballistica_web"]["enabled"]:
if settings["ballistica_web"]["enable"]:
bs.set_public_party_stats_url(
f'https://bombsquad-community.web.app/server-manager/?host={addr}&port={port}')

View file

@ -15,7 +15,7 @@ cLastIdle = 0
class checkIdle(object):
def start(self):
self.t1 = bs.AppTimer(2, babase.Call(self.check), repeat=True)
self.t1 = babase.AppTimer(2, babase.Call(self.check), repeat=True)
self.lobbies = {}
def check(self):
@ -55,8 +55,8 @@ class checkIdle(object):
if lobby_afk in range(INLOBBY_TIME, INLOBBY_TIME + 10):
bs.broadcastmessage("Join game within " + str(
INLOBBY_TIME + 10 - lobby_afk) + " secs",
color=(1, 0, 0), transient=True,
clients=[player['client_id']])
color=(1, 0, 0), transient=True,
clients=[player['client_id']])
if lobby_afk > INLOBBY_TIME + 10:
bs.disconnect_client(player['client_id'], 0)
# clean the lobbies dict
@ -69,4 +69,4 @@ class checkIdle(object):
for player in bs.get_game_roster():
if player["account_id"] == pbid:
bs.broadcastmessage(msg, color=(1, 0, 0), transient=True,
clients=[player['client_id']])
clients=[player['client_id']])

Binary file not shown.

View file

@ -291,9 +291,6 @@ class Env:
:attr:`~babase.App.env` attr on the :class:`~babase.App` class.
"""
#: Is this build targeting an Android based OS?
android: bool
#: The app's api version.
#:
#: Only Python modules and packages associated with the current API
@ -304,27 +301,36 @@ class Env:
#: accordingly and set to target the newer API version number.
api_version: int
#: Whether the app is targeting an arcade-centric experience.
arcade: bool
#: Architecture we are running on.
arch: bacommon.app.AppArchitecture
#: A directory where the app can place files guaranteed to exist
#: as long as the app remains running (and likely longer). The app
#: must be prepared for the possibility of any or all files here
#: disappearing between runs, though the conditions for and likelyhood
#: of this occurring varies between platforms. Note that debug builds
#: may explicitly delete random cache files at launch to exercise this
#: constraint.
cache_directory: str
#: Path of the directory where the app's config file and other
#: user data live. By default, :attr:`cache_directory` and
#: :attr:`python_directory_user` are located within this directory as
#: well (though that varies per platform).
config_directory: str
#: Where the app's config file is stored on disk.
config_file_path: str
#: Where bundled static app data lives.
data_directory: str
#: Whether the app is running in debug mode.
#: Whether this is a debug build of the app.
#:
#: Debug builds generally run substantially slower than non-debug
#: Debug builds generally run substantially slower than release
#: builds due to compiler optimizations being disabled and extra
#: checks being run.
debug: bool
#: Whether the app is targeting a demo experience.
demo: bool
#: runtime checks being enabled.
debug_build: bool
#: Human readable name of the device running this app.
device_name: str
@ -352,14 +358,23 @@ class Env:
#: This is the opposite of `gui`.
headless: bool
#: Locale tag for the current environment in BCP 47 or POSIX localization
#: string form; will be something like ``en-US`` or ``en_US.UTF-8``.
#: Raw string locale tag for the current environment in BCP 47 or POSIX
#: localization string form; will be something like ``en-US`` or
#: ``en_US.UTF-8``. Most things needing locale functionality should look
#: at :class:`~babase.LocaleSubsystem`.
locale_tag: str
#: Whether this is a monolithic build of the app.
#:
#: Monolithic builds contain and manage their own embedded Python
#: interpreter. Modular builds, on the other hand, consist of binary
#: Python modules used with a standalone Python interpreter.
monolithic_build: bool
#: Platform-specific os version string provided by the native layer.
#:
#: Note that more detailed OS information may be available through
#: the Python :mod:`platform` module.
#: Note that more detailed OS information is generally available through
#: the stdlib :mod:`platform` module.
os_version: str
#: Platform we are running on.
@ -393,13 +408,7 @@ class Env:
#: in case it is used again.
supports_soft_quit: bool
#: Whether the app is running in test mode.
#:
#: Test mode enables extra checks and features that are useful for
#: release testing but which do not slow the game down significantly.
test: bool
#: Whether the app is targeting a TV-centric experience.
#: Whether the app is currently running on a TV.
tv: bool
#: App variant we are running.
@ -407,7 +416,6 @@ class Env:
#: Whether the app is currently running in VR.
vr: bool
pass
class FeatureSetData:
@ -581,6 +589,12 @@ def app_is_active() -> bool:
return bool()
def apply_app_config() -> None:
""":meta private:"""
# This is a dummy stub; the actual implementation is native code.
return None
def appname() -> str:
"""Return current app name (all lowercase)."""
# This is a dummy stub; the actual implementation is native code.
@ -647,6 +661,34 @@ def asset_loads_allowed() -> bool:
return bool()
def atexit(call: Callable[[], None]) -> None:
"""Register a synchronous call to run just before the engine shuts down Python.
Most shutdown functionality should instead use the app's :meth:`~babase.App.add_shutdown_task()` functionality, which runs
earlier in the shutdown sequence and operates asynchronousy. This call
is only for components that need to shut down at the very end or in a
specific order.
Currently this only works in monolithic app builds (see
:attr:`~babase.Env.monolithic_build`).
This is similar to Python's standard :func:`atexit.register()`
- calls are run on the main thread in the reverse order they were
registered. The key difference is that this runs *before* Python blocks
waiting for all non-daemon threads to exit, allowing this to be used
to gracefully spin down such threads.
It is highly encouraged on to avoid daemon threads on monolithic builds
and to instead use this or other functionality to kill your thread.
This avoids the inherent danger in daemon threads of accessing Python
state during or after interpreter shutdown. Currently daemon threads
should still be used on modular builds as this function is not available
there.
"""
# This is a dummy stub; the actual implementation is native code.
return None
def audio_shutdown_begin() -> None:
""":meta private:"""
# This is a dummy stub; the actual implementation is native code.
@ -721,7 +763,7 @@ def clipboard_set_text(value: str) -> None:
return None
def commit_config(config: str) -> None:
def commit_app_config(config: str) -> None:
""":meta private:"""
# This is a dummy stub; the actual implementation is native code.
return None
@ -780,6 +822,7 @@ def dev_console_add_text(
h_align: str,
v_align: str,
scale: float,
style: str,
) -> None:
""":meta private:"""
# This is a dummy stub; the actual implementation is native code.
@ -816,6 +859,97 @@ def dev_console_tab_width() -> float:
return float()
def discord_add_button(label: str, url: str) -> None:
"""Add Discord rich presence button.
Args:
label: Label for the button
url: URL to open when the button is clicked
"""
# This is a dummy stub; the actual implementation is native code.
return None
def discord_is_ready() -> bool:
""" """
# This is a dummy stub; the actual implementation is native code.
return bool()
def discord_join_lobby(lobby_secret: str) -> None:
"""Join a discord lobby.
Args:
lobby_secret: Unique identifier for the lobby
"""
# This is a dummy stub; the actual implementation is native code.
return None
def discord_leave_lobby() -> None:
"""Leave a discord lobby."""
# This is a dummy stub; the actual implementation is native code.
return None
def discord_richpresence(
state: str | None = None,
details: str | None = None,
large_image_key: str | None = None,
large_image_text: str | None = None,
small_image_key: str | None = None,
small_image_text: str | None = None,
start_timestamp: str | None = None,
end_timestamp: str | None = None,
) -> None:
"""Set Discord Rich Presence information.
Args:
state: The user's current status
details: What the user is currently doing
large_image_key: Key for the large image
large_image_text: Text displayed when hovering over the large image
small_image_key: Key for the small image
small_image_text: Text displayed when hovering over the small image
start_timestamp: Unix timestamp for game start time
end_timestamp: Unix timestamp for game end time
"""
# This is a dummy stub; the actual implementation is native code.
return None
def discord_send_lobby_message(message: str) -> None:
"""Args:
message: Message to send to a discord lobby.
"""
# This is a dummy stub; the actual implementation is native code.
return None
def discord_set_party(
party_id: str | None = None,
current_party_size: int | None = None,
max_party_size: int | None = None,
) -> None:
"""Set Discord Party information.
Args:
party_id: Unique identifier for the party
current_party_size: Current number of members in the party
max_party_size: Maximum number of members allowed in the party
"""
# This is a dummy stub; the actual implementation is native code.
return None
def discord_shutdown() -> None:
"""Shutdown and disconnect the Discord client."""
# This is a dummy stub; the actual implementation is native code.
return None
def discord_start() -> None:
"""start the discord sdk and connect the client."""
# This is a dummy stub; the actual implementation is native code.
return None
def displaytime() -> babase.DisplayTime:
"""Return the current display-time in seconds.
@ -869,12 +1003,6 @@ def displaytimer(time: float, call: Callable[[], Any]) -> None:
return None
def do_apply_app_config() -> None:
""":meta private:"""
# This is a dummy stub; the actual implementation is native code.
return None
def do_once() -> bool:
"""Return whether this is the first time running a line of code.
@ -1139,6 +1267,17 @@ def get_string_width(string: str, suppress_warning: bool = False) -> float:
return float()
def get_suppress_config_and_state_writes() -> None:
"""Are config and state writes suppressed?
This can be used by tools intending to manipulate these files
manually. Such tools should be sure to restart or quit the app
when done to restore normal behavior.
"""
# This is a dummy stub; the actual implementation is native code.
return None
def get_thread_name() -> str:
"""Return the name of the current thread.
@ -1184,18 +1323,6 @@ def get_virtual_screen_size() -> tuple[float, float]:
return (0.0, 0.0)
def get_volatile_data_directory() -> str:
"""Return the path to the app volatile data directory.
This directory is for data generated by the app that does not
need to be backed up and can be recreated if necessary.
:meta private:
"""
# This is a dummy stub; the actual implementation is native code.
return str()
def getapp() -> babase.App:
""":meta private:"""
# This is a dummy stub; the actual implementation is native code.
@ -1269,7 +1396,7 @@ def increment_analytics_count(name: str, increment: int = 1) -> None:
def increment_analytics_count_raw_2(
name: str, uses_increment: bool = True, increment: int = 1
name: str, uses_increment: int = 1, increment: int = 1
) -> None:
""":meta private:"""
# This is a dummy stub; the actual implementation is native code.
@ -1282,18 +1409,6 @@ def increment_analytics_counts_raw(name: str, increment: int = 1) -> None:
return None
def invoke_main_menu() -> None:
"""High level call to bring up the main menu if it is not present.
This is essentially the same as pressing the menu button on a
controller.
:meta private:
"""
# This is a dummy stub; the actual implementation is native code.
return None
def is_log_full() -> bool:
""":meta private:"""
# This is a dummy stub; the actual implementation is native code.
@ -1380,6 +1495,12 @@ def mark_log_sent() -> None:
return None
def menu_press() -> None:
""":meta private:"""
# This is a dummy stub; the actual implementation is native code.
return None
def music_player_play(files: Any) -> None:
"""Start internal music file playback.
@ -1549,12 +1670,6 @@ def print_load_info() -> None:
return None
def push_back_press() -> None:
""":meta private:"""
# This is a dummy stub; the actual implementation is native code.
return None
def pushcall(
call: Callable,
from_other_thread: bool = False,
@ -1564,7 +1679,8 @@ def pushcall(
) -> None:
"""Push a call to the logic-thread's event loop.
This function expects to be called from the logic thread, and will automatically save and restore the context to behave seamlessly.
This function expects to be called from the logic thread, and will
automatically save and restore the context to behave seamlessly.
To push a call from outside of the logic thread, pass
``from_other_thread=True``. In that case the call will run with no
@ -1600,6 +1716,15 @@ def reached_end_of_babase() -> None:
return None
def reload_hooks() -> None:
"""Reload functions and other objects held by the native layer.
Call this if you replace things in a hooks module to get the
native layer to see your changes.
"""
# This is a dummy stub; the actual implementation is native code.
return None
def reload_media() -> None:
"""Reload all currently loaded game media.
@ -1611,6 +1736,15 @@ def reload_media() -> None:
return None
def request_main_ui() -> None:
"""High level call to request a main ui if it is not already open.
Can be called from any thread.
"""
# This is a dummy stub; the actual implementation is native code.
return None
def request_permission(permission: babase.Permission) -> None:
""":meta private:"""
# This is a dummy stub; the actual implementation is native code.
@ -1660,6 +1794,15 @@ def screenmessage(
return None
def set_account_sign_in_state(signed_in: bool, name: str | None = None) -> None:
"""Keep the base layer informed of who is currently signed in (or not).
:meta private:
"""
# This is a dummy stub; the actual implementation is native code.
return None
def set_analytics_screen(screen: str) -> None:
"""Used for analytics to see where in the app players spend their time.
@ -1744,6 +1887,15 @@ def set_low_level_config_value(key: str, value: int) -> None:
return None
def set_main_ui_input_device(input_device_id: int | None) -> None:
"""Sets the input-device that currently owns the main ui.
:meta private:
"""
# This is a dummy stub; the actual implementation is native code.
return None
def set_platform_misc_read_vals(mode: str) -> None:
""":meta private:"""
# This is a dummy stub; the actual implementation is native code.
@ -1762,21 +1914,6 @@ def set_thread_name(name: str) -> None:
return None
def set_ui_account_state(signed_in: bool, name: str | None = None) -> None:
""":meta private:"""
# This is a dummy stub; the actual implementation is native code.
return None
def set_ui_input_device(input_device_id: int | None) -> None:
"""Sets the input-device that currently owns the user interface.
:meta private:
"""
# This is a dummy stub; the actual implementation is native code.
return None
def set_ui_scale(scale: str) -> None:
""":meta private:"""
# This is a dummy stub; the actual implementation is native code.
@ -1848,6 +1985,17 @@ def supports_vsync() -> bool:
return bool()
def suppress_config_and_state_writes() -> None:
"""Disable subsequent writes of app config and state files by the engine.
This can be used by tools intending to manipulate these files
manually. Such tools should be sure to restart or quit the app
when done to restore normal behavior.
"""
# This is a dummy stub; the actual implementation is native code.
return None
def temp_testing() -> bool:
""":meta private:"""
# This is a dummy stub; the actual implementation is native code.

View file

@ -102,13 +102,22 @@ def classic_app_mode_handle_app_intent_exec(command: str) -> None:
return None
def get_account_display_state() -> Any:
def get_account_state() -> Any:
"""(internal)"""
# This is a dummy stub; the actual implementation is native code.
return _uninferrable()
def set_account_display_state(vals: dict) -> None:
def reload_hooks() -> None:
"""Reload functions and other objects held by the native layer.
Call this if you replace things in a hooks module to get the
native layer to see your changes.
"""
# This is a dummy stub; the actual implementation is native code.
return None
def set_account_state(vals: dict) -> None:
"""(internal)"""
# This is a dummy stub; the actual implementation is native code.
return None

View file

@ -68,16 +68,46 @@ def game_service_has_leaderboard(game: str, config: str) -> bool:
return bool()
def get_bootstrap_server_address() -> str:
"""Return the address of the current valid bootstrap server.
Will error if a bootstrap addr has not been set.
"""
# This is a dummy stub; the actual implementation is native code.
return str()
def get_bootstrap_server_addresses() -> list[str]:
"""Return server addresses useable for bootstrapping.
Bootstrapping involves locating and arranging a connection
with a nearby regional server. Servers are returned in precedence
order; first should be tried first, etc.
"""
# This is a dummy stub; the actual implementation is native code.
return ['blah', 'blah2']
def get_classic_news_show() -> str:
"""(internal)"""
# This is a dummy stub; the actual implementation is native code.
return str()
def get_master_server_address(source: int = -1, version: int = 1) -> str:
def get_legacy_master_server_address() -> str:
"""(internal)
Return the address of the master server.
Return the address of the legacy master server.
"""
# This is a dummy stub; the actual implementation is native code.
return str()
def get_master_server_address() -> str:
"""Return the address of the master server.
This is the primary address, suitable for opening in web browsers,
etc.
"""
# This is a dummy stub; the actual implementation is native code.
return str()
@ -119,18 +149,6 @@ def get_v1_account_name() -> str:
return str()
def get_v1_account_product_purchased(item: str) -> bool:
"""(internal)"""
# This is a dummy stub; the actual implementation is native code.
return bool()
def get_v1_account_product_purchases_state() -> int:
"""(internal)"""
# This is a dummy stub; the actual implementation is native code.
return int()
def get_v1_account_public_login_id() -> str | None:
"""(internal)"""
# This is a dummy stub; the actual implementation is native code.
@ -149,15 +167,6 @@ def get_v1_account_state_num() -> int:
return int()
def get_v1_account_ticket_count() -> int:
"""(internal)
Returns the number of tickets for the current account.
"""
# This is a dummy stub; the actual implementation is native code.
return int()
def get_v1_account_type() -> str:
"""(internal)"""
# This is a dummy stub; the actual implementation is native code.
@ -248,6 +257,12 @@ def run_v1_account_transactions() -> None:
return None
def set_bootstrap_server_address(address: str) -> None:
"""Set which of our bootstrap server addresses we should use."""
# This is a dummy stub; the actual implementation is native code.
return None
def show_ad(
purpose: str, on_completion_call: Callable[[], None] | None = None
) -> None:

View file

@ -1123,21 +1123,21 @@ def camerashake(intensity: float = 1.0) -> None:
return None
def capture_gamepad_input(call: Callable[[dict], None]) -> None:
"""(internal)
Add a callable to be called for subsequent gamepad events.
def capture_game_controller_input(call: Callable[[dict], None]) -> None:
"""Add a callable to be called for subsequent game controller events.
The method is passed a dict containing info about the event.
:meta private:
"""
# This is a dummy stub; the actual implementation is native code.
return None
def capture_keyboard_input(call: Callable[[dict], None]) -> None:
"""(internal)
Add a callable to be called for subsequent keyboard-game-pad events.
"""Add a callable to be called for subsequent keyboard-game-pad events.
The method is passed a dict containing info about the event.
:meta private:
"""
# This is a dummy stub; the actual implementation is native code.
return None
@ -1236,11 +1236,11 @@ def get_collision_info(*args: Any) -> Any:
return _uninferrable()
def get_configurable_game_pads() -> list:
"""(internal)
Returns a list of the currently connected gamepads that can be
def get_configurable_game_controllers() -> list:
"""Returns a list of the currently connected gamepads that can be
configured.
:meta private:
"""
# This is a dummy stub; the actual implementation is native code.
return list()
@ -1300,11 +1300,19 @@ def get_game_roster() -> list[dict[str, Any]]:
def get_local_active_input_devices_count() -> int:
"""(internal)"""
""":meta private:"""
# This is a dummy stub; the actual implementation is native code.
return int()
def get_main_ui_input_device() -> bascenev1.InputDevice | None:
"""Return the input-device currently controlling the main ui, or
None if there is none.
"""
# This is a dummy stub; the actual implementation is native code.
return InputDevice()
def get_package_collision_mesh(
package: bascenev1.AssetPackage, name: str
) -> bascenev1.CollisionMesh:
@ -1385,16 +1393,6 @@ def get_replay_speed_exponent() -> int:
return int()
def get_ui_input_device() -> bascenev1.InputDevice | None:
"""(internal)
Returns the input-device that currently owns the user interface, or
None if there is none.
"""
# This is a dummy stub; the actual implementation is native code.
return InputDevice()
# Show that our return type varies based on "doraise" value:
@overload
def getactivity(doraise: Literal[True] = True) -> bascenev1.Activity: ...
@ -1463,11 +1461,11 @@ def getinputdevice(
def getinputdevice(name: str, unique_id: str, doraise: bool = True) -> Any:
"""(internal)
Given a type name and a unique identifier, returns an InputDevice.
"""Given a type name and a unique identifier, returns an InputDevice.
Throws an Exception if the input-device is not found, or returns None
if 'doraise' is False.
:meta private:
"""
return None
@ -1583,11 +1581,7 @@ def is_replay_paused() -> bool:
def ls_input_devices() -> None:
"""Print debugging info about game objects.
This call only functions in debug builds of the game.
It prints various info about the current object count, etc.
"""
"""Log debugging info about input devices."""
# This is a dummy stub; the actual implementation is native code.
return None
@ -1697,19 +1691,28 @@ def register_session(session: bascenev1.Session) -> bascenev1.SessionData:
return bascenev1.SessionData()
def release_gamepad_input() -> None:
"""(internal)
def release_game_controller_input() -> None:
"""Resumes normal game controller event processing.
Resumes normal gamepad event processing.
:meta private:
"""
# This is a dummy stub; the actual implementation is native code.
return None
def release_keyboard_input() -> None:
"""(internal)
"""Resumes normal keyboard event processing.
Resumes normal keyboard event processing.
:meta private:
"""
# This is a dummy stub; the actual implementation is native code.
return None
def reload_hooks() -> None:
"""Reload functions and other objects held by the native layer.
Call this if you replace things in a hooks module to get the
native layer to see your changes.
"""
# This is a dummy stub; the actual implementation is native code.
return None
@ -1843,7 +1846,7 @@ def set_replay_speed_exponent(speed: int) -> None:
def set_touchscreen_editing(editing: bool) -> None:
"""(internal)"""
""":meta private:"""
# This is a dummy stub; the actual implementation is native code.
return None

View file

@ -309,9 +309,17 @@ def containerwidget(
]
| None
) = None,
toolbar_cancel_button_style: (
Literal[
'back',
'close',
]
| None
) = None,
on_select_call: Callable[[], None] | None = None,
claim_outside_clicks: bool | None = None,
claims_up_down: bool | None = None,
darken_behind: bool | None = None,
) -> bauiv1.Widget:
"""Create or edit a container widget.
@ -340,6 +348,7 @@ def get_special_widget(
name: Literal[
'squad_button',
'back_button',
'menu_button',
'account_button',
'achievements_button',
'settings_button',
@ -465,6 +474,15 @@ def on_ui_scale_change() -> None:
return None
def reload_hooks() -> None:
"""Reload functions and other objects held by the native layer.
Call this if you replace things in a hooks module to get the
native layer to see your changes.
"""
# This is a dummy stub; the actual implementation is native code.
return None
def root_ui_back_press() -> None:
"""(internal)"""
# This is a dummy stub; the actual implementation is native code.