mirror of
https://github.com/LmeSzinc/StarRailCopilot.git
synced 2024-11-22 08:37:42 +00:00
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:
parent
9d514f4e9d
commit
880bb2a911
@ -83,6 +83,11 @@ select.state-light {
|
||||
background-color: transparent !important;
|
||||
}
|
||||
|
||||
[id^="pywebio-scope-arg_stored-stored-value-"] {
|
||||
border-bottom: .125rem solid #7a77bb;
|
||||
background-color: #343a40;
|
||||
}
|
||||
|
||||
textarea {
|
||||
border: 1px solid #21262d;
|
||||
}
|
||||
|
@ -84,6 +84,11 @@ select.state-light {
|
||||
background-color: transparent !important;
|
||||
}
|
||||
|
||||
[id^="pywebio-scope-arg_stored-stored-value-"] {
|
||||
border-bottom: .125rem solid #4e4c97;
|
||||
background-color: #e9ecef;
|
||||
}
|
||||
|
||||
textarea {
|
||||
border: 1px solid lightgrey;
|
||||
}
|
||||
|
@ -200,8 +200,8 @@
|
||||
"UseImmersifier": true,
|
||||
"DoubleEvent": true,
|
||||
"WeeklyFarming": false,
|
||||
"UseStamina": false,
|
||||
"SimulatedUniverseElite": {}
|
||||
"SimulatedUniverseFarm": {},
|
||||
"UseStamina": false
|
||||
},
|
||||
"RogueBlessing": {
|
||||
"PresetBlessingFilter": "preset",
|
||||
|
@ -1475,15 +1475,15 @@
|
||||
"type": "checkbox",
|
||||
"value": false
|
||||
},
|
||||
"SimulatedUniverseFarm": {
|
||||
"type": "stored",
|
||||
"value": {},
|
||||
"display": "disabled",
|
||||
"stored": "StoredSimulatedUniverseElite"
|
||||
},
|
||||
"UseStamina": {
|
||||
"type": "checkbox",
|
||||
"value": false
|
||||
},
|
||||
"SimulatedUniverseElite": {
|
||||
"type": "stored",
|
||||
"value": {},
|
||||
"display": "hide",
|
||||
"stored": "StoredSimulatedUniverseElite"
|
||||
}
|
||||
},
|
||||
"RogueBlessing": {
|
||||
|
@ -258,9 +258,10 @@ RogueWorld:
|
||||
UseImmersifier: true
|
||||
DoubleEvent: true
|
||||
WeeklyFarming: false
|
||||
UseStamina: false
|
||||
SimulatedUniverseElite:
|
||||
SimulatedUniverseFarm:
|
||||
stored: StoredSimulatedUniverseElite
|
||||
display: disabled
|
||||
UseStamina: false
|
||||
|
||||
RogueBlessing:
|
||||
PresetBlessingFilter:
|
||||
|
@ -294,15 +294,15 @@
|
||||
"order": 0,
|
||||
"color": "#777777"
|
||||
},
|
||||
"SimulatedUniverseElite": {
|
||||
"name": "SimulatedUniverseElite",
|
||||
"path": "Rogue.RogueWorld.SimulatedUniverseElite",
|
||||
"i18n": "RogueWorld.SimulatedUniverseElite.name",
|
||||
"SimulatedUniverseFarm": {
|
||||
"name": "SimulatedUniverseFarm",
|
||||
"path": "Rogue.RogueWorld.SimulatedUniverseFarm",
|
||||
"i18n": "RogueWorld.SimulatedUniverseFarm.name",
|
||||
"stored": "StoredSimulatedUniverseElite",
|
||||
"attrs": {
|
||||
"time": "2020-01-01 00:00:00",
|
||||
"total": 0,
|
||||
"value": 100
|
||||
"total": 100,
|
||||
"value": 0
|
||||
},
|
||||
"order": 0,
|
||||
"color": "#777777"
|
||||
|
@ -139,8 +139,8 @@ class GeneratedConfig:
|
||||
RogueWorld_UseImmersifier = True
|
||||
RogueWorld_DoubleEvent = True
|
||||
RogueWorld_WeeklyFarming = False
|
||||
RogueWorld_SimulatedUniverseFarm = {}
|
||||
RogueWorld_UseStamina = False
|
||||
RogueWorld_SimulatedUniverseElite = {}
|
||||
|
||||
# Group `RogueBlessing`
|
||||
RogueBlessing_PresetBlessingFilter = 'preset' # preset, custom
|
||||
|
@ -653,6 +653,7 @@ class ConfigUpdater:
|
||||
('Dungeon.Dungeon.NameAtDoubleCalyx', 'Dungeon.Dungeon.NameAtDoubleCalyx', convert_20_dungeon),
|
||||
('Dungeon.DungeonDaily.CalyxGolden', 'Dungeon.DungeonDaily.CalyxGolden', convert_20_dungeon),
|
||||
('Dungeon.DungeonDaily.CalyxCrimson', 'Dungeon.DungeonDaily.CalyxCrimson', convert_20_dungeon),
|
||||
('Rogue.RogueWorld.SimulatedUniverseElite', 'Rogue.RogueWorld.SimulatedUniverseFarm', convert_rogue_farm),
|
||||
]
|
||||
|
||||
@cached_property
|
||||
@ -863,6 +864,8 @@ class ConfigUpdater:
|
||||
yield 'Rogue.RogueBlessing.CustomResonanceFilter'
|
||||
if deep_get(data, 'Rogue.RogueBlessing.PresetCurioFilter') != 'custom':
|
||||
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]:
|
||||
"""
|
||||
|
@ -30,3 +30,10 @@ def convert_20_dungeon(value):
|
||||
return 'Calyx_Crimson_Abundance_Jarilo_BackwaterPass'
|
||||
|
||||
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
|
||||
|
@ -976,13 +976,13 @@
|
||||
"name": "Farm 100 Elites Weekly",
|
||||
"help": ""
|
||||
},
|
||||
"SimulatedUniverseFarm": {
|
||||
"name": "Progress of elite boss farmed",
|
||||
"help": ""
|
||||
},
|
||||
"UseStamina": {
|
||||
"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."
|
||||
},
|
||||
"SimulatedUniverseElite": {
|
||||
"name": "RogueWorld.SimulatedUniverseElite.name",
|
||||
"help": "RogueWorld.SimulatedUniverseElite.help"
|
||||
}
|
||||
},
|
||||
"RogueBlessing": {
|
||||
|
@ -976,13 +976,13 @@
|
||||
"name": "Granja 100 élites semanalmente",
|
||||
"help": ""
|
||||
},
|
||||
"SimulatedUniverseFarm": {
|
||||
"name": "Progreso de élites derrotadas",
|
||||
"help": ""
|
||||
},
|
||||
"UseStamina": {
|
||||
"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"
|
||||
},
|
||||
"SimulatedUniverseElite": {
|
||||
"name": "RogueWorld.SimulatedUniverseElite.name",
|
||||
"help": "RogueWorld.SimulatedUniverseElite.help"
|
||||
}
|
||||
},
|
||||
"RogueBlessing": {
|
||||
|
@ -976,13 +976,13 @@
|
||||
"name": "RogueWorld.WeeklyFarming.name",
|
||||
"help": "RogueWorld.WeeklyFarming.help"
|
||||
},
|
||||
"SimulatedUniverseFarm": {
|
||||
"name": "RogueWorld.SimulatedUniverseFarm.name",
|
||||
"help": "RogueWorld.SimulatedUniverseFarm.help"
|
||||
},
|
||||
"UseStamina": {
|
||||
"name": "RogueWorld.UseStamina.name",
|
||||
"help": "RogueWorld.UseStamina.help"
|
||||
},
|
||||
"SimulatedUniverseElite": {
|
||||
"name": "RogueWorld.SimulatedUniverseElite.name",
|
||||
"help": "RogueWorld.SimulatedUniverseElite.help"
|
||||
}
|
||||
},
|
||||
"RogueBlessing": {
|
||||
|
@ -976,13 +976,13 @@
|
||||
"name": "每周刷100精英怪",
|
||||
"help": ""
|
||||
},
|
||||
"SimulatedUniverseFarm": {
|
||||
"name": "刷精英怪进度",
|
||||
"help": ""
|
||||
},
|
||||
"UseStamina": {
|
||||
"name": "使用开拓力刷内圈遗器",
|
||||
"help": "每日副本任务将不再打本,所有开拓力将优先被用于领取浸器奖励,双倍活动时除外"
|
||||
},
|
||||
"SimulatedUniverseElite": {
|
||||
"name": "剩余Boss材料掉落次数",
|
||||
"help": "RogueWorld.SimulatedUniverseElite.help"
|
||||
}
|
||||
},
|
||||
"RogueBlessing": {
|
||||
|
@ -976,13 +976,13 @@
|
||||
"name": "每週農100精英怪",
|
||||
"help": ""
|
||||
},
|
||||
"SimulatedUniverseFarm": {
|
||||
"name": "農精英怪進度",
|
||||
"help": ""
|
||||
},
|
||||
"UseStamina": {
|
||||
"name": "用開拓力農遺器",
|
||||
"help": "每日副本任務將不再打本,所有開拓力將優先被用於領取浸器獎勵,雙倍活動時除外"
|
||||
},
|
||||
"SimulatedUniverseElite": {
|
||||
"name": "RogueWorld.SimulatedUniverseElite.name",
|
||||
"help": "RogueWorld.SimulatedUniverseElite.help"
|
||||
}
|
||||
},
|
||||
"RogueBlessing": {
|
||||
|
@ -211,25 +211,10 @@ class StoredSimulatedUniverse(StoredCounter, StoredExpiredAtMonday0400):
|
||||
class StoredSimulatedUniverseElite(StoredCounter, StoredExpiredAtMonday0400):
|
||||
# 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_DEFAULT = 100
|
||||
# FIXED_TOTAL --- Times of boss drop chance per week. In current version of StarRail, this value is 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 = 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
|
||||
# value --- Times left to farm. Resets to 100 every Monday 04:00, and decreases each time the elite boss is cleared.
|
||||
|
||||
|
||||
class StoredAssignment(StoredCounter):
|
||||
|
@ -51,4 +51,4 @@ class StoredGenerated:
|
||||
Assignment = StoredAssignment("Assignment.Assignment.Assignment")
|
||||
Credit = StoredInt("DataUpdate.ItemStorage.Credit")
|
||||
StallerJade = StoredInt("DataUpdate.ItemStorage.StallerJade")
|
||||
SimulatedUniverseElite = StoredSimulatedUniverseElite("Rogue.RogueWorld.SimulatedUniverseElite")
|
||||
SimulatedUniverseFarm = StoredSimulatedUniverseElite("Rogue.RogueWorld.SimulatedUniverseFarm")
|
||||
|
@ -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["name"] += f'_{key}'
|
||||
kwargs["value"] = value
|
||||
return put_input(**kwargs).style("--input--")
|
||||
return put_input(**kwargs).style(style)
|
||||
|
||||
|
||||
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", {})
|
||||
time_ = values.pop("time", "")
|
||||
|
||||
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,
|
||||
)
|
||||
]
|
||||
)
|
||||
if "value" in values and "total" in values:
|
||||
# display as counter style
|
||||
counter = f'{values["value"]} / {values["total"]}'
|
||||
rows = [product_stored_row(
|
||||
kwargs, "counter", counter)]
|
||||
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,
|
||||
)
|
||||
]
|
||||
)
|
||||
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:
|
||||
|
@ -350,9 +350,9 @@ class RogueEntry(RouteBase, RogueRewardHandler, RoguePathHandler, DungeonUI):
|
||||
# Always run
|
||||
return
|
||||
|
||||
if self.config.stored.SimulatedUniverseElite.is_expired():
|
||||
if self.config.stored.SimulatedUniverseFarm.is_expired():
|
||||
# Expired, reset farming counter
|
||||
self.config.stored.SimulatedUniverseElite.farm_reset()
|
||||
self.config.stored.SimulatedUniverseFarm.set(0)
|
||||
|
||||
if self.config.stored.SimulatedUniverse.is_expired():
|
||||
# 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:
|
||||
logger.info(
|
||||
'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(
|
||||
'Reached weekly point limit but still continue to farm materials')
|
||||
logger.attr(
|
||||
"Farming Counter", self.config.stored.SimulatedUniverseElite.farm_get_remain())
|
||||
"Farming Counter", self.config.stored.SimulatedUniverseFarm.to_counter())
|
||||
else:
|
||||
raise RogueReachedWeeklyPointLimit
|
||||
else:
|
||||
|
@ -168,11 +168,11 @@ class RouteBase(RouteBase_, RogueExit, RogueEvent, RogueReward):
|
||||
# logger.attr("result",result)
|
||||
|
||||
if 'enemy' in result:
|
||||
# runs when one elite battle finishes, and decreases rogue farming count by 1
|
||||
if self.config.RogueWorld_WeeklyFarming and self.config.stored.SimulatedUniverseElite.farm_not_complete():
|
||||
self.config.stored.SimulatedUniverseElite.farm_dec()
|
||||
# runs when one elite battle finishes, and increases rogue farming count by 1
|
||||
if not self.config.stored.SimulatedUniverseFarm.is_full():
|
||||
self.config.stored.SimulatedUniverseFarm.add()
|
||||
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
|
||||
|
||||
def _domain_event_expected_end(self):
|
||||
|
Loading…
Reference in New Issue
Block a user