Apply StoredCounter for counting farm times (#419)

* Apply StoredCounter in counting farm times

* i18n for SimulatedUniverseElite counter (probably used for display in future)

* change display style to "counter" style

* Configure ConfigUpdater.redirect and rename `SimulatedUniverseElite` config item to `SimulatedUniverseFarm`

* show `Rogue.RogueWorld.SimulatedUniverseFarm` in disabled mode only when `Rogue.RogueWorld.WeeklyFarming` is checked

* treat Rogue_RogueWorld_SimulatedUniverseFarm specially to display value only;
i18n for SimulatedUniverseFarm item;
bugfix on counter convert

* Set display style of stored counter

* update counter despite whether farming is enabled
This commit is contained in:
Schwarze-Katze 2024-05-09 15:36:52 +08:00 committed by GitHub
parent 9d514f4e9d
commit 880bb2a911
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
19 changed files with 107 additions and 80 deletions

View File

@ -83,6 +83,11 @@ select.state-light {
background-color: transparent !important; background-color: transparent !important;
} }
[id^="pywebio-scope-arg_stored-stored-value-"] {
border-bottom: .125rem solid #7a77bb;
background-color: #343a40;
}
textarea { textarea {
border: 1px solid #21262d; border: 1px solid #21262d;
} }

View File

@ -84,6 +84,11 @@ select.state-light {
background-color: transparent !important; background-color: transparent !important;
} }
[id^="pywebio-scope-arg_stored-stored-value-"] {
border-bottom: .125rem solid #4e4c97;
background-color: #e9ecef;
}
textarea { textarea {
border: 1px solid lightgrey; border: 1px solid lightgrey;
} }

View File

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

View File

@ -1475,15 +1475,15 @@
"type": "checkbox", "type": "checkbox",
"value": false "value": false
}, },
"SimulatedUniverseFarm": {
"type": "stored",
"value": {},
"display": "disabled",
"stored": "StoredSimulatedUniverseElite"
},
"UseStamina": { "UseStamina": {
"type": "checkbox", "type": "checkbox",
"value": false "value": false
},
"SimulatedUniverseElite": {
"type": "stored",
"value": {},
"display": "hide",
"stored": "StoredSimulatedUniverseElite"
} }
}, },
"RogueBlessing": { "RogueBlessing": {

View File

@ -258,9 +258,10 @@ RogueWorld:
UseImmersifier: true UseImmersifier: true
DoubleEvent: true DoubleEvent: true
WeeklyFarming: false WeeklyFarming: false
UseStamina: false SimulatedUniverseFarm:
SimulatedUniverseElite:
stored: StoredSimulatedUniverseElite stored: StoredSimulatedUniverseElite
display: disabled
UseStamina: false
RogueBlessing: RogueBlessing:
PresetBlessingFilter: PresetBlessingFilter:

View File

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

View File

@ -139,8 +139,8 @@ class GeneratedConfig:
RogueWorld_UseImmersifier = True RogueWorld_UseImmersifier = True
RogueWorld_DoubleEvent = True RogueWorld_DoubleEvent = True
RogueWorld_WeeklyFarming = False RogueWorld_WeeklyFarming = False
RogueWorld_SimulatedUniverseFarm = {}
RogueWorld_UseStamina = False RogueWorld_UseStamina = False
RogueWorld_SimulatedUniverseElite = {}
# Group `RogueBlessing` # Group `RogueBlessing`
RogueBlessing_PresetBlessingFilter = 'preset' # preset, custom RogueBlessing_PresetBlessingFilter = 'preset' # preset, custom

View File

@ -653,6 +653,7 @@ class ConfigUpdater:
('Dungeon.Dungeon.NameAtDoubleCalyx', 'Dungeon.Dungeon.NameAtDoubleCalyx', convert_20_dungeon), ('Dungeon.Dungeon.NameAtDoubleCalyx', 'Dungeon.Dungeon.NameAtDoubleCalyx', convert_20_dungeon),
('Dungeon.DungeonDaily.CalyxGolden', 'Dungeon.DungeonDaily.CalyxGolden', convert_20_dungeon), ('Dungeon.DungeonDaily.CalyxGolden', 'Dungeon.DungeonDaily.CalyxGolden', convert_20_dungeon),
('Dungeon.DungeonDaily.CalyxCrimson', 'Dungeon.DungeonDaily.CalyxCrimson', convert_20_dungeon), ('Dungeon.DungeonDaily.CalyxCrimson', 'Dungeon.DungeonDaily.CalyxCrimson', convert_20_dungeon),
('Rogue.RogueWorld.SimulatedUniverseElite', 'Rogue.RogueWorld.SimulatedUniverseFarm', convert_rogue_farm),
] ]
@cached_property @cached_property
@ -863,6 +864,8 @@ class ConfigUpdater:
yield 'Rogue.RogueBlessing.CustomResonanceFilter' yield 'Rogue.RogueBlessing.CustomResonanceFilter'
if deep_get(data, 'Rogue.RogueBlessing.PresetCurioFilter') != 'custom': if deep_get(data, 'Rogue.RogueBlessing.PresetCurioFilter') != 'custom':
yield 'Rogue.RogueBlessing.CustomCurioFilter' yield 'Rogue.RogueBlessing.CustomCurioFilter'
if deep_get(data, 'Rogue.RogueWorld.WeeklyFarming') != True:
yield 'Rogue.RogueWorld.SimulatedUniverseFarm'
def get_hidden_args(self, data) -> t.Set[str]: def get_hidden_args(self, data) -> t.Set[str]:
""" """

View File

@ -30,3 +30,10 @@ def convert_20_dungeon(value):
return 'Calyx_Crimson_Abundance_Jarilo_BackwaterPass' return 'Calyx_Crimson_Abundance_Jarilo_BackwaterPass'
return value return value
def convert_rogue_farm(value):
if isinstance(value, dict) and 'value' in value.keys():
value['value'] = 100 - value['value']
value['total'] = 100
return value

View File

@ -976,13 +976,13 @@
"name": "Farm 100 Elites Weekly", "name": "Farm 100 Elites Weekly",
"help": "" "help": ""
}, },
"SimulatedUniverseFarm": {
"name": "Progress of elite boss farmed",
"help": ""
},
"UseStamina": { "UseStamina": {
"name": "Farm Planers Using Trailblase Power", "name": "Farm Planers Using Trailblase Power",
"help": "Task \"Dungeon\" will no longer run, and all trailblaze power will be used first to claim immersion rewards, except for double events." "help": "Task \"Dungeon\" will no longer run, and all trailblaze power will be used first to claim immersion rewards, except for double events."
},
"SimulatedUniverseElite": {
"name": "RogueWorld.SimulatedUniverseElite.name",
"help": "RogueWorld.SimulatedUniverseElite.help"
} }
}, },
"RogueBlessing": { "RogueBlessing": {

View File

@ -976,13 +976,13 @@
"name": "Granja 100 élites semanalmente", "name": "Granja 100 élites semanalmente",
"help": "" "help": ""
}, },
"SimulatedUniverseFarm": {
"name": "Progreso de élites derrotadas",
"help": ""
},
"UseStamina": { "UseStamina": {
"name": "Reclamar de planers mediante poder trazacaminos", "name": "Reclamar de planers mediante poder trazacaminos",
"help": "La tarea de mazmorra ya no se ejecutará y todo el poder trazacaminos se usará primero para reclamar recompensas de inmersión, excepto para eventos dobles" "help": "La tarea de mazmorra ya no se ejecutará y todo el poder trazacaminos se usará primero para reclamar recompensas de inmersión, excepto para eventos dobles"
},
"SimulatedUniverseElite": {
"name": "RogueWorld.SimulatedUniverseElite.name",
"help": "RogueWorld.SimulatedUniverseElite.help"
} }
}, },
"RogueBlessing": { "RogueBlessing": {

View File

@ -976,13 +976,13 @@
"name": "RogueWorld.WeeklyFarming.name", "name": "RogueWorld.WeeklyFarming.name",
"help": "RogueWorld.WeeklyFarming.help" "help": "RogueWorld.WeeklyFarming.help"
}, },
"SimulatedUniverseFarm": {
"name": "RogueWorld.SimulatedUniverseFarm.name",
"help": "RogueWorld.SimulatedUniverseFarm.help"
},
"UseStamina": { "UseStamina": {
"name": "RogueWorld.UseStamina.name", "name": "RogueWorld.UseStamina.name",
"help": "RogueWorld.UseStamina.help" "help": "RogueWorld.UseStamina.help"
},
"SimulatedUniverseElite": {
"name": "RogueWorld.SimulatedUniverseElite.name",
"help": "RogueWorld.SimulatedUniverseElite.help"
} }
}, },
"RogueBlessing": { "RogueBlessing": {

View File

@ -976,13 +976,13 @@
"name": "每周刷100精英怪", "name": "每周刷100精英怪",
"help": "" "help": ""
}, },
"SimulatedUniverseFarm": {
"name": "刷精英怪进度",
"help": ""
},
"UseStamina": { "UseStamina": {
"name": "使用开拓力刷内圈遗器", "name": "使用开拓力刷内圈遗器",
"help": "每日副本任务将不再打本,所有开拓力将优先被用于领取浸器奖励,双倍活动时除外" "help": "每日副本任务将不再打本,所有开拓力将优先被用于领取浸器奖励,双倍活动时除外"
},
"SimulatedUniverseElite": {
"name": "剩余Boss材料掉落次数",
"help": "RogueWorld.SimulatedUniverseElite.help"
} }
}, },
"RogueBlessing": { "RogueBlessing": {

View File

@ -976,13 +976,13 @@
"name": "每週農100精英怪", "name": "每週農100精英怪",
"help": "" "help": ""
}, },
"SimulatedUniverseFarm": {
"name": "農精英怪進度",
"help": ""
},
"UseStamina": { "UseStamina": {
"name": "用開拓力農遺器", "name": "用開拓力農遺器",
"help": "每日副本任務將不再打本,所有開拓力將優先被用於領取浸器獎勵,雙倍活動時除外" "help": "每日副本任務將不再打本,所有開拓力將優先被用於領取浸器獎勵,雙倍活動時除外"
},
"SimulatedUniverseElite": {
"name": "RogueWorld.SimulatedUniverseElite.name",
"help": "RogueWorld.SimulatedUniverseElite.help"
} }
}, },
"RogueBlessing": { "RogueBlessing": {

View File

@ -211,25 +211,10 @@ class StoredSimulatedUniverse(StoredCounter, StoredExpiredAtMonday0400):
class StoredSimulatedUniverseElite(StoredCounter, StoredExpiredAtMonday0400): 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. # FIXED_TOTAL --- Times of boss drop chance per week. In current version of StarRail, this value is 100.
FIXED_DEFAULT = 100 FIXED_TOTAL = 100
# Times left to farm. Resets to 100 every Monday 04:00, and decreases each time the elite boss is cleared. # value --- Times left to farm. Resets to 100 every Monday 04:00, and decreases each time the elite boss is cleared.
value = FIXED_DEFAULT
def farm_dec(self, delta=1):
self.value -= delta
if self.value < 0:
self.value = 0
def farm_reset(self):
self.value = self.FIXED_DEFAULT
def farm_not_complete(self) -> bool:
return self.value > 0
def farm_get_remain(self) -> int:
return self.value
class StoredAssignment(StoredCounter): class StoredAssignment(StoredCounter):

View File

@ -51,4 +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") SimulatedUniverseFarm = StoredSimulatedUniverseElite("Rogue.RogueWorld.SimulatedUniverseFarm")

View File

@ -325,11 +325,11 @@ def put_arg_input(kwargs: T_Output_Kwargs) -> Output:
) )
def product_stored_row(kwargs: T_Output_Kwargs, key, value): def product_stored_row(kwargs: T_Output_Kwargs, key, value, style = "--input--"):
kwargs = copy.copy(kwargs) kwargs = copy.copy(kwargs)
kwargs["name"] += f'_{key}' kwargs["name"] += f'_{key}'
kwargs["value"] = value kwargs["value"] = value
return put_input(**kwargs).style("--input--") return put_input(**kwargs).style(style)
def put_arg_stored(kwargs: T_Output_Kwargs) -> Output: def put_arg_stored(kwargs: T_Output_Kwargs) -> Output:
@ -339,19 +339,40 @@ def put_arg_stored(kwargs: T_Output_Kwargs) -> Output:
values = kwargs.pop("value", {}) values = kwargs.pop("value", {})
time_ = values.pop("time", "") time_ = values.pop("time", "")
rows = [product_stored_row(kwargs, key, value) for key, value in values.items() if value] if "value" in values and "total" in values:
if time_: # display as counter style
rows += [product_stored_row(kwargs, "time", time_)] counter = f'{values["value"]} / {values["total"]}'
return put_scope( rows = [product_stored_row(
f"arg_container-stored-{name}", kwargs, "counter", counter)]
[ if time_:
get_title_help(kwargs), rows += [product_stored_row(kwargs, "time", time_)]
put_scope( return put_scope(
f"arg_stored-stored-value-{name}", f"arg_container-stored-{name}",
rows, [
) get_title_help(kwargs),
] put_scope(
) f"arg_stored-stored-value-{name}",
rows,
)
]
)
else:
# display per key
rows = [product_stored_row(kwargs, key, value)
for key, value in values.items() if value]
if time_:
rows += [product_stored_row(kwargs, "time", time_)]
return put_scope(
f"arg_container-stored-{name}",
[
get_title_help(kwargs),
put_scope(
f"arg_stored-stored-value-{name}",
rows,
)
]
)
def put_arg_select(kwargs: T_Output_Kwargs) -> Output: def put_arg_select(kwargs: T_Output_Kwargs) -> Output:

View File

@ -350,9 +350,9 @@ class RogueEntry(RouteBase, RogueRewardHandler, RoguePathHandler, DungeonUI):
# Always run # Always run
return return
if self.config.stored.SimulatedUniverseElite.is_expired(): if self.config.stored.SimulatedUniverseFarm.is_expired():
# Expired, reset farming counter # Expired, reset farming counter
self.config.stored.SimulatedUniverseElite.farm_reset() self.config.stored.SimulatedUniverseFarm.set(0)
if self.config.stored.SimulatedUniverse.is_expired(): if self.config.stored.SimulatedUniverse.is_expired():
# Expired, do rogue # Expired, do rogue
@ -361,11 +361,11 @@ class RogueEntry(RouteBase, RogueRewardHandler, RoguePathHandler, DungeonUI):
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.SimulatedUniverseElite.farm_not_complete(): elif self.config.RogueWorld_WeeklyFarming and not self.config.stored.SimulatedUniverseFarm.is_full():
logger.info( logger.info(
'Reached weekly point limit but still continue to farm materials') 'Reached weekly point limit but still continue to farm materials')
logger.attr( logger.attr(
"Farming Counter", self.config.stored.SimulatedUniverseElite.farm_get_remain()) "Farming Counter", self.config.stored.SimulatedUniverseFarm.to_counter())
else: else:
raise RogueReachedWeeklyPointLimit raise RogueReachedWeeklyPointLimit
else: else:

View File

@ -168,11 +168,11 @@ class RouteBase(RouteBase_, RogueExit, RogueEvent, RogueReward):
# logger.attr("result",result) # logger.attr("result",result)
if 'enemy' in result: if 'enemy' in result:
# runs when one elite battle finishes, and decreases rogue farming count by 1 # runs when one elite battle finishes, and increases rogue farming count by 1
if self.config.RogueWorld_WeeklyFarming and self.config.stored.SimulatedUniverseElite.farm_not_complete(): if not self.config.stored.SimulatedUniverseFarm.is_full():
self.config.stored.SimulatedUniverseElite.farm_dec() self.config.stored.SimulatedUniverseFarm.add()
logger.info( logger.info(
f"Cleared elite boss, decreasing farming count by 1, now {self.config.stored.SimulatedUniverseElite.farm_get_remain()}") f"Cleared elite boss, increasing farming count by 1, now " + self.config.stored.SimulatedUniverseFarm.to_counter())
return result return result
def _domain_event_expected_end(self): def _domain_event_expected_end(self):