chore(deps): update asf-ui digest to 10e22ad
[ArchiSteamFarm.git] / ArchiSteamFarm.OfficialPlugins.Monitoring / TradeStatistics.cs
blobda53fcce14f201e9779fea2f7c6942229fe116f0
1 // ----------------------------------------------------------------------------------------------
2 // _ _ _ ____ _ _____
3 // / \ _ __ ___ | |__ (_)/ ___| | |_ ___ __ _ _ __ ___ | ___|__ _ _ __ _ __ ___
4 // / _ \ | '__|/ __|| '_ \ | |\___ \ | __|/ _ \ / _` || '_ ` _ \ | |_ / _` || '__|| '_ ` _ \
5 // / ___ \ | | | (__ | | | || | ___) || |_| __/| (_| || | | | | || _|| (_| || | | | | | | |
6 // /_/ \_\|_| \___||_| |_||_||____/ \__|\___| \__,_||_| |_| |_||_| \__,_||_| |_| |_| |_|
7 // ----------------------------------------------------------------------------------------------
8 // |
9 // Copyright 2015-2024 Ɓ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.Threading;
26 using ArchiSteamFarm.Steam.Exchange;
28 namespace ArchiSteamFarm.OfficialPlugins.Monitoring;
30 internal sealed class TradeStatistics {
31 private readonly Lock Lock = new();
33 internal int AcceptedOffers { get; private set; }
34 internal int BlacklistedOffers { get; private set; }
35 internal int ConfirmedOffers { get; private set; }
36 internal int IgnoredOffers { get; private set; }
37 internal int ItemsGiven { get; private set; }
38 internal int ItemsReceived { get; private set; }
39 internal int RejectedOffers { get; private set; }
41 internal void Include(ParseTradeResult result) {
42 ArgumentNullException.ThrowIfNull(result);
44 lock (Lock) {
45 switch (result.Result) {
46 case ParseTradeResult.EResult.Accepted when result.Confirmed:
47 ConfirmedOffers++;
49 ItemsGiven += result.ItemsToGive?.Count ?? 0;
50 ItemsReceived += result.ItemsToReceive?.Count ?? 0;
52 goto case ParseTradeResult.EResult.Accepted;
53 case ParseTradeResult.EResult.Accepted:
54 AcceptedOffers++;
56 break;
57 case ParseTradeResult.EResult.Rejected:
58 RejectedOffers++;
60 break;
61 case ParseTradeResult.EResult.Blacklisted:
62 BlacklistedOffers++;
64 break;
65 case ParseTradeResult.EResult.Ignored:
66 IgnoredOffers++;
68 break;