Skip to content

Commit

Permalink
Merge branch 'main' into asf-update
Browse files Browse the repository at this point in the history
  • Loading branch information
Citrinate committed Mar 19, 2024
2 parents 25da7b3 + 7d0973f commit 4cb3cf1
Show file tree
Hide file tree
Showing 5 changed files with 17 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
7 changes: 7 additions & 0 deletions FreePackages/Data/FilterablePackage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ internal sealed class FilterablePackage {
internal List<string>? 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) {}
Expand All @@ -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<SteamApps.PICSProductInfoCallback.PICSProductInfo> productInfos) => AddPackageContents(productInfos.Select(productInfo => (productInfo.ID, productInfo.KeyValues)));
Expand Down Expand Up @@ -104,6 +106,11 @@ internal bool IsAvailable() {
return false;
}

if (BetaTesterPackage) {
// Playtests can't be activated through packages
return false;
}

return true;
}

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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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] <Licenses>`|`Master`|Adds given `licenses`, explained [here](https://github.com/JustArchiNET/ArchiSteamFarm/wiki/Commands#addlicense-licenses), to the given bot's packages queue
`queuelicense^ [Bots] <Licenses>`|`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
Expand Down

0 comments on commit 4cb3cf1

Please sign in to comment.