diff --git a/module/config/argument/args.json b/module/config/argument/args.json index d2338c2318..7efd415507 100644 --- a/module/config/argument/args.json +++ b/module/config/argument/args.json @@ -7944,7 +7944,7 @@ "type": "stored", "value": {}, "display": "hide", - "stored": "StoredInt", + "stored": "StoredActionPoint", "order": 6, "color": "#008000" } diff --git a/module/config/argument/argument.yaml b/module/config/argument/argument.yaml index 0f564233c1..bdb2d35c4b 100644 --- a/module/config/argument/argument.yaml +++ b/module/config/argument/argument.yaml @@ -728,7 +728,7 @@ OpsiStorage: order: 8 color: "#7700BB" ActionPoint: - stored: StoredInt + stored: StoredActionPoint order: 6 color: "#008000" diff --git a/module/config/argument/stored.json b/module/config/argument/stored.json index a5bd36b649..d9a732008b 100644 --- a/module/config/argument/stored.json +++ b/module/config/argument/stored.json @@ -65,10 +65,10 @@ "name": "ActionPoint", "path": "OpsiGeneral.OpsiStorage.ActionPoint", "i18n": "OpsiStorage.ActionPoint.name", - "stored": "StoredInt", + "stored": "StoredActionPoint", "attrs": { "time": "2020-01-01 00:00:00", - "value": 0 + "value": "" }, "order": 6, "color": "#008000" diff --git a/module/config/stored/classes.py b/module/config/stored/classes.py index 99f117165b..5c942660c5 100644 --- a/module/config/stored/classes.py +++ b/module/config/stored/classes.py @@ -1,3 +1,4 @@ +import re from datetime import datetime from module.base.decorator import cached_property @@ -110,6 +111,10 @@ class StoredInt(StoredBase): value = 0 +class StoredStr(StoredBase): + value = '' + + class StoredCounter(StoredBase): value = 0 total = 0 @@ -156,3 +161,19 @@ class StoredOil(StoredCounter): class StoredCoin(StoredCounter): pass + + +class StoredActionPoint(StoredStr): + _current = 0 + _total = 0 + + def __setattr__(self, key, value): + if key == 'value' and value: + res = re.search(r'(\d+) \((\d+)\)', value) + if res: + self._current = int(res.group(1)) + self._total = int(res.group(2)) + super().__setattr__(key, value) + + def set(self, current, total): + self.value = f'{current} ({total})' diff --git a/module/config/stored/stored_generated.py b/module/config/stored/stored_generated.py index 6a51a0cc43..fecde6d5ce 100644 --- a/module/config/stored/stored_generated.py +++ b/module/config/stored/stored_generated.py @@ -1,9 +1,11 @@ from module.config.stored.classes import ( + StoredActionPoint, StoredBase, StoredCoin, StoredCounter, StoredInt, StoredOil, + StoredStr, ) @@ -18,4 +20,4 @@ class StoredGenerated: Cube = StoredInt("Gacha.GachaStorage.Cube") YellowCoin = StoredInt("OpsiGeneral.OpsiStorage.YellowCoin") PurpleCoin = StoredInt("OpsiGeneral.OpsiStorage.PurpleCoin") - ActionPoint = StoredInt("OpsiGeneral.OpsiStorage.ActionPoint") + ActionPoint = StoredActionPoint("OpsiGeneral.OpsiStorage.ActionPoint") diff --git a/module/os_handler/action_point.py b/module/os_handler/action_point.py index 317cb8f578..093100b7b4 100644 --- a/module/os_handler/action_point.py +++ b/module/os_handler/action_point.py @@ -140,7 +140,7 @@ def action_point_update(self): logger.info(f'Action points: {current}({total}), oil: {oil}') self.config.stored.Oil.value = oil - self.config.stored.ActionPoint.value = total + self.config.stored.ActionPoint.set(current, total) self._action_point_current = current self._action_point_box = box self._action_point_total = total