hello API 8 !

This commit is contained in:
Ayush Saini 2023-08-13 17:21:49 +05:30
parent 3a2b6ade68
commit 0284fee95c
1166 changed files with 26061 additions and 375100 deletions

37
dist/ba_data/python/baplus/__init__.py vendored Normal file
View file

@ -0,0 +1,37 @@
# Released under the MIT License. See LICENSE for details.
#
"""Closed-source bits of ballistica.
This code concerns sensitive things like accounts and master-server
communication so the native C++ parts of it remain closed. Native
precompiled static libraries of this portion are provided for those who
want to compile the rest of the engine, and a fully open-source engine
can also be built by removing this 'plus' feature-set.
"""
from __future__ import annotations
# Note: there's not much here.
# All comms with this feature-set should go through app.plus.
import logging
from baplus._subsystem import PlusSubsystem
__all__ = [
'PlusSubsystem',
]
# Sanity check: we want to keep ballistica's dependencies and
# bootstrapping order clearly defined; let's check a few particular
# modules to make sure they never directly or indirectly import us
# before their own execs complete.
if __debug__:
for _mdl in 'babase', '_babase':
if not hasattr(__import__(_mdl), '_REACHED_END_OF_MODULE'):
logging.warning(
'%s was imported before %s finished importing;'
' should not happen.',
__name__,
_mdl,
)

15
dist/ba_data/python/baplus/_hooks.py vendored Normal file
View file

@ -0,0 +1,15 @@
# Released under the MIT License. See LICENSE for details.
#
"""Snippets of code for use by the c++ layer."""
# (most of these are self-explanatory)
# pylint: disable=missing-function-docstring
from __future__ import annotations
import _baplus
def submit_analytics_counts(sval: str) -> None:
_baplus.add_v1_account_transaction(
{'type': 'ANALYTICS_COUNTS', 'values': sval}
)
_baplus.run_v1_account_transactions()

251
dist/ba_data/python/baplus/_subsystem.py vendored Normal file
View file

@ -0,0 +1,251 @@
# Released under the MIT License. See LICENSE for details.
#
"""Provides classic app subsystem."""
from __future__ import annotations
from typing import TYPE_CHECKING
import _baplus
from babase import AppSubsystem
if TYPE_CHECKING:
from typing import Callable, Any
from babase import CloudSubsystem, AccountV2Subsystem
class PlusSubsystem(AppSubsystem):
"""Subsystem for plus functionality in the app.
The single shared instance of this app can be accessed at
babase.app.plus. Note that it is possible for this to be None if the
plus package is not present, and code should handle that case
gracefully.
"""
# pylint: disable=too-many-public-methods
# Note: this is basically just a wrapper around _baplus for
# type-checking purposes. Maybe there's some smart way we could skip
# the overhead of this wrapper at runtime.
accounts: AccountV2Subsystem
cloud: CloudSubsystem
def on_app_loading(self) -> None:
_baplus.on_app_loading()
self.accounts.on_app_loading()
# noinspection PyUnresolvedReferences
@staticmethod
def add_v1_account_transaction(
transaction: dict, callback: Callable | None = None
) -> None:
"""(internal)"""
return _baplus.add_v1_account_transaction(transaction, callback)
@staticmethod
def game_service_has_leaderboard(game: str, config: str) -> bool:
"""(internal)
Given a game and config string, returns whether there is a leaderboard
for it on the game service.
"""
return _baplus.game_service_has_leaderboard(game, config)
@staticmethod
def get_master_server_address(source: int = -1, version: int = 1) -> str:
"""(internal)
Return the address of the master server.
"""
return _baplus.get_master_server_address(source, version)
@staticmethod
def get_news_show() -> str:
"""(internal)"""
return _baplus.get_news_show()
@staticmethod
def get_price(item: str) -> str | None:
"""(internal)"""
return _baplus.get_price(item)
@staticmethod
def get_purchased(item: str) -> bool:
"""(internal)"""
return _baplus.get_purchased(item)
@staticmethod
def get_purchases_state() -> int:
"""(internal)"""
return _baplus.get_purchases_state()
@staticmethod
def get_v1_account_display_string(full: bool = True) -> str:
"""(internal)"""
return _baplus.get_v1_account_display_string(full)
@staticmethod
def get_v1_account_misc_read_val(name: str, default_value: Any) -> Any:
"""(internal)"""
return _baplus.get_v1_account_misc_read_val(name, default_value)
@staticmethod
def get_v1_account_misc_read_val_2(name: str, default_value: Any) -> Any:
"""(internal)"""
return _baplus.get_v1_account_misc_read_val_2(name, default_value)
@staticmethod
def get_v1_account_misc_val(name: str, default_value: Any) -> Any:
"""(internal)"""
return _baplus.get_v1_account_misc_val(name, default_value)
@staticmethod
def get_v1_account_name() -> str:
"""(internal)"""
return _baplus.get_v1_account_name()
@staticmethod
def get_v1_account_public_login_id() -> str | None:
"""(internal)"""
return _baplus.get_v1_account_public_login_id()
@staticmethod
def get_v1_account_state() -> str:
"""(internal)"""
return _baplus.get_v1_account_state()
@staticmethod
def get_v1_account_state_num() -> int:
"""(internal)"""
return _baplus.get_v1_account_state_num()
@staticmethod
def get_v1_account_ticket_count() -> int:
"""(internal)
Returns the number of tickets for the current account.
"""
return _baplus.get_v1_account_ticket_count()
@staticmethod
def get_v1_account_type() -> str:
"""(internal)"""
return _baplus.get_v1_account_type()
@staticmethod
def get_v2_fleet() -> str:
"""(internal)"""
return _baplus.get_v2_fleet()
@staticmethod
def have_outstanding_v1_account_transactions() -> bool:
"""(internal)"""
return _baplus.have_outstanding_v1_account_transactions()
@staticmethod
def in_game_purchase(item: str, price: int) -> None:
"""(internal)"""
return _baplus.in_game_purchase(item, price)
@staticmethod
def is_blessed() -> bool:
"""(internal)"""
return _baplus.is_blessed()
@staticmethod
def mark_config_dirty() -> None:
"""(internal)
Category: General Utility Functions
"""
return _baplus.mark_config_dirty()
@staticmethod
def power_ranking_query(callback: Callable, season: Any = None) -> None:
"""(internal)"""
return _baplus.power_ranking_query(callback, season)
@staticmethod
def purchase(item: str) -> None:
"""(internal)"""
return _baplus.purchase(item)
@staticmethod
def report_achievement(
achievement: str, pass_to_account: bool = True
) -> None:
"""(internal)"""
return _baplus.report_achievement(achievement, pass_to_account)
@staticmethod
def reset_achievements() -> None:
"""(internal)"""
return _baplus.reset_achievements()
@staticmethod
def restore_purchases() -> None:
"""(internal)"""
return _baplus.restore_purchases()
@staticmethod
def run_v1_account_transactions() -> None:
"""(internal)"""
return _baplus.run_v1_account_transactions()
@staticmethod
def sign_in_v1(account_type: str) -> None:
"""(internal)
Category: General Utility Functions
"""
return _baplus.sign_in_v1(account_type)
@staticmethod
def sign_out_v1(v2_embedded: bool = False) -> None:
"""(internal)
Category: General Utility Functions
"""
return _baplus.sign_out_v1(v2_embedded)
@staticmethod
def submit_score(
game: str,
config: str,
name: Any,
score: int | None,
callback: Callable,
order: str = 'increasing',
tournament_id: str | None = None,
score_type: str = 'points',
campaign: str | None = None,
level: str | None = None,
) -> None:
"""(internal)
Submit a score to the server; callback will be called with the results.
As a courtesy, please don't send fake scores to the server. I'd prefer
to devote my time to improving the game instead of trying to make the
score server more mischief-proof.
"""
return _baplus.submit_score(
game,
config,
name,
score,
callback,
order,
tournament_id,
score_type,
campaign,
level,
)
@staticmethod
def tournament_query(
callback: Callable[[dict | None], None], args: dict
) -> None:
"""(internal)"""
return _baplus.tournament_query(callback, args)