mirror of
https://github.com/TheFunny/ArisuAutoSweeper
synced 2025-12-16 19:55:12 +00:00
feat: separate stage ap count
This commit is contained in:
parent
71da6fd996
commit
93bf1f73e2
48
tasks/stage/ap.py
Normal file
48
tasks/stage/ap.py
Normal file
@ -0,0 +1,48 @@
|
||||
from module.base.base import ModuleBase
|
||||
from module.logger import logger
|
||||
|
||||
|
||||
class AP(ModuleBase):
|
||||
_stage = 0
|
||||
|
||||
@property
|
||||
def stage(self) -> int:
|
||||
return self._stage
|
||||
|
||||
@classmethod
|
||||
def set_stage(cls, stage: int):
|
||||
cls._stage = stage
|
||||
|
||||
@property
|
||||
def stage_ap(self) -> int | list:
|
||||
"""
|
||||
To be redefined in subclass.
|
||||
|
||||
Returns:
|
||||
Task ap
|
||||
"""
|
||||
return 0
|
||||
|
||||
@property
|
||||
def current_ap(self):
|
||||
return self.config.stored.AP.value
|
||||
|
||||
def update_ap(self, count: int, stage: int = None):
|
||||
ap = self.config.stored.AP
|
||||
ap_old = ap.value
|
||||
ap_new = ap_old - self.stage_ap_cost(stage) * count
|
||||
ap.set(ap_new, ap.total)
|
||||
logger.info(f'Set AP: {ap_old} -> {ap_new}')
|
||||
|
||||
def stage_ap_cost(self, stage: int = None) -> int:
|
||||
if isinstance(self.stage_ap, int):
|
||||
return self.stage_ap
|
||||
if isinstance(self.stage_ap, list):
|
||||
if not stage:
|
||||
stage = self.stage if self.stage else len(self.stage_ap)
|
||||
return self.stage_ap[stage - 1]
|
||||
|
||||
def is_ap_enough(self, count: int, stage: int = None) -> bool:
|
||||
cost = self.stage_ap_cost(stage) * count
|
||||
logger.info(f'Check AP: {self.current_ap} / {cost}')
|
||||
return self.current_ap >= cost
|
||||
Loading…
Reference in New Issue
Block a user