Skip to content

Commit

Permalink
fixed in-game resume and removed continues code
Browse files Browse the repository at this point in the history
  • Loading branch information
efroemling committed Sep 28, 2024
1 parent bbbea7b commit 3d3d3a4
Show file tree
Hide file tree
Showing 14 changed files with 38 additions and 429 deletions.
40 changes: 20 additions & 20 deletions .efrocachemap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
### 1.7.37 (build 22017, api 9, 2024-09-27)
### 1.7.37 (build 22018, api 9, 2024-09-28)
- Bumping api version to 9. As you'll see below, there's some UI changes that
will require a bit of work for any UI mods to adapt to. If your mods don't
touch UI stuff at all you can simply bump your api version and call it a day.
Expand All @@ -17,6 +17,8 @@
- Campaign hard mode no longer requires pro.
- Full player profile color customization no longer requires pro.
- Removed nag screens for purchasing pro or bundle offers.
- Removed continue logic. Continues have been disabled server-side for a while
but now removing the client code to clean things up a bit.
- Switching over to the new 'toolbar mode' UI that has been in the works for
several years. This includes a number of handy things such as consistent
buttons and widgets for league status, currencies, inventory, and the store.
Expand Down
2 changes: 0 additions & 2 deletions src/assets/.asset_manifest_public.json
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,6 @@
"ba_data/python/bauiv1lib/__pycache__/config.cpython-312.opt-1.pyc",
"ba_data/python/bauiv1lib/__pycache__/confirm.cpython-312.opt-1.pyc",
"ba_data/python/bauiv1lib/__pycache__/connectivity.cpython-312.opt-1.pyc",
"ba_data/python/bauiv1lib/__pycache__/continues.cpython-312.opt-1.pyc",
"ba_data/python/bauiv1lib/__pycache__/credits.cpython-312.opt-1.pyc",
"ba_data/python/bauiv1lib/__pycache__/discord.cpython-312.opt-1.pyc",
"ba_data/python/bauiv1lib/__pycache__/feedback.cpython-312.opt-1.pyc",
Expand Down Expand Up @@ -425,7 +424,6 @@
"ba_data/python/bauiv1lib/config.py",
"ba_data/python/bauiv1lib/confirm.py",
"ba_data/python/bauiv1lib/connectivity.py",
"ba_data/python/bauiv1lib/continues.py",
"ba_data/python/bauiv1lib/coop/__init__.py",
"ba_data/python/bauiv1lib/coop/__pycache__/__init__.cpython-312.opt-1.pyc",
"ba_data/python/bauiv1lib/coop/__pycache__/browser.cpython-312.opt-1.pyc",
Expand Down
2 changes: 0 additions & 2 deletions src/assets/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,6 @@ SCRIPT_TARGETS_PY_PUBLIC = \
$(BUILD_DIR)/ba_data/python/bauiv1lib/config.py \
$(BUILD_DIR)/ba_data/python/bauiv1lib/confirm.py \
$(BUILD_DIR)/ba_data/python/bauiv1lib/connectivity.py \
$(BUILD_DIR)/ba_data/python/bauiv1lib/continues.py \
$(BUILD_DIR)/ba_data/python/bauiv1lib/coop/__init__.py \
$(BUILD_DIR)/ba_data/python/bauiv1lib/coop/browser.py \
$(BUILD_DIR)/ba_data/python/bauiv1lib/coop/gamebutton.py \
Expand Down Expand Up @@ -624,7 +623,6 @@ SCRIPT_TARGETS_PYC_PUBLIC = \
$(BUILD_DIR)/ba_data/python/bauiv1lib/__pycache__/config.cpython-312.opt-1.pyc \
$(BUILD_DIR)/ba_data/python/bauiv1lib/__pycache__/confirm.cpython-312.opt-1.pyc \
$(BUILD_DIR)/ba_data/python/bauiv1lib/__pycache__/connectivity.cpython-312.opt-1.pyc \
$(BUILD_DIR)/ba_data/python/bauiv1lib/__pycache__/continues.cpython-312.opt-1.pyc \
$(BUILD_DIR)/ba_data/python/bauiv1lib/coop/__pycache__/__init__.cpython-312.opt-1.pyc \
$(BUILD_DIR)/ba_data/python/bauiv1lib/coop/__pycache__/browser.cpython-312.opt-1.pyc \
$(BUILD_DIR)/ba_data/python/bauiv1lib/coop/__pycache__/gamebutton.cpython-312.opt-1.pyc \
Expand Down
8 changes: 7 additions & 1 deletion src/assets/ba_data/python/baclassic/_appmode.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,15 @@ def _root_ui_menu_press(self) -> None:

ui = app.ui_v1

# If *any* main-window is up, kill it.
# If *any* main-window is up, kill it and resume play.
old_window = ui.get_main_window()
if old_window is not None:

classic = app.classic

assert classic is not None
classic.resume()

ui.clear_main_window()
return

Expand Down
12 changes: 0 additions & 12 deletions src/assets/ba_data/python/baclassic/_appsubsystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -720,18 +720,6 @@ def get_main_menu_session(self) -> type[bascenev1.Session]:

return MainMenuSession

def continues_window(
self,
activity: bascenev1.Activity,
cost: int,
continue_call: Callable[[], Any],
cancel_call: Callable[[], Any],
) -> None:
"""(internal)"""
from bauiv1lib.continues import ContinuesWindow

ContinuesWindow(activity, cost, continue_call, cancel_call)

def profile_browser_window(
self,
transition: str = 'in_right',
Expand Down
2 changes: 1 addition & 1 deletion src/assets/ba_data/python/baenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@

# Build number and version of the ballistica binary we expect to be
# using.
TARGET_BALLISTICA_BUILD = 22017
TARGET_BALLISTICA_BUILD = 22018
TARGET_BALLISTICA_VERSION = '1.7.37'


Expand Down
116 changes: 0 additions & 116 deletions src/assets/ba_data/python/bascenev1/_gameactivity.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,6 @@ def __init__(self, settings: dict):
"""Instantiate the Activity."""
super().__init__(settings)

plus = babase.app.plus

# Holds some flattened info about the player set at the point
# when on_begin() is called.
self.initialplayerinfos: list[bascenev1.PlayerInfo] | None = None
Expand Down Expand Up @@ -239,23 +237,6 @@ def __init__(self, settings: dict):
None
)
self._zoom_message_times: dict[int, float] = {}
self._is_waiting_for_continue = False

self._continue_cost = (
25
if plus is None
else plus.get_v1_account_misc_read_val('continueStartCost', 25)
)
self._continue_cost_mult = (
2
if plus is None
else plus.get_v1_account_misc_read_val('continuesMult', 2)
)
self._continue_cost_offset = (
0
if plus is None
else plus.get_v1_account_misc_read_val('continuesOffset', 0)
)

@property
def map(self) -> _map.Map:
Expand Down Expand Up @@ -362,103 +343,6 @@ def on_transition_in(self) -> None:
if music is not None:
_music.setmusic(music)

def on_continue(self) -> None:
"""
This is called if a game supports and offers a continue and the player
accepts. In this case the player should be given an extra life or
whatever is relevant to keep the game going.
"""

def _continue_choice(self, do_continue: bool) -> None:
plus = babase.app.plus
assert plus is not None
self._is_waiting_for_continue = False
if self.has_ended():
return
with self.context:
if do_continue:
_bascenev1.getsound('shieldUp').play()
_bascenev1.getsound('cashRegister').play()
plus.add_v1_account_transaction(
{'type': 'CONTINUE', 'cost': self._continue_cost}
)
if plus is not None:
plus.run_v1_account_transactions()
self._continue_cost = (
self._continue_cost * self._continue_cost_mult
+ self._continue_cost_offset
)
self.on_continue()
else:
self.end_game()

def is_waiting_for_continue(self) -> bool:
"""Returns whether or not this activity is currently waiting for the
player to continue (or timeout)"""
return self._is_waiting_for_continue

def continue_or_end_game(self) -> None:
"""If continues are allowed, prompts the player to purchase a continue
and calls either end_game or continue_game depending on the result
"""
# pylint: disable=too-many-nested-blocks
# pylint: disable=cyclic-import
from bascenev1._coopsession import CoopSession

classic = babase.app.classic
assert classic is not None
continues_window = classic.continues_window

# Turning these off. I want to migrate towards monetization that
# feels less pay-to-win-ish.
allow_continues = False

plus = babase.app.plus
try:
if (
plus is not None
and plus.get_v1_account_misc_read_val('enableContinues', False)
and allow_continues
):
session = self.session

# We only support continuing in non-tournament games.
tournament_id = session.tournament_id
if tournament_id is None:
# We currently only support continuing in sequential
# co-op campaigns.
if isinstance(session, CoopSession):
assert session.campaign is not None
if session.campaign.sequential:
gnode = self.globalsnode

# Only attempt this if we're not currently paused
# and there appears to be no UI.
assert babase.app.classic is not None
hmmw = babase.app.ui_v1.has_main_window()
if not gnode.paused and not hmmw:
self._is_waiting_for_continue = True
with babase.ContextRef.empty():
babase.apptimer(
0.5,
lambda: continues_window(
self,
self._continue_cost,
continue_call=babase.WeakCall(
self._continue_choice, True
),
cancel_call=babase.WeakCall(
self._continue_choice, False
),
),
)
return

except Exception:
logging.exception('Error handling continues.')

self.end_game()

@override
def on_begin(self) -> None:
super().on_begin()
Expand Down
16 changes: 1 addition & 15 deletions src/assets/ba_data/python/bascenev1lib/game/football.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Released under the MIT License. See LICENSE for details.
#
# pylint: disable=too-many-lines
"""Implements football games (both co-op and teams varieties)."""

# ba_meta require api 9
Expand Down Expand Up @@ -655,11 +654,6 @@ def _update_bots(self) -> None:
for bot in bots:
bot.target_flag = None

# If we're waiting on a continue, stop here so they don't keep scoring.
if self.is_waiting_for_continue():
self._bots.stop_moving()
return

# If we've got a flag and no player are holding it, find the closest
# bot to it, and make them the designated flag-bearer.
assert self._flag is not None
Expand Down Expand Up @@ -816,14 +810,6 @@ def end_game(self) -> None:
self._bots.final_celebrate()
bs.timer(0.001, bs.Call(self.do_end, 'defeat'))

@override
def on_continue(self) -> None:
# Subtract one touchdown from the bots and get them moving again.
assert self._bot_team is not None
self._bot_team.score -= 7
self._bots.start_moving()
self.update_scores()

def update_scores(self) -> None:
"""update scoreboard and check for winners"""
# FIXME: tidy this up
Expand All @@ -838,7 +824,7 @@ def update_scores(self) -> None:
if not have_scoring_team:
self._scoring_team = team
if team is self._bot_team:
self.continue_or_end_game()
self.end_game()
else:
bs.setmusic(bs.MusicType.VICTORY)

Expand Down
14 changes: 2 additions & 12 deletions src/assets/ba_data/python/bascenev1lib/game/onslaught.py
Original file line number Diff line number Diff line change
Expand Up @@ -1195,7 +1195,7 @@ def _update_player_spawn_info(self) -> None:

def _respawn_players_for_wave(self) -> None:
# Respawn applicable players.
if self._wavenum > 1 and not self.is_waiting_for_continue():
if self._wavenum > 1:
for player in self.players:
if (
not player.is_alive()
Expand Down Expand Up @@ -1642,19 +1642,9 @@ def end_game(self) -> None:
self.do_end('defeat', delay=2.0)
bs.setmusic(None)

@override
def on_continue(self) -> None:
for player in self.players:
if not player.is_alive():
self.spawn_player(player)

def _checkroundover(self) -> None:
"""Potentially end the round based on the state of the game."""
if self.has_ended():
return
if not any(player.is_alive() for player in self.teams[0].players):
# Allow continuing after wave 1.
if self._wavenum > 1:
self.continue_or_end_game()
else:
self.end_game()
self.end_game()
10 changes: 1 addition & 9 deletions src/assets/ba_data/python/bascenev1lib/game/runaround.py
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ def _handle_reached_end(self) -> None:
self._lives -= 1
if self._lives == 0:
self._bots.stop_moving()
self.continue_or_end_game()
self.end_game()

# Heartbeat behavior
if self._lives < 5:
Expand Down Expand Up @@ -613,14 +613,6 @@ def _safesetattr(node: bs.Node, attr: str, value: Any) -> None:
),
)

@override
def on_continue(self) -> None:
self._lives = 3
assert self._lives_text is not None
assert self._lives_text.node
self._lives_text.node.text = str(self._lives)
self._bots.start_moving()

@override
def spawn_player(self, player: Player) -> bs.Actor:
pos = (
Expand Down
Loading

0 comments on commit 3d3d3a4

Please sign in to comment.