Skip to content

Commit

Permalink
Improve booster command fail response message
Browse files Browse the repository at this point in the history
  • Loading branch information
Citrinate committed May 28, 2024
1 parent 07317f4 commit d857ad2
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
20 changes: 19 additions & 1 deletion BoosterManager/Boosters/BoosterJob.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using ArchiSteamFarm.Collections;
using ArchiSteamFarm.Steam;
using BoosterManager.Localization;

Expand All @@ -15,6 +16,8 @@ internal sealed class BoosterJob {
private bool CreatedFromSaveState = false;
private readonly object LockObject = new();
private bool JobStopped = false;
private ConcurrentHashSet<uint> UncraftableGameIDs = new();
private ConcurrentHashSet<uint> UnmarketableGameIDs = new();

private BoosterHandler BoosterHandler => BoosterHandler.BoosterHandlers[Bot.BotName];
private BoosterQueue BoosterQueue => BoosterHandler.BoosterQueue;
Expand Down Expand Up @@ -166,7 +169,16 @@ void OnBoosterInfosUpdated(Dictionary<uint, Steam.BoosterInfo> boosterInfos) {
try {
// At this point, all boosters that can be added to the queue have been
if (NumBoosters == 0) {
StatusReporter.Report(Bot, Strings.BoostersUncraftable, log: CreatedFromSaveState);
if (UnmarketableGameIDs.Count > 0) {
if (UncraftableGameIDs.Count > 0) {
StatusReporter.Report(Bot, String.Format(Strings.BoostersUncraftableAndUnmarketable, String.Join(", ", UnmarketableGameIDs)), log: CreatedFromSaveState);
} else {
StatusReporter.Report(Bot, Strings.BoostersUnmarketable, log: CreatedFromSaveState);
}
} else {
StatusReporter.Report(Bot, Strings.BoostersUncraftable, log: CreatedFromSaveState);
}

Finish();

return;
Expand Down Expand Up @@ -226,6 +238,12 @@ internal void OnBoosterUnqueueable (uint gameID, BoosterDequeueReason reason) {
lock(LockObject) {
GameIDsToBooster.RemoveAll(x => x == gameID);
}

if (reason == BoosterDequeueReason.Uncraftable) {
UncraftableGameIDs.Add(gameID);
} else if (reason == BoosterDequeueReason.Unmarketable) {
UnmarketableGameIDs.Add(gameID);
}

SaveJobState();
}
Expand Down
8 changes: 8 additions & 0 deletions BoosterManager/Localization/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -553,4 +553,12 @@
<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>
<data name="BoostersUnmarketable" xml:space="preserve">
<value>The requested boosters are unmarketable and won't be crafted</value>
<comment/>
</data>
<data name="BoostersUncraftableAndUnmarketable" xml:space="preserve">
<value>No boosters will be crafted. This bot either can't craft the requested boosters, or the requested boosters are unmarketable. The following boosters are unmarketable: {0}</value>
<comment>{0} will be replaced by a list of appIDs</comment>
</data>
</root>

0 comments on commit d857ad2

Please sign in to comment.