Decompiled source of Hyland Point Casino App v1.3.3

Mods/HylandPointCasino.dll

Decompiled 4 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using HylandPointCasino;
using MelonLoader;
using S1API.DeadDrops;
using S1API.Items;
using S1API.Money;
using S1API.PhoneApp;
using S1API.UI;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: MelonInfo(typeof(Core), "HylandPointCasino", "1.3.0", "Ghostx10742", null)]
[assembly: MelonGame("TVGS", "Schedule I")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = "")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
namespace HylandPointCasino;

public class BlackjackGame
{
	private CasinoApp _app;

	private Text _pt;

	private Text _ptt;

	private Text _dt;

	private Text _dtt;

	private Text _res;

	private Text _betText;

	private GameObject _betRow;

	private GameObject _actionRow;

	private List<int> _deck;

	private List<int> _ph;

	private List<int> _dh;

	private int _currentBet;

	private bool _gameActive;

	public BlackjackGame(CasinoApp app, GameObject panel)
	{
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_0040: Expected O, but got Unknown
		//IL_0161: Unknown result type (might be due to invalid IL or missing references)
		//IL_029a: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_033d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0384: Unknown result type (might be due to invalid IL or missing references)
		//IL_03d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_024b: Unknown result type (might be due to invalid IL or missing references)
		_app = app;
		_deck = Shuf();
		VerticalLayoutGroup obj = panel.AddComponent<VerticalLayoutGroup>();
		((LayoutGroup)obj).childAlignment = (TextAnchor)1;
		((HorizontalOrVerticalLayoutGroup)obj).spacing = 5f;
		((LayoutGroup)obj).padding = new RectOffset(8, 8, 8, 8);
		((HorizontalOrVerticalLayoutGroup)obj).childForceExpandWidth = true;
		((HorizontalOrVerticalLayoutGroup)obj).childForceExpandHeight = false;
		UIFactory.Text("H", "BLACKJACK", panel.transform, 16, (TextAnchor)4, (FontStyle)1);
		UIFactory.Text("DL", "Dealer:", panel.transform, 11, (TextAnchor)3, (FontStyle)0);
		_dt = UIFactory.Text("DC", "", panel.transform, 16, (TextAnchor)4, (FontStyle)1);
		_dtt = UIFactory.Text("DT", "", panel.transform, 11, (TextAnchor)4, (FontStyle)0);
		UIFactory.Text("PL", "You:", panel.transform, 11, (TextAnchor)3, (FontStyle)0);
		_pt = UIFactory.Text("PC", "", panel.transform, 16, (TextAnchor)4, (FontStyle)1);
		_ptt = UIFactory.Text("PT", "", panel.transform, 11, (TextAnchor)4, (FontStyle)0);
		_res = UIFactory.Text("Res", "", panel.transform, 13, (TextAnchor)4, (FontStyle)1);
		_betText = UIFactory.Text("Bet", "Bet: $0", panel.transform, 14, (TextAnchor)4, (FontStyle)1);
		_betRow = UIFactory.Panel("BR", panel.transform, Color.clear, (Vector2?)null, (Vector2?)null, false);
		_betRow.AddComponent<LayoutElement>().preferredHeight = 42f;
		HorizontalLayoutGroup obj2 = _betRow.AddComponent<HorizontalLayoutGroup>();
		((HorizontalOrVerticalLayoutGroup)obj2).spacing = 4f;
		((HorizontalOrVerticalLayoutGroup)obj2).childForceExpandWidth = true;
		((HorizontalOrVerticalLayoutGroup)obj2).childForceExpandHeight = true;
		int[] array = new int[5] { 25, 50, 100, 500, 1000 };
		for (int i = 0; i < array.Length; i++)
		{
			int num = array[i];
			int amt = num;
			string label = ((num >= 1000) ? "$1K" : ("$" + num));
			UI.BtnSized("Q" + num, label, _betRow.transform, delegate
			{
				_currentBet = amt;
				_betText.text = "Bet: $" + amt;
			}, new Color(0.25f, 0.25f, 0.35f), 55f, 38f, 11);
		}
		UI.Btn("Deal", "DEAL", panel.transform, Deal, new Color(0.15f, 0.4f, 0.15f), 14);
		_actionRow = UIFactory.Panel("AR", panel.transform, Color.clear, (Vector2?)null, (Vector2?)null, false);
		_actionRow.AddComponent<LayoutElement>().preferredHeight = 42f;
		HorizontalLayoutGroup obj3 = _actionRow.AddComponent<HorizontalLayoutGroup>();
		((HorizontalOrVerticalLayoutGroup)obj3).spacing = 6f;
		((HorizontalOrVerticalLayoutGroup)obj3).childForceExpandWidth = true;
		((HorizontalOrVerticalLayoutGroup)obj3).childForceExpandHeight = true;
		UI.BtnSized("Hit", "HIT", _actionRow.transform, Hit, new Color(0.2f, 0.45f, 0.2f), 100f, 38f, 14);
		UI.BtnSized("Stand", "STAND", _actionRow.transform, Stand, new Color(0.45f, 0.2f, 0.2f), 100f, 38f, 14);
		_actionRow.SetActive(false);
		UI.Btn("Back", "BACK TO LOBBY", panel.transform, delegate
		{
			_app.ShowGame("menu");
		}, new Color(0.3f, 0.3f, 0.3f), 11);
	}

	private void Deal()
	{
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		//IL_0056: Unknown result type (might be due to invalid IL or missing references)
		//IL_0084: Unknown result type (might be due to invalid IL or missing references)
		//IL_0162: Unknown result type (might be due to invalid IL or missing references)
		if (_gameActive)
		{
			return;
		}
		if (_currentBet <= 0)
		{
			_res.text = "Pick a bet!";
			((Graphic)_res).color = Color.yellow;
			return;
		}
		if (!CasinoBank.CanAfford(_currentBet))
		{
			_res.text = "Not enough credit!";
			((Graphic)_res).color = Color.red;
			return;
		}
		if (!CasinoBank.PlaceBet(_currentBet))
		{
			_res.text = "Bet failed!";
			((Graphic)_res).color = Color.red;
			return;
		}
		_gameActive = true;
		_res.text = "";
		_ph = new List<int>
		{
			Dr(),
			Dr()
		};
		_dh = new List<int>
		{
			Dr(),
			Dr()
		};
		_betRow.SetActive(false);
		_actionRow.SetActive(true);
		UpdUI(hide: true);
		if (Tot(_ph) == 21)
		{
			int num = (int)((float)_currentBet * 2.5f);
			CasinoBank.PayWinnings(num);
			_res.text = "BLACKJACK! +$" + num;
			((Graphic)_res).color = new Color(1f, 0.84f, 0f);
			EndHand();
		}
		_app.RefreshBalance();
	}

	private void Hit()
	{
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		if (_gameActive)
		{
			_ph.Add(Dr());
			UpdUI(hide: true);
			if (Tot(_ph) > 21)
			{
				_res.text = "BUST! -$" + _currentBet;
				((Graphic)_res).color = Color.red;
				EndHand();
			}
		}
	}

	private void Stand()
	{
		//IL_0095: Unknown result type (might be due to invalid IL or missing references)
		//IL_0108: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
		if (_gameActive)
		{
			while (Tot(_dh) < 17)
			{
				_dh.Add(Dr());
			}
			UpdUI(hide: false);
			int num = Tot(_ph);
			int num2 = Tot(_dh);
			if (num2 > 21 || num > num2)
			{
				int num3 = _currentBet * 2;
				CasinoBank.PayWinnings(num3);
				_res.text = "You win! +$" + num3;
				((Graphic)_res).color = new Color(0.2f, 1f, 0.2f);
			}
			else if (num == num2)
			{
				CasinoBank.PayWinnings(_currentBet);
				_res.text = "Push! Bet returned";
				((Graphic)_res).color = new Color(0.8f, 0.8f, 0.2f);
			}
			else
			{
				_res.text = "Dealer wins! -$" + _currentBet;
				((Graphic)_res).color = Color.red;
			}
			EndHand();
			_app.RefreshBalance();
		}
	}

	private void EndHand()
	{
		_gameActive = false;
		_actionRow.SetActive(false);
		_betRow.SetActive(true);
		UpdUI(hide: false);
	}

	private void UpdUI(bool hide)
	{
		_pt.text = HS(_ph);
		_ptt.text = "Total: " + Tot(_ph);
		if (hide && _dh.Count >= 2)
		{
			_dt.text = CN(_dh[0]) + "  [?]";
			_dtt.text = "";
		}
		else
		{
			_dt.text = HS(_dh);
			_dtt.text = "Total: " + Tot(_dh);
		}
	}

	private List<int> Shuf()
	{
		List<int> list = new List<int>();
		for (int i = 0; i < 52; i++)
		{
			list.Add(i);
		}
		for (int num = list.Count - 1; num > 0; num--)
		{
			int index = Random.Range(0, num + 1);
			int value = list[num];
			list[num] = list[index];
			list[index] = value;
		}
		return list;
	}

	private int Dr()
	{
		if (_deck.Count == 0)
		{
			_deck = Shuf();
		}
		int result = _deck[0];
		_deck.RemoveAt(0);
		return result;
	}

	private int Rk(int c)
	{
		return c % 13 + 1;
	}

	private int Tot(List<int> h)
	{
		int num = 0;
		int num2 = 0;
		foreach (int item in h)
		{
			int num3 = Rk(item);
			if (num3 == 1)
			{
				num2++;
				num += 11;
			}
			else
			{
				num = ((num3 < 10) ? (num + num3) : (num + 10));
			}
		}
		while (num > 21 && num2 > 0)
		{
			num -= 10;
			num2--;
		}
		return num;
	}

	private string CN(int c)
	{
		string[] array = new string[13]
		{
			"A", "2", "3", "4", "5", "6", "7", "8", "9", "10",
			"J", "Q", "K"
		};
		string[] array2 = new string[4] { "♠", "♥", "♦", "♣" };
		return array[c % 13] + array2[c / 13];
	}

	private string HS(List<int> h)
	{
		string[] array = new string[h.Count];
		for (int i = 0; i < h.Count; i++)
		{
			array[i] = CN(h[i]);
		}
		return string.Join("  ", array);
	}
}
public class CasinoApp : PhoneApp
{
	public static CasinoApp Instance;

	private Text _balanceText;

	private Text _winningsText;

	private GameObject _mainMenu;

	private GameObject _slotsPanel;

	private GameObject _bjPanel;

	private GameObject _rlPanel;

	private GameObject _rtbPanel;

	private SlotsGame _slotsGame;

	private BlackjackGame _bjGame;

	private RouletteGame _rlGame;

	private RideTheBusGame _rtbGame;

	protected override string AppName => "HylandPointCasino";

	protected override string AppTitle => "Hyland Pt. Casino";

	protected override string IconLabel => "Casino";

	protected override string IconFileName => "casino_icon.png";

	protected override void OnCreated()
	{
		((PhoneApp)this).OnCreated();
		Instance = this;
	}

	protected override void OnCreatedUI(GameObject container)
	{
		//IL_001a: 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_00a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b2: Expected O, but got Unknown
		//IL_012c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0151: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c3: Expected O, but got Unknown
		//IL_021f: Unknown result type (might be due to invalid IL or missing references)
		//IL_025c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0299: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_02fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_0379: Unknown result type (might be due to invalid IL or missing references)
		//IL_03f4: Unknown result type (might be due to invalid IL or missing references)
		//IL_046f: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = UIFactory.Panel("Root", container.transform, new Color(0.05f, 0.08f, 0.05f), (Vector2?)null, (Vector2?)null, true);
		GameObject val2 = UIFactory.Panel("Header", val.transform, new Color(0.1f, 0.15f, 0.1f), (Vector2?)null, (Vector2?)null, false);
		Anchor(val2, 0f, 0.85f, 1f, 1f);
		VerticalLayoutGroup obj = val2.AddComponent<VerticalLayoutGroup>();
		((LayoutGroup)obj).childAlignment = (TextAnchor)4;
		((HorizontalOrVerticalLayoutGroup)obj).spacing = 2f;
		((LayoutGroup)obj).padding = new RectOffset(5, 5, 4, 4);
		((HorizontalOrVerticalLayoutGroup)obj).childForceExpandWidth = true;
		((HorizontalOrVerticalLayoutGroup)obj).childForceExpandHeight = false;
		UIFactory.Text("T", "HYLAND POINT CASINO", val2.transform, 15, (TextAnchor)4, (FontStyle)1);
		_balanceText = UIFactory.Text("B", "Credit: $0", val2.transform, 12, (TextAnchor)4, (FontStyle)0);
		_winningsText = UIFactory.Text("W", "", val2.transform, 10, (TextAnchor)4, (FontStyle)0);
		((Graphic)_winningsText).color = new Color(0.5f, 1f, 0.5f);
		_mainMenu = UIFactory.Panel("Menu", val.transform, new Color(0.05f, 0.08f, 0.05f), (Vector2?)null, (Vector2?)null, false);
		Anchor(_mainMenu, 0f, 0f, 1f, 0.85f);
		VerticalLayoutGroup obj2 = _mainMenu.AddComponent<VerticalLayoutGroup>();
		((LayoutGroup)obj2).childAlignment = (TextAnchor)1;
		((HorizontalOrVerticalLayoutGroup)obj2).spacing = 10f;
		((LayoutGroup)obj2).padding = new RectOffset(15, 15, 15, 15);
		((HorizontalOrVerticalLayoutGroup)obj2).childForceExpandWidth = true;
		((HorizontalOrVerticalLayoutGroup)obj2).childForceExpandHeight = false;
		UIFactory.Text("W2", "Pick your game:", _mainMenu.transform, 14, (TextAnchor)4, (FontStyle)0);
		UI.Btn("Slots", "SLOT MACHINE", _mainMenu.transform, delegate
		{
			ShowGame("slots");
		}, new Color(0.6f, 0.2f, 0.2f), 14);
		UI.Btn("BJ", "BLACKJACK", _mainMenu.transform, delegate
		{
			ShowGame("blackjack");
		}, new Color(0.15f, 0.35f, 0.15f), 14);
		UI.Btn("RL", "ROULETTE", _mainMenu.transform, delegate
		{
			ShowGame("roulette");
		}, new Color(0.2f, 0.2f, 0.6f), 14);
		UI.Btn("RTB", "RIDE THE BUS", _mainMenu.transform, delegate
		{
			ShowGame("ridethebus");
		}, new Color(0.5f, 0.3f, 0.1f), 14);
		_slotsPanel = UIFactory.Panel("SlotsP", val.transform, new Color(0.05f, 0.08f, 0.05f), (Vector2?)null, (Vector2?)null, false);
		Anchor(_slotsPanel, 0f, 0f, 1f, 0.85f);
		_slotsGame = new SlotsGame(this, _slotsPanel);
		_slotsPanel.SetActive(false);
		_bjPanel = UIFactory.Panel("BJP", val.transform, new Color(0.05f, 0.08f, 0.05f), (Vector2?)null, (Vector2?)null, false);
		Anchor(_bjPanel, 0f, 0f, 1f, 0.85f);
		_bjGame = new BlackjackGame(this, _bjPanel);
		_bjPanel.SetActive(false);
		_rlPanel = UIFactory.Panel("RLP", val.transform, new Color(0.05f, 0.08f, 0.05f), (Vector2?)null, (Vector2?)null, false);
		Anchor(_rlPanel, 0f, 0f, 1f, 0.85f);
		_rlGame = new RouletteGame(this, _rlPanel);
		_rlPanel.SetActive(false);
		_rtbPanel = UIFactory.Panel("RTBP", val.transform, new Color(0.05f, 0.08f, 0.05f), (Vector2?)null, (Vector2?)null, false);
		Anchor(_rtbPanel, 0f, 0f, 1f, 0.85f);
		_rtbGame = new RideTheBusGame(this, _rtbPanel);
		_rtbPanel.SetActive(false);
		RefreshBalance();
	}

	protected override void OnPhoneClosed()
	{
		((PhoneApp)this).OnPhoneClosed();
		CasinoBank.OnAppClosed();
	}

	public void ShowGame(string game)
	{
		_mainMenu.SetActive(game == "menu");
		_slotsPanel.SetActive(game == "slots");
		_bjPanel.SetActive(game == "blackjack");
		_rlPanel.SetActive(game == "roulette");
		_rtbPanel.SetActive(game == "ridethebus");
		RefreshBalance();
	}

	public void RefreshBalance()
	{
		if ((Object)(object)_balanceText != (Object)null)
		{
			_balanceText.text = "Credit: " + CasinoBank.FormatMoney(CasinoBank.CreditBalance);
		}
		if ((Object)(object)_winningsText != (Object)null)
		{
			if (CasinoBank.PendingPayout > 0f)
			{
				_winningsText.text = "Winnings: " + CasinoBank.FormatMoney(CasinoBank.PendingPayout) + " (close app to collect)";
			}
			else if (CasinoBank.HasUncollected)
			{
				_winningsText.text = CasinoBank.FormatMoney(CasinoBank.UncollectedAmount) + " at casino dead drop";
			}
			else
			{
				_winningsText.text = "";
			}
		}
	}

	private void Anchor(GameObject go, float xMin, float yMin, float xMax, float yMax)
	{
		//IL_0009: Unknown result type (might be due to invalid IL or missing references)
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		RectTransform component = go.GetComponent<RectTransform>();
		component.anchorMin = new Vector2(xMin, yMin);
		component.anchorMax = new Vector2(xMax, yMax);
		component.offsetMin = Vector2.zero;
		component.offsetMax = Vector2.zero;
	}
}
public static class CasinoBank
{
	private static float _pendingPayout = 0f;

	private static bool _hasUncollected = false;

	private static float _uncollectedAmount = 0f;

	private static Vector3 _dropPosition = Vector3.zero;

	public static bool ShowPayoutChoice = false;

	public static string LastCollectMessage = "";

	public static float LastCollectTime = -10f;

	private static float _lastProxCheck = 0f;

	private const float PROX_INTERVAL = 0.5f;

	private const float COLLECT_RANGE = 3f;

	public static float CreditBalance
	{
		get
		{
			try
			{
				return Money.GetOnlineBalance();
			}
			catch
			{
				return 0f;
			}
		}
	}

	public static float PendingPayout => _pendingPayout;

	public static bool HasUncollected => _hasUncollected;

	public static float UncollectedAmount => _uncollectedAmount;

	public static void Initialize()
	{
		MelonLogger.Msg("[HPC] CasinoBank initialized. Credit-in, payout choice on app close.");
	}

	public static bool CanAfford(int amount)
	{
		if (amount > 0)
		{
			return CreditBalance >= (float)amount;
		}
		return false;
	}

	public static bool PlaceBet(int amount)
	{
		if (amount <= 0)
		{
			return false;
		}
		if (CreditBalance < (float)amount)
		{
			return false;
		}
		try
		{
			Money.CreateOnlineTransaction("Casino Bet", 0f - (float)amount, 1f, "Hyland Point Casino");
			MelonLogger.Msg("[HPC] Bet: -$" + amount + " from credit.");
			return true;
		}
		catch (Exception ex)
		{
			MelonLogger.Error("[HPC] PlaceBet error: " + ex.Message);
			return false;
		}
	}

	public static void PayWinnings(float amount)
	{
		if (!(amount <= 0f))
		{
			_pendingPayout += amount;
			MelonLogger.Msg("[HPC] Winnings buffered: +$" + (int)amount + " | Total pending: $" + (int)_pendingPayout);
		}
	}

	public static void OnAppClosed()
	{
		if (_pendingPayout > 0f)
		{
			ShowPayoutChoice = true;
			MelonLogger.Msg("[HPC] App closed with $" + (int)_pendingPayout + " pending. Showing payout choice.");
		}
	}

	public static void PayoutAsCash()
	{
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		//IL_004a: Unknown result type (might be due to invalid IL or missing references)
		float pendingPayout = _pendingPayout;
		_pendingPayout = 0f;
		ShowPayoutChoice = false;
		try
		{
			DeadDropInstance val = FindCasinoDrop();
			if (val != null)
			{
				CashInstance val2 = Money.CreateCashInstance(pendingPayout);
				val.Storage.AddItem((ItemInstance)(object)val2);
				_hasUncollected = true;
				_uncollectedAmount += pendingPayout;
				_dropPosition = val.Position;
				MelonLogger.Msg("[HPC] $" + (int)pendingPayout + " cash deposited into casino dead drop.");
			}
			else
			{
				Money.ChangeCashBalance(pendingPayout, true, true);
				LastCollectMessage = FormatMoney(pendingPayout) + " added to cash (no drop found)";
				LastCollectTime = Time.time;
			}
		}
		catch (Exception ex)
		{
			MelonLogger.Error("[HPC] Cash payout failed: " + ex.Message);
			try
			{
				Money.ChangeCashBalance(pendingPayout, true, true);
			}
			catch
			{
			}
			LastCollectMessage = FormatMoney(pendingPayout) + " added to cash";
			LastCollectTime = Time.time;
		}
	}

	public static void PayoutAsCredit()
	{
		float pendingPayout = _pendingPayout;
		_pendingPayout = 0f;
		ShowPayoutChoice = false;
		try
		{
			Money.CreateOnlineTransaction("Casino Winnings", pendingPayout, 1f, "Hyland Point Casino");
			LastCollectMessage = FormatMoney(pendingPayout) + " added to credit!";
			LastCollectTime = Time.time;
			MelonLogger.Msg("[HPC] $" + (int)pendingPayout + " paid out as credit.");
		}
		catch (Exception ex)
		{
			MelonLogger.Error("[HPC] Credit payout failed: " + ex.Message);
			LastCollectMessage = "Payout error!";
			LastCollectTime = Time.time;
		}
	}

	private static DeadDropInstance FindCasinoDrop()
	{
		try
		{
			DeadDropInstance[] all = DeadDropManager.All;
			if (all == null || all.Length == 0)
			{
				return null;
			}
			DeadDropInstance val = ((IEnumerable<DeadDropInstance>)all).FirstOrDefault((Func<DeadDropInstance, bool>)((DeadDropInstance d) => d.Name != null && d.Name.ToLower().Contains("casino")));
			if (val != null)
			{
				return val;
			}
			MelonLogger.Warning("[HPC] No 'casino' dead drop found. Available:");
			DeadDropInstance[] array = all;
			foreach (DeadDropInstance val2 in array)
			{
				MelonLogger.Msg("[HPC]   - \"" + val2.Name + "\"");
			}
			return (all.Length != 0) ? all[0] : null;
		}
		catch
		{
			return null;
		}
	}

	public static void CheckProximityDismiss()
	{
		//IL_0043: Unknown result type (might be due to invalid IL or missing references)
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_0048: Unknown result type (might be due to invalid IL or missing references)
		//IL_0049: Unknown result type (might be due to invalid IL or missing references)
		//IL_004a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0058: Unknown result type (might be due to invalid IL or missing references)
		//IL_0059: Unknown result type (might be due to invalid IL or missing references)
		if (!_hasUncollected || Time.time - _lastProxCheck < 0.5f)
		{
			return;
		}
		_lastProxCheck = Time.time;
		try
		{
			Vector3 val = (((Object)(object)Camera.main != (Object)null) ? ((Component)Camera.main).transform.position : Vector3.zero);
			if (!(val == Vector3.zero) && Vector3.Distance(val, _dropPosition) <= 3f)
			{
				LastCollectMessage = FormatMoney(_uncollectedAmount) + " collected!";
				LastCollectTime = Time.time;
				_hasUncollected = false;
				_uncollectedAmount = 0f;
				MelonLogger.Msg("[HPC] Player near casino dead drop — HUD cleared.");
			}
		}
		catch
		{
		}
	}

	public static string FormatMoney(float amount)
	{
		if (amount < 0f)
		{
			amount = 0f;
		}
		return "$" + ((int)amount).ToString("N0");
	}
}
public class Core : MelonMod
{
	public static Core Instance;

	private static GUIStyle _hudStyle;

	private static GUIStyle _hudHeaderStyle;

	private static GUIStyle _hudBoxStyle;

	private static GUIStyle _popupBoxStyle;

	private static GUIStyle _popupTitleStyle;

	private static GUIStyle _popupAmountStyle;

	private static GUIStyle _popupBtnStyle;

	private static GUIStyle _popupBtnHoverStyle;

	private static bool _stylesInit;

	public override void OnInitializeMelon()
	{
		Instance = this;
		CasinoBank.Initialize();
		((MelonBase)this).LoggerInstance.Msg("Hyland Point Casino v1.3.0 loaded!");
	}

	public override void OnUpdate()
	{
		CasinoBank.CheckProximityDismiss();
	}

	public override void OnGUI()
	{
		//IL_0072: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0118: Unknown result type (might be due to invalid IL or missing references)
		//IL_0148: Unknown result type (might be due to invalid IL or missing references)
		if (!_stylesInit)
		{
			InitStyles();
		}
		if (CasinoBank.ShowPayoutChoice)
		{
			DrawPayoutPopup();
			return;
		}
		bool hasUncollected = CasinoBank.HasUncollected;
		bool flag = !string.IsNullOrEmpty(CasinoBank.LastCollectMessage) && Time.time - CasinoBank.LastCollectTime < 4f;
		if (hasUncollected || flag)
		{
			float num = 300f;
			float num2 = 60f;
			float num3 = 15f;
			float num4 = (float)Screen.height - num2 - 15f;
			GUI.Box(new Rect(num3, num4, num, num2), "", _hudBoxStyle);
			if (hasUncollected)
			{
				GUI.Label(new Rect(num3 + 10f, num4 + 8f, num - 20f, 22f), "CASINO WINNINGS", _hudHeaderStyle);
				GUI.Label(new Rect(num3 + 10f, num4 + 32f, num - 20f, 20f), CasinoBank.FormatMoney(CasinoBank.UncollectedAmount) + " in dead drop — go collect!", _hudStyle);
			}
			else if (flag)
			{
				GUI.Label(new Rect(num3 + 10f, num4 + 8f, num - 20f, 22f), "COLLECTED!", _hudHeaderStyle);
				GUI.Label(new Rect(num3 + 10f, num4 + 32f, num - 20f, 20f), CasinoBank.LastCollectMessage, _hudStyle);
			}
		}
	}

	private void DrawPayoutPopup()
	{
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_0079: Unknown result type (might be due to invalid IL or missing references)
		//IL_009b: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_0121: Unknown result type (might be due to invalid IL or missing references)
		//IL_0143: Unknown result type (might be due to invalid IL or missing references)
		//IL_0148: Unknown result type (might be due to invalid IL or missing references)
		//IL_0151: Unknown result type (might be due to invalid IL or missing references)
		//IL_0164: Unknown result type (might be due to invalid IL or missing references)
		//IL_018d: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ad: Expected O, but got Unknown
		//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e5: 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_020b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0214: Unknown result type (might be due to invalid IL or missing references)
		//IL_0226: Unknown result type (might be due to invalid IL or missing references)
		//IL_024e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0270: Unknown result type (might be due to invalid IL or missing references)
		GUI.Box(new Rect(0f, 0f, (float)Screen.width, (float)Screen.height), "", _hudBoxStyle);
		float num = 360f;
		float num2 = 200f;
		float num3 = ((float)Screen.width - num) / 2f;
		float num4 = ((float)Screen.height - num2) / 2f;
		GUI.Box(new Rect(num3, num4, num, num2), "", _popupBoxStyle);
		GUI.Label(new Rect(num3, num4 + 15f, num, 30f), "COLLECT WINNINGS", _popupTitleStyle);
		GUI.Label(new Rect(num3, num4 + 50f, num, 30f), CasinoBank.FormatMoney(CasinoBank.PendingPayout), _popupAmountStyle);
		GUI.Label(new Rect(num3, num4 + 80f, num, 20f), "How do you want your winnings?", _hudStyle);
		float num5 = 140f;
		float num6 = 45f;
		float num7 = num4 + 120f;
		float num8 = 20f;
		float num9 = num3 + num / 2f - num5 - num8 / 2f;
		float num10 = num3 + num / 2f + num8 / 2f;
		if (GUI.Button(new Rect(num9, num7, num5, num6), "", GUIStyle.none))
		{
			CasinoBank.PayoutAsCash();
		}
		Rect val = new Rect(num9, num7, num5, num6);
		bool flag = ((Rect)(ref val)).Contains(Event.current.mousePosition);
		GUI.Box(new Rect(num9, num7, num5, num6), "", flag ? _popupBtnHoverStyle : _popupBtnStyle);
		GUI.Label(new Rect(num9, num7, num5, 25f), "CASH", _popupTitleStyle);
		GUIStyle val2 = new GUIStyle(_hudStyle);
		val2.fontSize = 11;
		val2.alignment = (TextAnchor)1;
		GUI.Label(new Rect(num9, num7 + 24f, num5, 20f), "Dead drop pickup", val2);
		if (GUI.Button(new Rect(num10, num7, num5, num6), "", GUIStyle.none))
		{
			CasinoBank.PayoutAsCredit();
		}
		val = new Rect(num10, num7, num5, num6);
		bool flag2 = ((Rect)(ref val)).Contains(Event.current.mousePosition);
		GUI.Box(new Rect(num10, num7, num5, num6), "", flag2 ? _popupBtnHoverStyle : _popupBtnStyle);
		GUI.Label(new Rect(num10, num7, num5, 25f), "CREDIT", _popupTitleStyle);
		GUI.Label(new Rect(num10, num7 + 24f, num5, 20f), "Instant deposit", val2);
	}

	private static void InitStyles()
	{
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0014: Expected O, but got Unknown
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: Expected O, but got Unknown
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		//IL_005d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0067: Expected O, but got Unknown
		//IL_0097: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c0: Expected O, but got Unknown
		//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0104: Unknown result type (might be due to invalid IL or missing references)
		//IL_010e: Expected O, but got Unknown
		//IL_0110: Unknown result type (might be due to invalid IL or missing references)
		//IL_0116: Expected O, but got Unknown
		//IL_012d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0157: Unknown result type (might be due to invalid IL or missing references)
		//IL_0161: Expected O, but got Unknown
		//IL_0191: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ba: Expected O, but got Unknown
		//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_0209: Unknown result type (might be due to invalid IL or missing references)
		//IL_0213: Expected O, but got Unknown
		//IL_0215: Unknown result type (might be due to invalid IL or missing references)
		//IL_021b: Expected O, but got Unknown
		//IL_0232: Unknown result type (might be due to invalid IL or missing references)
		//IL_025c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0266: Expected O, but got Unknown
		//IL_0268: Unknown result type (might be due to invalid IL or missing references)
		//IL_026e: Expected O, but got Unknown
		//IL_0285: Unknown result type (might be due to invalid IL or missing references)
		_hudBoxStyle = new GUIStyle(GUI.skin.box);
		Texture2D val = new Texture2D(1, 1);
		val.SetPixel(0, 0, new Color(0.05f, 0.05f, 0.05f, 0.85f));
		val.Apply();
		_hudBoxStyle.normal.background = val;
		_hudHeaderStyle = new GUIStyle(GUI.skin.label);
		_hudHeaderStyle.fontSize = 14;
		_hudHeaderStyle.fontStyle = (FontStyle)1;
		_hudHeaderStyle.normal.textColor = new Color(0.3f, 1f, 0.3f);
		_hudHeaderStyle.alignment = (TextAnchor)4;
		_hudStyle = new GUIStyle(GUI.skin.label);
		_hudStyle.fontSize = 12;
		_hudStyle.normal.textColor = new Color(0.9f, 0.9f, 0.9f);
		_hudStyle.alignment = (TextAnchor)4;
		_popupBoxStyle = new GUIStyle(GUI.skin.box);
		Texture2D val2 = new Texture2D(1, 1);
		val2.SetPixel(0, 0, new Color(0.08f, 0.1f, 0.08f, 0.95f));
		val2.Apply();
		_popupBoxStyle.normal.background = val2;
		_popupTitleStyle = new GUIStyle(GUI.skin.label);
		_popupTitleStyle.fontSize = 18;
		_popupTitleStyle.fontStyle = (FontStyle)1;
		_popupTitleStyle.normal.textColor = new Color(0.3f, 1f, 0.3f);
		_popupTitleStyle.alignment = (TextAnchor)4;
		_popupAmountStyle = new GUIStyle(GUI.skin.label);
		_popupAmountStyle.fontSize = 28;
		_popupAmountStyle.fontStyle = (FontStyle)1;
		_popupAmountStyle.normal.textColor = new Color(1f, 0.84f, 0f);
		_popupAmountStyle.alignment = (TextAnchor)4;
		_popupBtnStyle = new GUIStyle(GUI.skin.box);
		Texture2D val3 = new Texture2D(1, 1);
		val3.SetPixel(0, 0, new Color(0.15f, 0.2f, 0.15f, 1f));
		val3.Apply();
		_popupBtnStyle.normal.background = val3;
		_popupBtnHoverStyle = new GUIStyle(GUI.skin.box);
		Texture2D val4 = new Texture2D(1, 1);
		val4.SetPixel(0, 0, new Color(0.2f, 0.35f, 0.2f, 1f));
		val4.Apply();
		_popupBtnHoverStyle.normal.background = val4;
		_stylesInit = true;
	}
}
public class RideTheBusGame
{
	private CasinoApp _app;

	private Text _cardText;

	private Text _questionText;

	private Text _resultText;

	private Text _betText;

	private Text _payoutText;

	private GameObject _betRow;

	private GameObject _choiceRow;

	private GameObject _cashOutRow;

	private GameObject _btnA;

	private GameObject _btnB;

	private GameObject _btnC;

	private GameObject _btnD;

	private int _currentBet;

	private int _round;

	private List<int> _cards = new List<int>();

	private bool _gameActive;

	private static readonly int[] ROUND_PAYOUT = new int[5] { 0, 2, 3, 4, 5 };

	private static readonly string[] SUIT_SYMBOLS = new string[4] { "♠", "♥", "♦", "♣" };

	private static readonly string[] RANK_NAMES = new string[13]
	{
		"A", "2", "3", "4", "5", "6", "7", "8", "9", "10",
		"J", "Q", "K"
	};

	public RideTheBusGame(CasinoApp app, GameObject panel)
	{
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_003f: Expected O, but got Unknown
		//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
		//IL_014b: Unknown result type (might be due to invalid IL or missing references)
		//IL_021f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0273: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_0359: Unknown result type (might be due to invalid IL or missing references)
		//IL_03a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_03f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_043d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0470: Unknown result type (might be due to invalid IL or missing references)
		//IL_04d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_051b: Unknown result type (might be due to invalid IL or missing references)
		_app = app;
		VerticalLayoutGroup obj = panel.AddComponent<VerticalLayoutGroup>();
		((LayoutGroup)obj).childAlignment = (TextAnchor)1;
		((HorizontalOrVerticalLayoutGroup)obj).spacing = 5f;
		((LayoutGroup)obj).padding = new RectOffset(8, 8, 6, 6);
		((HorizontalOrVerticalLayoutGroup)obj).childForceExpandWidth = true;
		((HorizontalOrVerticalLayoutGroup)obj).childForceExpandHeight = false;
		UIFactory.Text("H", "RIDE THE BUS", panel.transform, 16, (TextAnchor)4, (FontStyle)1);
		_cardText = UIFactory.Text("Cards", "", panel.transform, 20, (TextAnchor)4, (FontStyle)1);
		_questionText = UIFactory.Text("Q", "Place a bet to start!", panel.transform, 13, (TextAnchor)4, (FontStyle)0);
		((Graphic)_questionText).color = new Color(0.9f, 0.8f, 0.3f);
		_payoutText = UIFactory.Text("Pay", "", panel.transform, 11, (TextAnchor)4, (FontStyle)0);
		((Graphic)_payoutText).color = new Color(0.5f, 1f, 0.5f);
		_resultText = UIFactory.Text("Res", "", panel.transform, 13, (TextAnchor)4, (FontStyle)1);
		_betText = UIFactory.Text("Bet", "Bet: $0", panel.transform, 14, (TextAnchor)4, (FontStyle)1);
		_betRow = UIFactory.Panel("BR", panel.transform, Color.clear, (Vector2?)null, (Vector2?)null, false);
		_betRow.AddComponent<LayoutElement>().preferredHeight = 40f;
		HorizontalLayoutGroup obj2 = _betRow.AddComponent<HorizontalLayoutGroup>();
		((HorizontalOrVerticalLayoutGroup)obj2).spacing = 4f;
		((HorizontalOrVerticalLayoutGroup)obj2).childForceExpandWidth = true;
		((HorizontalOrVerticalLayoutGroup)obj2).childForceExpandHeight = true;
		int[] array = new int[4] { 25, 50, 100, 500 };
		for (int i = 0; i < array.Length; i++)
		{
			int num = array[i];
			int amt = num;
			UI.BtnSized("Q" + num, "$" + num, _betRow.transform, delegate
			{
				_currentBet = amt;
				_betText.text = "Bet: $" + amt;
			}, new Color(0.25f, 0.25f, 0.35f), 60f, 35f, 11);
		}
		UI.BtnSized("ALL", "ALL", _betRow.transform, delegate
		{
			_currentBet = (int)CasinoBank.CreditBalance;
			_betText.text = "Bet: " + CasinoBank.FormatMoney(_currentBet);
		}, new Color(0.5f, 0.2f, 0.2f), 60f, 35f, 11);
		UI.Btn("Start", "START RIDE", panel.transform, StartGame, new Color(0.5f, 0.3f, 0.1f), 14);
		_choiceRow = UIFactory.Panel("CR2", panel.transform, Color.clear, (Vector2?)null, (Vector2?)null, false);
		_choiceRow.AddComponent<LayoutElement>().preferredHeight = 45f;
		HorizontalLayoutGroup obj3 = _choiceRow.AddComponent<HorizontalLayoutGroup>();
		((HorizontalOrVerticalLayoutGroup)obj3).spacing = 4f;
		((HorizontalOrVerticalLayoutGroup)obj3).childForceExpandWidth = true;
		((HorizontalOrVerticalLayoutGroup)obj3).childForceExpandHeight = true;
		_btnA = UI.BtnSized("A", "A", _choiceRow.transform, delegate
		{
			Choose(0);
		}, new Color(0.3f, 0.3f, 0.5f), 60f, 40f, 13);
		_btnB = UI.BtnSized("B", "B", _choiceRow.transform, delegate
		{
			Choose(1);
		}, new Color(0.3f, 0.3f, 0.5f), 60f, 40f, 13);
		_btnC = UI.BtnSized("C", "C", _choiceRow.transform, delegate
		{
			Choose(2);
		}, new Color(0.3f, 0.3f, 0.5f), 60f, 40f, 13);
		_btnD = UI.BtnSized("D", "D", _choiceRow.transform, delegate
		{
			Choose(3);
		}, new Color(0.3f, 0.3f, 0.5f), 60f, 40f, 13);
		_choiceRow.SetActive(false);
		_cashOutRow = UIFactory.Panel("COR", panel.transform, Color.clear, (Vector2?)null, (Vector2?)null, false);
		_cashOutRow.AddComponent<LayoutElement>().preferredHeight = 40f;
		UI.Btn("CO", "CASH OUT", _cashOutRow.transform, CashOut, new Color(0.6f, 0.5f, 0.1f), 14);
		_cashOutRow.SetActive(false);
		UI.Btn("Back", "BACK TO LOBBY", panel.transform, delegate
		{
			if (_gameActive)
			{
				CashOut();
			}
			_app.ShowGame("menu");
		}, new Color(0.3f, 0.3f, 0.3f), 11);
	}

	private void StartGame()
	{
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		//IL_0056: Unknown result type (might be due to invalid IL or missing references)
		//IL_0084: Unknown result type (might be due to invalid IL or missing references)
		if (!_gameActive)
		{
			if (_currentBet <= 0)
			{
				_resultText.text = "Enter a bet!";
				((Graphic)_resultText).color = Color.yellow;
				return;
			}
			if (!CasinoBank.CanAfford(_currentBet))
			{
				_resultText.text = "Not enough credit!";
				((Graphic)_resultText).color = Color.red;
				return;
			}
			if (!CasinoBank.PlaceBet(_currentBet))
			{
				_resultText.text = "Bet failed!";
				((Graphic)_resultText).color = Color.red;
				return;
			}
			_gameActive = true;
			_round = 1;
			_cards.Clear();
			_resultText.text = "";
			_betRow.SetActive(false);
			ShowRound();
			_app.RefreshBalance();
		}
	}

	private void ShowRound()
	{
		_choiceRow.SetActive(true);
		_cashOutRow.SetActive(_round > 1);
		if (_round > 1)
		{
			_payoutText.text = "Current: " + ROUND_PAYOUT[_round - 1] + "x ($" + _currentBet * ROUND_PAYOUT[_round - 1] + ") | Next: " + ROUND_PAYOUT[_round] + "x";
		}
		else
		{
			_payoutText.text = "Win: " + ROUND_PAYOUT[_round] + "x ($" + _currentBet * ROUND_PAYOUT[_round] + ")";
		}
		_cardText.text = ((_cards.Count > 0) ? string.Join("  ", _cards.ConvertAll((int c) => CardName(c)).ToArray()) : "?");
		switch (_round)
		{
		case 1:
			_questionText.text = "Is the card RED or BLACK?";
			SetBtnLabels("RED", "BLACK", "", "");
			_btnC.SetActive(false);
			_btnD.SetActive(false);
			break;
		case 2:
			_questionText.text = "HIGHER or LOWER?";
			SetBtnLabels("HIGHER", "LOWER", "", "");
			_btnC.SetActive(false);
			_btnD.SetActive(false);
			break;
		case 3:
		{
			int num = RankVal(_cards[0]);
			int num2 = RankVal(_cards[1]);
			int num3 = Mathf.Min(num, num2);
			int num4 = Mathf.Max(num, num2);
			_questionText.text = "INSIDE or OUTSIDE " + num3 + "-" + num4 + "?";
			SetBtnLabels("INSIDE", "OUTSIDE", "", "");
			_btnC.SetActive(false);
			_btnD.SetActive(false);
			break;
		}
		case 4:
			_questionText.text = "What SUIT is the final card?";
			SetBtnLabels("♠", "♥", "♦", "♣");
			_btnC.SetActive(true);
			_btnD.SetActive(true);
			break;
		}
	}

	private void SetBtnLabels(string a, string b, string c, string d)
	{
		SetLbl(_btnA, a);
		SetLbl(_btnB, b);
		SetLbl(_btnC, c);
		SetLbl(_btnD, d);
	}

	private void SetLbl(GameObject go, string txt)
	{
		Text componentInChildren = go.GetComponentInChildren<Text>();
		if ((Object)(object)componentInChildren != (Object)null)
		{
			componentInChildren.text = txt;
		}
	}

	private void Choose(int choice)
	{
		//IL_02c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_0270: Unknown result type (might be due to invalid IL or missing references)
		//IL_0211: Unknown result type (might be due to invalid IL or missing references)
		if (!_gameActive)
		{
			return;
		}
		int num = Random.Range(0, 52);
		_cards.Add(num);
		bool flag = false;
		switch (_round)
		{
		case 1:
		{
			bool flag4 = Suit(num) == 1 || Suit(num) == 2;
			flag = (choice == 0 && flag4) || (choice == 1 && !flag4);
			break;
		}
		case 2:
		{
			int num7 = RankVal(_cards[_cards.Count - 2]);
			int num8 = RankVal(num);
			flag = num8 != num7 && ((choice == 0 && num8 > num7) || (choice == 1 && num8 < num7));
			break;
		}
		case 3:
		{
			int num2 = RankVal(_cards[0]);
			int num3 = RankVal(_cards[1]);
			int num4 = Mathf.Min(num2, num3);
			int num5 = Mathf.Max(num2, num3);
			int num6 = RankVal(num);
			bool flag2 = num6 > num4 && num6 < num5;
			bool flag3 = num6 < num4 || num6 > num5;
			flag = (choice == 0 && flag2) || (choice == 1 && flag3);
			break;
		}
		case 4:
			flag = Suit(num) == choice;
			break;
		}
		_cardText.text = string.Join("  ", _cards.ConvertAll((int c2) => CardName(c2)).ToArray());
		if (flag)
		{
			if (_round == 4)
			{
				int num9 = _currentBet * ROUND_PAYOUT[_round];
				CasinoBank.PayWinnings(num9);
				_resultText.text = "ALL CORRECT! " + ROUND_PAYOUT[_round] + "x = +$" + num9 + "!";
				((Graphic)_resultText).color = new Color(1f, 0.84f, 0f);
				_payoutText.text = "";
				EndGame();
			}
			else
			{
				_resultText.text = "CORRECT! Round " + _round + " passed!";
				((Graphic)_resultText).color = new Color(0.2f, 1f, 0.2f);
				_round++;
				ShowRound();
			}
		}
		else
		{
			_resultText.text = "WRONG! " + CardName(num) + " — You lose $" + _currentBet;
			((Graphic)_resultText).color = Color.red;
			_payoutText.text = "";
			EndGame();
		}
		_app.RefreshBalance();
	}

	private void CashOut()
	{
		//IL_007c: Unknown result type (might be due to invalid IL or missing references)
		if (_gameActive && _round > 1)
		{
			int num = _currentBet * ROUND_PAYOUT[_round - 1];
			CasinoBank.PayWinnings(num);
			_resultText.text = "CASHED OUT at " + ROUND_PAYOUT[_round - 1] + "x! +$" + num;
			((Graphic)_resultText).color = new Color(0.9f, 0.7f, 0.1f);
			_payoutText.text = "";
			EndGame();
			_app.RefreshBalance();
		}
	}

	private void EndGame()
	{
		_gameActive = false;
		_round = 0;
		_choiceRow.SetActive(false);
		_cashOutRow.SetActive(false);
		_betRow.SetActive(true);
		_questionText.text = "Place a bet to ride again!";
	}

	private int Suit(int card)
	{
		return card / 13;
	}

	private int RankVal(int card)
	{
		return card % 13 + 1;
	}

	private string CardName(int card)
	{
		return RANK_NAMES[card % 13] + SUIT_SYMBOLS[card / 13];
	}
}
public class RouletteGame
{
	private CasinoApp _app;

	private Text _resultText;

	private Text _betText;

	private Text _betTypeText;

	private int _currentBet;

	private string _betType = "red";

	private int _betNumber;

	private static readonly int[] RED_NUMS = new int[18]
	{
		1, 3, 5, 7, 9, 12, 14, 16, 18, 19,
		21, 23, 25, 27, 30, 32, 34, 36
	};

	public RouletteGame(CasinoApp app, GameObject panel)
	{
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_003f: Expected O, but got Unknown
		//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_0147: Unknown result type (might be due to invalid IL or missing references)
		//IL_0189: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_0224: Unknown result type (might be due to invalid IL or missing references)
		//IL_0266: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_030c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0385: Unknown result type (might be due to invalid IL or missing references)
		//IL_03c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0409: Unknown result type (might be due to invalid IL or missing references)
		//IL_044b: Unknown result type (might be due to invalid IL or missing references)
		//IL_048d: Unknown result type (might be due to invalid IL or missing references)
		//IL_04ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_059a: Unknown result type (might be due to invalid IL or missing references)
		//IL_05ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_062f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0667: Unknown result type (might be due to invalid IL or missing references)
		_app = app;
		VerticalLayoutGroup obj = panel.AddComponent<VerticalLayoutGroup>();
		((LayoutGroup)obj).childAlignment = (TextAnchor)1;
		((HorizontalOrVerticalLayoutGroup)obj).spacing = 5f;
		((LayoutGroup)obj).padding = new RectOffset(8, 8, 6, 6);
		((HorizontalOrVerticalLayoutGroup)obj).childForceExpandWidth = true;
		((HorizontalOrVerticalLayoutGroup)obj).childForceExpandHeight = false;
		UIFactory.Text("H", "ROULETTE", panel.transform, 16, (TextAnchor)4, (FontStyle)1);
		_resultText = UIFactory.Text("Res", "", panel.transform, 13, (TextAnchor)4, (FontStyle)0);
		_betTypeText = UIFactory.Text("BT", "Bet: RED (2x)", panel.transform, 12, (TextAnchor)4, (FontStyle)1);
		((Graphic)_betTypeText).color = new Color(1f, 0.4f, 0.4f);
		GameObject val = UIFactory.Panel("CR", panel.transform, Color.clear, (Vector2?)null, (Vector2?)null, false);
		val.AddComponent<LayoutElement>().preferredHeight = 38f;
		HorizontalLayoutGroup obj2 = val.AddComponent<HorizontalLayoutGroup>();
		((HorizontalOrVerticalLayoutGroup)obj2).spacing = 4f;
		((HorizontalOrVerticalLayoutGroup)obj2).childForceExpandWidth = true;
		((HorizontalOrVerticalLayoutGroup)obj2).childForceExpandHeight = true;
		UI.BtnSized("R", "RED", val.transform, delegate
		{
			SetBet("red");
		}, new Color(0.7f, 0.15f, 0.15f), 80f, 34f);
		UI.BtnSized("B", "BLACK", val.transform, delegate
		{
			SetBet("black");
		}, new Color(0.15f, 0.15f, 0.15f), 80f, 34f);
		GameObject val2 = UIFactory.Panel("OR", panel.transform, Color.clear, (Vector2?)null, (Vector2?)null, false);
		val2.AddComponent<LayoutElement>().preferredHeight = 38f;
		HorizontalLayoutGroup obj3 = val2.AddComponent<HorizontalLayoutGroup>();
		((HorizontalOrVerticalLayoutGroup)obj3).spacing = 3f;
		((HorizontalOrVerticalLayoutGroup)obj3).childForceExpandWidth = true;
		((HorizontalOrVerticalLayoutGroup)obj3).childForceExpandHeight = true;
		UI.BtnSized("OD", "ODD", val2.transform, delegate
		{
			SetBet("odd");
		}, new Color(0.3f, 0.3f, 0.4f), 55f, 34f, 10);
		UI.BtnSized("EV", "EVEN", val2.transform, delegate
		{
			SetBet("even");
		}, new Color(0.3f, 0.3f, 0.4f), 55f, 34f, 10);
		UI.BtnSized("LO", "1-18", val2.transform, delegate
		{
			SetBet("low");
		}, new Color(0.3f, 0.3f, 0.4f), 55f, 34f, 10);
		UI.BtnSized("HI", "19-36", val2.transform, delegate
		{
			SetBet("high");
		}, new Color(0.3f, 0.3f, 0.4f), 55f, 34f, 10);
		GameObject val3 = UIFactory.Panel("NR", panel.transform, Color.clear, (Vector2?)null, (Vector2?)null, false);
		val3.AddComponent<LayoutElement>().preferredHeight = 36f;
		HorizontalLayoutGroup obj4 = val3.AddComponent<HorizontalLayoutGroup>();
		((HorizontalOrVerticalLayoutGroup)obj4).spacing = 3f;
		((HorizontalOrVerticalLayoutGroup)obj4).childForceExpandWidth = true;
		((HorizontalOrVerticalLayoutGroup)obj4).childForceExpandHeight = true;
		UI.BtnSized("M5", "-5", val3.transform, delegate
		{
			ChangeNum(-5);
		}, new Color(0.25f, 0.25f, 0.3f), 45f, 32f, 11);
		UI.BtnSized("M1", "-1", val3.transform, delegate
		{
			ChangeNum(-1);
		}, new Color(0.25f, 0.25f, 0.3f), 45f, 32f, 11);
		UI.BtnSized("PN", "Pick #", val3.transform, delegate
		{
			SetBet("number");
		}, new Color(0.5f, 0.35f, 0.1f), 60f, 32f, 11);
		UI.BtnSized("P1", "+1", val3.transform, delegate
		{
			ChangeNum(1);
		}, new Color(0.25f, 0.25f, 0.3f), 45f, 32f, 11);
		UI.BtnSized("P5", "+5", val3.transform, delegate
		{
			ChangeNum(5);
		}, new Color(0.25f, 0.25f, 0.3f), 45f, 32f, 11);
		_betText = UIFactory.Text("BA", "Bet: $0", panel.transform, 14, (TextAnchor)4, (FontStyle)1);
		GameObject val4 = UIFactory.Panel("QR", panel.transform, Color.clear, (Vector2?)null, (Vector2?)null, false);
		val4.AddComponent<LayoutElement>().preferredHeight = 38f;
		HorizontalLayoutGroup obj5 = val4.AddComponent<HorizontalLayoutGroup>();
		((HorizontalOrVerticalLayoutGroup)obj5).spacing = 4f;
		((HorizontalOrVerticalLayoutGroup)obj5).childForceExpandWidth = true;
		((HorizontalOrVerticalLayoutGroup)obj5).childForceExpandHeight = true;
		int[] array = new int[4] { 25, 50, 100, 500 };
		for (int i = 0; i < array.Length; i++)
		{
			int num = array[i];
			int amt = num;
			UI.BtnSized("Q" + num, "$" + num, val4.transform, delegate
			{
				_currentBet = amt;
				_betText.text = "Bet: $" + amt;
			}, new Color(0.25f, 0.25f, 0.35f), 60f, 34f, 11);
		}
		UI.BtnSized("ALL", "ALL", val4.transform, delegate
		{
			_currentBet = (int)CasinoBank.CreditBalance;
			_betText.text = "Bet: " + CasinoBank.FormatMoney(_currentBet);
		}, new Color(0.5f, 0.2f, 0.2f), 60f, 34f, 11);
		UI.Btn("Spin", "SPIN THE WHEEL", panel.transform, Spin, new Color(0.15f, 0.5f, 0.15f), 14);
		UI.Btn("Back", "BACK TO LOBBY", panel.transform, delegate
		{
			_app.ShowGame("menu");
		}, new Color(0.3f, 0.3f, 0.3f), 11);
	}

	private void SetBet(string type)
	{
		//IL_004e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
		_betType = type;
		if (type == "number")
		{
			_betTypeText.text = "Bet: #" + _betNumber + " (36x)";
			((Graphic)_betTypeText).color = new Color(1f, 0.84f, 0f);
			return;
		}
		string text = type.ToUpper();
		if (type == "low")
		{
			text = "1-18";
		}
		if (type == "high")
		{
			text = "19-36";
		}
		_betTypeText.text = "Bet: " + text + " (2x)";
		((Graphic)_betTypeText).color = (Color)((type == "red") ? new Color(1f, 0.4f, 0.4f) : Color.white);
	}

	private void ChangeNum(int delta)
	{
		//IL_005b: Unknown result type (might be due to invalid IL or missing references)
		_betNumber = Mathf.Clamp(_betNumber + delta, 0, 36);
		_betType = "number";
		_betTypeText.text = "Bet: #" + _betNumber + " (36x)";
		((Graphic)_betTypeText).color = new Color(1f, 0.84f, 0f);
	}

	private void Spin()
	{
		//IL_001f: Unknown result type (might be due to invalid IL or missing references)
		//IL_004d: Unknown result type (might be due to invalid IL or missing references)
		//IL_007b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0268: Unknown result type (might be due to invalid IL or missing references)
		//IL_0214: Unknown result type (might be due to invalid IL or missing references)
		if (_currentBet <= 0)
		{
			_resultText.text = "Enter a bet!";
			((Graphic)_resultText).color = Color.yellow;
			return;
		}
		if (!CasinoBank.CanAfford(_currentBet))
		{
			_resultText.text = "Not enough credit!";
			((Graphic)_resultText).color = Color.red;
			return;
		}
		if (!CasinoBank.PlaceBet(_currentBet))
		{
			_resultText.text = "Bet failed!";
			((Graphic)_resultText).color = Color.red;
			return;
		}
		int num = Random.Range(0, 37);
		bool flag = Array.IndexOf(RED_NUMS, num) >= 0;
		string text = ((num == 0) ? "GREEN" : (flag ? "RED" : "BLACK"));
		bool flag2 = false;
		int num2 = 2;
		if (_betType == "number")
		{
			flag2 = num == _betNumber;
			num2 = 36;
		}
		else if (_betType == "red")
		{
			flag2 = flag;
		}
		else if (_betType == "black")
		{
			flag2 = !flag && num != 0;
		}
		else if (_betType == "odd")
		{
			flag2 = num > 0 && num % 2 == 1;
		}
		else if (_betType == "even")
		{
			flag2 = num > 0 && num % 2 == 0;
		}
		else if (_betType == "low")
		{
			flag2 = num >= 1 && num <= 18;
		}
		else if (_betType == "high")
		{
			flag2 = num >= 19 && num <= 36;
		}
		if (flag2)
		{
			int num3 = _currentBet * num2;
			CasinoBank.PayWinnings(num3);
			_resultText.text = num + " " + text + "! WIN +$" + num3;
			((Graphic)_resultText).color = new Color(0.2f, 1f, 0.2f);
		}
		else
		{
			_resultText.text = num + " " + text + ". -$" + _currentBet;
			((Graphic)_resultText).color = Color.red;
		}
		_app.RefreshBalance();
	}
}
public class SlotsGame
{
	private CasinoApp _app;

	private Text _reelText;

	private Text _resultText;

	private Text _betText;

	private int _currentBet;

	private readonly string[] SYMBOLS = new string[6] { "7", "BAR", "BELL", "PLUM", "LEMON", "CHERRY" };

	public SlotsGame(CasinoApp app, GameObject panel)
	{
		//IL_006a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0074: Expected O, but got Unknown
		//IL_0103: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0215: Unknown result type (might be due to invalid IL or missing references)
		//IL_024d: Unknown result type (might be due to invalid IL or missing references)
		_app = app;
		VerticalLayoutGroup obj = panel.AddComponent<VerticalLayoutGroup>();
		((LayoutGroup)obj).childAlignment = (TextAnchor)1;
		((HorizontalOrVerticalLayoutGroup)obj).spacing = 8f;
		((LayoutGroup)obj).padding = new RectOffset(10, 10, 10, 10);
		((HorizontalOrVerticalLayoutGroup)obj).childForceExpandWidth = true;
		((HorizontalOrVerticalLayoutGroup)obj).childForceExpandHeight = false;
		UIFactory.Text("H", "SLOT MACHINE", panel.transform, 16, (TextAnchor)4, (FontStyle)1);
		_reelText = UIFactory.Text("R", "[ ? ] [ ? ] [ ? ]", panel.transform, 22, (TextAnchor)4, (FontStyle)1);
		_resultText = UIFactory.Text("Res", "", panel.transform, 13, (TextAnchor)4, (FontStyle)0);
		_betText = UIFactory.Text("Bet", "Bet: $0", panel.transform, 14, (TextAnchor)4, (FontStyle)1);
		GameObject val = UIFactory.Panel("QR", panel.transform, Color.clear, (Vector2?)null, (Vector2?)null, false);
		val.AddComponent<LayoutElement>().preferredHeight = 42f;
		HorizontalLayoutGroup obj2 = val.AddComponent<HorizontalLayoutGroup>();
		((HorizontalOrVerticalLayoutGroup)obj2).spacing = 6f;
		((HorizontalOrVerticalLayoutGroup)obj2).childForceExpandWidth = true;
		((HorizontalOrVerticalLayoutGroup)obj2).childForceExpandHeight = true;
		int[] array = new int[4] { 25, 50, 100, 500 };
		for (int i = 0; i < array.Length; i++)
		{
			int num = array[i];
			int amt = num;
			UI.BtnSized("Q" + num, "$" + num, val.transform, delegate
			{
				_currentBet = amt;
				_betText.text = "Bet: $" + amt;
			}, new Color(0.25f, 0.25f, 0.35f), 65f, 38f);
		}
		UI.Btn("Spin", "SPIN", panel.transform, Spin, new Color(0.15f, 0.5f, 0.15f), 16);
		UI.Btn("Back", "BACK TO LOBBY", panel.transform, delegate
		{
			_app.ShowGame("menu");
		}, new Color(0.3f, 0.3f, 0.3f), 11);
	}

	private void Spin()
	{
		//IL_001f: Unknown result type (might be due to invalid IL or missing references)
		//IL_004d: Unknown result type (might be due to invalid IL or missing references)
		//IL_007b: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_016e: Unknown result type (might be due to invalid IL or missing references)
		if (_currentBet <= 0)
		{
			_resultText.text = "Pick a bet!";
			((Graphic)_resultText).color = Color.yellow;
			return;
		}
		if (!CasinoBank.CanAfford(_currentBet))
		{
			_resultText.text = "Not enough credit!";
			((Graphic)_resultText).color = Color.red;
			return;
		}
		if (!CasinoBank.PlaceBet(_currentBet))
		{
			_resultText.text = "Bet failed!";
			((Graphic)_resultText).color = Color.red;
			return;
		}
		int num = Random.Range(0, SYMBOLS.Length);
		int num2 = Random.Range(0, SYMBOLS.Length);
		int num3 = Random.Range(0, SYMBOLS.Length);
		_reelText.text = "[ " + SYMBOLS[num] + " ] [ " + SYMBOLS[num2] + " ] [ " + SYMBOLS[num3] + " ]";
		if (num == num2 && num2 == num3)
		{
			int num4 = ((num == 0) ? 25 : 10);
			int num5 = _currentBet * num4;
			CasinoBank.PayWinnings(num5);
			_resultText.text = ((num == 0) ? "JACKPOT! " : "3 MATCH! ") + "+$" + num5;
			((Graphic)_resultText).color = new Color(1f, 0.84f, 0f);
		}
		else if (num == num2 || num2 == num3 || num == num3)
		{
			int num6 = _currentBet * 2;
			CasinoBank.PayWinnings(num6);
			_resultText.text = "2 MATCH! +$" + num6;
			((Graphic)_resultText).color = new Color(0.2f, 1f, 0.2f);
		}
		else
		{
			_resultText.text = "No match. -$" + _currentBet;
			((Graphic)_resultText).color = Color.red;
		}
		_app.RefreshBalance();
	}
}
public static class UI
{
	public static GameObject Btn(string name, string label, Transform parent, Action onClick, Color bgColor, int fontSize = 12)
	{
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		var (result, val, _) = UIFactory.RoundedButtonWithLabel(name, label, parent, bgColor, 160f, 40f, fontSize, Color.white);
		((UnityEvent)val.onClick).AddListener(UnityAction.op_Implicit((Action)delegate
		{
			onClick();
		}));
		return result;
	}

	public static GameObject BtnSized(string name, string label, Transform parent, Action onClick, Color bgColor, float w, float h, int fontSize = 12)
	{
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		var (result, val, _) = UIFactory.RoundedButtonWithLabel(name, label, parent, bgColor, w, h, fontSize, Color.white);
		((UnityEvent)val.onClick).AddListener(UnityAction.op_Implicit((Action)delegate
		{
			onClick();
		}));
		return result;
	}
}