Skip to content

Commit

Permalink
Bug fixing
Browse files Browse the repository at this point in the history
  • Loading branch information
Citrinate committed May 27, 2024
1 parent cc29619 commit 07317f4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
23 changes: 13 additions & 10 deletions BoosterManager/Boosters/BoosterJob.cs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ internal void Stop() {
}
}

private void Update() {
private void SaveJobState() {
if (JobStopped) {
return;
}
Expand All @@ -165,17 +165,19 @@ private void Update() {
void OnBoosterInfosUpdated(Dictionary<uint, Steam.BoosterInfo> boosterInfos) {
try {
// At this point, all boosters that can be added to the queue have been
DateTime? lastBoosterCraftTime = LastBoosterCraftTime;
if (lastBoosterCraftTime == null) {
if (NumBoosters == 0) {
StatusReporter.Report(Bot, Strings.BoostersUncraftable, log: CreatedFromSaveState);
Finish();

return;
}

Update();
SaveJobState();

if (lastBoosterCraftTime.Value.Date == DateTime.Today) {
DateTime? lastBoosterCraftTime = LastBoosterCraftTime;
if (lastBoosterCraftTime == null) {
StatusReporter.Report(Bot, String.Format(Strings.QueueStatusShortWithoutTime, NumBoosters, String.Format("{0:N0}", GemsNeeded)), log: CreatedFromSaveState);
} else if (lastBoosterCraftTime.Value.Date == DateTime.Today) {
StatusReporter.Report(Bot, String.Format(Strings.QueueStatusShort, NumBoosters, String.Format("{0:N0}", GemsNeeded), String.Format("{0:t}", lastBoosterCraftTime)), log: CreatedFromSaveState);
} else {
StatusReporter.Report(Bot, String.Format(Strings.QueueStatusShortWithDate, NumBoosters, String.Format("{0:N0}", GemsNeeded), String.Format("{0:d}", lastBoosterCraftTime), String.Format("{0:t}", lastBoosterCraftTime)), log: CreatedFromSaveState);
Expand Down Expand Up @@ -225,7 +227,7 @@ internal void OnBoosterUnqueueable (uint gameID, BoosterDequeueReason reason) {
GameIDsToBooster.RemoveAll(x => x == gameID);
}

Update();
SaveJobState();
}

internal void OnBoosterDequeued(Booster booster, BoosterDequeueReason reason) {
Expand All @@ -235,7 +237,7 @@ internal void OnBoosterDequeued(Booster booster, BoosterDequeueReason reason) {
Boosters.Remove(booster);
}
StatusReporter.Report(Bot, String.Format(Strings.BoosterUnexpectedlyUncraftable, booster.Info.Name, booster.GameID));
Update();
SaveJobState();

return;
}
Expand All @@ -249,6 +251,7 @@ internal void OnBoosterDequeued(Booster booster, BoosterDequeueReason reason) {

Bot.ArchiLogger.LogGenericInfo(String.Format(Strings.PermanentBoosterRequeued, booster.GameID));
BoosterQueue.AddBooster(booster.GameID, this);
BoosterQueue.Start();

return;
}
Expand All @@ -260,7 +263,7 @@ internal void OnBoosterDequeued(Booster booster, BoosterDequeueReason reason) {
}
}

Update();
SaveJobState();

return;
}
Expand Down Expand Up @@ -305,7 +308,7 @@ internal bool RemoveUnqueuedBooster(uint gameID) {
removed = GameIDsToBooster.Remove(gameID);
}

Update();
SaveJobState();

return removed;
}
Expand Down Expand Up @@ -341,7 +344,7 @@ internal List<uint> RemoveAllBoosters() {
}
}

Update();
SaveJobState();

return gameIDsRemoved;
}
Expand Down
4 changes: 4 additions & 0 deletions BoosterManager/Localization/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -549,4 +549,8 @@
<value>Attempting to assign {0} boosters...</value>
<comment>{0} will be replaced by a number of boosters</comment>
</data>
<data name="QueueStatusShortWithoutTime" xml:space="preserve">
<value>{0} boosters from {1} gems will be crafted</value>
<comment>{0} will be replaced by a number of boosters, {1} will be replaced by a number of gems</comment>
</data>
</root>

0 comments on commit 07317f4

Please sign in to comment.