Skip to content

Commit

Permalink
Upd: appearance of ActionPoint
Browse files Browse the repository at this point in the history
  • Loading branch information
Air111 committed Jul 3, 2024
1 parent 7a68318 commit d25d8b6
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 6 deletions.
2 changes: 1 addition & 1 deletion module/config/argument/args.json
Original file line number Diff line number Diff line change
Expand Up @@ -7972,7 +7972,7 @@
"type": "stored",
"value": {},
"display": "hide",
"stored": "StoredInt",
"stored": "StoredActionPoint",
"order": 6,
"color": "#008000"
}
Expand Down
2 changes: 1 addition & 1 deletion module/config/argument/argument.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,7 @@ OpsiStorage:
order: 8
color: "#7700BB"
ActionPoint:
stored: StoredInt
stored: StoredActionPoint
order: 6
color: "#008000"

Expand Down
4 changes: 2 additions & 2 deletions module/config/argument/stored.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
21 changes: 21 additions & 0 deletions module/config/stored/classes.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import re
from datetime import datetime

from module.base.decorator import cached_property
Expand Down Expand Up @@ -110,6 +111,10 @@ class StoredInt(StoredBase):
value = 0


class StoredStr(StoredBase):
value = ''


class StoredCounter(StoredBase):
value = 0
total = 0
Expand Down Expand Up @@ -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})'
4 changes: 3 additions & 1 deletion module/config/stored/stored_generated.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
from module.config.stored.classes import (
StoredActionPoint,
StoredBase,
StoredCoin,
StoredCounter,
StoredInt,
StoredOil,
StoredStr,
)


Expand All @@ -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")
2 changes: 1 addition & 1 deletion module/os_handler/action_point.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d25d8b6

Please sign in to comment.