Seperate stored counter into an independent class

This commit is contained in:
katze 2024-04-01 01:58:46 +08:00
parent 792eb2157a
commit f262140fb6
15 changed files with 73 additions and 19 deletions

View File

@ -200,7 +200,8 @@
"UseImmersifier": true, "UseImmersifier": true,
"DoubleEvent": true, "DoubleEvent": true,
"UseStamina": false, "UseStamina": false,
"WeeklyFarming": false "WeeklyFarming": false,
"SimulatedUniverseElite": {}
}, },
"RogueBlessing": { "RogueBlessing": {
"PresetBlessingFilter": "preset", "PresetBlessingFilter": "preset",

View File

@ -1473,6 +1473,12 @@
"WeeklyFarming": { "WeeklyFarming": {
"type": "checkbox", "type": "checkbox",
"value": false "value": false
},
"SimulatedUniverseElite": {
"type": "stored",
"value": {},
"display": "hide",
"stored": "StoredSimulatedUniverseElite"
} }
}, },
"RogueBlessing": { "RogueBlessing": {

View File

@ -248,6 +248,8 @@ RogueWorld:
DoubleEvent: true DoubleEvent: true
UseStamina: false UseStamina: false
WeeklyFarming: false WeeklyFarming: false
SimulatedUniverseElite:
stored: StoredSimulatedUniverseElite
RogueBlessing: RogueBlessing:
PresetBlessingFilter: PresetBlessingFilter:

View File

@ -293,5 +293,18 @@
}, },
"order": 0, "order": 0,
"color": "#777777" "color": "#777777"
},
"SimulatedUniverseElite": {
"name": "SimulatedUniverseElite",
"path": "Rogue.RogueWorld.SimulatedUniverseElite",
"i18n": "RogueWorld.SimulatedUniverseElite.name",
"stored": "StoredSimulatedUniverseElite",
"attrs": {
"time": "2020-01-01 00:00:00",
"total": 0,
"value": 100
},
"order": 0,
"color": "#777777"
} }
} }

View File

@ -140,6 +140,7 @@ class GeneratedConfig:
RogueWorld_DoubleEvent = True RogueWorld_DoubleEvent = True
RogueWorld_UseStamina = False RogueWorld_UseStamina = False
RogueWorld_WeeklyFarming = False RogueWorld_WeeklyFarming = False
RogueWorld_SimulatedUniverseElite = {}
# Group `RogueBlessing` # Group `RogueBlessing`
RogueBlessing_PresetBlessingFilter = 'preset' # preset, custom RogueBlessing_PresetBlessingFilter = 'preset' # preset, custom

View File

@ -976,6 +976,10 @@
"WeeklyFarming": { "WeeklyFarming": {
"name": "Boss Material Farming", "name": "Boss Material Farming",
"help": "Do not stop after point reward is full; farm the boss 100 times instead to obtain trace materials" "help": "Do not stop after point reward is full; farm the boss 100 times instead to obtain trace materials"
},
"SimulatedUniverseElite": {
"name": "RogueWorld.SimulatedUniverseElite.name",
"help": "RogueWorld.SimulatedUniverseElite.help"
} }
}, },
"RogueBlessing": { "RogueBlessing": {

View File

@ -976,6 +976,10 @@
"WeeklyFarming": { "WeeklyFarming": {
"name": "Recolección de Materiales de Jefes", "name": "Recolección de Materiales de Jefes",
"help": "No detenerse después de que los puntos semanales estén llenos, farmear al jefe 100 veces para obtener materiales de rastro" "help": "No detenerse después de que los puntos semanales estén llenos, farmear al jefe 100 veces para obtener materiales de rastro"
},
"SimulatedUniverseElite": {
"name": "RogueWorld.SimulatedUniverseElite.name",
"help": "RogueWorld.SimulatedUniverseElite.help"
} }
}, },
"RogueBlessing": { "RogueBlessing": {

View File

@ -976,6 +976,10 @@
"WeeklyFarming": { "WeeklyFarming": {
"name": "ボス素材を収集", "name": "ボス素材を収集",
"help": "週間ポイントが満点に達しても停止せず、100回のボスをファームして軌跡素材を入手" "help": "週間ポイントが満点に達しても停止せず、100回のボスをファームして軌跡素材を入手"
},
"SimulatedUniverseElite": {
"name": "RogueWorld.SimulatedUniverseElite.name",
"help": "RogueWorld.SimulatedUniverseElite.help"
} }
}, },
"RogueBlessing": { "RogueBlessing": {

View File

@ -976,6 +976,10 @@
"WeeklyFarming": { "WeeklyFarming": {
"name": "刷取Boss材料", "name": "刷取Boss材料",
"help": "每周积分满后不停止刷取100次Boss以获取形迹材料" "help": "每周积分满后不停止刷取100次Boss以获取形迹材料"
},
"SimulatedUniverseElite": {
"name": "剩余Boss材料掉落次数",
"help": "RogueWorld.SimulatedUniverseElite.help"
} }
}, },
"RogueBlessing": { "RogueBlessing": {

View File

@ -976,6 +976,10 @@
"WeeklyFarming": { "WeeklyFarming": {
"name": "刷取Boss材料", "name": "刷取Boss材料",
"help": "每週積分滿後不停止刷取100次Boss以獲取形跡材料" "help": "每週積分滿後不停止刷取100次Boss以獲取形跡材料"
},
"SimulatedUniverseElite": {
"name": "RogueWorld.SimulatedUniverseElite.name",
"help": "RogueWorld.SimulatedUniverseElite.help"
} }
}, },
"RogueBlessing": { "RogueBlessing": {

View File

@ -205,25 +205,29 @@ class StoredImmersifier(StoredCounter):
class StoredSimulatedUniverse(StoredCounter, StoredExpiredAtMonday0400): class StoredSimulatedUniverse(StoredCounter, StoredExpiredAtMonday0400):
pass
class StoredSimulatedUniverseElite(StoredCounter, StoredExpiredAtMonday0400):
# These variables are used in Rogue Farming feature. # These variables are used in Rogue Farming feature.
# Times of boss drop chance per week. In current version of StarRail, this value is 100. # Times of boss drop chance per week. In current version of StarRail, this value is 100.
FIXED_DEFAULT = 100 FIXED_DEFAULT = 100
# Times left to farm. Resets to 100 every Monday 04:00, and decreases each time the elite boss is cleared. # Times left to farm. Resets to 100 every Monday 04:00, and decreases each time the elite boss is cleared.
FarmingCounter = FIXED_DEFAULT value = FIXED_DEFAULT
def farm_dec(self, value = 1): def farm_dec(self, value = 1):
self.FarmingCounter -= value self.value -= value
def farm_reset(self,): def farm_reset(self):
self.FarmingCounter = self.FIXED_DEFAULT self.value = self.FIXED_DEFAULT
def farm_not_complete(self) -> bool: def farm_not_complete(self) -> bool:
return self.FarmingCounter > 0 return self.value > 0
def farm_get_remain(self) -> int: def farm_get_remain(self) -> int:
return self.FarmingCounter return self.value
class StoredAssignment(StoredCounter): class StoredAssignment(StoredCounter):

View File

@ -20,6 +20,7 @@ from module.config.stored.classes import (
StoredImmersifier, StoredImmersifier,
StoredInt, StoredInt,
StoredSimulatedUniverse, StoredSimulatedUniverse,
StoredSimulatedUniverseElite,
StoredTrailblazePower, StoredTrailblazePower,
) )
@ -50,3 +51,4 @@ class StoredGenerated:
Assignment = StoredAssignment("Assignment.Assignment.Assignment") Assignment = StoredAssignment("Assignment.Assignment.Assignment")
Credit = StoredInt("DataUpdate.ItemStorage.Credit") Credit = StoredInt("DataUpdate.ItemStorage.Credit")
StallerJade = StoredInt("DataUpdate.ItemStorage.StallerJade") StallerJade = StoredInt("DataUpdate.ItemStorage.StallerJade")
SimulatedUniverseElite = StoredSimulatedUniverseElite("Rogue.RogueWorld.SimulatedUniverseElite")

View File

@ -386,7 +386,7 @@ class MapControl(Combat, AimDetectorMixin):
end_point = waypoints[-1] end_point = waypoints[-1]
end_point.expected_end.append('item') end_point.expected_end.append('item')
self.goto(*waypoints) return self.goto(*waypoints)
def clear_enemy(self, *waypoints): def clear_enemy(self, *waypoints):
""" """
@ -403,7 +403,7 @@ class MapControl(Combat, AimDetectorMixin):
end_point = waypoints[-1] end_point = waypoints[-1]
end_point.expected_end.append('enemy') end_point.expected_end.append('enemy')
self.goto(*waypoints) return self.goto(*waypoints)
if __name__ == '__main__': if __name__ == '__main__':

View File

@ -348,16 +348,20 @@ class RogueEntry(RouteBase, RogueRewardHandler, RoguePathHandler, DungeonUI):
return return
if self.config.stored.SimulatedUniverse.is_expired(): if self.config.stored.SimulatedUniverse.is_expired():
# Expired, do rogue and reset farming counter # Expired, do rogue
self.config.stored.SimulatedUniverse.farm_reset() pass
if self.config.stored.SimulatedUniverseElite.is_expired():
# Expired, reset farming counter
self.config.stored.SimulatedUniverseElite.farm_reset()
elif self.config.stored.SimulatedUniverse.is_full(): elif self.config.stored.SimulatedUniverse.is_full():
if self.config.RogueWorld_UseImmersifier and self.config.stored.Immersifier.value > 0: if self.config.RogueWorld_UseImmersifier and self.config.stored.Immersifier.value > 0:
logger.info( logger.info(
'Reached weekly point limit but still have immersifiers left, continue to use them') 'Reached weekly point limit but still have immersifiers left, continue to use them')
elif self.config.RogueWorld_WeeklyFarming and self.config.stored.SimulatedUniverse.farm_not_complete(): elif self.config.RogueWorld_WeeklyFarming and self.config.stored.SimulatedUniverseElite.farm_not_complete():
logger.attr( logger.attr(
"Farming Counter", self.config.stored.SimulatedUniverse.farm_get_remain()) "Farming Counter", self.config.stored.SimulatedUniverseElite.farm_get_remain())
logger.info( logger.info(
'Reached weekly point limit but still continue to farm materials') 'Reached weekly point limit but still continue to farm materials')
else: else:

View File

@ -170,13 +170,14 @@ class RouteBase(RouteBase_, RogueExit, RogueEvent, RogueReward):
pass pass
result = super().clear_enemy(*waypoints) result = super().clear_enemy(*waypoints)
# logger.attr("result",result)
# runs when one elite battle finishes (do not handle whether the battle succeeded or failed), and decreases rogue farming count by 1 if 'enemy' in result:
if self.config.RogueWorld_WeeklyFarming and self.config.stored.SimulatedUniverse.farm_not_complete(): # runs when one elite battle finishes (do not handle whether the battle succeeded or failed), and decreases rogue farming count by 1
self.config.stored.SimulatedUniverse.farm_dec() if self.config.RogueWorld_WeeklyFarming and self.config.stored.SimulatedUniverseElite.farm_not_complete():
logger.info( self.config.stored.SimulatedUniverseElite.farm_dec()
f"Cleared elite boss, decrease farming count by 1, now {self.config.stored.SimulatedUniverse.FarmingCounter}") logger.info(
f"Cleared elite boss, decrease farming count by 1, now {self.config.stored.SimulatedUniverseElite.farm_get_remain()}")
return result return result
def _domain_event_expected_end(self): def _domain_event_expected_end(self):