Decompiled source of RoundsTracker v1.0.20

rounds-tracker.dll

Decompiled a day ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Configuration;
using ExitGames.Client.Photon;
using GameMessageLib;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using ModdingUtils.Utils;
using Photon.Pun;
using Photon.Realtime;
using RarityLib.Utils;
using TMPro;
using UnboundLib;
using UnboundLib.GameModes;
using UnboundLib.Networking;
using UnboundLib.Utils.UI;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Networking;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("rounds-tracker")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+1086f9175f55ece98adc55b6c7a3035f6342aa72")]
[assembly: AssemblyProduct("rounds-tracker")]
[assembly: AssemblyTitle("rounds-tracker")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace RoundsTracker
{
	internal static class Api
	{
		[CompilerGenerated]
		private sealed class <PollEloFromHttp>d__6 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public string sessionId;

			public string steamId;

			private int <i>5__1;

			private string <url>5__2;

			private UnityWebRequest <req>5__3;

			private string <text>5__4;

			private MatchCollection <matches>5__5;

			private IEnumerator <>s__6;

			private Match <m>5__7;

			private string <obj>5__8;

			private float <before>5__9;

			private float <after>5__10;

			private float <change>5__11;

			private int <dBefore>5__12;

			private int <dChange>5__13;

			private int <dAfter>5__14;

			private string <sign>5__15;

			private MessageType <msgType>5__16;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <PollEloFromHttp>d__6(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				int num = <>1__state;
				if (num == -3 || num == 2)
				{
					try
					{
					}
					finally
					{
						<>m__Finally1();
					}
				}
				<url>5__2 = null;
				<req>5__3 = null;
				<text>5__4 = null;
				<matches>5__5 = null;
				<>s__6 = null;
				<m>5__7 = null;
				<obj>5__8 = null;
				<sign>5__15 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0068: Unknown result type (might be due to invalid IL or missing references)
				//IL_0072: Expected O, but got Unknown
				//IL_0442: Unknown result type (might be due to invalid IL or missing references)
				//IL_044c: Expected O, but got Unknown
				//IL_032a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0373: Unknown result type (might be due to invalid IL or missing references)
				bool result;
				try
				{
					switch (<>1__state)
					{
					default:
						result = false;
						goto end_IL_0000;
					case 0:
						<>1__state = -1;
						if (string.IsNullOrEmpty(sessionId) || string.IsNullOrEmpty(steamId))
						{
							result = false;
						}
						else
						{
							<>2__current = (object)new WaitForSeconds(2f);
							<>1__state = 1;
							result = true;
						}
						goto end_IL_0000;
					case 1:
						<>1__state = -1;
						<i>5__1 = 0;
						break;
					case 2:
						<>1__state = -3;
						if (!<req>5__3.isNetworkError && !<req>5__3.isHttpError)
						{
							<text>5__4 = <req>5__3.downloadHandler.text;
							if (<text>5__4 != null && <text>5__4.Contains("\"elo\"") && !RT._eloShownThisGame)
							{
								<matches>5__5 = Regex.Matches(<text>5__4, "\\{[^{}]*\\}");
								<>s__6 = <matches>5__5.GetEnumerator();
								try
								{
									while (<>s__6.MoveNext())
									{
										<m>5__7 = (Match)<>s__6.Current;
										<obj>5__8 = <m>5__7.Value;
										if (!<obj>5__8.Contains("\"before\"") || !<obj>5__8.Contains("\"change\"") || <obj>5__8.Contains("\"steam_id\""))
										{
											continue;
										}
										<before>5__9 = ExtractFloat(<obj>5__8, "before", 0f);
										<after>5__10 = ExtractFloat(<obj>5__8, "after", 0f);
										<change>5__11 = ExtractFloat(<obj>5__8, "change", 0f);
										if (<change>5__11 == 0f)
										{
											break;
										}
										if (RT._eloShownThisGame)
										{
											result = false;
										}
										else
										{
											RT._eloShownThisGame = true;
											<dBefore>5__12 = (int)Math.Round(<before>5__9);
											<dChange>5__13 = (int)Math.Round(<change>5__11);
											<dAfter>5__14 = (int)Math.Round(<after>5__10);
											<sign>5__15 = ((<dChange>5__13 > 0) ? "+" : "");
											<msgType>5__16 = (MessageType)((<dChange>5__13 > 0) ? 1 : 2);
											GameMessage.Show($"ELO {<dBefore>5__12} -> {<sign>5__15}{<dChange>5__13} -> {<dAfter>5__14}", <msgType>5__16, RT.NotifDuration);
											RT.Log($"ELO change (http-poll): {<before>5__9:F1} -> {<sign>5__15}{<change>5__11:F1} -> {<after>5__10:F1}");
											result = false;
										}
										goto IL_041d;
									}
								}
								finally
								{
									if (<>s__6 is IDisposable disposable)
									{
										disposable.Dispose();
									}
								}
								<>s__6 = null;
								<matches>5__5 = null;
							}
							<text>5__4 = null;
						}
						<>m__Finally1();
						<req>5__3 = null;
						if (<i>5__1 >= 4)
						{
							goto IL_045e;
						}
						<>2__current = (object)new WaitForSeconds(3f);
						<>1__state = 3;
						result = true;
						goto end_IL_0000;
					case 3:
						{
							<>1__state = -1;
							goto IL_045e;
						}
						IL_041d:
						<>m__Finally1();
						goto end_IL_0000;
						IL_045e:
						<url>5__2 = null;
						<i>5__1++;
						break;
					}
					if (<i>5__1 < 5)
					{
						if (RT._eloShownThisGame)
						{
							result = false;
						}
						else
						{
							<url>5__2 = RT.ApiUrlValue + "/api/elo/check?session_id=" + Uri.EscapeDataString(sessionId) + "&steam_id=" + Uri.EscapeDataString(steamId);
							<req>5__3 = UnityWebRequest.Get(<url>5__2);
							<>1__state = -3;
							<req>5__3.timeout = 5;
							<>2__current = <req>5__3.SendWebRequest();
							<>1__state = 2;
							result = true;
						}
					}
					else
					{
						RT.LogDebug("ELO http-poll: no result after all attempts");
						result = false;
					}
					end_IL_0000:;
				}
				catch
				{
					//try-fault
					((IDisposable)this).Dispose();
					throw;
				}
				return result;
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			private void <>m__Finally1()
			{
				<>1__state = -1;
				if (<req>5__3 != null)
				{
					((IDisposable)<req>5__3).Dispose();
				}
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		[CompilerGenerated]
		private sealed class <SendCoroutine>d__4 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public RoundReport report;

			public int attempt;

			private string <json>5__1;

			private string <url>5__2;

			private UnityWebRequest <req>5__3;

			private float <delay>5__4;

			private string <responseText>5__5;

			private Exception <ex>5__6;

			private Exception <ex>5__7;

			private Exception <ex>5__8;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <SendCoroutine>d__4(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				int num = <>1__state;
				if (num == -3 || (uint)(num - 1) <= 1u)
				{
					try
					{
					}
					finally
					{
						<>m__Finally1();
					}
				}
				<json>5__1 = null;
				<url>5__2 = null;
				<req>5__3 = null;
				<responseText>5__5 = null;
				<ex>5__6 = null;
				<ex>5__7 = null;
				<ex>5__8 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
				//IL_00bd: Expected O, but got Unknown
				//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e6: Expected O, but got Unknown
				//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f7: Expected O, but got Unknown
				//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
				//IL_0202: Expected O, but got Unknown
				try
				{
					switch (<>1__state)
					{
					default:
						return false;
					case 0:
						<>1__state = -1;
						<json>5__1 = ReportSerializer.ToJson(report);
						<url>5__2 = RT.ApiUrlValue + "/api/rounds";
						RT.LogDebug($"Sending {<json>5__1.Length} bytes to {<url>5__2} (attempt {attempt + 1}/{5})");
						<req>5__3 = new UnityWebRequest(<url>5__2, "POST");
						<>1__state = -3;
						<req>5__3.uploadHandler = (UploadHandler)new UploadHandlerRaw(Encoding.UTF8.GetBytes(<json>5__1));
						<req>5__3.downloadHandler = (DownloadHandler)new DownloadHandlerBuffer();
						<req>5__3.SetRequestHeader("Content-Type", "application/json");
						<req>5__3.timeout = 2;
						<>2__current = <req>5__3.SendWebRequest();
						<>1__state = 1;
						return true;
					case 1:
						<>1__state = -3;
						if (<req>5__3.isNetworkError || <req>5__3.isHttpError)
						{
							RT.LogError($"Send error: {<req>5__3.error} (attempt {attempt + 1}/{5})");
							if (attempt + 1 < 5)
							{
								<delay>5__4 = 1f * Mathf.Pow(2f, (float)attempt);
								RT.LogDebug($"Retry in {<delay>5__4}s (attempt {attempt + 1}/{5})");
								<>2__current = (object)new WaitForSeconds(<delay>5__4);
								<>1__state = 2;
								return true;
							}
							RT.LogError($"Send failed after {5} attempts, data not sent");
							if (RT.ShowSendErrorNotifications.Value)
							{
								GameMessage.Error($"Rounds Tracker: failed to send data ({5} attempts)", 5f);
							}
							break;
						}
						<responseText>5__5 = <req>5__3.downloadHandler.text;
						RT.Log("Send OK: " + <responseText>5__5.Substring(0, Math.Min(<responseText>5__5.Length, 500)));
						if (<responseText>5__5 != null && <responseText>5__5.Contains("\"elo\""))
						{
							try
							{
								ParseEloResponse(<responseText>5__5);
							}
							catch (Exception ex)
							{
								<ex>5__6 = ex;
								RT.LogError("ELO parse error: " + <ex>5__6.Message);
							}
						}
						if (<responseText>5__5 != null && <responseText>5__5.Contains("\"xp_change\""))
						{
							try
							{
								ParseXpResponse(<responseText>5__5);
							}
							catch (Exception ex)
							{
								<ex>5__7 = ex;
								RT.LogError("XP parse error: " + <ex>5__7.Message);
							}
						}
						if (<responseText>5__5 != null && <responseText>5__5.Contains("\"new_achievements\""))
						{
							try
							{
								ParseAchievementsResponse(<responseText>5__5, report.is_game_over);
							}
							catch (Exception ex)
							{
								<ex>5__8 = ex;
								RT.LogError("ACH parse error: " + <ex>5__8.Message);
							}
						}
						<responseText>5__5 = null;
						break;
					case 2:
						<>1__state = -3;
						((MonoBehaviour)RT.Instance).StartCoroutine(SendCoroutine(report, attempt + 1));
						break;
					}
					<>m__Finally1();
					<req>5__3 = null;
					return false;
				}
				catch
				{
					//try-fault
					((IDisposable)this).Dispose();
					throw;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			private void <>m__Finally1()
			{
				<>1__state = -1;
				if (<req>5__3 != null)
				{
					((IDisposable)<req>5__3).Dispose();
				}
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		private const int MaxAttempts = 5;

		private const int AttemptTimeout = 2;

		private const float RetryBaseDelay = 1f;

		public static void Send(RoundReport report)
		{
			if (RT.EnableTracking.Value && !string.IsNullOrEmpty(report.steam_id))
			{
				((MonoBehaviour)RT.Instance).StartCoroutine(SendCoroutine(report, 0));
			}
		}

		[IteratorStateMachine(typeof(<SendCoroutine>d__4))]
		private static IEnumerator SendCoroutine(RoundReport report, int attempt)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <SendCoroutine>d__4(0)
			{
				report = report,
				attempt = attempt
			};
		}

		private static void ParseEloResponse(string json)
		{
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
			float num = 0f;
			float num2 = 0f;
			float num3 = 0f;
			bool flag = false;
			List<EloPlayerData> list = new List<EloPlayerData>();
			MatchCollection matchCollection = Regex.Matches(json, "\\{[^{}]*\\}");
			foreach (Match item in matchCollection)
			{
				string value = item.Value;
				string text = ExtractStr(value, "steam_id");
				if (!string.IsNullOrEmpty(text))
				{
					list.Add(new EloPlayerData
					{
						steam_id = text,
						before = ExtractFloat(value, "before", 0f),
						after = ExtractFloat(value, "after", 0f),
						change = ExtractFloat(value, "change", 0f)
					});
				}
				else if (value.Contains("\"before\"") && value.Contains("\"change\""))
				{
					num = ExtractFloat(value, "before", 0f);
					num2 = ExtractFloat(value, "after", 0f);
					num3 = ExtractFloat(value, "change", 0f);
					flag = true;
				}
			}
			if (flag && num3 != 0f && RT.ShowEloNotifications.Value && !RT._eloShownThisGame)
			{
				RT._eloShownThisGame = true;
				int num4 = (int)Math.Round(num);
				int num5 = (int)Math.Round(num3);
				int num6 = (int)Math.Round(num2);
				string text2 = ((num5 > 0) ? "+" : "");
				MessageType val = (MessageType)((num5 > 0) ? 1 : 2);
				GameMessage.Show($"ELO {num4} -> {text2}{num5} -> {num6}", val, RT.NotifDuration);
				RT.Log($"ELO change (server): {num:F1} -> {text2}{num3:F1} -> {num2:F1}");
			}
			if (list.Count > 0)
			{
				Networking.BroadcastEloResults(list);
			}
		}

		[IteratorStateMachine(typeof(<PollEloFromHttp>d__6))]
		public static IEnumerator PollEloFromHttp(string sessionId, string steamId)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <PollEloFromHttp>d__6(0)
			{
				sessionId = sessionId,
				steamId = steamId
			};
		}

		private static void ParseXpResponse(string json)
		{
			XpChangeData xpChangeData = null;
			List<XpChangeData> list = new List<XpChangeData>();
			MatchCollection matchCollection = Regex.Matches(json, "\\{[^{}]*\\}");
			foreach (Match item in matchCollection)
			{
				string value = item.Value;
				if (value.Contains("\"xp_gained\""))
				{
					string text = ExtractStr(value, "steam_id");
					XpChangeData xpChangeData2 = new XpChangeData
					{
						steam_id = text,
						xp_gained = (int)ExtractFloat(value, "xp_gained", 0f),
						xp_before = (int)ExtractFloat(value, "xp_before", 0f),
						xp_after = (int)ExtractFloat(value, "xp_after", 0f),
						level_before = (int)ExtractFloat(value, "level_before", 1f),
						level_after = (int)ExtractFloat(value, "level_after", 1f)
					};
					if (string.IsNullOrEmpty(text))
					{
						xpChangeData = xpChangeData2;
					}
					else
					{
						list.Add(xpChangeData2);
					}
				}
			}
			if (xpChangeData != null && xpChangeData.xp_gained > 0 && RT.ShowXpNotifications.Value && !RT._xpShownThisGame)
			{
				RT._xpShownThisGame = true;
				((MonoBehaviour)RT.Instance).StartCoroutine(RT.ShowXpNotification(xpChangeData, null));
				RT.Log($"XP change (server): +{xpChangeData.xp_gained} Lv.{xpChangeData.level_before}->{xpChangeData.level_after}");
			}
			if (list.Count > 0)
			{
				Networking.BroadcastXpResults(list);
			}
		}

		private static void ParseAchievementsResponse(string json, bool isGameOver)
		{
			if (!isGameOver || !RT.ShowXpNotifications.Value)
			{
				return;
			}
			List<AchievementNotif> list = new List<AchievementNotif>();
			MatchCollection matchCollection = Regex.Matches(json, "\\{[^{}]*\\}");
			foreach (Match item in matchCollection)
			{
				string value = item.Value;
				if (value.Contains("\"icon\""))
				{
					string text = ExtractStr(value, "icon");
					string text2 = ExtractStr(value, "name");
					string id = ExtractStr(value, "id");
					if (!string.IsNullOrEmpty(text2))
					{
						list.Add(new AchievementNotif
						{
							id = id,
							icon = (text ?? "\ud83c\udfc5"),
							name = text2,
							xp = (int)ExtractFloat(value, "xp", 0f),
							description = (ExtractStr(value, "description") ?? "")
						});
					}
				}
			}
			if (list.Count > 0)
			{
				RT.Log($"New achievements: {list.Count}");
				((MonoBehaviour)RT.Instance).StartCoroutine(RT.ShowAchievementNotifications(list));
			}
		}

		private static string ExtractStr(string obj, string field)
		{
			Match match = Regex.Match(obj, "\"" + field + "\":\"((?:[^\"\\\\]|\\\\.)*)\"");
			return match.Success ? match.Groups[1].Value : null;
		}

		private static float ExtractFloat(string obj, string field, float defaultVal)
		{
			Match match = Regex.Match(obj, "\"" + field + "\":(-?[0-9]+(?:\\.[0-9]+)?)");
			if (!match.Success)
			{
				return defaultVal;
			}
			float result;
			return float.TryParse(match.Groups[1].Value, NumberStyles.Float, CultureInfo.InvariantCulture, out result) ? result : defaultVal;
		}
	}
	internal static class WinRateCache
	{
		[CompilerGenerated]
		private sealed class <LoadCoroutine>d__15 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			private float <waited>5__1;

			private int <lastCardCount>5__2;

			private float <stableTime>5__3;

			private float <stabilizeWaited>5__4;

			private string <modsParam>5__5;

			private string <url>5__6;

			private bool <serverSuccess>5__7;

			private int <currentCount>5__8;

			private HashSet<string> <modSet>5__9;

			private List<CardInfo> <allCards>5__10;

			private List<CardInfo>.Enumerator <>s__11;

			private CardInfo <card>5__12;

			private string <modName>5__13;

			private CardInfo[] <>s__14;

			private int <>s__15;

			private CardInfo <card>5__16;

			private string <modName>5__17;

			private ReadOnlyCollection<CardInfo> <hidden>5__18;

			private IEnumerator<CardInfo> <>s__19;

			private CardInfo <card>5__20;

			private string <modName>5__21;

			private List<string> <parts>5__22;

			private HashSet<string>.Enumerator <>s__23;

			private string <mod>5__24;

			private Exception <ex>5__25;

			private int <attempt>5__26;

			private float <delay>5__27;

			private UnityWebRequest <req>5__28;

			private string <rawText>5__29;

			private Exception <ex>5__30;

			private string <cached>5__31;

			private Exception <ex>5__32;

			private Exception <ex>5__33;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <LoadCoroutine>d__15(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				int num = <>1__state;
				if (num == -3 || num == 4)
				{
					try
					{
					}
					finally
					{
						<>m__Finally1();
					}
				}
				<modsParam>5__5 = null;
				<url>5__6 = null;
				<modSet>5__9 = null;
				<allCards>5__10 = null;
				<>s__11 = default(List<CardInfo>.Enumerator);
				<card>5__12 = null;
				<modName>5__13 = null;
				<>s__14 = null;
				<card>5__16 = null;
				<modName>5__17 = null;
				<hidden>5__18 = null;
				<>s__19 = null;
				<card>5__20 = null;
				<modName>5__21 = null;
				<parts>5__22 = null;
				<>s__23 = default(HashSet<string>.Enumerator);
				<mod>5__24 = null;
				<ex>5__25 = null;
				<req>5__28 = null;
				<rawText>5__29 = null;
				<ex>5__30 = null;
				<cached>5__31 = null;
				<ex>5__32 = null;
				<ex>5__33 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_009d: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a7: Expected O, but got Unknown
				//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
				//IL_0208: Expected O, but got Unknown
				//IL_0711: Unknown result type (might be due to invalid IL or missing references)
				//IL_071b: Expected O, but got Unknown
				try
				{
					switch (<>1__state)
					{
					default:
						return false;
					case 0:
						<>1__state = -1;
						_loading = true;
						<waited>5__1 = 0f;
						goto IL_00cf;
					case 1:
						<>1__state = -1;
						<waited>5__1 += 1f;
						goto IL_00cf;
					case 2:
						<>1__state = -1;
						<stabilizeWaited>5__4 += 1f;
						goto IL_0230;
					case 3:
						<>1__state = -1;
						goto IL_0731;
					case 4:
						{
							<>1__state = -3;
							if (<req>5__28.isNetworkError || <req>5__28.isHttpError)
							{
								RT.LogError("WinRateCache load error: " + <req>5__28.error + " (attempt " + (<attempt>5__26 + 1) + "/" + 3 + ")");
							}
							else
							{
								try
								{
									<rawText>5__29 = <req>5__28.downloadHandler.text;
									RT.Log("WinRateCache: HTTP=" + <req>5__28.responseCode + " length=" + <rawText>5__29.Length + " bytes");
									ParseResponse(<rawText>5__29);
									if (_cache.Count > 0)
									{
										_loaded = true;
										<serverSuccess>5__7 = true;
										SaveToFile(<rawText>5__29);
										RT.Log("WinRateCache: updated from server, " + _cache.Count + " cards");
										if (RT.ShowCardUpdateNotifications.Value)
										{
											GameMessage.Success("Card data updated (" + _cache.Count + " cards)", 5f);
										}
									}
									<rawText>5__29 = null;
								}
								catch (Exception ex)
								{
									<ex>5__30 = ex;
									RT.LogError("WinRateCache parse error: " + <ex>5__30.Message);
								}
							}
							<>m__Finally1();
							<req>5__28 = null;
							<attempt>5__26++;
							goto IL_0971;
						}
						IL_0246:
						<modsParam>5__5 = "";
						try
						{
							<modSet>5__9 = new HashSet<string>();
							<modSet>5__9.Add("Vanilla");
							try
							{
								<allCards>5__10 = Cards.all;
								if (<allCards>5__10 != null)
								{
									<>s__11 = <allCards>5__10.GetEnumerator();
									try
									{
										while (<>s__11.MoveNext())
										{
											<card>5__12 = <>s__11.Current;
											if (!((Object)(object)<card>5__12 == (Object)null) && !((Object)(object)((Component)<card>5__12).gameObject == (Object)null))
											{
												<modName>5__13 = DC.ExtractModName(((Object)((Component)<card>5__12).gameObject).name);
												<modSet>5__9.Add(<modName>5__13);
												<modName>5__13 = null;
												<card>5__12 = null;
											}
										}
									}
									finally
									{
										((IDisposable)<>s__11).Dispose();
									}
									<>s__11 = default(List<CardInfo>.Enumerator);
								}
								<allCards>5__10 = null;
							}
							catch
							{
								if ((Object)(object)CardChoice.instance != (Object)null && CardChoice.instance.cards != null)
								{
									<>s__14 = CardChoice.instance.cards;
									for (<>s__15 = 0; <>s__15 < <>s__14.Length; <>s__15++)
									{
										<card>5__16 = <>s__14[<>s__15];
										if (!((Object)(object)<card>5__16 == (Object)null))
										{
											<modName>5__17 = DC.ExtractModName(((Object)((Component)<card>5__16).gameObject).name);
											<modSet>5__9.Add(<modName>5__17);
											<modName>5__17 = null;
											<card>5__16 = null;
										}
									}
									<>s__14 = null;
								}
							}
							try
							{
								<hidden>5__18 = Cards.instance.HiddenCards;
								if (<hidden>5__18 != null)
								{
									<>s__19 = <hidden>5__18.GetEnumerator();
									try
									{
										while (<>s__19.MoveNext())
										{
											<card>5__20 = <>s__19.Current;
											if (!((Object)(object)<card>5__20 == (Object)null) && !((Object)(object)((Component)<card>5__20).gameObject == (Object)null))
											{
												<modName>5__21 = DC.ExtractModName(((Object)((Component)<card>5__20).gameObject).name);
												<modSet>5__9.Add(<modName>5__21);
												<modName>5__21 = null;
												<card>5__20 = null;
											}
										}
									}
									finally
									{
										if (<>s__19 != null)
										{
											<>s__19.Dispose();
										}
									}
									<>s__19 = null;
								}
								<hidden>5__18 = null;
							}
							catch
							{
							}
							RT.Log("WinRateCache: detected " + <modSet>5__9.Count + " installed mods");
							if (<modSet>5__9.Count > 0)
							{
								<parts>5__22 = new List<string>();
								<>s__23 = <modSet>5__9.GetEnumerator();
								try
								{
									while (<>s__23.MoveNext())
									{
										<mod>5__24 = <>s__23.Current;
										<parts>5__22.Add(Uri.EscapeDataString(<mod>5__24));
										<mod>5__24 = null;
									}
								}
								finally
								{
									((IDisposable)<>s__23).Dispose();
								}
								<>s__23 = default(HashSet<string>.Enumerator);
								<modsParam>5__5 = "?mods=" + string.Join(",", <parts>5__22.ToArray());
								<parts>5__22 = null;
							}
							<modSet>5__9 = null;
						}
						catch (Exception ex)
						{
							<ex>5__25 = ex;
							RT.LogError("WinRateCache: mod detection error: " + <ex>5__25.Message);
						}
						<url>5__6 = RT.ApiUrlValue + "/api/cards/winrates" + <modsParam>5__5;
						RT.Log("WinRateCache: loading from " + <url>5__6);
						<serverSuccess>5__7 = false;
						<attempt>5__26 = 0;
						goto IL_0971;
						IL_0230:
						if (<stabilizeWaited>5__4 < 45f)
						{
							<currentCount>5__8 = 0;
							try
							{
								if ((Object)(object)CardChoice.instance != (Object)null && CardChoice.instance.cards != null)
								{
									<currentCount>5__8 = CardChoice.instance.cards.Length;
								}
							}
							catch
							{
							}
							if (<currentCount>5__8 > 0 && <currentCount>5__8 == <lastCardCount>5__2)
							{
								<stableTime>5__3 += 1f;
								if (<stableTime>5__3 >= 15f)
								{
									RT.LogDebug("WinRateCache: card count stabilized at " + <currentCount>5__8 + " after " + <stabilizeWaited>5__4 + "s");
									goto IL_0246;
								}
							}
							else
							{
								<stableTime>5__3 = 0f;
								<lastCardCount>5__2 = <currentCount>5__8;
							}
							<>2__current = (object)new WaitForSeconds(1f);
							<>1__state = 2;
							return true;
						}
						goto IL_0246;
						IL_00e3:
						<lastCardCount>5__2 = 0;
						<stableTime>5__3 = 0f;
						<stabilizeWaited>5__4 = 0f;
						goto IL_0230;
						IL_00cf:
						if (<waited>5__1 < 45f)
						{
							try
							{
								if ((Object)(object)CardChoice.instance != (Object)null && CardChoice.instance.cards != null && CardChoice.instance.cards.Length > 10)
								{
									goto IL_00e3;
								}
							}
							catch
							{
							}
							<>2__current = (object)new WaitForSeconds(1f);
							<>1__state = 1;
							return true;
						}
						goto IL_00e3;
						IL_0971:
						if (<attempt>5__26 >= 3 || <serverSuccess>5__7)
						{
							break;
						}
						if (<attempt>5__26 > 0)
						{
							<delay>5__27 = 1f * Mathf.Pow(2f, (float)(<attempt>5__26 - 1));
							RT.LogDebug("WinRateCache: retry " + <attempt>5__26 + "/" + 2 + " in " + <delay>5__27 + "s");
							<>2__current = (object)new WaitForSeconds(<delay>5__27);
							<>1__state = 3;
							return true;
						}
						goto IL_0731;
						IL_0731:
						<req>5__28 = UnityWebRequest.Get(<url>5__6);
						<>1__state = -3;
						<req>5__28.timeout = 10;
						<>2__current = <req>5__28.SendWebRequest();
						<>1__state = 4;
						return true;
					}
					if (!<serverSuccess>5__7)
					{
						<cached>5__31 = LoadFromFile();
						if (<cached>5__31 != null)
						{
							try
							{
								ParseResponse(<cached>5__31);
								if (_cache.Count > 0)
								{
									_loaded = true;
									RT.Log("WinRateCache: loaded from local cache, " + _cache.Count + " cards");
									if (RT.ShowCardUpdateNotifications.Value)
									{
										GameMessage.Warn("Card data: using cached version (" + _cache.Count + " cards)", 5f);
									}
								}
							}
							catch (Exception ex)
							{
								<ex>5__32 = ex;
								RT.LogError("WinRateCache cached parse error: " + <ex>5__32.Message);
							}
						}
						else
						{
							RT.Log("WinRateCache: no local cache available");
							if (RT.ShowCardUpdateNotifications.Value)
							{
								GameMessage.Error("Card data unavailable", 5f);
							}
						}
						<cached>5__31 = null;
					}
					_loading = false;
					if (_onLoaded != null)
					{
						try
						{
							_onLoaded();
						}
						catch (Exception ex)
						{
							<ex>5__33 = ex;
							RT.LogError("WinRateCache onLoaded error: " + <ex>5__33.Message);
						}
						_onLoaded = null;
					}
					return false;
				}
				catch
				{
					//try-fault
					((IDisposable)this).Dispose();
					throw;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			private void <>m__Finally1()
			{
				<>1__state = -1;
				if (<req>5__28 != null)
				{
					((IDisposable)<req>5__28).Dispose();
				}
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		private static Dictionary<string, WinRateEntry> _cache = new Dictionary<string, WinRateEntry>();

		private static bool _loaded = false;

		private static bool _loading = false;

		private static Action _onLoaded;

		public static bool IsLoaded => _loaded;

		private static string CacheFilePath
		{
			get
			{
				string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)RT.Instance).Info.Location);
				return Path.Combine(directoryName, "winrate_cache.json");
			}
		}

		public static string MakeKey(string cardName, string modName, string rarity)
		{
			return cardName + "|" + (modName ?? "Vanilla") + "|" + (rarity ?? "Common");
		}

		public static WinRateEntry Get(string key)
		{
			if (_cache.TryGetValue(key, out var value))
			{
				return value;
			}
			return null;
		}

		public static List<string> FindSimilar(string cardName, int max)
		{
			List<string> list = new List<string>();
			if (string.IsNullOrEmpty(cardName))
			{
				return list;
			}
			string value = cardName.ToLowerInvariant();
			foreach (KeyValuePair<string, WinRateEntry> item in _cache)
			{
				if (list.Count >= max)
				{
					break;
				}
				if (item.Key.ToLowerInvariant().Contains(value))
				{
					list.Add(item.Key + "(wr=" + item.Value.round_win_rate + ")");
				}
			}
			return list;
		}

		public static void Clear()
		{
			_cache.Clear();
			_loaded = false;
		}

		public static void Load(Action onComplete = null)
		{
			if (!_loading)
			{
				_onLoaded = onComplete;
				((MonoBehaviour)RT.Instance).StartCoroutine(LoadCoroutine());
			}
		}

		private static void SaveToFile(string rawJson)
		{
			try
			{
				File.WriteAllText(CacheFilePath, rawJson, Encoding.UTF8);
				RT.LogDebug("WinRateCache: saved to " + CacheFilePath);
			}
			catch (Exception ex)
			{
				RT.LogError("WinRateCache save error: " + ex.Message);
			}
		}

		private static string LoadFromFile()
		{
			try
			{
				if (File.Exists(CacheFilePath))
				{
					string text = File.ReadAllText(CacheFilePath, Encoding.UTF8);
					if (!string.IsNullOrEmpty(text) && text.Length > 10)
					{
						RT.LogDebug("WinRateCache: loaded from file, length=" + text.Length);
						return text;
					}
				}
			}
			catch (Exception ex)
			{
				RT.LogError("WinRateCache file read error: " + ex.Message);
			}
			return null;
		}

		[IteratorStateMachine(typeof(<LoadCoroutine>d__15))]
		private static IEnumerator LoadCoroutine()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <LoadCoroutine>d__15(0);
		}

		private static void ParseResponse(string json)
		{
			_cache.Clear();
			if (string.IsNullOrEmpty(json) || json.Length < 3)
			{
				return;
			}
			MatchCollection matchCollection = Regex.Matches(json, "\\{[^{}]*\\}");
			int num = 0;
			foreach (Match item in matchCollection)
			{
				string value = item.Value;
				string text = ExtractJsonString(value, "cn");
				if (!string.IsNullOrEmpty(text))
				{
					string text2 = ExtractJsonString(value, "mn");
					string text3 = ExtractJsonString(value, "r");
					string text4 = ExtractJsonString(value, "t");
					float num2 = ExtractJsonFloat(value, "wr", 0f);
					float pick_rate = ExtractJsonFloat(value, "pr", 0f);
					float num3 = ExtractJsonFloat(value, "s", -9999f);
					num++;
					if (num <= 3)
					{
						RT.Log($"WinRateCache PARSE[{num}] => cn=\"{text}\" mn=\"{text2}\" r=\"{text3}\" wr={num2} t=\"{text4}\" s={num3}");
					}
					string key = MakeKey(text, text2, text3);
					float? score = ((num3 > -9000f) ? new float?(num3) : null);
					string[] tags = ((!string.IsNullOrEmpty(text4)) ? text4.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries) : null);
					_cache[key] = new WinRateEntry
					{
						round_win_rate = num2,
						pick_rate = pick_rate,
						tags = tags,
						score = score
					};
				}
			}
			RT.Log($"WinRateCache ParseResponse done: {num} objects, {_cache.Count} cached");
		}

		private static string ExtractJsonString(string obj, string field)
		{
			Match match = Regex.Match(obj, "\"" + field + "\":\"((?:[^\"\\\\]|\\\\.)*)\"");
			return match.Success ? match.Groups[1].Value : null;
		}

		private static float ExtractJsonFloat(string obj, string field, float defaultVal)
		{
			Match match = Regex.Match(obj, "\"" + field + "\":(-?[0-9]+(?:\\.[0-9]+)?)");
			if (!match.Success)
			{
				return defaultVal;
			}
			float result;
			return float.TryParse(match.Groups[1].Value, NumberStyles.Float, CultureInfo.InvariantCulture, out result) ? result : defaultVal;
		}
	}
	public class RoundCollector
	{
		public List<PickEvent> Picks = new List<PickEvent>();

		public List<CardData> Added = new List<CardData>();

		public List<CardData> Removed = new List<CardData>();

		public int PointsWon;

		public int PointsPlayed;

		public void Reset()
		{
			Picks.Clear();
			Added.Clear();
			Removed.Clear();
			PointsWon = 0;
			PointsPlayed = 0;
		}

		public void AddPick(PickEvent pick)
		{
			Picks.Add(pick);
			RT.LogDebug($"Collector: Added pick {pick.card_name}, total picks: {Picks.Count}");
		}

		public void AddAdded(CardData card)
		{
			Added.Add(card);
			RT.LogDebug($"Collector: Added card {card.card_name}, total added: {Added.Count}");
		}

		public void AddRemoved(CardData card)
		{
			Removed.Add(card);
			RT.LogDebug($"Collector: Removed card {card.card_name}, total removed: {Removed.Count}");
		}
	}
	[HarmonyPatch(typeof(CardChoice), "Pick")]
	internal class CardChoicePatch
	{
		private static FieldInfo SpawnedCardsField = AccessTools.Field(typeof(CardChoice), "spawnedCards");

		private static FieldInfo PickerTypeField = AccessTools.Field(typeof(CardChoice), "pickerType");

		private static void Postfix(CardChoice __instance, GameObject pickedCard, int ___pickrID)
		{
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Invalid comparison between Unknown and I4
			if (!RT.EnableTracking.Value || (Object)(object)pickedCard == (Object)null || PhotonNetwork.OfflineMode)
			{
				return;
			}
			try
			{
				PickerType val = (PickerType)(PickerTypeField?.GetValue(__instance));
				Player val2 = null;
				if ((int)val == 0)
				{
					Player[] playersInTeam = PlayerManager.instance.GetPlayersInTeam(___pickrID);
					val2 = ((playersInTeam != null && playersInTeam.Length != 0) ? playersInTeam[0] : null);
				}
				else if (___pickrID < PlayerManager.instance.players.Count)
				{
					val2 = PlayerManager.instance.players[___pickrID];
				}
				if ((Object)(object)val2 == (Object)null || !val2.data.view.IsMine)
				{
					return;
				}
				CardData cardData = DC.FromGO(pickedCard);
				if (cardData == null || string.IsNullOrEmpty(cardData.card_name))
				{
					return;
				}
				List<GameObject> list = SpawnedCardsField?.GetValue(__instance) as List<GameObject>;
				List<CardData> list2 = new List<CardData>();
				int num = 0;
				if (list != null)
				{
					for (int i = 0; i < list.Count; i++)
					{
						GameObject val3 = list[i];
						if ((Object)(object)val3 == (Object)null)
						{
							continue;
						}
						CardData cardData2 = DC.FromGO(val3);
						if (cardData2 != null && !string.IsNullOrEmpty(cardData2.card_name))
						{
							list2.Add(cardData2);
							if ((Object)(object)val3 == (Object)(object)pickedCard)
							{
								num = list2.Count - 1;
							}
						}
					}
				}
				PickEvent pick = new PickEvent
				{
					card_name = cardData.card_name,
					mod_name = cardData.mod_name,
					rarity = cardData.rarity,
					description = cardData.description,
					color_theme = cardData.color_theme,
					card_color = cardData.card_color,
					card_color_bg = cardData.card_color_bg,
					stats = cardData.stats,
					position = num,
					pick_number = RT.NextPickNumber(),
					offered_cards = list2
				};
				RT.Collector.AddPick(pick);
				if (RT._picksToChoose == 0 && list2.Count > 0)
				{
					RT._picksToChoose = list2.Count;
					RT.LogDebug($"Detected picks_to_choose={RT._picksToChoose}");
				}
				RT.Log($"Pick: {cardData.card_name} (pos {num + 1} of {list2.Count})");
			}
			catch (Exception ex)
			{
				RT.LogError("CardChoice.Pick error: " + ex.Message);
			}
		}
	}
	[HarmonyPatch(typeof(CardChoice), "StartPick")]
	internal class StartPickPatch
	{
		private static void Prefix(int picksToSet)
		{
			if (!RT.EnableTracking.Value || PhotonNetwork.OfflineMode)
			{
				return;
			}
			try
			{
				if (RT._drawsPerPickPhase == 0 && picksToSet > 0)
				{
					RT._drawsPerPickPhase = picksToSet;
					RT.LogDebug($"Detected draws_per_pick_phase={picksToSet}");
				}
			}
			catch (Exception ex)
			{
				RT.LogError("StartPick patch error: " + ex.Message);
			}
		}
	}
	[HarmonyPatch]
	internal class AssignCardPatch
	{
		private static MethodBase TargetMethod()
		{
			Type typeFromHandle = typeof(Cards);
			MethodInfo methodInfo = AccessTools.Method(typeFromHandle, "RPCA_AssignCard", new Type[7]
			{
				typeof(string),
				typeof(int),
				typeof(bool),
				typeof(string),
				typeof(float),
				typeof(float),
				typeof(bool)
			}, (Type[])null);
			if (methodInfo == null)
			{
				methodInfo = AccessTools.Method(typeFromHandle, "RPCA_AssignCard", new Type[6]
				{
					typeof(string),
					typeof(int),
					typeof(bool),
					typeof(string),
					typeof(float),
					typeof(float)
				}, (Type[])null);
			}
			return methodInfo;
		}

		private static void Postfix(string cardObjectName, int playerID, bool reassign)
		{
			if (!RT.EnableTracking.Value || reassign || PhotonNetwork.OfflineMode)
			{
				return;
			}
			try
			{
				Player val = PlayerManager.instance.players.Find((Player p) => p.playerID == playerID);
				if (!((Object)(object)val == (Object)null) && val.data.view.IsMine)
				{
					CardData cardData = DC.FromObjectName(cardObjectName);
					if (cardData != null && !string.IsNullOrEmpty(cardData.card_name))
					{
						RT.Collector.AddAdded(cardData);
						RT.Log("Added: " + cardData.card_name);
					}
				}
			}
			catch (Exception ex)
			{
				RT.LogError("RPCA_AssignCard error: " + ex.Message);
			}
		}
	}
	internal static class CardTracker
	{
		private static Dictionary<string, List<CardInfo>> _savedCardsById = new Dictionary<string, List<CardInfo>>();

		private static int _callCounter = 0;

		private static Stack<string> _callIdStack = new Stack<string>();

		public static void ClearAll()
		{
			_savedCardsById.Clear();
			_callCounter = 0;
			_callIdStack.Clear();
		}

		public static void RemoveAllCardsPrefix(Player player, bool clearBar)
		{
			if ((Object)(object)player == (Object)null || !((Object)(object)player.data?.view != (Object)null) || !player.data.view.IsMine || !RT.EnableTracking.Value || PhotonNetwork.OfflineMode)
			{
				return;
			}
			try
			{
				_callCounter++;
				string text = $"{player.playerID}_{_callCounter}_{Time.frameCount}";
				_callIdStack.Push(text);
				List<CardInfo> list = new List<CardInfo>();
				List<string> list2 = new List<string>();
				if (player.data?.currentCards != null)
				{
					foreach (CardInfo currentCard in player.data.currentCards)
					{
						if ((Object)(object)currentCard != (Object)null)
						{
							list.Add(currentCard);
							list2.Add(currentCard.cardName);
						}
					}
				}
				_savedCardsById[text] = list;
				if (_savedCardsById.Count > 100)
				{
					List<string> list3 = _savedCardsById.Keys.Take(_savedCardsById.Count - 50).ToList();
					foreach (string item in list3)
					{
						_savedCardsById.Remove(item);
					}
				}
				RT.LogDebug(string.Format("RemoveAllCardsPrefix: callId={0}, stack={1}, cards=[{2}]", text, _callIdStack.Count, string.Join(", ", list2)));
			}
			catch (Exception ex)
			{
				RT.LogError("RemoveAllCardsPrefix error: " + ex.Message);
			}
		}

		public static void AddCardsPostfix(Player player, CardInfo[] cards, bool[] reassigns, string[] twoLetterCodes, float[] forceDisplays, float[] forceDisplayDelays, bool addToCardBar)
		{
			if ((Object)(object)player == (Object)null)
			{
				return;
			}
			bool flag = (Object)(object)player.data?.view != (Object)null && player.data.view.IsMine;
			string text = null;
			if (flag && _callIdStack.Count > 0)
			{
				text = _callIdStack.Pop();
			}
			if (!flag)
			{
				return;
			}
			List<CardInfo> value = null;
			if (!string.IsNullOrEmpty(text) && _savedCardsById.TryGetValue(text, out value))
			{
				_savedCardsById.Remove(text);
			}
			List<string> list = new List<string>();
			if (cards != null)
			{
				for (int i = 0; i < cards.Length; i++)
				{
					if ((Object)(object)cards[i] != (Object)null)
					{
						bool flag2 = reassigns != null && i < reassigns.Length && reassigns[i];
						list.Add(cards[i].cardName + "(" + (flag2 ? "R" : "N") + ")");
					}
				}
			}
			List<string> values = value?.Select((CardInfo c) => c.cardName).ToList() ?? new List<string>();
			RT.LogDebug(string.Format("AddCardsPostfix: callId={0}, stack={1}, saved=[{2}], new=[{3}]", text, _callIdStack.Count, string.Join(", ", values), string.Join(", ", list)));
			if (!RT.EnableTracking.Value)
			{
				return;
			}
			if (cards == null || value == null || value.Count == 0)
			{
				RT.LogDebug("AddCardsPostfix: No data to process");
			}
			else
			{
				if (PhotonNetwork.OfflineMode)
				{
					return;
				}
				try
				{
					Dictionary<string, int> dictionary = new Dictionary<string, int>();
					for (int j = 0; j < cards.Length; j++)
					{
						if ((Object)(object)cards[j] != (Object)null && reassigns != null && j < reassigns.Length && reassigns[j])
						{
							string name = ((Object)cards[j]).name;
							if (!dictionary.ContainsKey(name))
							{
								dictionary[name] = 0;
							}
							dictionary[name]++;
						}
					}
					foreach (CardInfo item in value)
					{
						string name2 = ((Object)item).name;
						if (dictionary.ContainsKey(name2) && dictionary[name2] > 0)
						{
							dictionary[name2]--;
							continue;
						}
						RT.LogDebug("AddCardsPostfix: REMOVED " + item.cardName + " (name=" + name2 + ")");
						GameObject gameObject = ((Component)item).gameObject;
						CardData cardData = DC.FromInfo(item, (gameObject != null) ? ((Object)gameObject).name : null);
						if (cardData != null && !string.IsNullOrEmpty(cardData.card_name))
						{
							RT.Collector.AddRemoved(cardData);
							RT.Log("Removed: " + cardData.card_name);
						}
					}
				}
				catch (Exception ex)
				{
					RT.LogError("AddCardsPostfix error: " + ex.Message);
				}
			}
		}
	}
	internal static class DC
	{
		public static CardData FromGO(GameObject obj)
		{
			if ((Object)(object)obj == (Object)null)
			{
				return null;
			}
			CardInfo component = obj.GetComponent<CardInfo>();
			return ((Object)(object)component != (Object)null) ? FromInfo(component, ((Object)obj).name) : null;
		}

		public static CardData FromObjectName(string objectName)
		{
			if (string.IsNullOrEmpty(objectName))
			{
				return null;
			}
			try
			{
				CardInfo cardWithObjectName = Cards.instance.GetCardWithObjectName(objectName);
				if ((Object)(object)cardWithObjectName != (Object)null)
				{
					return FromInfo(cardWithObjectName, objectName);
				}
			}
			catch
			{
			}
			return ParseObjectName(objectName);
		}

		public static CardData ParseObjectName(string objectName)
		{
			string mod_name = ExtractModName(objectName);
			string card_name = objectName;
			if (objectName.StartsWith("__"))
			{
				string[] array = objectName.Split(new string[1] { "__" }, StringSplitOptions.RemoveEmptyEntries);
				if (array.Length >= 2)
				{
					card_name = array[1];
				}
			}
			return new CardData
			{
				card_name = card_name,
				mod_name = mod_name,
				rarity = "Common",
				description = null,
				color_theme = null,
				card_color = null,
				card_color_bg = null,
				rarity_color = null,
				rarity_color_off = null,
				stats = new List<Stat>(),
				allow_multiple = null
			};
		}

		public static string ExtractModName(string objectName)
		{
			if (string.IsNullOrEmpty(objectName))
			{
				return "Vanilla";
			}
			string text = objectName;
			int num = text.IndexOf("(Clone)");
			if (num >= 0)
			{
				text = text.Substring(0, num).Trim();
			}
			if (text.StartsWith("__"))
			{
				string[] array = text.Split(new string[1] { "__" }, StringSplitOptions.RemoveEmptyEntries);
				if (array.Length >= 1)
				{
					return array[0];
				}
			}
			return "Vanilla";
		}

		public static CardData FromInfo(CardInfo info, string objectName = null)
		{
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0206: Unknown result type (might be due to invalid IL or missing references)
			//IL_021e: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)info == (Object)null)
			{
				return null;
			}
			string mod_name = "Vanilla";
			object obj = objectName;
			if (obj == null)
			{
				GameObject gameObject = ((Component)info).gameObject;
				obj = ((gameObject != null) ? ((Object)gameObject).name : null) ?? "";
			}
			string text = (string)obj;
			if (text.StartsWith("__"))
			{
				string[] array = text.Split(new string[1] { "__" }, StringSplitOptions.RemoveEmptyEntries);
				if (array.Length >= 1)
				{
					mod_name = array[0];
				}
			}
			List<Stat> list = new List<Stat>();
			try
			{
				if (info.cardStats != null)
				{
					CardInfoStat[] cardStats = info.cardStats;
					foreach (CardInfoStat val in cardStats)
					{
						list.Add(new Stat
						{
							stat = (val.stat ?? ""),
							amount = (val.amount ?? ""),
							positive = val.positive
						});
					}
				}
			}
			catch
			{
			}
			string description = null;
			try
			{
				description = info.cardDestription;
			}
			catch
			{
			}
			string rarity = "Common";
			try
			{
				rarity = ((object)(Rarity)(ref info.rarity)).ToString();
			}
			catch
			{
			}
			string color_theme = null;
			try
			{
				color_theme = ((object)(CardThemeColorType)(ref info.colorTheme)).ToString();
			}
			catch
			{
			}
			string card_color = null;
			try
			{
				card_color = "#" + ColorUtility.ToHtmlStringRGB(info.cardColor);
			}
			catch
			{
			}
			string card_color_bg = null;
			try
			{
				if ((Object)(object)CardChoice.instance != (Object)null)
				{
					Color cardColor = CardChoice.instance.GetCardColor2(info.colorTheme);
					card_color_bg = "#" + ColorUtility.ToHtmlStringRGB(cardColor);
				}
			}
			catch
			{
			}
			bool? allow_multiple = null;
			try
			{
				allow_multiple = info.allowMultiple;
			}
			catch
			{
			}
			string rarity_color = null;
			string rarity_color_off = null;
			try
			{
				Rarity rarityData = RarityUtils.GetRarityData(info.rarity);
				if (rarityData != null)
				{
					rarity_color = "#" + ColorUtility.ToHtmlStringRGB(rarityData.color);
					rarity_color_off = "#" + ColorUtility.ToHtmlStringRGB(rarityData.colorOff);
				}
			}
			catch
			{
			}
			return new CardData
			{
				card_name = (info.cardName ?? ""),
				mod_name = mod_name,
				rarity = rarity,
				description = description,
				color_theme = color_theme,
				card_color = card_color,
				card_color_bg = card_color_bg,
				rarity_color = rarity_color,
				rarity_color_off = rarity_color_off,
				stats = list,
				allow_multiple = allow_multiple
			};
		}
	}
	[Serializable]
	public class CardData
	{
		public string card_name;

		public string mod_name;

		public string rarity;

		public string description;

		public string color_theme;

		public string card_color;

		public string card_color_bg;

		public string rarity_color;

		public string rarity_color_off;

		public List<Stat> stats = new List<Stat>();

		public bool? allow_multiple;
	}
	[Serializable]
	public class PickEvent : CardData
	{
		public int position;

		public int pick_number;

		public List<CardData> offered_cards = new List<CardData>();
	}
	[Serializable]
	public class Stat
	{
		public string stat;

		public string amount;

		public bool positive;
	}
	[Serializable]
	public class RoundReport
	{
		public string report_id;

		public string session_id;

		public int round_number;

		public string steam_id;

		public string nickname;

		public string player_color;

		public bool is_round_winner;

		public int points_won;

		public int points_played;

		public List<CardData> current_cards = new List<CardData>();

		public List<PickEvent> picks = new List<PickEvent>();

		public List<CardData> offered_cards = new List<CardData>();

		public List<CardData> added = new List<CardData>();

		public List<CardData> removed = new List<CardData>();

		public List<PlayerInfo> players = new List<PlayerInfo>();

		public string game_mode;

		public int player_count;

		public int points_to_win_round;

		public int rounds_to_win_game;

		public int game_continued_count;

		public int picks_to_choose;

		public int draws_per_pick_phase;

		public bool is_game_over;

		public bool is_legitimate_game_over;

		public string tracker_version;
	}
	[Serializable]
	public class PlayerInfo
	{
		public int player_id;

		public string steam_id;

		public string nickname;

		public string player_color;
	}
	public class WinRateEntry
	{
		public float round_win_rate;

		public float pick_rate;

		public string[] tags;

		public float? score;
	}
	[Serializable]
	public class EloPlayerData
	{
		public string steam_id;

		public float before;

		public float after;

		public float change;
	}
	internal class WinRateCacheDto
	{
		public string cn;

		public string mn;

		public string r;

		public float wr;

		public string t;

		public float s;
	}
	[Serializable]
	internal class LocalEloResponseDto
	{
		public float elo;

		public int elo_games;

		public int xp;

		public int level;
	}
	[Serializable]
	public class XpChangeData
	{
		public string steam_id;

		public int xp_gained;

		public int xp_before;

		public int xp_after;

		public int level_before;

		public int level_after;
	}
	[Serializable]
	public class AchievementNotif
	{
		public string id;

		public string icon;

		public string name;

		public int xp;

		public string description;
	}
	internal static class Networking
	{
		[CompilerGenerated]
		private sealed class <FetchLocalEloCoroutine>d__19 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public string steamId;

			private string <url>5__1;

			private UnityWebRequest <req>5__2;

			private string <text>5__3;

			private LocalEloResponseDto <resp>5__4;

			private int <displayElo>5__5;

			private int <xpInLevel>5__6;

			private int <xpForLevel>5__7;

			private int <pct>5__8;

			private Exception <ex>5__9;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <FetchLocalEloCoroutine>d__19(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				int num = <>1__state;
				if (num == -3 || num == 1)
				{
					try
					{
					}
					finally
					{
						<>m__Finally1();
					}
				}
				<url>5__1 = null;
				<req>5__2 = null;
				<text>5__3 = null;
				<resp>5__4 = null;
				<ex>5__9 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				bool result;
				try
				{
					switch (<>1__state)
					{
					default:
						result = false;
						break;
					case 0:
						<>1__state = -1;
						<url>5__1 = RT.ApiUrlValue + "/api/elo/me?steam_id=" + steamId;
						<req>5__2 = UnityWebRequest.Get(<url>5__1);
						<>1__state = -3;
						<req>5__2.timeout = 10;
						<>2__current = <req>5__2.SendWebRequest();
						<>1__state = 1;
						result = true;
						break;
					case 1:
						<>1__state = -3;
						if (<req>5__2.isNetworkError || <req>5__2.isHttpError)
						{
							RT.LogDebug("FetchLocalElo error: " + <req>5__2.error);
							result = false;
						}
						else
						{
							<text>5__3 = <req>5__2.downloadHandler.text;
							if (!string.IsNullOrEmpty(<text>5__3))
							{
								try
								{
									<resp>5__4 = JsonUtility.FromJson<LocalEloResponseDto>(<text>5__3);
									if (<resp>5__4 != null && <resp>5__4.elo > 0f)
									{
										<displayElo>5__5 = (int)Math.Round(<resp>5__4.elo);
										<xpInLevel>5__6 = <resp>5__4.xp - 300 * (<resp>5__4.level - 1) * <resp>5__4.level / 2;
										<xpForLevel>5__7 = 300 * <resp>5__4.level;
										<pct>5__8 = ((<xpForLevel>5__7 > 0) ? ((int)Math.Round((float)<xpInLevel>5__6 / (float)<xpForLevel>5__7 * 100f)) : 0);
										GameMessage.Show($"ELO: {<displayElo>5__5}  ({<resp>5__4.elo_games} games)", (MessageType)0, RT.NotifDuration);
										GameMessage.Show($"Lv.{<resp>5__4.level}  ({<pct>5__8}% to next)", (MessageType)0, RT.NotifDuration);
										RT.Log($"Current ELO: {<resp>5__4.elo:F1} ({<resp>5__4.elo_games} games) | Lv.{<resp>5__4.level} {<pct>5__8}% to next");
									}
									<resp>5__4 = null;
								}
								catch (Exception ex)
								{
									<ex>5__9 = ex;
									RT.LogError("FetchLocalElo parse: " + <ex>5__9.Message);
								}
								<text>5__3 = null;
								<>m__Finally1();
								<req>5__2 = null;
								result = false;
								break;
							}
							result = false;
						}
						<>m__Finally1();
						break;
					}
				}
				catch
				{
					//try-fault
					((IDisposable)this).Dispose();
					throw;
				}
				return result;
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			private void <>m__Finally1()
			{
				<>1__state = -1;
				if (<req>5__2 != null)
				{
					((IDisposable)<req>5__2).Dispose();
				}
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		[CompilerGenerated]
		private sealed class <PollEloFromRoomProperties>d__8 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			private string <mySteamId>5__1;

			private string <myKey>5__2;

			private float <elapsed>5__3;

			private Hashtable <roomProps>5__4;

			private string <value>5__5;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <PollEloFromRoomProperties>d__8(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<mySteamId>5__1 = null;
				<myKey>5__2 = null;
				<roomProps>5__4 = null;
				<value>5__5 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0127: Unknown result type (might be due to invalid IL or missing references)
				//IL_0131: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<mySteamId>5__1 = RT.GetSteamId();
					if (string.IsNullOrEmpty(<mySteamId>5__1))
					{
						return false;
					}
					<myKey>5__2 = GetEloKey(<mySteamId>5__1);
					<elapsed>5__3 = 0f;
					RT.LogDebug("ELO poll: waiting for room prop '" + <myKey>5__2 + "'");
					break;
				case 1:
					<>1__state = -1;
					<elapsed>5__3 += 0.5f;
					<roomProps>5__4 = null;
					break;
				}
				if (<elapsed>5__3 < 10f)
				{
					if (RT._eloShownThisGame)
					{
						return false;
					}
					if (PhotonNetwork.CurrentRoom == null)
					{
						RT.LogDebug("ELO poll: room is null, stopping");
						return false;
					}
					<roomProps>5__4 = ((RoomInfo)PhotonNetwork.CurrentRoom).CustomProperties;
					if (<roomProps>5__4 != null && ((Dictionary<object, object>)(object)<roomProps>5__4).ContainsKey((object)<myKey>5__2))
					{
						<value>5__5 = <roomProps>5__4[(object)<myKey>5__2] as string;
						if (!string.IsNullOrEmpty(<value>5__5))
						{
							ProcessEloPropertyValue(<value>5__5, <mySteamId>5__1);
							return false;
						}
						<value>5__5 = null;
					}
					<>2__current = (object)new WaitForSeconds(0.5f);
					<>1__state = 1;
					return true;
				}
				RT.LogDebug("ELO poll: timeout, falling back to HTTP check");
				return false;
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		[CompilerGenerated]
		private sealed class <PollXpFromRoomProperties>d__12 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			private string <mySteamId>5__1;

			private string <myKey>5__2;

			private float <elapsed>5__3;

			private Hashtable <roomProps>5__4;

			private string <value>5__5;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <PollXpFromRoomProperties>d__12(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<mySteamId>5__1 = null;
				<myKey>5__2 = null;
				<roomProps>5__4 = null;
				<value>5__5 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0127: Unknown result type (might be due to invalid IL or missing references)
				//IL_0131: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<mySteamId>5__1 = RT.GetSteamId();
					if (string.IsNullOrEmpty(<mySteamId>5__1))
					{
						return false;
					}
					<myKey>5__2 = GetXpKey(<mySteamId>5__1);
					<elapsed>5__3 = 0f;
					RT.LogDebug("XP poll: waiting for room prop '" + <myKey>5__2 + "'");
					break;
				case 1:
					<>1__state = -1;
					<elapsed>5__3 += 0.5f;
					<roomProps>5__4 = null;
					break;
				}
				if (<elapsed>5__3 < 10f)
				{
					if (RT._xpShownThisGame)
					{
						return false;
					}
					if (PhotonNetwork.CurrentRoom == null)
					{
						RT.LogDebug("XP poll: room is null, stopping");
						return false;
					}
					<roomProps>5__4 = ((RoomInfo)PhotonNetwork.CurrentRoom).CustomProperties;
					if (<roomProps>5__4 != null && ((Dictionary<object, object>)(object)<roomProps>5__4).ContainsKey((object)<myKey>5__2))
					{
						<value>5__5 = <roomProps>5__4[(object)<myKey>5__2] as string;
						if (!string.IsNullOrEmpty(<value>5__5))
						{
							ProcessXpPropertyValue(<value>5__5, <mySteamId>5__1);
							return false;
						}
						<value>5__5 = null;
					}
					<>2__current = (object)new WaitForSeconds(0.5f);
					<>1__state = 1;
					return true;
				}
				RT.LogDebug("XP poll: timeout");
				return false;
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		private const string ELO_PROP_PREFIX = "rt_elo_";

		private const string XP_PROP_PREFIX = "rt_xp_";

		private const float ELO_POLL_INTERVAL = 0.5f;

		private const float ELO_POLL_TIMEOUT = 10f;

		private static string GetEloKey(string steamId)
		{
			return string.Format("{0}{1}_{2}", "rt_elo_", steamId, RT._gameContinuedCount);
		}

		private static string GetXpKey(string steamId)
		{
			return string.Format("{0}{1}_{2}", "rt_xp_", steamId, RT._gameContinuedCount);
		}

		public static void BroadcastEloResults(List<EloPlayerData> allElo)
		{
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Expected O, but got Unknown
			if (PhotonNetwork.OfflineMode || allElo == null || allElo.Count == 0)
			{
				return;
			}
			if (PhotonNetwork.CurrentRoom == null)
			{
				RT.LogError("BroadcastEloResults: no current room");
				return;
			}
			Hashtable val = new Hashtable();
			int num = 0;
			foreach (EloPlayerData item in allElo)
			{
				if (!string.IsNullOrEmpty(item.steam_id))
				{
					string eloKey = GetEloKey(item.steam_id);
					string text2 = (string)(val[(object)eloKey] = string.Format(CultureInfo.InvariantCulture, "{0}|{1}|{2}", item.before, item.after, item.change));
					num++;
					RT.Log("BroadcastElo prop: ****" + item.steam_id.Substring(Math.Max(0, item.steam_id.Length - 4)) + " = " + text2);
				}
			}
			if (num > 0)
			{
				PhotonNetwork.CurrentRoom.SetCustomProperties(val, (Hashtable)null, (WebFlags)null);
				RT.Log($"BroadcastElo: set {num} room properties");
			}
		}

		public static void StartEloPropertyPoll()
		{
			if (RT.EnableTracking.Value && RT.ShowEloNotifications.Value && !RT._eloShownThisGame)
			{
				if (!PhotonNetwork.OfflineMode)
				{
					((MonoBehaviour)RT.Instance).StartCoroutine(PollEloFromRoomProperties());
				}
				string sessionId = RT.GetSessionId();
				string steamId = RT.GetSteamId();
				if (!string.IsNullOrEmpty(sessionId) && !string.IsNullOrEmpty(steamId))
				{
					((MonoBehaviour)RT.Instance).StartCoroutine(Api.PollEloFromHttp(sessionId, steamId));
				}
			}
		}

		[IteratorStateMachine(typeof(<PollEloFromRoomProperties>d__8))]
		private static IEnumerator PollEloFromRoomProperties()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <PollEloFromRoomProperties>d__8(0);
		}

		private static void ProcessEloPropertyValue(string value, string mySteamId)
		{
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				string[] array = value.Split(new char[1] { '|' });
				if (array.Length < 3)
				{
					return;
				}
				float num = float.Parse(array[0], CultureInfo.InvariantCulture);
				float num2 = float.Parse(array[1], CultureInfo.InvariantCulture);
				float num3 = float.Parse(array[2], CultureInfo.InvariantCulture);
				RT.Log($"ELO from room prop for ****{mySteamId.Substring(Math.Max(0, mySteamId.Length - 4))}: {num:F1} -> {num2:F1} ({num3:F1})");
				if (num <= 0f && num2 <= 0f)
				{
					RT.LogDebug("ELO room prop: invalid data (all zeros), skipping — HTTP poll will handle");
				}
				else if (!RT._eloShownThisGame)
				{
					RT._eloShownThisGame = true;
					if (num3 != 0f && RT.ShowEloNotifications.Value)
					{
						int num4 = (int)Math.Round(num);
						int num5 = (int)Math.Round(num3);
						int num6 = (int)Math.Round(num2);
						string text = ((num5 > 0) ? "+" : "");
						MessageType val = (MessageType)((num5 > 0) ? 1 : 2);
						GameMessage.Show($"ELO {num4} -> {text}{num5} -> {num6}", val, RT.NotifDuration);
						RT.Log($"ELO change (room prop): {num:F1} -> {text}{num3:F1} -> {num2:F1}");
					}
				}
			}
			catch (Exception ex)
			{
				RT.LogError("ELO prop parse error: " + ex.Message);
			}
		}

		public static void BroadcastXpResults(List<XpChangeData> allXp)
		{
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Expected O, but got Unknown
			if (PhotonNetwork.OfflineMode || allXp == null || allXp.Count == 0)
			{
				return;
			}
			if (PhotonNetwork.CurrentRoom == null)
			{
				RT.LogError("BroadcastXpResults: no current room");
				return;
			}
			Hashtable val = new Hashtable();
			int num = 0;
			foreach (XpChangeData item in allXp)
			{
				if (!string.IsNullOrEmpty(item.steam_id))
				{
					string xpKey = GetXpKey(item.steam_id);
					string text2 = (string)(val[(object)xpKey] = string.Format(CultureInfo.InvariantCulture, "{0}|{1}|{2}|{3}|{4}", item.xp_gained, item.xp_before, item.xp_after, item.level_before, item.level_after));
					num++;
					RT.LogDebug("BroadcastXp prop: ****" + item.steam_id.Substring(Math.Max(0, item.steam_id.Length - 4)) + " = " + text2);
				}
			}
			if (num > 0)
			{
				PhotonNetwork.CurrentRoom.SetCustomProperties(val, (Hashtable)null, (WebFlags)null);
				RT.Log($"BroadcastXp: set {num} room properties");
			}
		}

		public static void StartXpPropertyPoll()
		{
			if (!PhotonNetwork.OfflineMode && RT.EnableTracking.Value && RT.ShowXpNotifications.Value && !RT._xpShownThisGame)
			{
				((MonoBehaviour)RT.Instance).StartCoroutine(PollXpFromRoomProperties());
			}
		}

		[IteratorStateMachine(typeof(<PollXpFromRoomProperties>d__12))]
		private static IEnumerator PollXpFromRoomProperties()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <PollXpFromRoomProperties>d__12(0);
		}

		public static void ProcessXpPropertyValue(string value, string mySteamId)
		{
			try
			{
				string[] array = value.Split(new char[1] { '|' });
				if (array.Length >= 5)
				{
					XpChangeData xpChangeData = new XpChangeData
					{
						steam_id = mySteamId,
						xp_gained = int.Parse(array[0], CultureInfo.InvariantCulture),
						xp_before = int.Parse(array[1], CultureInfo.InvariantCulture),
						xp_after = int.Parse(array[2], CultureInfo.InvariantCulture),
						level_before = int.Parse(array[3], CultureInfo.InvariantCulture),
						level_after = int.Parse(array[4], CultureInfo.InvariantCulture)
					};
					RT.Log($"XP from room prop for ****{mySteamId.Substring(Math.Max(0, mySteamId.Length - 4))}: +{xpChangeData.xp_gained} Lv.{xpChangeData.level_before}->{xpChangeData.level_after}");
					if (!RT._xpShownThisGame && xpChangeData.xp_gained > 0 && RT.ShowXpNotifications.Value)
					{
						RT._xpShownThisGame = true;
						((MonoBehaviour)RT.Instance).StartCoroutine(RT.ShowXpNotification(xpChangeData, null));
					}
				}
			}
			catch (Exception ex)
			{
				RT.LogError("XP prop parse error: " + ex.Message);
			}
		}

		[UnboundRPC]
		public static void RPCA_CardRemoved(int playerID, string cardName, string cardObjectName)
		{
			RT.LogDebug($"RPCA_CardRemoved (ignored): player={playerID}, card={cardName}");
		}

		[UnboundRPC]
		public static void RPCA_ShareSteamId(int playerID, string steamId)
		{
			if (!string.IsNullOrEmpty(steamId))
			{
				RT.PlayerSteamIds[playerID] = steamId;
				RT.LogDebug($"Received Steam ID for player {playerID}: {steamId.Substring(0, Math.Min(4, steamId.Length))}****");
			}
		}

		[UnboundRPC]
		public static void RPCA_ShareEloResult(string data)
		{
		}

		public static void BroadcastSteamId()
		{
			if (!PhotonNetwork.OfflineMode)
			{
				Player localPlayer = RT.GetLocalPlayer();
				string steamId = RT.GetSteamId();
				if ((Object)(object)localPlayer != (Object)null && !string.IsNullOrEmpty(steamId))
				{
					NetworkingManager.RPC(typeof(Networking), "RPCA_ShareSteamId", new object[2] { localPlayer.playerID, steamId });
				}
			}
		}

		public static void FetchLocalElo()
		{
			string steamId = RT.GetSteamId();
			if (!string.IsNullOrEmpty(steamId) && RT.EnableTracking.Value && RT.ShowEloNotifications.Value)
			{
				((MonoBehaviour)RT.Instance).StartCoroutine(FetchLocalEloCoroutine(steamId));
			}
		}

		[IteratorStateMachine(typeof(<FetchLocalEloCoroutine>d__19))]
		private static IEnumerator FetchLocalEloCoroutine(string steamId)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <FetchLocalEloCoroutine>d__19(0)
			{
				steamId = steamId
			};
		}

		public static void EnsureSteamInfo()
		{
			if (RT._steamInfoTried)
			{
				return;
			}
			RT._steamInfoTried = true;
			try
			{
				Type type = Type.GetType("SteamManager, Assembly-CSharp");
				if (type == null)
				{
					return;
				}
				PropertyInfo property = type.GetProperty("Initialized", BindingFlags.Static | BindingFlags.Public);
				if (property == null || !(bool)property.GetValue(null))
				{
					return;
				}
				Type type2 = Type.GetType("Steamworks.SteamUser, Assembly-CSharp-firstpass") ?? Type.GetType("Steamworks.SteamUser, com.rlabrecque.steamworks.net");
				if (type2 != null)
				{
					MethodInfo method = type2.GetMethod("GetSteamID", BindingFlags.Static | BindingFlags.Public);
					if (method != null)
					{
						object obj = method.Invoke(null, null);
						if (obj != null)
						{
							RT._steamId = obj.ToString();
						}
					}
				}
				Type type3 = Type.GetType("Steamworks.SteamFriends, Assembly-CSharp-firstpass") ?? Type.GetType("Steamworks.SteamFriends, com.rlabrecque.steamworks.net");
				if (!(type3 != null))
				{
					return;
				}
				MethodInfo method2 = type3.GetMethod("GetPersonaName", BindingFlags.Static | BindingFlags.Public);
				if (method2 != null)
				{
					object obj2 = method2.Invoke(null, null);
					if (obj2 != null)
					{
						RT._steamNickname = obj2.ToString();
					}
				}
			}
			catch (Exception ex)
			{
				RT.LogError("Steam info error: " + ex.Message);
			}
		}

		public static void CollectSessionPlayers()
		{
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			RT.SessionPlayers.Clear();
			foreach (Player player in PlayerManager.instance.players)
			{
				if ((Object)(object)player == (Object)null || (Object)(object)player.data == (Object)null)
				{
					continue;
				}
				string value = null;
				if ((Object)(object)player.data.view != (Object)null && player.data.view.IsMine)
				{
					value = RT.GetSteamId();
				}
				else
				{
					RT.PlayerSteamIds.TryGetValue(player.playerID, out value);
				}
				string nickname = null;
				try
				{
					if ((Object)(object)player.data.view != (Object)null && player.data.view.Owner != null)
					{
						nickname = player.data.view.Owner.NickName;
					}
				}
				catch
				{
				}
				string player_color = null;
				try
				{
					PlayerSkin playerSkinColors = PlayerSkinBank.GetPlayerSkinColors(player.playerID);
					player_color = "#" + ColorUtility.ToHtmlStringRGB(playerSkinColors.color);
				}
				catch
				{
				}
				RT.SessionPlayers.Add(new PlayerInfo
				{
					player_id = player.playerID,
					steam_id = value,
					nickname = nickname,
					player_color = player_color
				});
			}
			RT.LogDebug($"Collected {RT.SessionPlayers.Count} session players, " + $"{RT.SessionPlayers.Count((PlayerInfo p) => p.steam_id != null)} with Steam ID");
		}

		public static void RefreshSessionPlayers()
		{
			if (RT.SessionPlayers.Count == 0)
			{
				CollectSessionPlayers();
				return;
			}
			bool flag = false;
			foreach (PlayerInfo sessionPlayer in RT.SessionPlayers)
			{
				if (sessionPlayer.steam_id == null && RT.PlayerSteamIds.TryGetValue(sessionPlayer.player_id, out var value) && !string.IsNullOrEmpty(value))
				{
					sessionPlayer.steam_id = value;
					flag = true;
					RT.LogDebug($"RefreshSessionPlayers: player {sessionPlayer.player_id} got steam_id");
				}
			}
			if (flag)
			{
				RT.LogDebug($"RefreshSessionPlayers: now {RT.SessionPlayers.Count((PlayerInfo p) => p.steam_id != null)}/{RT.SessionPlayers.Count} with Steam ID");
			}
		}
	}
	internal static class ReportSerializer
	{
		public static string ToJson(RoundReport r)
		{
			StringBuilder stringBuilder = new StringBuilder(4096);
			stringBuilder.Append('{');
			AppendStr(stringBuilder, "report_id", r.report_id);
			stringBuilder.Append(',');
			AppendStr(stringBuilder, "session_id", r.session_id);
			stringBuilder.Append(',');
			AppendInt(stringBuilder, "round_number", r.round_number);
			stringBuilder.Append(',');
			AppendStr(stringBuilder, "steam_id", r.steam_id);
			stringBuilder.Append(',');
			AppendStr(stringBuilder, "nickname", r.nickname);
			stringBuilder.Append(',');
			AppendStr(stringBuilder, "player_color", r.player_color);
			stringBuilder.Append(',');
			AppendBool(stringBuilder, "is_round_winner", r.is_round_winner);
			stringBuilder.Append(',');
			AppendInt(stringBuilder, "points_won", r.points_won);
			stringBuilder.Append(',');
			AppendInt(stringBuilder, "points_played", r.points_played);
			stringBuilder.Append(',');
			AppendKey(stringBuilder, "current_cards");
			AppendCardList(stringBuilder, r.current_cards);
			stringBuilder.Append(',');
			AppendKey(stringBuilder, "picks");
			AppendPickList(stringBuilder, r.picks);
			stringBuilder.Append(',');
			AppendKey(stringBuilder, "offered_cards");
			AppendCardList(stringBuilder, r.offered_cards);
			stringBuilder.Append(',');
			AppendKey(stringBuilder, "added");
			AppendCardList(stringBuilder, r.added);
			stringBuilder.Append(',');
			AppendKey(stringBuilder, "removed");
			AppendCardList(stringBuilder, r.removed);
			stringBuilder.Append(',');
			AppendKey(stringBuilder, "players");
			AppendPlayerList(stringBuilder, r.players);
			stringBuilder.Append(',');
			AppendStr(stringBuilder, "game_mode", r.game_mode);
			stringBuilder.Append(',');
			AppendInt(stringBuilder, "player_count", r.player_count);
			stringBuilder.Append(',');
			AppendInt(stringBuilder, "points_to_win_round", r.points_to_win_round);
			stringBuilder.Append(',');
			AppendInt(stringBuilder, "rounds_to_win_game", r.rounds_to_win_game);
			stringBuilder.Append(',');
			AppendInt(stringBuilder, "game_continued_count", r.game_continued_count);
			stringBuilder.Append(',');
			AppendInt(stringBuilder, "picks_to_choose", r.picks_to_choose);
			stringBuilder.Append(',');
			AppendInt(stringBuilder, "draws_per_pick_phase", r.draws_per_pick_phase);
			stringBuilder.Append(',');
			AppendBool(stringBuilder, "is_game_over", r.is_game_over);
			stringBuilder.Append(',');
			AppendBool(stringBuilder, "is_legitimate_game_over", r.is_legitimate_game_over);
			stringBuilder.Append(',');
			AppendStr(stringBuilder, "tracker_version", r.tracker_version);
			stringBuilder.Append('}');
			return stringBuilder.ToString();
		}

		private static void AppendKey(StringBuilder sb, string key)
		{
			sb.Append('"').Append(key).Append('"')
				.Append(':');
		}

		private static void AppendStr(StringBuilder sb, string key, string value)
		{
			AppendKey(sb, key);
			if (value == null)
			{
				sb.Append("null");
				return;
			}
			sb.Append('"');
			EscapeString(sb, value);
			sb.Append('"');
		}

		private static void AppendInt(StringBuilder sb, string key, int value)
		{
			AppendKey(sb, key);
			sb.Append(value);
		}

		private static void AppendBool(StringBuilder sb, string key, bool value)
		{
			AppendKey(sb, key);
			sb.Append(value ? "true" : "false");
		}

		private static void AppendNullableBool(StringBuilder sb, string key, bool? value)
		{
			AppendKey(sb, key);
			if (!value.HasValue)
			{
				sb.Append("null");
			}
			else
			{
				sb.Append(value.Value ? "true" : "false");
			}
		}

		private static void EscapeString(StringBuilder sb, string value)
		{
			foreach (char c in value)
			{
				switch (c)
				{
				case '"':
					sb.Append("\\\"");
					continue;
				case '\\':
					sb.Append("\\\\");
					continue;
				case '\n':
					sb.Append("\\n");
					continue;
				case '\r':
					sb.Append("\\r");
					continue;
				case '\t':
					sb.Append("\\t");
					continue;
				}
				if (c < ' ')
				{
					sb.AppendFormat("\\u{0:x4}", (int)c);
				}
				else
				{
					sb.Append(c);
				}
			}
		}

		private static void AppendCard(StringBuilder sb, CardData c)
		{
			sb.Append('{');
			AppendStr(sb, "card_name", c.card_name);
			sb.Append(',');
			AppendStr(sb, "mod_name", c.mod_name);
			sb.Append(',');
			AppendStr(sb, "rarity", c.rarity);
			sb.Append(',');
			AppendStr(sb, "description", c.description);
			sb.Append(',');
			AppendStr(sb, "color_theme", c.color_theme);
			sb.Append(',');
			AppendStr(sb, "card_color", c.card_color);
			sb.Append(',');
			AppendStr(sb, "card_color_bg", c.card_color_bg);
			sb.Append(',');
			AppendStr(sb, "rarity_color", c.rarity_color);
			sb.Append(',');
			AppendStr(sb, "rarity_color_off", c.rarity_color_off);
			sb.Append(',');
			AppendKey(sb, "stats");
			AppendStatList(sb, c.stats);
			sb.Append(',');
			AppendNullableBool(sb, "allow_multiple", c.allow_multiple);
			sb.Append('}');
		}

		private static void AppendPick(StringBuilder sb, PickEvent p)
		{
			sb.Append('{');
			AppendStr(sb, "card_name", p.card_name);
			sb.Append(',');
			AppendStr(sb, "mod_name", p.mod_name);
			sb.Append(',');
			AppendStr(sb, "rarity", p.rarity);
			sb.Append(',');
			AppendStr(sb, "description", p.description);
			sb.Append(',');
			AppendStr(sb, "color_theme", p.color_theme);
			sb.Append(',');
			AppendStr(sb, "card_color", p.card_color);
			sb.Append(',');
			AppendStr(sb, "card_color_bg", p.card_color_bg);
			sb.Append(',');
			AppendStr(sb, "rarity_color", p.rarity_color);
			sb.Append(',');
			AppendStr(sb, "rarity_color_off", p.rarity_color_off);
			sb.Append(',');
			AppendKey(sb, "stats");
			AppendStatList(sb, p.stats);
			sb.Append(',');
			AppendNullableBool(sb, "allow_multiple", p.allow_multiple);
			sb.Append(',');
			AppendInt(sb, "position", p.position);
			sb.Append(',');
			AppendInt(sb, "pick_number", p.pick_number);
			sb.Append(',');
			AppendKey(sb, "offered_cards");
			AppendCardList(sb, p.offered_cards);
			sb.Append('}');
		}

		private static void AppendPlayer(StringBuilder sb, PlayerInfo p)
		{
			sb.Append('{');
			AppendInt(sb, "player_id", p.player_id);
			sb.Append(',');
			AppendStr(sb, "steam_id", p.steam_id);
			sb.Append(',');
			AppendStr(sb, "nickname", p.nickname);
			sb.Append(',');
			AppendStr(sb, "player_color", p.player_color);
			sb.Append('}');
		}

		private static void AppendStat(StringBuilder sb, Stat s)
		{
			sb.Append('{');
			AppendStr(sb, "stat", s.stat);
			sb.Append(',');
			AppendStr(sb, "amount", s.amount);
			sb.Append(',');
			AppendBool(sb, "positive", s.positive);
			sb.Append('}');
		}

		private static void AppendCardList(StringBuilder sb, List<CardData> list)
		{
			sb.Append('[');
			if (list != null)
			{
				for (int i = 0; i < list.Count; i++)
				{
					if (i > 0)
					{
						sb.Append(',');
					}
					AppendCard(sb, list[i]);
				}
			}
			sb.Append(']');
		}

		private static void AppendPickList(StringBuilder sb, List<PickEvent> list)
		{
			sb.Append('[');
			if (list != null)
			{
				for (int i = 0; i < list.Count; i++)
				{
					if (i > 0)
					{
						sb.Append(',');
					}
					AppendPick(sb, list[i]);
				}
			}
			sb.Append(']');
		}

		private static void AppendPlayerList(StringBuilder sb, List<PlayerInfo> list)
		{
			sb.Append('[');
			if (list != null)
			{
				for (int i = 0; i < list.Count; i++)
				{
					if (i > 0)
					{
						sb.Append(',');
					}
					AppendPlayer(sb, list[i]);
				}
			}
			sb.Append(']');
		}

		private static void AppendStatList(StringBuilder sb, List<Stat> list)
		{
			sb.Append('[');
			if (list != null)
			{
				for (int i = 0; i < list.Count; i++)
				{
					if (i > 0)
					{
						sb.Append(',');
					}
					AppendStat(sb, list[i]);
				}
			}
			sb.Append(']');
		}
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInIncompatibility("r00t.systems.best.patch")]
	[BepInPlugin("com.rounds.tracker", "Rounds Tracker", "1.0.20")]
	[BepInProcess("Rounds.exe")]
	public class RT : BaseUnityPlugin
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static UnityAction <>9__56_0;

			public static UnityAction<bool> <>9__58_0;

			public static UnityAction<bool> <>9__58_1;

			public static UnityAction<bool> <>9__58_2;

			public static UnityAction<bool> <>9__58_3;

			public static UnityAction<bool> <>9__58_4;

			public static UnityAction<bool> <>9__58_5;

			public static UnityAction<bool> <>9__58_6;

			public static UnityAction<bool> <>9__58_7;

			public static UnityAction<bool> <>9__58_8;

			public static UnityAction<float> <>9__58_9;

			internal void <Start>b__56_0()
			{
				_pendingEnableTracking = EnableTracking.Value;
				_pendingShowWinRates = ShowWinRates.Value;
				_pendingShowPickRates = ShowPickRates.Value;
				_pendingShowCardScore = ShowCardScore.Value;
				_pendingShowCardTags = ShowCardTags.Value;
				_pendingShowUpdateNotif = ShowCardUpdateNotifications.Value;
				_pendingShowEloNotif = ShowEloNotifications.Value;
				_pendingShowXpNotif = ShowXpNotifications.Value;
				_pendingShowSendErrorNotif = ShowSendErrorNotifications.Value;
				_pendingNotifDuration = NotificationDuration.Value;
			}

			internal void <BuildMenu>b__58_0(bool val)
			{
				if (!_menuBuilding)
				{
					_pendingShowWinRates = val;
					_configDirty = true;
				}
			}

			internal void <BuildMenu>b__58_1(bool val)
			{
				if (!_menuBuilding)
				{
					_pendingShowPickRates = val;
					_configDirty = true;
				}
			}

			internal void <BuildMenu>b__58_2(bool val)
			{
				if (!_menuBuilding)
				{
					_pendingShowCardScore = val;
					_configDirty = true;
				}
			}

			internal void <BuildMenu>b__58_3(bool val)
			{
				if (!_menuBuilding)
				{
					_pendingShowCardTags = val;
					_configDirty = true;
				}
			}

			internal void <BuildMenu>b__58_4(bool val)
			{
				if (!_menuBuilding)
				{
					_pendingEnableTracking = val;
					_configDirty = true;
				}
			}

			internal void <BuildMenu>b__58_5(bool val)
			{
				if (!_menuBuilding)
				{
					_pendingShowUpdateNotif = val;
					_configDirty = true;
				}
			}

			internal void <BuildMenu>b__58_6(bool val)
			{
				if (!_menuBuilding)
				{
					_pendingShowEloNotif = val;
					_configDirty = true;
				}
			}

			internal void <BuildMenu>b__58_7(bool val)
			{
				if (!_menuBuilding)
				{
					_pendingShowXpNotif = val;
					_configDirty = true;
				}
			}

			internal void <BuildMenu>b__58_8(bool val)
			{
				if (!_menuBuilding)
				{
					_pendingShowSendErrorNotif = val;
					_configDirty = true;
				}
			}

			internal void <BuildMenu>b__58_9(float val)
			{
				if (!_menuBuilding)
				{
					_pendingNotifDuration = (int)val;
					_configDirty = true;
				}
			}
		}

		[CompilerGenerated]
		private sealed class <OnGameEnd>d__66 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public IGameModeHandler gm;

			public RT <>4__this;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <OnGameEnd>d__66(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				if (<>1__state != 0)
				{
					return false;
				}
				<>1__state = -1;
				if (!EnableTracking.Value || PhotonNetwork.OfflineMode)
				{
					return false;
				}
				if (_gameOverSent)
				{
					LogDebug("GameEnd: already sent from PointEnd-GameOver, skip");
					return false;
				}
				if (_lastRoundSent < _roundNumber + 1)
				{
					_roundNumber++;
					<>4__this.SendRoundReport("GameEnd");
					_collector.Reset();
					Networking.StartEloPropertyPoll();
					Networking.StartXpPropertyPoll();
				}
				else
				{
					LogDebug("GameEnd: round already sent, skip");
				}
				return false;
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		[CompilerGenerated]
		private sealed class <OnGameStart>d__61 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public IGameModeHandler gm;

			public RT <>4__this;

			private Room <room>5__1;

			private Exception <ex>5__2;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <OnGameStart>d__61(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<room>5__1 = null;
				<ex>5__2 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0121: Unknown result type (might be due to invalid IL or missing references)
				//IL_012b: Expected O, but got Unknown
				//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
				//IL_0105: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					if (_configDirty)
					{
						FlushConfig();
					}
					try
					{
						<room>5__1 = PhotonNetwork.CurrentRoom;
						Room obj = <room>5__1;
						Log(string.Format("[RT-DEBUG] Room={0}, IsOffline={1}", ((obj != null) ? obj.Name : null) ?? "null", PhotonNetwork.OfflineMode));
						<room>5__1 = null;
					}
					catch (Exception ex)
					{
						<ex>5__2 = ex;
						LogError("[RT-DEBUG] Room error: " + <ex>5__2.Message);
					}
					ResetSession();
					CardTracker.ClearAll();
					_collector.Reset();
					LogDebug("Game started, session reset");
					if (!EnableTracking.Value || PhotonNetwork.OfflineMode)
					{
						return false;
					}
					Networking.BroadcastSteamId();
					<>2__current = (object)new WaitForSeconds(2f);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					Networking.BroadcastSteamId();
					<>2__current = (object)new WaitForSeconds(1f);
					<>1__state = 2;
					return true;
				case 2:
					<>1__state = -1;
					Networking.CollectSessionPlayers();
					return false;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		[CompilerGenerated]
		private sealed class <OnPickEnd>d__63 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public IGameModeHandler gm;

			public RT <>4__this;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <OnPickEnd>d__63(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				if (<>1__state != 0)
				{
					return false;
				}
				<>1__state = -1;
				LogDebug($"PickEnd: picks={_collector.Picks.Count}, added={_collector.Added.Count}, removed={_collector.Removed.Count}");
				return false;
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		[CompilerGenerated]
		private sealed class <OnPickStart>d__62 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public IGameModeHandler gm;

			public RT <>4__this;

			private int <currentThreshold>5__1;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <OnPickStart>d__62(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				if (<>1__state != 0)
				{
					return false;
				}
				<>1__state = -1;
				if (_configDirty)
				{
					FlushConfig();
				}
				<currentThreshold>5__1 = GetRoundsToWinGame().GetValueOrDefault();
				if (_lastKnownThreshold > 0 && <currentThreshold>5__1 > _lastKnownThreshold && !_gameOverSent)
				{
					LogDebug($"PickStart: missed game-over detected (threshold {_lastKnownThreshold}→{<currentThreshold>5__1}), sending retroactive report");
					_roundNumber++;
					<>4__this.SendRoundReport("PickStart-MissedGameOver");
					_collector.Reset();
					_gameOverSent = true;
					Networking.StartEloPropertyPoll();
					Networking.StartXpPropertyPoll();
				}
				if (<currentThreshold>5__1 > 0)
				{
					_lastKnownThreshold = <currentThreshold>5__1;
				}
				if (_gameOverSent)
				{
					_gameContinuedCount++;
					_eloShownThisGame = false;
					_xpShownThisGame = false;
					LogDebug($"PickStart: game continued (count={_gameContinuedCount})");
					_gameOverSent = false;
				}
				return false;
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		[CompilerGenerated]
		private sealed class <OnPointEnd>d__64 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public IGameModeHandler gm;

			public RT <>4__this;

			private Player <winner>5__1;

			private Player <local>5__2;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <OnPointEnd>d__64(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<winner>5__1 = null;
				<local>5__2 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				if (<>1__state != 0)
				{
					return false;
				}
				<>1__state = -1;
				if (!EnableTracking.Value || PhotonNetwork.OfflineMode)
				{
					return false;
				}
				<winner>5__1 = PlayerManager.instance.GetLastPlayerAlive();
				<local>5__2 = GetLocalPlayer();
				if ((Object)(object)<local>5__2 != (Object)null)
				{
					_collector.PointsPlayed++;
					if ((Object)(object)<winner>5__1 != (Object)null && <winner>5__1.data.view.IsMine)
					{
						_collector.PointsWon++;
					}
				}
				LogDebug($"PointEnd: {_collector.PointsWon}/{_collector.PointsPlayed}");
				if (<>4__this.IsGameOver(gm))
				{
					_roundNumber++;
					<>4__this.SendRoundReport("PointEnd-GameOver");
					_collector.Reset();
					_gameOverSent = true;
					Networking.StartEloPropertyPoll();
					Networking.StartXpPropertyPoll();
				}
				return false;
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		[CompilerGenerated]
		private sealed class <OnRoundEnd>d__65 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public IGameModeHandler gm;

			public RT <>4__this;

			private bool <gameOver>5__1;

			private string <source>5__2;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <OnRoundEnd>d__65(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<source>5__2 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				if (<>1__state != 0)
				{
					return false;
				}
				<>1__state = -1;
				if (!EnableTracking.Value || PhotonNetwork.OfflineMode)
				{
					return false;
				}
				if (_gameOverSent)
				{
					LogDebug("RoundEnd: already sent from PointEnd-GameOver, skip");
					return false;
				}
				_roundNumber++;
				<gameOver>5__1 = <>4__this.IsGameOver(gm);
				<source>5__2 = (<gameOver>5__1 ? "RoundEnd-GameOver" : "RoundEnd");
				<>4__this.SendRoundReport(<source>5__2);
				_collector.Reset();
				if (<gameOver>5__1)
				{
					_gameOverSent = true;
					Networking.StartEloPropertyPoll();
					Networking.StartXpPropertyPoll();
				}
				return false;
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		[CompilerGenerated]
		private sealed class <ShowAchievementNotifications>d__85 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public List<AchievementNotif> achievements;

			private List<AchievementNotif>.Enumerator <>s__1;

			private AchievementNotif <ach>5__2;

			private string <desc>5__3;

			private string <msg>5__4;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <ShowAchievementNotifications>d__85(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>s__1 = default(List<AchievementNotif>.Enumerator);
				<ach>5__2 = null;
				<desc>5__3 = null;
				<msg>5__4 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				if (<>1__state != 0)
				{
					return false;
				}
				<>1__state = -1;
				if (achievements == null || achievements.Count == 0)
				{
					return false;
				}
				<>s__1 = achievements.GetEnumerator();
				try
				{
					while (<>s__1.MoveNext())
					{
						<ach>5__2 = <>s__1.Current;
						<desc>5__3 = ((!string.IsNullOrEmpty(<ach>5__2.description)) ? (" (" + <ach>5__2.description + ")") : "");
						<msg>5__4 = $"[Achievement] {<ach>5__2.name}! +{<ach>5__2.xp} XP{<desc>5__3}";
						GameMessage.Show(<msg>5__4, (MessageType)1, NotifDuration);
						Log(<msg>5__4);
						<desc>5__3 = null;
						<msg>5__4 = null;
						<ach>5__2 = null;
					}
				}
				finally
				{
					((IDisposable)<>s__1).Dispose();
				}
				<>s__1 = default(List<AchievementNotif>.Enumerator);
				return false;
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		[CompilerGenerated]
		private sealed class <ShowXpNotification>d__84 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public XpChangeData xp;

			public List<AchievementNotif> achievements;

			private bool <leveledUp>5__1;

			private string <msg>5__2;

			private int <xpInLevel>5__3;

			private int <xpForLevel>5__4;

			private int <pct>5__5;

			private List<AchievementNotif>.Enumerator <>s__6;

			private AchievementNotif <ach>5__7;

			private string <achDesc>5__8;

			private string <achMsg>5__9;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <ShowXpNotification>d__84(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<msg>5__2 = null;
				<>s__6 = default(List<AchievementNotif>.Enumerator);
				<ach>5__7 = null;
				<achDesc>5__8 = null;
				<achMsg>5__9 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				if (<>1__state != 0)
				{
					return false;
				}
				<>1__state = -1;
				if (xp == null || xp.xp_gained <= 0)
				{
					return false;
				}
				<leveledUp>5__1 = xp.level_after > xp.level_before;
				if (<leveledUp>5__1)
				{
					<msg>5__2 = $"+{xp.xp_gained} XP  Level up! Lv.{xp.level_after}";
				}
				else
				{
					<xpInLevel>5__3 = xp.xp_after - 300 * (xp.level_after - 1) * xp.level_after / 2;
					<xpForLevel>5__4 = 300 * xp.level_after;
					<pct>5__5 = ((<xpForLevel>5__4 > 0) ? ((int)Math.Round((float)<xpInLevel>5__3 / (float)<xpForLevel>5__4 * 100f)) : 0);
					<msg>5__2 = $"+{xp.xp_gained} XP  Lv.{xp.level_after}  ({<pct>5__5}% to next)";
				}
				GameMessage.Show(<msg>5__2, (MessageType)0, NotifDuration);
				Log("[XP] " + <msg>5__2);
				if (achievements != null && achievements.Count > 0)
				{
					<>s__6 = achievements.GetEnumerator();
					try
					{
						while (<>s__6.MoveNext())
						{
							<ach>5__7 = <>s__6.Current;
							<achDesc>5__8 = ((!string.IsNullOrEmpty(<ach>5__7.description)) ? (" (" + <ach>5__7.description + ")") : "");
							<achMsg>5__9 = $"[Achievement] {<ach>5__7.name}! +{<ach>5__7.xp} XP{<achDesc>5__8}";
							GameMessage.Show(<achMsg>5__9, (MessageType)1, NotifDuration);
							Log(<achMsg>5__9);
							<achDesc>5__8 = null;
							<achMsg>5__9 = null;
							<ach>5__7 = null;
						}
					}
					finally
					{
						((IDisposable)<>s__6).Dispose();
					}
					<>s__6 = default(List<AchievementNotif>.Enumerator);
				}
				return false;
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		public const string ModId = "com.rounds.tracker";

		public const string ModName = "Rounds Tracker";

		public const string Version = "1.0.20";

		public const string SettingsResetVersion = "1";

		public const bool ENABLE_LOGS = false;

		public static ConfigEntry<bool> EnableTracking;

		public static ConfigEntry<bool> ShowWinRates;

		public static ConfigEntry<bool> ShowPickRates;

		public static ConfigEntry<bool> ShowCardScore;

		public static ConfigEntry<bool> ShowCardTags;

		public static ConfigEntry<bool> ShowCardUpdateNotifications;

		public static ConfigEntry<bool> ShowEloNotifications;

		public static ConfigEntry<bool> ShowXpNotifications;

		public static ConfigEntry<bool> ShowSendErrorNotifications;

		public static ConfigEntry<int> NotificationDur