mirror of
https://github.com/JustArchiNET/ArchiSteamFarm
synced 2024-11-10 15:14:41 +00:00
Implement ArchiBoT way of skipping unreleased games for farming purpose, closes #425
This commit is contained in:
parent
88489c961a
commit
f3b53d3da2
6 changed files with 79 additions and 13 deletions
|
@ -305,6 +305,48 @@ namespace ArchiSteamFarm {
|
|||
}
|
||||
}
|
||||
|
||||
internal async Task<HashSet<uint>> GetUnreleasedAppIDs(HashSet<uint> appIDs) {
|
||||
if ((appIDs == null) || (appIDs.Count == 0)) {
|
||||
ArchiLogger.LogNullError(nameof(appIDs));
|
||||
return null;
|
||||
}
|
||||
|
||||
AsyncJobMultiple<SteamApps.PICSProductInfoCallback>.ResultSet productInfo;
|
||||
|
||||
try {
|
||||
productInfo = await SteamApps.PICSGetProductInfo(appIDs, Enumerable.Empty<uint>());
|
||||
} catch (Exception e) {
|
||||
ArchiLogger.LogGenericException(e);
|
||||
return null;
|
||||
}
|
||||
|
||||
HashSet<uint> result = new HashSet<uint>();
|
||||
foreach (KeyValuePair<uint, SteamApps.PICSProductInfoCallback.PICSProductInfo> app in productInfo.Results.SelectMany(productResult => productResult.Apps)) {
|
||||
if (!appIDs.Contains(app.Key)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
string releaseState = app.Value.KeyValues["common"]["ReleaseState"].Value;
|
||||
if (string.IsNullOrEmpty(releaseState)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (releaseState) {
|
||||
case "released":
|
||||
break;
|
||||
case "prerelease":
|
||||
case "preloadonly":
|
||||
result.Add(app.Key);
|
||||
break;
|
||||
default:
|
||||
ArchiLogger.LogGenericWarning(string.Format(Strings.WarningUnknownValuePleaseReport, nameof(releaseState), releaseState));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
internal static async Task InitializeCMs(uint cellID, IServerListProvider serverListProvider) {
|
||||
if (serverListProvider == null) {
|
||||
Program.ArchiLogger.LogNullError(nameof(serverListProvider));
|
||||
|
|
|
@ -178,6 +178,20 @@ namespace ArchiSteamFarm {
|
|||
return;
|
||||
}
|
||||
|
||||
// Remove from our list all games that were not released yet
|
||||
HashSet<uint> appIDs = new HashSet<uint>(GamesToFarm.Select(game => game.AppID));
|
||||
|
||||
HashSet<uint> unreleasedAppIDs = await Bot.GetUnreleasedAppIDs(appIDs).ConfigureAwait(false);
|
||||
if ((unreleasedAppIDs != null) && (unreleasedAppIDs.Count > 0)) {
|
||||
if (GamesToFarm.RemoveWhere(game => unreleasedAppIDs.Contains(game.AppID)) > 0) {
|
||||
if (GamesToFarm.Count == 0) {
|
||||
Bot.ArchiLogger.LogGenericInfo(Strings.NothingToIdle);
|
||||
await Bot.OnFarmingFinished(false).ConfigureAwait(false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Bot.ArchiLogger.LogGenericInfo(string.Format(Strings.GamesToIdle, GamesToFarm.Count, GamesToFarm.Sum(game => game.CardsRemaining), TimeRemaining.ToHumanReadable()));
|
||||
|
||||
// This is the last moment for final check if we can farm
|
||||
|
|
|
@ -114,6 +114,16 @@ namespace ArchiSteamFarm {
|
|||
}
|
||||
}
|
||||
|
||||
internal int RemoveWhere(Predicate<T> match) {
|
||||
Lock.EnterWriteLock();
|
||||
|
||||
try {
|
||||
return HashSet.RemoveWhere(match);
|
||||
} finally {
|
||||
Lock.ExitWriteLock();
|
||||
}
|
||||
}
|
||||
|
||||
internal bool ReplaceIfNeededWith(ICollection<T> items) {
|
||||
Lock.EnterUpgradeableReadLock();
|
||||
|
||||
|
|
18
ArchiSteamFarm/Localization/Strings.Designer.cs
generated
18
ArchiSteamFarm/Localization/Strings.Designer.cs
generated
|
@ -1413,15 +1413,6 @@ namespace ArchiSteamFarm.Localization {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Received unknown confirmation type, please report this: {0}.
|
||||
/// </summary>
|
||||
internal static string WarningMobileAuthenticatorUnknownConfirmationType {
|
||||
get {
|
||||
return ResourceManager.GetString("WarningMobileAuthenticatorUnknownConfirmationType", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Please review our privacy policy section on the wiki if you're concerned about what ASF is in fact doing!.
|
||||
/// </summary>
|
||||
|
@ -1458,6 +1449,15 @@ namespace ArchiSteamFarm.Localization {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Received unknown value for {0}, please report this: {1}.
|
||||
/// </summary>
|
||||
internal static string WarningUnknownValuePleaseReport {
|
||||
get {
|
||||
return ResourceManager.GetString("WarningUnknownValuePleaseReport", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Ignoring WCF command because --client wasn't specified: {0}.
|
||||
/// </summary>
|
||||
|
|
|
@ -334,9 +334,9 @@ StackTrace:
|
|||
<value><{0}> Please enter your WCF host: </value>
|
||||
<comment>{0} will be replaced by bot's name. Please note that this translation should end with space</comment>
|
||||
</data>
|
||||
<data name="WarningMobileAuthenticatorUnknownConfirmationType" xml:space="preserve">
|
||||
<value>Received unknown confirmation type, please report this: {0}</value>
|
||||
<comment>{0} will be replaced by unknown confirmation type</comment>
|
||||
<data name="WarningUnknownValuePleaseReport" xml:space="preserve">
|
||||
<value>Received unknown value for {0}, please report this: {1}</value>
|
||||
<comment>{0} will be replaced by object's name, {1} will be replaced by value for that object</comment>
|
||||
</data>
|
||||
<data name="WarningTooManyGamesToPlay" xml:space="preserve">
|
||||
<value>Playing more than {0} games concurrently is not possible, only first {0} entries from {1} will be used!</value>
|
||||
|
|
|
@ -175,7 +175,7 @@ namespace ArchiSteamFarm {
|
|||
} else if (description.StartsWith("Trade with ", StringComparison.Ordinal)) {
|
||||
type = Steam.ConfirmationDetails.EType.Trade;
|
||||
} else {
|
||||
Bot.ArchiLogger.LogGenericWarning(string.Format(Strings.WarningMobileAuthenticatorUnknownConfirmationType, description));
|
||||
Bot.ArchiLogger.LogGenericWarning(string.Format(Strings.WarningUnknownValuePleaseReport, nameof(description), description));
|
||||
type = Steam.ConfirmationDetails.EType.Other;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue