From d51fe28fe341645e4dc3328cfb3aba2a551f7aa9 Mon Sep 17 00:00:00 2001 From: DoctorReid Date: Sat, 6 Jul 2024 11:33:21 +0800 Subject: [PATCH] =?UTF-8?q?#356=20=E6=94=B9=E7=94=A8=E7=B2=BE=E8=8B=B1?= =?UTF-8?q?=E6=80=AA=E8=AE=A1=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/gui/settings/settings_sim_uni_view.py | 12 +++--- src/sr/app/sim_uni/sim_uni_app.py | 6 --- src/sr/app/sim_uni/sim_uni_config.py | 24 +++++++++++ src/sr/app/sim_uni/sim_uni_run_record.py | 40 +++++++++++++++++++ src/sr/app/sim_uni/test_sim_uni_route_app.py | 6 --- .../op/v2/sim_uni_run_elite_route_v2.py | 1 + 6 files changed, 71 insertions(+), 18 deletions(-) diff --git a/src/gui/settings/settings_sim_uni_view.py b/src/gui/settings/settings_sim_uni_view.py index 7dd5f571..3a72849c 100644 --- a/src/gui/settings/settings_sim_uni_view.py +++ b/src/gui/settings/settings_sim_uni_view.py @@ -42,8 +42,8 @@ def __init__(self, page: ft.Page, ctx: Context): SettingsListGroupTitle(gt('模拟宇宙', 'ui')), SettingsListItem(gt('每周挑战', 'ui'), self.weekly_uni_num), SettingsListItem(gt('挑战难度', 'ui'), self.weekly_uni_diff), - SettingsListItem(gt('每周次数', 'ui'), self.weekly_times), - SettingsListItem(gt('每天次数', 'ui'), self.daily_times), + SettingsListItem(gt('每周精英次数', 'ui'), self.weekly_times), + SettingsListItem(gt('每天精英次数', 'ui'), self.daily_times), SettingsListGroupTitle(gt('挑战设置', 'ui')), SettingsListItem(gt('第三宇宙', 'ui'), self.uni_03_dd), SettingsListItem(gt('第四宇宙', 'ui'), self.uni_04_dd), @@ -82,10 +82,10 @@ def _load_config(self): self.weekly_uni_diff.value = str(self.sr_ctx.sim_uni_config.weekly_uni_diff) self.weekly_uni_diff.update() - self.weekly_times.value = str(self.sr_ctx.sim_uni_config.weekly_times) + self.weekly_times.value = str(self.sr_ctx.sim_uni_config.elite_weekly_times) self.weekly_times.update() - self.daily_times.value = str(self.sr_ctx.sim_uni_config.daily_times) + self.daily_times.value = str(self.sr_ctx.sim_uni_config.elite_daily_times) self.daily_times.update() def _on_sim_uni_challenge_changed(self, e): @@ -116,7 +116,7 @@ def _on_weekly_times_changed(self, e): if text != self.weekly_times.value: self.weekly_times.value = text self.weekly_times.update() - self.sr_ctx.sim_uni_config.weekly_times = int(text) + self.sr_ctx.sim_uni_config.elite_weekly_times = int(text) def _on_daily_times_changed(self, e): """ @@ -128,7 +128,7 @@ def _on_daily_times_changed(self, e): if text != self.daily_times.value: self.daily_times.value = text self.daily_times.update() - self.sr_ctx.sim_uni_config.daily_times = int(text) + self.sr_ctx.sim_uni_config.elite_daily_times = int(text) _settings_sim_uni_view: Optional[SettingsSimUniView] = None diff --git a/src/sr/app/sim_uni/sim_uni_app.py b/src/sr/app/sim_uni/sim_uni_app.py index 73f4cd28..ae5db2c9 100644 --- a/src/sr/app/sim_uni/sim_uni_app.py +++ b/src/sr/app/sim_uni/sim_uni_app.py @@ -277,7 +277,6 @@ def _run_world(self) -> OperationOneRoundResult: op = SimUniRunWorld(self.ctx, self.current_uni_num, config=uni_challenge_config, - op_callback=self.on_world_finished, max_reward_to_get=self.max_reward_to_get - self.get_reward_cnt if get_reward else 0, get_reward_callback=self._on_sim_uni_get_reward if get_reward else None ) @@ -288,11 +287,6 @@ def _on_sim_uni_get_reward(self, use_power: int, user_qty: int): if self.get_reward_callback is not None: self.get_reward_callback(use_power, user_qty) - def on_world_finished(self, op_result: OperationResult): - if op_result.success and op_result.status == SimUniRunWorld.STATUS_SUCCESS: - log.info('成功通过 记录次数+1') - self.run_record.add_times() - def _exception_exit(self) -> OperationOneRoundResult: self.exception_times += 1 op = SimUniExit(self.ctx) diff --git a/src/sr/app/sim_uni/sim_uni_config.py b/src/sr/app/sim_uni/sim_uni_config.py index 9fba188f..4392ea63 100644 --- a/src/sr/app/sim_uni/sim_uni_config.py +++ b/src/sr/app/sim_uni/sim_uni_config.py @@ -67,3 +67,27 @@ def daily_times(self) -> int: @daily_times.setter def daily_times(self, new_value: int): self.update('daily_times', new_value) + + @property + def elite_weekly_times(self) -> int: + """ + 每周挑战精英的次数 + :return: + """ + return self.get('elite_weekly_times', 100) + + @elite_weekly_times.setter + def elite_weekly_times(self, new_value: int): + self.update('elite_weekly_times', new_value) + + @property + def elite_daily_times(self) -> int: + """ + 每天挑战的次数 + :return: + """ + return self.get('elite_daily_times', 15) + + @elite_daily_times.setter + def elite_daily_times(self, new_value: int): + self.update('elite_daily_times', new_value) diff --git a/src/sr/app/sim_uni/sim_uni_run_record.py b/src/sr/app/sim_uni/sim_uni_run_record.py index 23add103..c28b7cf8 100644 --- a/src/sr/app/sim_uni/sim_uni_run_record.py +++ b/src/sr/app/sim_uni/sim_uni_run_record.py @@ -12,6 +12,13 @@ def __init__(self, config: SimUniConfig, account_idx: Optional[int] = None): super().__init__(AppDescriptionEnum.SIM_UNIVERSE.value.id, account_idx=account_idx) self.config = config + def _init_after_read_file(self): + AppRunRecord._init_after_read_file(self) + + if self.weekly_times > 0: # 2024-07-06 加入 下次可去除原来的次数判断 + self.elite_weekly_times = self.weekly_times * 3 + self.elite_daily_times = self.daily_times * 3 + @property def run_status_under_now(self): """ @@ -74,3 +81,36 @@ def daily_times(self) -> int: @daily_times.setter def daily_times(self, new_value: int): self.update('daily_times', new_value) + + @property + def elite_weekly_times(self) -> int: + """ + 每周挑战精英的次数 + :return: + """ + return self.get('elite_weekly_times', 0) + + @elite_weekly_times.setter + def elite_weekly_times(self, new_value: int): + self.update('elite_weekly_times', new_value) + + @property + def elite_daily_times(self) -> int: + """ + 每天挑战的次数 + :return: + """ + return self.get('elite_daily_times', 0) + + @elite_daily_times.setter + def elite_daily_times(self, new_value: int): + self.update('elite_daily_times', new_value) + + def add_elite_times(self, times: int = 1): + """ + 增加挑战精英的次数 + :param times: 本次完成次数 + :return: + """ + self.elite_daily_times = self.elite_daily_times + times + self.elite_weekly_times = self.elite_weekly_times + times \ No newline at end of file diff --git a/src/sr/app/sim_uni/test_sim_uni_route_app.py b/src/sr/app/sim_uni/test_sim_uni_route_app.py index 1cb4717c..96bf391f 100644 --- a/src/sr/app/sim_uni/test_sim_uni_route_app.py +++ b/src/sr/app/sim_uni/test_sim_uni_route_app.py @@ -59,11 +59,5 @@ def _run_world(self) -> OperationOneRoundResult: uni_challenge_config = self.config.get_challenge_config(self.uni_num) op = SimUniRunWorld(self.ctx, self.uni_num, config=uni_challenge_config, - op_callback=self._on_world_done ) return self.round_by_op(op.execute()) - - def _on_world_done(self, op_result: OperationResult): - run_record = self.ctx.sim_uni_run_record - if op_result.success: - run_record.add_times() diff --git a/src/sr/sim_uni/op/v2/sim_uni_run_elite_route_v2.py b/src/sr/sim_uni/op/v2/sim_uni_run_elite_route_v2.py index 1b0726e5..b5e102b4 100644 --- a/src/sr/sim_uni/op/v2/sim_uni_run_elite_route_v2.py +++ b/src/sr/sim_uni/op/v2/sim_uni_run_elite_route_v2.py @@ -154,6 +154,7 @@ def _after_fight(self) -> OperationOneRoundResult: :return: """ self.had_fight = True + self.ctx.sim_uni_run_record.add_elite_times() self._turn_to_previous_angle() self.moved_to_target = True # 与精英战斗后 该识别的目标都在附近了 就算识别不到也不需要往前走了