Set initial state of ShouldResumeFarming to false

ShouldResumeFarming indicates whether call to Resume() should start farming, which is used for example when account is marked as free to farm due to event. That event by default is triggered on ASF startup as well.

At the same time, the prerequisite to start farming is having our cache ready at least for the bot that is about to start farming. This happens in OnBotLicenseList() which notified CardsFarmer about new games added once it finishes, which also triggers the farming.

Previous behaviour resulted in a bit unwanted situation where CardsFarmer didn't bother waiting for cache to be ready, as the event about occupation triggered resume process, and that process due to true value started immediately. Changing default state of that value to false should suffice, as initial resume event won't cause the cards farming process to be started, and event about new games added already sets that flag back to true, so if cache being rebuilt happens before playing lock being released, Resume() should still trigger farming as wanted.

Give yourself a pat on the back if you understood something from that.
This commit is contained in:
Archi
2022-03-10 12:36:31 +01:00
parent 021d414143
commit 6edf62d849

View File

@@ -144,7 +144,7 @@ public sealed class CardsFarmer : IAsyncDisposable {
private bool KeepFarming;
private bool ParsingScheduled;
private bool PermanentlyPaused;
private bool ShouldResumeFarming = true;
private bool ShouldResumeFarming;
internal CardsFarmer(Bot bot) {
Bot = bot ?? throw new ArgumentNullException(nameof(bot));
@@ -291,7 +291,7 @@ public sealed class CardsFarmer : IAsyncDisposable {
internal void SetInitialState(bool paused) {
PermanentlyPaused = Paused = paused;
ShouldResumeFarming = true;
ShouldResumeFarming = false;
}
internal async Task StartFarming() {