Update browser.py

This commit is contained in:
Vishal 2024-01-12 13:14:00 +05:30 committed by GitHub
parent bd6e8f9822
commit d79b5773f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -104,6 +104,19 @@ class CoopBrowserWindow(bui.Window):
'campaignDifficulty', 'easy'
)
if (
self._campaign_difficulty == 'hard'
and not app.classic.accounts.have_pro_options()
):
plus.add_v1_account_transaction(
{
'type': 'SET_MISC_VAL',
'name': 'campaignDifficulty',
'value': 'easy',
}
)
self._campaign_difficulty = 'easy'
super().__init__(
root_widget=bui.containerwidget(
size=(self._width, self._height + top_extra),
@ -290,7 +303,6 @@ class CoopBrowserWindow(bui.Window):
self._refresh()
self._restore_state()
self._set_campaign_difficulty(self._campaign_difficulty, False)
# Even though we might display cached tournament data immediately, we
# don't consider it valid until we've pinged.
@ -498,11 +510,7 @@ class CoopBrowserWindow(bui.Window):
self._doing_tournament_query = False
self._update_for_data(tournament_data)
def _set_campaign_difficulty(
self,
difficulty: str,
check: bool
) -> None:
def _set_campaign_difficulty(self, difficulty: str) -> None:
# pylint: disable=cyclic-import
from bauiv1lib.purchase import PurchaseWindow
@ -510,16 +518,13 @@ class CoopBrowserWindow(bui.Window):
assert plus is not None
assert bui.app.classic is not None
#if difficulty != self._campaign_difficulty
if True:
if difficulty != self._campaign_difficulty:
if (
difficulty == 'hard'
and not bui.app.classic.accounts.have_pro_options()
):
if check:
PurchaseWindow(items=['pro'])
return
difficulty = 'easy'
PurchaseWindow(items=['pro'])
return
bui.getsound('gunCocking').play()
if difficulty not in ('easy', 'hard'):
print('ERROR: invalid campaign difficulty:', difficulty)
@ -565,9 +570,7 @@ class CoopBrowserWindow(bui.Window):
button_type='square',
autoselect=True,
enable_sound=False,
on_activate_call=bui.Call(
self._set_campaign_difficulty, 'easy', True
),
on_activate_call=bui.Call(self._set_campaign_difficulty, 'easy'),
on_select_call=bui.Call(self.sel_change, 'campaign', 'easyButton'),
color=sel_color
if self._campaign_difficulty == 'easy'
@ -593,9 +596,7 @@ class CoopBrowserWindow(bui.Window):
button_type='square',
autoselect=True,
enable_sound=False,
on_activate_call=bui.Call(
self._set_campaign_difficulty, 'hard', True
),
on_activate_call=bui.Call(self._set_campaign_difficulty, 'hard'),
on_select_call=bui.Call(self.sel_change, 'campaign', 'hardButton'),
color=sel_color_hard
if self._campaign_difficulty == 'hard'