Improve refundable games check

Free promos like Cortex Command added as "Complimentary" were previously skipped as being refundable.
This commit is contained in:
JustArchi
2018-02-07 07:30:07 +01:00
parent cf10f07124
commit 19730f565b

View File

@@ -374,7 +374,7 @@ namespace ArchiSteamFarm {
continue;
}
if ((packageData.PaymentMethod != EPaymentMethod.ActivationCode) && (packageData.TimeCreated > mostRecent)) {
if (IsRefundable(packageData.PaymentMethod) && (packageData.TimeCreated > mostRecent)) {
mostRecent = packageData.TimeCreated;
}
}
@@ -1474,6 +1474,23 @@ namespace ArchiSteamFarm {
return false;
}
private static bool IsRefundable(EPaymentMethod method) {
if (method == EPaymentMethod.None) {
ASF.ArchiLogger.LogNullError(nameof(method));
return false;
}
switch (method) {
case EPaymentMethod.ActivationCode:
case EPaymentMethod.Complimentary:
case EPaymentMethod.GuestPass:
case EPaymentMethod.HardwarePromo:
return false;
default:
return true;
}
}
private static bool IsValidCdKey(string key) {
if (!string.IsNullOrEmpty(key)) {
return Regex.IsMatch(key, @"^[0-9A-Z]{4,7}-[0-9A-Z]{4,7}-[0-9A-Z]{4,7}(?:(?:-[0-9A-Z]{4,7})?(?:-[0-9A-Z]{4,7}))?$", RegexOptions.CultureInvariant | RegexOptions.IgnoreCase);