Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add feature of material farming in task RogueWorld #361

Merged
merged 12 commits into from Apr 14, 2024

Conversation

Schwarze-Katze
Copy link
Contributor

@Schwarze-Katze Schwarze-Katze commented Mar 6, 2024

When RogueWorld_WeeklyFarming is enabled, task RogueWorld will not stop when weekly points are full, instead farming the boss 33 times (i.e., 11 simulated universe) to obtain trace materials.
RogueWorld_WeeklyFarmingCount denotes how many turns of rogue remain to complete this week and will be reset to 11 each Monday 04:00.
Does not handle whether the last rogue run failed due to one who use this feature may have less chance of failure.

#231 #247 #264 #288 #294

Correction: Sorry I was misled by #288. Rogue boss has 100 drop times per week, not 33 times. See this.

@Schwarze-Katze
Copy link
Contributor Author

Im not quite sure about the usage of self.config.stored.SimulatedUniverse.is_expired() function.
I assume this function would return True when a new week begins and the rogue counter/reward point resets. Please point out if I misunderstood.

Copy link
Contributor Author

@Schwarze-Katze Schwarze-Katze left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I discard the modification of .gitignore or seperate it into a new PR?

Copy link
Owner

@LmeSzinc LmeSzinc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Im not quite sure about the usage of self.config.stored.SimulatedUniverse.is_expired() function.

Check out the echo of war countdown

class StoredEchoOfWar(StoredCounter, StoredExpiredAtMonday0400):
FIXED_TOTAL = 3

https://github.com/LmeSzinc/AzurLaneAutoScript/wiki/6.1.-GUI-Option

Should I discard the modification of .gitignore or seperate it into a new PR?

yes, and comment that these are electron files

Comment on lines 350 to 353
if self.config.stored.SimulatedUniverse.is_expired():
# Expired, do rogue
pass
# Expired, do rogue and reset weekly farming count
self.config.RogueWorld_WeeklyFarmingCount = 11

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't share records, it should have its own counter, counter starts from 100 and reduces after cleared an elite or boss

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Understood. Thank your correction and I ll fix that later today.

@foodtooth
Copy link

why adding an extra local variable for this while we can just detect the material result after the elite fight? Extra local variable means redundant logic and conflicts as you may wanna do some dlc runs in-game by yourself

@Zebartin
Copy link
Contributor

Zebartin commented Mar 8, 2024

why adding an extra local variable for this while we can just detect the material result after the elite fight? Extra local variable means redundant logic and conflicts as you may wanna do some dlc runs in-game by yourself

you are right but is there any material result that is easy and reliable to detect?

  • the combat rewards shown at the left side disappear in seconds, easy but not reliable
  • detect item quantities or credit, reliable but time-consuming

@foodtooth
Copy link

why adding an extra local variable for this while we can just detect the material result after the elite fight? Extra local variable means redundant logic and conflicts as you may wanna do some dlc runs in-game by yourself

you are right but is there any material result that is easy and reliable to detect?

  • the combat rewards shown at the left side disappear in seconds, easy but not reliable
  • detect item quantities or credit, reliable but time-consuming

Not necessarily relying on any specific material, simply employing template matching for the multiplication sign and counting the quantity should be reliable enough. any thoughts?

@Schwarze-Katze
Copy link
Contributor Author

Schwarze-Katze commented Mar 9, 2024

I have taken @LmeSzinc 's suggestion and set a farming counter in self.config.stored.SimulatedUniverse class.
This counter starts from 100, and decreases each time the elite boss is cleared. When the counter is beyond 0, task SimulatedUniverse enters rogue route even though weekly rogue point is full.

I have noted the idea of detecting boss drop list by @foodtooth 's suggestion.
This way has several pros and cons:

  • ✔️More stable and energy-saving when user plays rogue both manually and by SRC
  • ✔️Avoids adding more and more variables
  • ❌Lacks of robustness, the drop list disappears soon thus may be ignored due to lag of simulator, which may cause the farming feature to stop earlier than expected. In commparison, the former way ensures to complete farming for expected times.
  • ❌Lacks of versatility, no other modules can benefit from this feature, thus has a low input-output ratio

I cannot conclude which way is better than the other, so I adopted the former one. Furthermore, consider of maintainability, every variable name in this commit contains farm prefix, which is unique in SimulatedUniverse module, making it easy to pick out for future modification.

@Schwarze-Katze
Copy link
Contributor Author

Schwarze-Katze commented Mar 10, 2024

🥲It seems that StoredSimulatedUniverse class will not save the counter to disk, causing the counter to reset when src restarts. I dont know how to save this counter, should I use this way or adding the counter value directly to GUI?

Another known issue: if SRC is terminated after clearing elite boss but before exiting elite boss's dungeon(which means just a little walk and one click, will not take much time), farming counter will decrease again at the next time the RogueWorld task enters that elite dungeon, resulting in decreasing the counter twice at one boss battle.

Comment on lines 207 to 211
class StoredSimulatedUniverse(StoredCounter, StoredExpiredAtMonday0400):
pass
# 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
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add standalone storage

class StoredSimulatedUniverseElite(StoredCounter, StoredExpiredAtMonday0400):
    pass

Comment on lines 172 to 178
result = super().clear_enemy(*waypoints)

# runs when one elite battle finishes (do not handle whether the battle succeeded or failed), and decreases rogue farming count by 1
if self.config.RogueWorld_WeeklyFarming and self.config.stored.SimulatedUniverse.farm_not_complete():
self.config.stored.SimulatedUniverse.farm_dec()
logger.info(
f"Cleared elite boss, decrease farming count by 1, now {self.config.stored.SimulatedUniverse.FarmingCounter}")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check the result above, reduce counter if "enemy" in result

@Schwarze-Katze
Copy link
Contributor Author

Schwarze-Katze commented Mar 31, 2024

Thanks to @LmeSzinc 's suggestion, I have fixed the problem.
Now MapControl.clear_enemy(self, *waypoints) and MapControl.clear_item(self, *waypoints) methods in tasks/map/control/control.py will return result array, instead of None. I think these two methods' not returning anything is a bug, so I let them to return self.goto(*waypoints)‘s result.
Any code who expect these two methods to return None may have unexpected result, but during my review no one uses the return value except mine.

@LmeSzinc LmeSzinc added good first issue / 首次贡献 Good for newcomers feature request / 功能请求 New feature or requests labels Apr 5, 2024
@LmeSzinc LmeSzinc changed the base branch from master to dev April 14, 2024 13:42
@LmeSzinc LmeSzinc merged commit 6c56f5e into LmeSzinc:dev Apr 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants