Skip to content

Commit

Permalink
Merge pull request #1807 from LmeSzinc/bug_fix
Browse files Browse the repository at this point in the history
Bug fix
  • Loading branch information
LmeSzinc authored Nov 1, 2022
2 parents ae6db3f + a2081be commit 67b9d29
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 13 deletions.
5 changes: 2 additions & 3 deletions module/config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,9 +313,8 @@ def set_record(self, **kwargs):
with self.multi_set():
for arg, value in kwargs.items():
record = arg.replace("Value", "Record")
if self.__getattribute__(arg) != value:
self.__setattr__(arg, value)
self.__setattr__(record, datetime.now().replace(microsecond=0))
self.__setattr__(arg, value)
self.__setattr__(record, datetime.now().replace(microsecond=0))

def multi_set(self):
"""
Expand Down
2 changes: 1 addition & 1 deletion module/config/i18n/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -2098,7 +2098,7 @@
},
"ActionPointPreserve": {
"name": "Keep X Amount of AP",
"help": "Stops task if total AP (including AP boxes in inventory) is below this number, 500 is recommended\nThis value will be auto reduced to 200 at 3 days before OpSi reset and to 0 at day before reset"
"help": "Stops task if total AP (including AP boxes in inventory) is below this number, 500 is recommended\nThis value will be auto reduced to 300 at 3 days before OpSi reset and to 0 at day before reset"
},
"HazardLevel": {
"name": "Target Zone Hazard Level",
Expand Down
2 changes: 1 addition & 1 deletion module/config/i18n/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -2098,7 +2098,7 @@
},
"ActionPointPreserve": {
"name": "保留 X 点行动力",
"help": "行动力低于 X 后停止,自动打开行动力箱子,X 包含箱子中的行动力,建议保留 500 点行动力\n这个值将在大世界重置前3天自动减少至200点,并在最后一天自动减少至0点"
"help": "行动力低于 X 后停止,自动打开行动力箱子,X 包含箱子中的行动力,建议保留 500 点行动力\n这个值将在大世界重置前3天自动减少至300点,并在最后一天自动减少至0点"
},
"HazardLevel": {
"name": "侵蚀等级",
Expand Down
2 changes: 1 addition & 1 deletion module/config/i18n/zh-TW.json
Original file line number Diff line number Diff line change
Expand Up @@ -2098,7 +2098,7 @@
},
"ActionPointPreserve": {
"name": "保留 X 點行動力",
"help": "行動力低於 X 後停止,自動打開行動力箱子,X 包含箱子中的行動力,建議保留 500 點行動力\n這個值將在大世界重置前3天自動減少至200點,並在最後一天自動減少至0點"
"help": "行動力低於 X 後停止,自動打開行動力箱子,X 包含箱子中的行動力,建議保留 500 點行動力\n這個值將在大世界重置前3天自動減少至300點,並在最後一天自動減少至0點"
},
"HazardLevel": {
"name": "侵蝕等級",
Expand Down
4 changes: 2 additions & 2 deletions module/os/map.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,11 +365,11 @@ def action_point_limit_override(self):
return True
elif remain <= 2:
logger.info('Just less than 3 days to OpSi reset, '
'set OpsiMeowfficerFarming.ActionPointPreserve < 200 temporarily')
'set OpsiMeowfficerFarming.ActionPointPreserve < 300 temporarily')
self.config.override(
OpsiMeowfficerFarming_ActionPointPreserve=min(
self.config.OpsiMeowfficerFarming_ActionPointPreserve,
200)
300)
)
return True
else:
Expand Down
3 changes: 2 additions & 1 deletion module/research/research.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,6 @@ def research_project_start(self, project, add_queue=True, skip_first_screenshot=
i = (index - self._research_project_offset) % 5
logger.info(f'Project offset: {self._research_project_offset}, project {index} is at {i}')
self.device.click(RESEARCH_ENTRANCE[i])
self._research_project_offset = (index - 2) % 5
self.ensure_research_stable()
click_count += 1
click_timer.reset()
Expand All @@ -232,12 +231,14 @@ def research_project_start(self, project, add_queue=True, skip_first_screenshot=
self.research_detail_quit()
# self.ensure_no_info_bar(timeout=3) # Research started
self.research_project_started = project
self._research_project_offset = (index - 2) % 5
return True
if not available and max_rgb <= 235 \
and self.appear(RESEARCH_UNAVAILABLE, offset=(5, 20)):
logger.info('Not enough resources to start this project')
self.research_detail_quit()
self.research_project_started = None
self._research_project_offset = (index - 2) % 5
return False

def research_project_start_with_requirements(self, project, add_queue=True):
Expand Down
16 changes: 12 additions & 4 deletions module/webui/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,8 @@ def _alas_thread_update_config(self) -> None:
try:
d = self.modified_config_queue.get(timeout=10)
config_name = self.alas_name
read = self.alas_config.read_file
write = self.alas_config.write_file
except queue.Empty:
continue
modified[d["name"]] = d["value"]
Expand All @@ -418,15 +420,21 @@ def _alas_thread_update_config(self) -> None:
d = self.modified_config_queue.get(timeout=1)
modified[d["name"]] = d["value"]
except queue.Empty:
self._save_config(modified, config_name)
self._save_config(modified, config_name, read, write)
modified.clear()
break

def _save_config(self, modified: Dict[str, str], config_name: str) -> None:
def _save_config(
self,
modified: Dict[str, str],
config_name: str,
read=State.config_updater.read_file,
write=State.config_updater.write_file
) -> None:
try:
valid = []
invalid = []
config = self.alas_config.read_file(self.alas_name)
config = read(config_name)
for k, v in modified.copy().items():
valuetype = deep_get(self.ALAS_ARGS, k + ".valuetype")
v = parse_pin_value(v, valuetype)
Expand Down Expand Up @@ -469,7 +477,7 @@ def _save_config(self, modified: Dict[str, str], config_name: str) -> None:
logger.info(
f"Save config {filepath_config(config_name)}, {dict_to_kv(modified)}"
)
self.alas_config.write_file(config_name, config)
write(config_name, config)
except Exception as e:
logger.exception(e)

Expand Down

0 comments on commit 67b9d29

Please sign in to comment.