Fix: Sync credits between dashboard and planner

This commit is contained in:
LmeSzinc 2024-06-18 02:19:59 +08:00
parent 0242feead6
commit a7bebab04d
3 changed files with 24 additions and 2 deletions

View File

@ -253,7 +253,13 @@ class CombatObtain(PlannerMixin):
ItemAmount: Arrow_of_the_Beast_Hunter, 85
"""
self.planner.load_obtained_amount(items)
with self.config.multi_set():
self.planner_write()
# Sync to dashboard
for item in items:
if item.item.name == 'Credit':
self.config.stored.Credit.value = item.value
return items
def obtained_is_full(self, dungeon: DungeonList | None, wave_done=0, obtain_get=True) -> bool:

View File

@ -7,6 +7,7 @@ from tasks.base.page import page_item
from tasks.item.assets.assets_item_data import OCR_DATA
from tasks.item.keywords import KEYWORDS_ITEM_TAB
from tasks.item.ui import ItemUI
from tasks.planner.model import PlannerMixin
class DataDigit(Digit):
@ -16,7 +17,7 @@ class DataDigit(Digit):
return super().after_process(result)
class DataUpdate(ItemUI):
class DataUpdate(ItemUI, PlannerMixin):
def _get_data(self):
"""
Page:
@ -53,3 +54,9 @@ class DataUpdate(ItemUI):
self.config.stored.Credit.value = credit
self.config.stored.StallerJade.value = jade
self.config.task_delay(server_update=True)
# Sync to planner
require = self.config.cross_get('Dungeon.Planner.Item_Credit.total', default=0)
if require:
self.config.cross_set('Dungeon.Planner.Item_Credit.value', credit)
self.config.cross_set('Dungeon.Planner.Item_Credit.time', self.config.stored.Credit.time)
self.planner_write()

View File

@ -652,6 +652,15 @@ class PlannerMixin(UI):
if add:
planner.add_planner_result(self.planner)
# Load from dashboard
try:
row = planner.rows['Credit']
value = self.config.stored.Credit.value
if value:
row.value = value
except KeyError:
pass
self.planner_write(planner)
@cached_property