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/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;