diff --git a/FreePackages.Tests/Apps.cs b/FreePackages.Tests/Apps.cs index a7d3a76..f76aaa3 100644 --- a/FreePackages.Tests/Apps.cs +++ b/FreePackages.Tests/Apps.cs @@ -57,6 +57,7 @@ public void CanDetectRedeemableAppWithAppRequirement() { Assert.IsTrue(app.MustOwnAppToPurchase > 0); Assert.IsTrue(PackageFilter.IsRedeemableApp(app)); + Assert.IsTrue(app.MustOwnAppToPurchase == app.DLCForAppID); } [TestMethod] diff --git a/FreePackages/Data/FilterableApp.cs b/FreePackages/Data/FilterableApp.cs index 1738eee..3f92703 100644 --- a/FreePackages/Data/FilterableApp.cs +++ b/FreePackages/Data/FilterableApp.cs @@ -14,6 +14,7 @@ internal sealed class FilterableApp { internal string? ReleaseState; internal string? State; internal uint MustOwnAppToPurchase; + internal uint DLCForAppID; internal List? RestrictedCountries; internal List? PurchaseRestrictedCountries; internal bool AllowPurchaseFromRestrictedCountries; @@ -41,6 +42,7 @@ internal FilterableApp(uint id, KeyValue kv) { ReleaseState = kv["common"]["releasestate"].AsString(); State = kv["extended"]["state"].AsString(); MustOwnAppToPurchase = kv["extended"]["mustownapptopurchase"].AsUnsignedInteger(); + DLCForAppID = kv["extended"]["dlcforappid"].AsUnsignedInteger(); RestrictedCountries = kv["common"]["restricted_countries"].AsString()?.ToUpper().Split(",").ToList(); PurchaseRestrictedCountries = kv["extended"]["purchaserestrictedcountries"].AsString()?.ToUpper().Split(" ").ToList(); AllowPurchaseFromRestrictedCountries = kv["extended"]["allowpurchasefromrestrictedcountries"].AsBoolean(); diff --git a/FreePackages/Data/FilterablePackage.cs b/FreePackages/Data/FilterablePackage.cs index cbe4651..5227b46 100644 --- a/FreePackages/Data/FilterablePackage.cs +++ b/FreePackages/Data/FilterablePackage.cs @@ -23,6 +23,7 @@ internal sealed class FilterablePackage { internal List? PurchaseRestrictedCountries; internal bool AllowPurchaseFromRestrictedCountries; internal bool FreeWeekend; + internal bool BetaTesterPackage; internal FilterablePackage(SteamApps.PICSProductInfoCallback.PICSProductInfo productInfo, bool isNew = false) : this(productInfo.ID, productInfo.KeyValues, isNew) {} internal FilterablePackage(KeyValue kv, bool isNew = false) : this(Convert.ToUInt32(kv.Name), kv, isNew) {} @@ -42,6 +43,7 @@ internal FilterablePackage(uint id, KeyValue kv, bool isNew) { PurchaseRestrictedCountries = kv["extended"]["purchaserestrictedcountries"].AsString()?.ToUpper().Split(" ").ToList(); AllowPurchaseFromRestrictedCountries = kv["extended"]["allowpurchasefromrestrictedcountries"].AsBoolean(); FreeWeekend = kv["extended"]["freeweekend"].AsBoolean(); + BetaTesterPackage = kv["extended"]["betatesterpackage"].AsBoolean(); } internal void AddPackageContents(IEnumerable productInfos) => AddPackageContents(productInfos.Select(productInfo => (productInfo.ID, productInfo.KeyValues))); @@ -104,6 +106,11 @@ internal bool IsAvailable() { return false; } + if (BetaTesterPackage) { + // Playtests can't be activated through packages + return false; + } + return true; } diff --git a/FreePackages/Handlers/PackageFilter.cs b/FreePackages/Handlers/PackageFilter.cs index c5d038e..c7aba4a 100644 --- a/FreePackages/Handlers/PackageFilter.cs +++ b/FreePackages/Handlers/PackageFilter.cs @@ -66,6 +66,12 @@ internal bool IsRedeemableApp(FilterableApp app, HashSet? includedAppIDs = return false; } + if (app.DLCForAppID > 0 && !OwnedAppIDs.Contains(app.DLCForAppID) && (includedAppIDs == null || !includedAppIDs.Contains(app.DLCForAppID))) { + // Missing a necessary app + // Note: Some apps have only DLCForAppid and are missing MustOwnAppToPurchase, so we need to check this also, ex: https://steamdb.info/app/41046 + return false; + } + if (app.RestrictedCountries != null && app.RestrictedCountries.Contains(Country, StringComparer.OrdinalIgnoreCase)) { // App is restricted in this bot's country return false; diff --git a/README.md b/README.md index fd384fb..aeb33f8 100644 --- a/README.md +++ b/README.md @@ -437,6 +437,7 @@ You can define as many filters as you'd like, and packages that pass any one of Command | Access | Description --- | --- | --- +`freepackages`|`FamilySharing`|Prints version of plugin. `queuestatus [Bots]`|`Master`|Prints the status of the given bot's packages queue `queuelicense [Bots] `|`Master`|Adds given `licenses`, explained [here](https://github.com/JustArchiNET/ArchiSteamFarm/wiki/Commands#addlicense-licenses), to the given bot's packages queue `queuelicense^ [Bots] `|`Master`|Adds given `licenses`, explained [here](https://github.com/JustArchiNET/ArchiSteamFarm/wiki/Commands#addlicense-licenses), to the given bot's packages queue using that bot's package filters