Skip to content

Commit

Permalink
Check DLCForAppID field
Browse files Browse the repository at this point in the history
  • Loading branch information
Citrinate committed Mar 19, 2024
1 parent 1120b09 commit 7d0973f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions FreePackages.Tests/Apps.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public void CanDetectRedeemableAppWithAppRequirement() {

Assert.IsTrue(app.MustOwnAppToPurchase > 0);
Assert.IsTrue(PackageFilter.IsRedeemableApp(app));
Assert.IsTrue(app.MustOwnAppToPurchase == app.DLCForAppID);
}

[TestMethod]
Expand Down
2 changes: 2 additions & 0 deletions FreePackages/Data/FilterableApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ internal sealed class FilterableApp {
internal string? ReleaseState;
internal string? State;
internal uint MustOwnAppToPurchase;
internal uint DLCForAppID;
internal List<string>? RestrictedCountries;
internal List<string>? PurchaseRestrictedCountries;
internal bool AllowPurchaseFromRestrictedCountries;
Expand Down Expand Up @@ -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();
Expand Down
6 changes: 6 additions & 0 deletions FreePackages/Handlers/PackageFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ internal bool IsRedeemableApp(FilterableApp app, HashSet<uint>? 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;
Expand Down

0 comments on commit 7d0973f

Please sign in to comment.