chore(deps): update dependency microsoft.identitymodel.jsonwebtokens to 8.4.0
[ArchiSteamFarm.git] / ArchiSteamFarm / Steam / Cards / Game.cs
blob18cf5312d4e0ebb6e3693988ed26c5827af19a68
1 // ----------------------------------------------------------------------------------------------
2 // _ _ _ ____ _ _____
3 // / \ _ __ ___ | |__ (_)/ ___| | |_ ___ __ _ _ __ ___ | ___|__ _ _ __ _ __ ___
4 // / _ \ | '__|/ __|| '_ \ | |\___ \ | __|/ _ \ / _` || '_ ` _ \ | |_ / _` || '__|| '_ ` _ \
5 // / ___ \ | | | (__ | | | || | ___) || |_| __/| (_| || | | | | || _|| (_| || | | | | | | |
6 // /_/ \_\|_| \___||_| |_||_||____/ \__|\___| \__,_||_| |_| |_||_| \__,_||_| |_| |_| |_|
7 // ----------------------------------------------------------------------------------------------
8 // |
9 // Copyright 2015-2025 Ɓukasz "JustArchi" Domeradzki
10 // Contact: JustArchi@JustArchi.net
11 // |
12 // Licensed under the Apache License, Version 2.0 (the "License");
13 // you may not use this file except in compliance with the License.
14 // You may obtain a copy of the License at
15 // |
16 // http://www.apache.org/licenses/LICENSE-2.0
17 // |
18 // Unless required by applicable law or agreed to in writing, software
19 // distributed under the License is distributed on an "AS IS" BASIS,
20 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 // See the License for the specific language governing permissions and
22 // limitations under the License.
24 using System;
25 using System.ComponentModel.DataAnnotations;
26 using System.Text.Json.Serialization;
28 namespace ArchiSteamFarm.Steam.Cards;
30 public sealed class Game : IEquatable<Game> {
31 [JsonInclude]
32 public uint AppID { get; }
34 [JsonInclude]
35 public string GameName { get; }
37 internal readonly byte BadgeLevel;
39 [JsonInclude]
40 [JsonRequired]
41 [Required]
42 public ushort CardsRemaining { get; internal set; }
44 [JsonInclude]
45 [JsonRequired]
46 [Required]
47 public float HoursPlayed { get; internal set; }
49 internal uint PlayableAppID { get; set; }
51 internal Game(uint appID, string gameName, float hoursPlayed, ushort cardsRemaining, byte badgeLevel) {
52 ArgumentOutOfRangeException.ThrowIfZero(appID);
53 ArgumentException.ThrowIfNullOrEmpty(gameName);
54 ArgumentOutOfRangeException.ThrowIfNegative(hoursPlayed);
56 AppID = appID;
57 GameName = gameName;
58 HoursPlayed = hoursPlayed;
59 CardsRemaining = cardsRemaining;
60 BadgeLevel = badgeLevel;
62 PlayableAppID = appID;
65 public bool Equals(Game? other) => (other != null) && (ReferenceEquals(other, this) || ((AppID == other.AppID) && (BadgeLevel == other.BadgeLevel) && (GameName == other.GameName)));
66 public override bool Equals(object? obj) => (obj != null) && ((obj == this) || (obj is Game game && Equals(game)));
67 public override int GetHashCode() => HashCode.Combine(AppID, BadgeLevel, GameName);