Skip to content

Commit

Permalink
#356 改用精英怪计数
Browse files Browse the repository at this point in the history
  • Loading branch information
DoctorReid committed Jul 6, 2024
1 parent 1c8e5d0 commit d51fe28
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 18 deletions.
12 changes: 6 additions & 6 deletions src/gui/settings/settings_sim_uni_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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):
"""
Expand All @@ -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
Expand Down
6 changes: 0 additions & 6 deletions src/sr/app/sim_uni/sim_uni_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand All @@ -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)
Expand Down
24 changes: 24 additions & 0 deletions src/sr/app/sim_uni/sim_uni_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
40 changes: 40 additions & 0 deletions src/sr/app/sim_uni/sim_uni_run_record.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down Expand Up @@ -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
6 changes: 0 additions & 6 deletions src/sr/app/sim_uni/test_sim_uni_route_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
1 change: 1 addition & 0 deletions src/sr/sim_uni/op/v2/sim_uni_run_elite_route_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 # 与精英战斗后 该识别的目标都在附近了 就算识别不到也不需要往前走了

Expand Down

0 comments on commit d51fe28

Please sign in to comment.