private void UpdateExistingGame(Game existingGame, Order.TpkdDict.Tpk tpkd) { if (existingGame == null) { return; } if (!Settings.keyTypeWhitelist.Contains(tpkd.key_type)) { return; } // if tpkd is redeemed but game isn't, add redeemed, remove unredeemed if (!string.IsNullOrWhiteSpace(tpkd.redeemed_key_val) && !existingGame.Tags.Any(t => t.Name == REDEEMED_STRING)) { existingGame.Tags.RemoveAll(t => t.Name == UNREDEEMED_STRING); existingGame.Tags.Add(new Tag(REDEEMED_STRING)); } // if tpkd is unredeemed but game isn't, add unredeemed, remove redeemed // this should be impossible if (string.IsNullOrWhiteSpace(tpkd.redeemed_key_val) && !existingGame.Tags.Any(t => t.Name == UNREDEEMED_STRING)) { existingGame.Tags.RemoveAll(t => t.Name == REDEEMED_STRING); existingGame.Tags.Add(new Tag(UNREDEEMED_STRING)); } PlayniteApi.Database.Games.Update(existingGame); }
private void UpdateExistingGame(Game existingGame, Order.TpkdDict.Tpk tpkd) { if (existingGame == null) { return; } if (!Settings.keyTypeWhitelist.Contains(tpkd.key_type)) { return; } existingGame.Tags.RemoveAll(t => PAST_TAGS.Contains(t.Name)); existingGame.Tags.Add(new Tag(IsKeyPresent(tpkd) ? REDEEMED_STR : UNREDEEMED_STR)); PlayniteApi.Database.Games.Update(existingGame); }
private static string GetGameId(Order.TpkdDict.Tpk tpk) => $"{tpk.machine_name}_{tpk.gamekey}";
private static bool IsKeyPresent(Order.TpkdDict.Tpk t) => !string.IsNullOrWhiteSpace(t.redeemed_key_val);