Decompiled source of CustomJadeboxMod v1.6.0

CustomJadebox.dll

Decompiled 3 weeks ago
using System;
using System.Collections;
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 AddWatermark;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Logging;
using CustomJadebox.JadeBoxes;
using CustomJadebox.Util;
using HarmonyLib;
using LBoL.Base;
using LBoL.Base.Extensions;
using LBoL.ConfigData;
using LBoL.Core;
using LBoL.Core.Adventures;
using LBoL.Core.Battle;
using LBoL.Core.Battle.BattleActions;
using LBoL.Core.Cards;
using LBoL.Core.GapOptions;
using LBoL.Core.JadeBoxes;
using LBoL.Core.Randoms;
using LBoL.Core.Stations;
using LBoL.Core.StatusEffects;
using LBoL.Core.Units;
using LBoL.EntityLib.Adventures;
using LBoL.EntityLib.Cards.Character.Cirno;
using LBoL.EntityLib.Cards.Character.Marisa;
using LBoL.EntityLib.Cards.Character.Reimu;
using LBoL.EntityLib.Cards.Character.Sakuya;
using LBoL.EntityLib.Exhibits.Common;
using LBoL.EntityLib.Exhibits.Mythic;
using LBoL.EntityLib.Exhibits.Shining;
using LBoL.EntityLib.JadeBoxes;
using LBoL.EntityLib.StatusEffects.Enemy;
using LBoL.Presentation;
using LBoL.Presentation.UI.Panels;
using LBoL.Presentation.UI.Widgets;
using LBoLEntitySideloader;
using LBoLEntitySideloader.Attributes;
using LBoLEntitySideloader.Entities;
using LBoLEntitySideloader.Resource;
using UnityEngine;
using UnityEngine.Events;

[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: IgnoresAccessChecksTo("LBoL.Base")]
[assembly: IgnoresAccessChecksTo("LBoL.ConfigData")]
[assembly: IgnoresAccessChecksTo("LBoL.Core")]
[assembly: IgnoresAccessChecksTo("LBoL.EntityLib")]
[assembly: IgnoresAccessChecksTo("LBoL.Presentation")]
[assembly: IgnoresAccessChecksTo("Untitled.ConfigDataBuilder.Base")]
[assembly: AssemblyCompany("CustomJadebox")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("CustomJadebox")]
[assembly: AssemblyTitle("CustomJadebox")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace CustomJadebox
{
	[BepInPlugin("crystalcreation.customjadebox", "customjadebox", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInProcess("LBoL.exe")]
	public class BepinexPlugin : BaseUnityPlugin
	{
		private static readonly Harmony harmony = PInfo.harmony;

		internal static ManualLogSource log;

		internal static TemplateSequenceTable sequenceTable = new TemplateSequenceTable(0);

		internal static IResourceSource embeddedSource = (IResourceSource)new EmbeddedSource(Assembly.GetExecutingAssembly());

		internal static DirectorySource directorySource = new DirectorySource("crystalcreation.customjadebox", "");

		public static BatchLocalization JadeboxBatchLoc = new BatchLocalization((IResourceSource)(object)directorySource, typeof(JadeBoxTemplate), "Jadeboxes", (Locale)0, false);

		private void Awake()
		{
			log = ((BaseUnityPlugin)this).Logger;
			Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
			((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
			EntityManager.RegisterSelf();
			harmony.PatchAll();
			if (Chainloader.PluginInfos.ContainsKey("neo.lbol.tools.watermark"))
			{
				WatermarkWrapper.ActivateWatermark();
			}
		}

		private void OnDestroy()
		{
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
		}
	}
	public class AllVulnerable
	{
		public sealed class WorldOfHurtDef : JadeBoxTemplate
		{
			[EntityLogic(typeof(WorldOfHurtDef))]
			public sealed class GetWorldOfHurt : JadeBox
			{
				protected override void OnEnterBattle()
				{
					((JadeBox)this).ReactBattleEvent<UnitEventArgs>(((Unit)((JadeBox)this).Battle.Player).TurnStarted, (EventSequencedReactor<UnitEventArgs>)OnBattleStarted);
				}

				private IEnumerable<BattleAction> OnBattleStarted(GameEventArgs args)
				{
					PlayerUnit player = ((JadeBox)this).Battle.Player;
					if (((Unit)((JadeBox)this).Battle.Player).TurnCounter == 1)
					{
						((JadeBox)this).NotifyActivating();
						int level = spiritGain - ((GameEntity)this).GameRun._stageIndex;
						if (level >= 1)
						{
							yield return (BattleAction)(object)new ApplyStatusEffectAction<Spirit>((Unit)(object)player, (int?)level, (int?)null, (int?)null, (int?)null, 0f, true);
						}
					}
					yield return (BattleAction)(object)new ApplyStatusEffectAction<Vulnerable>((Unit)(object)player, (int?)null, (int?)1, (int?)null, (int?)null, 0f, true);
					foreach (EnemyUnit enemy in ((JadeBox)this).Battle.AllAliveEnemies)
					{
						yield return (BattleAction)(object)new ApplyStatusEffectAction<Vulnerable>((Unit)(object)enemy, (int?)null, (int?)1, (int?)null, (int?)null, 0f, true);
					}
				}

				protected override void OnGain(GameRunController gameRun)
				{
					((MonoBehaviour)Singleton<GameMaster>.Instance).StartCoroutine(GainExhibits(gameRun));
				}

				private IEnumerator GainExhibits(GameRunController gameRun)
				{
					HashSet<Type> exhibit = new HashSet<Type> { typeof(Fengrenji) };
					foreach (Type et in exhibit)
					{
						yield return gameRun.GainExhibitRunner(Library.CreateExhibit(et), false, (VisualSourceData)null);
					}
					gameRun.ExhibitPool.RemoveAll((Type e) => exhibit.Contains(e));
				}
			}

			private static int spiritGain = 4;

			public override IdContainer GetId()
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				//IL_000e: Unknown result type (might be due to invalid IL or missing references)
				return IdContainer.op_Implicit("GetWorldOfHurt");
			}

			public override JadeBoxConfig MakeConfig()
			{
				JadeBoxConfig val = ((JadeBoxTemplate)this).DefaultConfig();
				val.Value1 = spiritGain;
				return val;
			}

			public override LocalizationOption LoadLocalization()
			{
				return (LocalizationOption)(object)BepinexPlugin.JadeboxBatchLoc.AddEntity((EntityDefinition)(object)this);
			}
		}
	}
	public class NeutralOnly
	{
		public sealed class ForgetYourNameDef : JadeBoxTemplate
		{
			[EntityLogic(typeof(ForgetYourNameDef))]
			public sealed class ForgetYourName : JadeBox
			{
				[HarmonyPatch]
				private class GameRunController_RollCards_Patch
				{
					private static IEnumerable<MethodBase> TargetMethods()
					{
						return (from m in AccessTools.GetDeclaredMethods(typeof(GameRunController))
							where m.Name == "RollCards"
							select m).ToList();
					}

					private static void Prefix(ref CardWeightTable weightTable, GameRunController __instance)
					{
						//IL_0033: Unknown result type (might be due to invalid IL or missing references)
						//IL_0039: Expected O, but got Unknown
						CheckJadeboxes(__instance);
						if (neutralOnlyActive && !synestasiaActive)
						{
							weightTable = new CardWeightTable(weightTable.RarityTable, OwnerWeightTable.OnlyNeutral, weightTable.CardTypeTable);
						}
					}
				}

				[HarmonyPatch(typeof(Debut), "ExchangeExhibit")]
				private class BanExhibitSwap_Patch
				{
					private static void Prefix(Debut __instance)
					{
						//IL_0024: Unknown result type (might be due to invalid IL or missing references)
						CheckJadeboxes(((Adventure)__instance).GameRun);
						if (neutralOnlyActive)
						{
							GameRunController currentGameRun = Singleton<GameMaster>.Instance.CurrentGameRun;
							currentGameRun.LoseBaseMana(ManaGroup.Single((ManaColor)7), false);
						}
					}
				}

				private static bool neutralOnlyActive;

				private static bool synestasiaActive;

				private static bool fullPowerActive;

				protected override void OnGain(GameRunController gameRun)
				{
					SetBaseMana(gameRun);
				}

				private static void SetBaseMana(GameRunController gameRun)
				{
					//IL_0002: 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_0083: Unknown result type (might be due to invalid IL or missing references)
					//IL_006a: Unknown result type (might be due to invalid IL or missing references)
					//IL_006f: Unknown result type (might be due to invalid IL or missing references)
					gameRun.BaseMana = ManaGroup.Empty;
					int num = 5;
					CheckJadeboxes(gameRun);
					if (fullPowerActive)
					{
						num = 4;
						Exhibit val = Library.CreateExhibit(((int)gameRun.PlayerType != 0) ? gameRun.Player.Config.ExhibitB : gameRun.Player.Config.ExhibitA);
						Debug.Log((object)("primary exhibit: " + ((GameEntity)val).Name));
						gameRun.GainBaseMana(BaseManaGroup.op_Implicit(val.BaseMana), false);
					}
					for (int i = 0; i < num; i++)
					{
						gameRun.GainBaseMana(ManaGroup.Single((ManaColor)7), false);
					}
					int rewardAndShopCardColorLimitFlag = gameRun.RewardAndShopCardColorLimitFlag;
					gameRun.RewardAndShopCardColorLimitFlag = rewardAndShopCardColorLimitFlag + 1;
					((MonoBehaviour)Singleton<GameMaster>.Instance).StartCoroutine(ResetDeck(gameRun));
				}

				private static IEnumerator ResetDeck(GameRunController gameRun)
				{
					yield return null;
					ResetStart50.ResetStart50Deck(gameRun);
				}

				private static void Init(GameRunController gameRun)
				{
					int rewardAndShopCardColorLimitFlag = gameRun.RewardAndShopCardColorLimitFlag;
					gameRun.RewardAndShopCardColorLimitFlag = rewardAndShopCardColorLimitFlag + 1;
					rewardAndShopCardColorLimitFlag = gameRun.AdditionalRewardCardCount;
					gameRun.AdditionalRewardCardCount = rewardAndShopCardColorLimitFlag + 1;
				}

				protected override void OnAdded()
				{
					Init(((GameEntity)this).GameRun);
				}

				private static void CheckJadeboxes(GameRunController run)
				{
					neutralOnlyActive = false;
					synestasiaActive = false;
					fullPowerActive = false;
					try
					{
						if (run == null)
						{
							Debug.Log((object)"game run controller is null");
							return;
						}
						IReadOnlyList<JadeBox> jadeBoxes = run.JadeBoxes;
						if (jadeBoxes != null && jadeBoxes.Count > 0)
						{
							neutralOnlyActive = run.JadeBoxes.Any((JadeBox jb) => jb is ForgetYourName);
							synestasiaActive = run.JadeBoxes.Any((JadeBox jb) => jb is AllCharacterCards);
							fullPowerActive = run.JadeBoxes.Any((JadeBox jb) => jb is TwoColorStart);
						}
					}
					catch (Exception ex)
					{
						Debug.LogError((object)("Error when checking jadeboxes in Forget your name: " + ex.Message + ex.StackTrace));
					}
				}
			}

			public override IdContainer GetId()
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				//IL_000e: Unknown result type (might be due to invalid IL or missing references)
				return IdContainer.op_Implicit("ForgetYourName");
			}

			public override LocalizationOption LoadLocalization()
			{
				return (LocalizationOption)(object)BepinexPlugin.JadeboxBatchLoc.AddEntity((EntityDefinition)(object)this);
			}

			public override JadeBoxConfig MakeConfig()
			{
				//IL_000a: Unknown result type (might be due to invalid IL or missing references)
				JadeBoxConfig val = ((JadeBoxTemplate)this).DefaultConfig();
				val.Mana = ManaGroup.Single((ManaColor)7);
				return val;
			}
		}
	}
	public static class PInfo
	{
		public const string GUID = "crystalcreation.customjadebox";

		public const string Name = "customjadebox";

		public const string version = "1.0.0";

		public static readonly Harmony harmony = new Harmony("crystalcreation.customjadebox");
	}
	internal class WatermarkWrapper
	{
		[MethodImpl(MethodImplOptions.NoInlining)]
		internal static void ActivateWatermark()
		{
			API.ActivateWatermark();
		}
	}
}
namespace CustomJadebox.Util
{
	public class ResetStart50
	{
		public static bool ResetStart50Deck(GameRunController run)
		{
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Expected O, but got Unknown
			if (run == null)
			{
				return false;
			}
			IReadOnlyList<JadeBox> jadeBoxes = run.JadeBoxes;
			bool flag = false;
			bool flag2 = false;
			bool flag3 = false;
			if (jadeBoxes != null && jadeBoxes.Count > 0)
			{
				flag = run.JadeBoxes.Any((JadeBox jb) => jb is NeutralOnly.ForgetYourNameDef.ForgetYourName);
				flag2 = run.JadeBoxes.Any((JadeBox jb) => jb is AllCharacterCards);
				flag3 = run.JadeBoxes.Any((JadeBox jb) => jb is OnlyRare.OnlyRareDef.OnlyRareJadebox);
			}
			if (jadeBoxes != null && jadeBoxes.Count > 0)
			{
				foreach (JadeBox item in jadeBoxes)
				{
					if (!(item is Start50))
					{
						continue;
					}
					run.RemoveDeckCards((IEnumerable<Card>)run.BaseDeck, false);
					for (int i = 0; i < item.Value1; i++)
					{
						OwnerWeightTable val = OwnerWeightTable.Valid;
						RarityWeightTable val2 = RarityWeightTable.EnemyCard;
						if (flag && !flag2)
						{
							val = OwnerWeightTable.OnlyNeutral;
						}
						if (flag3)
						{
							val2 = RarityWeightTable.OnlyRare;
						}
						Card[] array = run.RollCards(run.CardRng, new CardWeightTable(val2, val, CardTypeWeightTable.CanBeLoot), 1, (ManaGroup?)run.BaseMana, !flag, false, false, false, (Predicate<CardConfig>)null);
						run.AddDeckCards((IEnumerable<Card>)array, false, (VisualSourceData)null);
					}
					return true;
				}
			}
			return false;
		}
	}
}
namespace CustomJadebox.JadeBoxes
{
	public class AllExtraTurns
	{
		public sealed class AllExtraTurnsDef : JadeBoxTemplate
		{
			[EntityLogic(typeof(AllExtraTurnsDef))]
			public sealed class GetAllExtraTurns : JadeBox
			{
				protected override void OnEnterBattle()
				{
					((JadeBox)this).ReactBattleEvent<UnitEventArgs>(((Unit)((JadeBox)this).Battle.Player).TurnStarted, (EventSequencedReactor<UnitEventArgs>)OnBattleStarted);
				}

				private IEnumerable<BattleAction> OnBattleStarted(GameEventArgs args)
				{
					PlayerUnit player = ((JadeBox)this).Battle.Player;
					if (((Unit)player).IsExtraTurn)
					{
						yield break;
					}
					yield return (BattleAction)(object)new ApplyStatusEffectAction<ExtraTurn>((Unit)(object)player, (int?)1, (int?)null, (int?)null, (int?)null, 0f, true);
					foreach (EnemyUnit enemy in ((JadeBox)this).Battle.AllAliveEnemies)
					{
						yield return (BattleAction)(object)new ApplyStatusEffectAction<ExtraTurn>((Unit)(object)enemy, (int?)1, (int?)null, (int?)null, (int?)null, 0f, true);
					}
				}

				protected override void OnGain(GameRunController gameRun)
				{
					((MonoBehaviour)Singleton<GameMaster>.Instance).StartCoroutine(GainExhibits(gameRun));
				}

				private IEnumerator GainExhibits(GameRunController gameRun)
				{
					HashSet<Type> exhibit = new HashSet<Type> { typeof(Yueshan) };
					foreach (Type et in exhibit)
					{
						yield return gameRun.GainExhibitRunner(Library.CreateExhibit(et), false, (VisualSourceData)null);
					}
					gameRun.ExhibitPool.RemoveAll((Type e) => exhibit.Contains(e));
				}
			}

			public override IdContainer GetId()
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				//IL_000e: Unknown result type (might be due to invalid IL or missing references)
				return IdContainer.op_Implicit("GetAllExtraTurns");
			}

			public override LocalizationOption LoadLocalization()
			{
				return (LocalizationOption)(object)BepinexPlugin.JadeboxBatchLoc.AddEntity((EntityDefinition)(object)this);
			}

			public override JadeBoxConfig MakeConfig()
			{
				return ((JadeBoxTemplate)this).DefaultConfig();
			}
		}
	}
	public class AllShinies
	{
		public sealed class AllShiniesDef : JadeBoxTemplate
		{
			[EntityLogic(typeof(AllShiniesDef))]
			public sealed class GetAllShinies : JadeBox
			{
				private class CoroutineExtender : IEnumerable
				{
					public IEnumerator target_enumerator;

					public List<IEnumerator> preItems = new List<IEnumerator>();

					public List<IEnumerator> postItems = new List<IEnumerator>();

					public List<IEnumerator> midItems = new List<IEnumerator>();

					public CoroutineExtender()
					{
					}

					public CoroutineExtender(IEnumerator target_enumerator)
					{
						this.target_enumerator = target_enumerator;
					}

					public IEnumerator GetEnumerator()
					{
						foreach (IEnumerator preItem in preItems)
						{
							yield return preItem;
						}
						int i = 0;
						while (target_enumerator.MoveNext())
						{
							yield return target_enumerator.Current;
							i++;
						}
						foreach (IEnumerator postItem in postItems)
						{
							yield return postItem;
						}
					}
				}

				[HarmonyPatch(typeof(Exhibit), "TriggerGain")]
				private class Exhibit_Patch
				{
					private static void Postfix(ref IEnumerator __result)
					{
						CoroutineExtender coroutineExtender = new CoroutineExtender(__result);
						coroutineExtender.postItems.Add(GainOtherShinies());
						__result = coroutineExtender.GetEnumerator();
					}

					private static IEnumerator GainOtherShinies()
					{
						if (!((Object)(object)Singleton<GameMaster>.Instance != (Object)null) || Singleton<GameMaster>.Instance.CurrentGameRun == null || !AllShiniesJadebox(Singleton<GameMaster>.Instance.CurrentGameRun))
						{
							yield break;
						}
						Debug.Log((object)"start gaining shinies");
						GameRunController run = Singleton<GameMaster>.Instance.CurrentGameRun;
						if (run.CurrentStation == null || (int)run.CurrentStation.Type != 10)
						{
							yield break;
						}
						string bossName = ((BossStation)run.CurrentStation).BossId;
						if (!bossesDone.Contains(bossName))
						{
							bossesDone.Add(bossName);
							Exhibit[] exhibitList = ((BossStation)run.CurrentStation).BossRewards;
							Exhibit[] array = exhibitList;
							foreach (Exhibit exhibit in array)
							{
								if (!run.Player.Exhibits.Contains(exhibit))
								{
									Debug.Log((object)("gaining exhibit " + (object)exhibit));
									yield return run.GainExhibitRunner(exhibit, false, (VisualSourceData)null);
								}
								else
								{
									run.GainBaseMana(ManaGroup.Colorlesses(1), false);
								}
								yield return null;
								run.LoseBaseMana(BaseManaGroup.op_Implicit(exhibit.BaseMana), false);
							}
						}
						else
						{
							Debug.Log((object)("already gained exhibit from boss: " + bossName));
						}
					}
				}

				private static List<string> bossesDone = new List<string>();

				protected override void OnGain(GameRunController run)
				{
					((MonoBehaviour)Singleton<GameMaster>.Instance).StartCoroutine(RemoveFromPool(run));
					bossesDone = new List<string>();
				}

				protected override void OnAdded()
				{
					bossesDone = new List<string>();
				}

				private IEnumerator RemoveFromPool(GameRunController gameRun)
				{
					if (gameRun == null)
					{
						yield break;
					}
					HashSet<Type> exhibit = new HashSet<Type>
					{
						typeof(YizangnuoWuzhi),
						typeof(QipaiYouhua),
						typeof(HuiyeBaoxiang),
						typeof(LouguanJian)
					};
					foreach (Type item in exhibit)
					{
						Debug.Log((object)("removing from pool: " + item.Name + " was in pool: " + gameRun.ShiningExhibitPool.Contains(item)));
					}
					gameRun.ShiningExhibitPool.RemoveAll((Type e) => exhibit.Contains(e));
					yield return null;
				}

				public static bool AllShiniesJadebox(GameRunController run)
				{
					if (run == null)
					{
						return false;
					}
					IReadOnlyList<JadeBox> jadeBoxes = run.JadeBoxes;
					if (jadeBoxes != null && jadeBoxes.Count > 0 && run.JadeBoxes.Any((JadeBox jb) => jb is GetAllShinies))
					{
						return true;
					}
					return false;
				}
			}

			public override IdContainer GetId()
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				//IL_000e: Unknown result type (might be due to invalid IL or missing references)
				return IdContainer.op_Implicit("GetAllShinies");
			}

			public override JadeBoxConfig MakeConfig()
			{
				//IL_000a: Unknown result type (might be due to invalid IL or missing references)
				JadeBoxConfig val = ((JadeBoxTemplate)this).DefaultConfig();
				val.Mana = ManaGroup.Single((ManaColor)6);
				return val;
			}

			public override LocalizationOption LoadLocalization()
			{
				return (LocalizationOption)(object)BepinexPlugin.JadeboxBatchLoc.AddEntity((EntityDefinition)(object)this);
			}
		}
	}
	public class AllUpgraded
	{
		public sealed class AllUpgradedDef : JadeBoxTemplate
		{
			[EntityLogic(typeof(AllUpgradedDef))]
			public sealed class AllUpgradedJadebox : JadeBox
			{
				protected override void OnEnterBattle()
				{
					((JadeBox)this).ReactBattleEvent<UnitEventArgs>(((Unit)((JadeBox)this).Battle.Player).TurnStarted, (EventSequencedReactor<UnitEventArgs>)OnBattleStarted);
				}

				private IEnumerable<BattleAction> OnBattleStarted(GameEventArgs args)
				{
					if (((Unit)((JadeBox)this).Battle.Player).TurnCounter != 1)
					{
						yield break;
					}
					((JadeBox)this).NotifyActivating();
					foreach (EnemyUnit enemy in ((JadeBox)this).Battle.AllAliveEnemies)
					{
						yield return (BattleAction)(object)new ApplyStatusEffectAction<LoveGirlDamageReduce>((Unit)(object)enemy, (int?)regretsGain, (int?)null, (int?)null, (int?)null, 0f, false);
						yield return (BattleAction)(object)new ApplyStatusEffectAction<Firepower>((Unit)(object)enemy, (int?)firepowerGain, (int?)null, (int?)null, (int?)null, 0f, true);
					}
				}

				protected override void OnGain(GameRunController gameRun)
				{
					UpgradeAllCards();
					((MonoBehaviour)Singleton<GameMaster>.Instance).StartCoroutine(RemoveFromPool(gameRun));
				}

				protected override void OnAdded()
				{
					((JadeBox)this).HandleGameRunEvent<CardsEventArgs>(((GameEntity)this).GameRun.DeckCardsAdded, (GameEventHandler<CardsEventArgs>)OnDeckCardAdded);
				}

				public void OnDeckCardAdded(CardsEventArgs args)
				{
					try
					{
						UpgradeAllCards();
					}
					catch (Exception ex)
					{
						Debug.LogError((object)(" exception in OnDeckCardAdded: " + ex.Message + ex.StackTrace));
					}
				}

				private void UpgradeAllCards()
				{
					try
					{
						Debug.Log((object)("cards in deck: " + ((GameEntity)this).GameRun.BaseDeck.Count));
						foreach (Card item in ((GameEntity)this).GameRun.BaseDeck)
						{
							if (item.CanUpgrade && item.CanUpgradeAndPositive && !item.IsUpgraded)
							{
								item.Upgrade();
							}
						}
					}
					catch (Exception ex)
					{
						Debug.LogError((object)(" exception in UpgradeAllCards: " + ex.Message + ex.StackTrace));
					}
				}

				private IEnumerator RemoveFromPool(GameRunController gameRun)
				{
					HashSet<Type> exhibit = new HashSet<Type>
					{
						typeof(Chaidao),
						typeof(Fengrenji),
						typeof(Jiaobu),
						typeof(Shoubiao),
						typeof(Shouyinji),
						typeof(Zixingche)
					};
					gameRun.ExhibitPool.RemoveAll((Type e) => exhibit.Contains(e));
					yield return null;
				}
			}

			private static int firepowerGain = 2;

			private static int regretsGain = 1;

			public override IdContainer GetId()
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				//IL_000e: Unknown result type (might be due to invalid IL or missing references)
				return IdContainer.op_Implicit("AllUpgradedJadebox");
			}

			public override LocalizationOption LoadLocalization()
			{
				return (LocalizationOption)(object)BepinexPlugin.JadeboxBatchLoc.AddEntity((EntityDefinition)(object)this);
			}

			public override JadeBoxConfig MakeConfig()
			{
				JadeBoxConfig val = ((JadeBoxTemplate)this).DefaultConfig();
				val.Value1 = firepowerGain;
				val.Value2 = regretsGain;
				return val;
			}
		}
	}
	public class CardLimit
	{
		public sealed class CardLimitDef : JadeBoxTemplate
		{
			[EntityLogic(typeof(CardLimitDef))]
			public sealed class GetCardLimit : JadeBox
			{
				protected override void OnEnterBattle()
				{
					((JadeBox)this).ReactBattleEvent<UnitEventArgs>(((Unit)((JadeBox)this).Battle.Player).TurnStarted, (EventSequencedReactor<UnitEventArgs>)OnBattleStarted);
				}

				private IEnumerable<BattleAction> OnBattleStarted(GameEventArgs args)
				{
					int shiningCount = 0;
					PlayerUnit player = ((JadeBox)this).Battle.Player;
					foreach (Exhibit item in player.Exhibits)
					{
						if ((int)item.Config.Rarity == 3)
						{
							shiningCount++;
						}
					}
					ManaGroup val = default(ManaGroup);
					((ManaGroup)(ref val)).Philosophy = shiningCount;
					yield return (BattleAction)new GainManaAction(val);
					bool alreadyCharmed = false;
					foreach (StatusEffect item2 in ((Unit)player).StatusEffects)
					{
						if (((object)item2).GetType() == typeof(FoxCharm))
						{
							alreadyCharmed = true;
							break;
						}
					}
					if (!alreadyCharmed)
					{
						yield return (BattleAction)(object)new ApplyStatusEffectAction<FoxCharm>((Unit)(object)player, (int?)null, (int?)null, (int?)null, (int?)cardLimit, 0f, true);
					}
				}
			}

			public static int cardLimit = 5;

			public override IdContainer GetId()
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				//IL_000e: Unknown result type (might be due to invalid IL or missing references)
				return IdContainer.op_Implicit("GetCardLimit");
			}

			public override JadeBoxConfig MakeConfig()
			{
				//IL_001b: Unknown result type (might be due to invalid IL or missing references)
				JadeBoxConfig val = ((JadeBoxTemplate)this).DefaultConfig();
				val.Value1 = cardLimit;
				val.Mana = ManaGroup.Single((ManaColor)7);
				return val;
			}

			public override LocalizationOption LoadLocalization()
			{
				return (LocalizationOption)(object)BepinexPlugin.JadeboxBatchLoc.AddEntity((EntityDefinition)(object)this);
			}
		}
	}
	public class ChromaShift
	{
		public sealed class ChromaShiftDef : JadeBoxTemplate
		{
			[EntityLogic(typeof(ChromaShiftDef))]
			public sealed class GetChromaShift : JadeBox
			{
				private static Exhibit selectedExhibit;

				private static Exhibit secondaryExhibit;

				protected override void OnGain(GameRunController gameRun)
				{
					((MonoBehaviour)Singleton<GameMaster>.Instance).StartCoroutine(GainExhibit(gameRun));
					((MonoBehaviour)Singleton<GameMaster>.Instance).StartCoroutine(SetMana(gameRun));
				}

				private static IEnumerator GainExhibit(GameRunController gameRun)
				{
					List<Type> exhibits = new List<Type>
					{
						typeof(CirnoG),
						typeof(CirnoU),
						typeof(MarisaB),
						typeof(MarisaR),
						typeof(ReimuR),
						typeof(ReimuW),
						typeof(SakuyaU),
						typeof(SakuyaW)
					};
					RandomGen rng = gameRun.AdventureRng;
					List<Type> toRemove = new List<Type>();
					for (int j = 0; j < exhibits.Count; j++)
					{
						Type ex = exhibits[j];
						ManaGroup baseMana = gameRun.BaseMana;
						if (((ManaGroup)(ref baseMana)).HasColor(Library.CreateExhibit(ex).Config.BaseManaColor.Value))
						{
							toRemove.Add(ex);
						}
					}
					foreach (Type ex3 in toRemove)
					{
						exhibits.Remove(ex3);
					}
					int removeCount = exhibits.Count - 1;
					for (int i = 0; i < removeCount; i++)
					{
						int remove = rng.NextInt(0, exhibits.Count - 1);
						exhibits.RemoveAt(remove);
					}
					foreach (Type ex2 in exhibits)
					{
						Debug.Log((object)("giving exhibit: " + ex2.Name));
						selectedExhibit = Library.CreateExhibit(ex2);
						yield return gameRun.GainExhibitRunner(selectedExhibit, true, (VisualSourceData)null);
					}
					gameRun.ExhibitPool.RemoveAll((Type e) => exhibits.Contains(e));
				}

				private static IEnumerator SetMana(GameRunController gameRun)
				{
					yield return null;
					gameRun.LoseBaseMana(BaseManaGroup.op_Implicit(selectedExhibit.BaseMana), false);
					secondaryExhibit = Library.CreateExhibit(((int)gameRun.PlayerType == 0) ? gameRun.Player.Config.ExhibitB : gameRun.Player.Config.ExhibitA);
					Debug.Log((object)("players other exhibit: " + ((GameEntity)secondaryExhibit).Name));
					ManaColor colorToRemove = secondaryExhibit.Config.BaseManaColor.Value;
					ManaGroup baseMana = gameRun.BaseMana;
					int manaCount = ((ManaGroup)(ref baseMana)).GetValue(colorToRemove);
					Debug.Log((object)("about to remove: " + manaCount + " mana of color: " + ManaColorExtensions.ToLongName(colorToRemove)));
					for (int i = 0; i < manaCount; i++)
					{
						gameRun.LoseBaseMana(BaseManaGroup.op_Implicit(secondaryExhibit.BaseMana), false);
						gameRun.GainBaseMana(BaseManaGroup.op_Implicit(selectedExhibit.BaseMana), false);
					}
					yield return null;
					ReplaceCards(gameRun);
				}

				private static void ReplaceCards(GameRunController gameRun)
				{
					//IL_0029: Unknown result type (might be due to invalid IL or missing references)
					//IL_002e: Unknown result type (might be due to invalid IL or missing references)
					//IL_0055: Unknown result type (might be due to invalid IL or missing references)
					if (ResetStart50.ResetStart50Deck(gameRun))
					{
						return;
					}
					List<Card> list = new List<Card>();
					ManaColor value = secondaryExhibit.Config.BaseManaColor.Value;
					foreach (Card item in gameRun.BaseDeck)
					{
						if (item.Config.Colors.Contains(value) && item.IsBasic)
						{
							list.Add(item);
						}
					}
					for (int i = 0; i < list.Count; i++)
					{
						GetBasicForExhibit(gameRun);
					}
					foreach (Card item2 in list)
					{
						gameRun.RemoveDeckCard(item2, true);
					}
				}

				private static void GetBasicForExhibit(GameRunController gameRun)
				{
					Debug.Log((object)("about to add card for selected exhibit: " + ((GameEntity)selectedExhibit).Name));
					if (selectedExhibit is CirnoG)
					{
						gameRun.AddDeckCards((IEnumerable<Card>)Library.CreateCards<CirnoBlockG>(1, false), false, (VisualSourceData)null);
						return;
					}
					if (selectedExhibit is CirnoU)
					{
						gameRun.AddDeckCards((IEnumerable<Card>)Library.CreateCards<CirnoBlockU>(1, false), false, (VisualSourceData)null);
						return;
					}
					if (selectedExhibit is MarisaB)
					{
						gameRun.AddDeckCards((IEnumerable<Card>)Library.CreateCards<MarisaBlockB>(1, false), false, (VisualSourceData)null);
						return;
					}
					if (selectedExhibit is MarisaR)
					{
						gameRun.AddDeckCards((IEnumerable<Card>)Library.CreateCards<MarisaBlockR>(1, false), false, (VisualSourceData)null);
						return;
					}
					if (selectedExhibit is ReimuR)
					{
						gameRun.AddDeckCards((IEnumerable<Card>)Library.CreateCards<ReimuBlockR>(1, false), false, (VisualSourceData)null);
						return;
					}
					if (selectedExhibit is ReimuW)
					{
						gameRun.AddDeckCards((IEnumerable<Card>)Library.CreateCards<ReimuBlockW>(1, false), false, (VisualSourceData)null);
						return;
					}
					if (selectedExhibit is SakuyaU)
					{
						gameRun.AddDeckCards((IEnumerable<Card>)Library.CreateCards<SakuyaBlockU>(1, false), false, (VisualSourceData)null);
						return;
					}
					if (selectedExhibit is SakuyaW)
					{
						gameRun.AddDeckCards((IEnumerable<Card>)Library.CreateCards<SakuyaBlockW>(1, false), false, (VisualSourceData)null);
						return;
					}
					gameRun.AddDeckCards((IEnumerable<Card>)Library.CreateCards<ReimuBlockR>(1, true), false, (VisualSourceData)null);
					Debug.LogError((object)("cant find card for selected exhibit: " + ((GameEntity)selectedExhibit).Name));
				}
			}

			public override IdContainer GetId()
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				//IL_000e: Unknown result type (might be due to invalid IL or missing references)
				return IdContainer.op_Implicit("GetChromaShift");
			}

			public override LocalizationOption LoadLocalization()
			{
				return (LocalizationOption)(object)BepinexPlugin.JadeboxBatchLoc.AddEntity((EntityDefinition)(object)this);
			}

			public override JadeBoxConfig MakeConfig()
			{
				return ((JadeBoxTemplate)this).DefaultConfig();
			}
		}
	}
	public class DefenseBuff
	{
		public sealed class DefenseBuffDef : JadeBoxTemplate
		{
			[EntityLogic(typeof(DefenseBuffDef))]
			public sealed class GetDefenseBuff : JadeBox
			{
				protected override void OnEnterBattle()
				{
					((JadeBox)this).ReactBattleEvent<UnitEventArgs>(((Unit)((JadeBox)this).Battle.Player).TurnStarted, (EventSequencedReactor<UnitEventArgs>)OnBattleStarted);
				}

				private IEnumerable<BattleAction> OnBattleStarted(GameEventArgs args)
				{
					PlayerUnit player = ((JadeBox)this).Battle.Player;
					if (((Unit)((JadeBox)this).Battle.Player).TurnCounter == 1)
					{
						((JadeBox)this).NotifyActivating();
						yield return (BattleAction)(object)new ApplyStatusEffectAction<Spirit>((Unit)(object)player, (int?)statusGain, (int?)null, (int?)null, (int?)null, 0f, true);
						yield return (BattleAction)(object)new ApplyStatusEffectAction<FirepowerNegative>((Unit)(object)player, (int?)statusGain, (int?)null, (int?)null, (int?)null, 0f, true);
					}
				}

				private static void Init(GameRunController gameRun)
				{
					int additionalRewardCardCount = gameRun.AdditionalRewardCardCount;
					gameRun.AdditionalRewardCardCount = additionalRewardCardCount + 1;
				}

				protected override void OnAdded()
				{
					Init(((GameEntity)this).GameRun);
				}
			}

			private static int statusGain = 4;

			public override IdContainer GetId()
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				//IL_000e: Unknown result type (might be due to invalid IL or missing references)
				return IdContainer.op_Implicit("GetDefenseBuff");
			}

			public override JadeBoxConfig MakeConfig()
			{
				JadeBoxConfig val = ((JadeBoxTemplate)this).DefaultConfig();
				val.Value1 = statusGain;
				return val;
			}

			public override LocalizationOption LoadLocalization()
			{
				return (LocalizationOption)(object)BepinexPlugin.JadeboxBatchLoc.AddEntity((EntityDefinition)(object)this);
			}
		}
	}
	public class GapActivities
	{
		public sealed class GapActivitiesDef : JadeBoxTemplate
		{
			[EntityLogic(typeof(GapActivitiesDef))]
			public sealed class GetGapActivities : JadeBox
			{
				[HarmonyPatch]
				private class UpgradeDeckCardPrice_Patch
				{
					private static IEnumerable<MethodBase> TargetMethods()
					{
						yield return AccessTools.PropertyGetter(typeof(GameRunController), "UpgradeDeckCardPrice");
					}

					private static void Postfix(ref int __result)
					{
						if (IsGapActivityJadebox())
						{
							__result = newUpgradePrice;
						}
					}
				}

				[HarmonyPatch(typeof(GapStation), "OnEnter")]
				private class GapStation_OnEnter_Patch
				{
					private static void Postfix(GapStation __instance)
					{
						//IL_0035: Unknown result type (might be due to invalid IL or missing references)
						//IL_003b: Expected O, but got Unknown
						if (IsGapActivityJadebox())
						{
							UpgradeCard val = (UpgradeCard)__instance.GapOptions.Find((GapOption g) => g is UpgradeCard);
							if (val != null)
							{
								val.Price = newUpgradePrice;
							}
							else
							{
								Debug.Log((object)"could not find gap upgrade option");
							}
						}
					}
				}

				protected override void OnGain(GameRunController gameRun)
				{
					((MonoBehaviour)Singleton<GameMaster>.Instance).StartCoroutine(GainExhibits(gameRun));
				}

				private IEnumerator GainExhibits(GameRunController gameRun)
				{
					List<Type> exhibits = new List<Type>
					{
						typeof(Baota),
						typeof(Saiqianxiang),
						typeof(ShanliangDengpao),
						typeof(ShoushiYubi),
						typeof(Xunlongchi)
					};
					RandomGen rng = gameRun.AdventureRng;
					int removeCount = exhibits.Count - exibitsToGain;
					for (int i = 0; i < removeCount; i++)
					{
						int remove = rng.NextInt(0, exhibits.Count - 1);
						exhibits.RemoveAt(remove);
					}
					foreach (Type ex in exhibits)
					{
						yield return gameRun.GainExhibitRunner(Library.CreateExhibit(ex), true, (VisualSourceData)null);
					}
					gameRun.ExhibitPool.RemoveAll((Type e) => exhibits.Contains(e));
				}

				private static bool IsGapActivityJadebox()
				{
					GameRunController currentGameRun = Singleton<GameMaster>.Instance.CurrentGameRun;
					IReadOnlyList<JadeBox> jadeBoxes = currentGameRun.JadeBoxes;
					if (jadeBoxes != null && jadeBoxes.Count > 0 && currentGameRun.JadeBoxes.Any((JadeBox jb) => jb is GetGapActivities))
					{
						return true;
					}
					return false;
				}
			}

			private static int exibitsToGain = 2;

			private static int newUpgradePrice = 100;

			public override IdContainer GetId()
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				//IL_000e: Unknown result type (might be due to invalid IL or missing references)
				return IdContainer.op_Implicit("GetGapActivities");
			}

			public override JadeBoxConfig MakeConfig()
			{
				JadeBoxConfig val = ((JadeBoxTemplate)this).DefaultConfig();
				val.Value1 = exibitsToGain;
				val.Value2 = newUpgradePrice;
				return val;
			}

			public override LocalizationOption LoadLocalization()
			{
				return (LocalizationOption)(object)BepinexPlugin.JadeboxBatchLoc.AddEntity((EntityDefinition)(object)this);
			}
		}
	}
	public class IntoTheVoid
	{
		public sealed class IntoTheVoidDef : JadeBoxTemplate
		{
			[EntityLogic(typeof(IntoTheVoidDef))]
			public sealed class GetIntoTheVoid : JadeBox
			{
				protected override void OnEnterBattle()
				{
					((JadeBox)this).ReactBattleEvent<UnitEventArgs>(((Unit)((JadeBox)this).Battle.Player).TurnStarted, (EventSequencedReactor<UnitEventArgs>)OnBattleStarted);
				}

				private IEnumerable<BattleAction> OnBattleStarted(GameEventArgs args)
				{
					if (((Unit)((JadeBox)this).Battle.Player).TurnCounter == 1)
					{
						List<Card> list = ((JadeBox)this).Battle.DrawZone.ToList();
						list.AddRange(((JadeBox)this).Battle.HandZone);
						if (list.Count > 0)
						{
							SetupCards(list);
						}
						((JadeBox)this).HandleBattleEvent<CardsEventArgs>(((JadeBox)this).Battle.CardsAddedToDiscard, (GameEventHandler<CardsEventArgs>)OnAddCard);
						((JadeBox)this).HandleBattleEvent<CardsEventArgs>(((JadeBox)this).Battle.CardsAddedToHand, (GameEventHandler<CardsEventArgs>)OnAddCard);
						((JadeBox)this).HandleBattleEvent<CardsEventArgs>(((JadeBox)this).Battle.CardsAddedToExile, (GameEventHandler<CardsEventArgs>)OnAddCard);
						((JadeBox)this).HandleBattleEvent<CardsAddingToDrawZoneEventArgs>(((JadeBox)this).Battle.CardsAddedToDrawZone, (GameEventHandler<CardsAddingToDrawZoneEventArgs>)OnAddCardToDraw);
					}
					yield return null;
				}

				private void SetupCards(List<Card> list)
				{
					//IL_002e: Unknown result type (might be due to invalid IL or missing references)
					//IL_0033: Unknown result type (might be due to invalid IL or missing references)
					//IL_0046: Unknown result type (might be due to invalid IL or missing references)
					//IL_004b: Unknown result type (might be due to invalid IL or missing references)
					//IL_0065: Unknown result type (might be due to invalid IL or missing references)
					foreach (Card item in list)
					{
						if (!item.IsForbidden && !item.IsBasic)
						{
							ManaGroup cost = item.Cost;
							if (((ManaGroup)(ref cost)).Amount > 0)
							{
								cost = item.Cost;
								item.DecreaseBaseCost(ManaGroup.FromComponents((IEnumerable<ManaColor>)CollectionsExtensions.SampleManyOrAll<ManaColor>(((ManaGroup)(ref cost)).EnumerateComponents(), 1, ((GameEntity)this).GameRun.BattleRng)));
							}
							item.IsExile = true;
							item.NotifyActivating();
						}
					}
				}

				private void OnAddCardToDraw(CardsAddingToDrawZoneEventArgs args)
				{
					SetupCards(args.Cards.ToList());
				}

				public void OnAddCard(CardsEventArgs args)
				{
					SetupCards(args.Cards.ToList());
				}
			}

			public override IdContainer GetId()
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				//IL_000e: Unknown result type (might be due to invalid IL or missing references)
				return IdContainer.op_Implicit("GetIntoTheVoid");
			}

			public override JadeBoxConfig MakeConfig()
			{
				return ((JadeBoxTemplate)this).DefaultConfig();
			}

			public override LocalizationOption LoadLocalization()
			{
				return (LocalizationOption)(object)BepinexPlugin.JadeboxBatchLoc.AddEntity((EntityDefinition)(object)this);
			}
		}
	}
	public class OnlyRare
	{
		public sealed class OnlyRareDef : JadeBoxTemplate
		{
			[EntityLogic(typeof(OnlyRareDef))]
			public sealed class OnlyRareJadebox : JadeBox
			{
				[HarmonyPatch]
				private class GameRunController_RollCards_Patch
				{
					private static IEnumerable<MethodBase> TargetMethods()
					{
						return (from m in AccessTools.GetDeclaredMethods(typeof(GameRunController))
							where m.Name == "RollCards"
							select m).ToList();
					}

					private static void Prefix(ref CardWeightTable weightTable, GameRunController __instance)
					{
						//IL_005d: Unknown result type (might be due to invalid IL or missing references)
						//IL_0063: Expected O, but got Unknown
						//IL_003f: Unknown result type (might be due to invalid IL or missing references)
						//IL_0045: Expected O, but got Unknown
						if (IsOnlyRareJadebox(__instance))
						{
							if (IsInShopStation(__instance) && weightTable.CardTypeTable != CardTypeWeightTable.OnlyTool)
							{
								weightTable = new CardWeightTable(RarityWeightTable.OnlyRare, weightTable.OwnerTable, CardTypeWeightTable.CanBeLoot);
							}
							else
							{
								weightTable = new CardWeightTable(RarityWeightTable.OnlyRare, weightTable.OwnerTable, weightTable.CardTypeTable);
							}
						}
					}
				}

				[HarmonyPatch(typeof(StartGamePanel), "Awake")]
				private class StartGamePanel_Awake_Patch
				{
					private static void Postfix(ref StartGamePanel __instance)
					{
						try
						{
							JadeBoxToggle onlyRareToggle = null;
							JadeBoxToggle noRareToggle = null;
							foreach (KeyValuePair<JadeBox, JadeBoxToggle> jadeBoxToggle in __instance._jadeBoxToggles)
							{
								if (((object)jadeBoxToggle.Value.JadeBox).GetType() == typeof(OnlyRareJadebox))
								{
									Debug.Log((object)"found only rare toggle");
									onlyRareToggle = jadeBoxToggle.Value;
								}
								if (((object)jadeBoxToggle.Value.JadeBox).GetType() == typeof(NoRareCard))
								{
									Debug.Log((object)"found no rare toggle");
									noRareToggle = jadeBoxToggle.Value;
								}
							}
							if (!((Object)(object)onlyRareToggle != (Object)null) || !((Object)(object)noRareToggle != (Object)null))
							{
								return;
							}
							((UnityEvent<bool>)(object)onlyRareToggle.Toggle.onValueChanged).AddListener((UnityAction<bool>)delegate
							{
								Debug.Log((object)"toggled onlyRareToggle");
								if ((Object)(object)noRareToggle != (Object)null && noRareToggle.IsOn)
								{
									Debug.Log((object)"disabling noRareToggle");
									noRareToggle.Toggle.SetIsOnWithoutNotify(false);
								}
							});
							((UnityEvent<bool>)(object)noRareToggle.Toggle.onValueChanged).AddListener((UnityAction<bool>)delegate
							{
								Debug.Log((object)"toggled noRareToggle");
								if ((Object)(object)onlyRareToggle != (Object)null && onlyRareToggle.IsOn)
								{
									Debug.Log((object)"disabling onlyRareToggle");
									onlyRareToggle.Toggle.SetIsOnWithoutNotify(false);
								}
							});
						}
						catch (Exception ex)
						{
							Debug.Log((object)("error when checking  toggles: " + ex.Message + ex.StackTrace));
						}
					}
				}

				protected override void OnGain(GameRunController gameRun)
				{
					((MonoBehaviour)Singleton<GameMaster>.Instance).StartCoroutine(ResetDeck(gameRun));
				}

				private static IEnumerator ResetDeck(GameRunController gameRun)
				{
					yield return null;
					ResetStart50.ResetStart50Deck(gameRun);
				}

				private static bool IsInShopStation(GameRunController gameRun)
				{
					//IL_001f: Unknown result type (might be due to invalid IL or missing references)
					//IL_0024: Unknown result type (might be due to invalid IL or missing references)
					//IL_0025: Unknown result type (might be due to invalid IL or missing references)
					//IL_0027: Invalid comparison between Unknown and I4
					if (gameRun == null || gameRun.CurrentStation == null)
					{
						return false;
					}
					StationType type = gameRun.CurrentStation.Type;
					return (int)type == 5;
				}

				public static bool IsOnlyRareJadebox(GameRunController run)
				{
					if (run == null)
					{
						return false;
					}
					IReadOnlyList<JadeBox> jadeBoxes = run.JadeBoxes;
					if (jadeBoxes != null && jadeBoxes.Count > 0 && run.JadeBoxes.Any((JadeBox jb) => jb is OnlyRareJadebox))
					{
						return true;
					}
					return false;
				}
			}

			public override IdContainer GetId()
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				//IL_000e: Unknown result type (might be due to invalid IL or missing references)
				return IdContainer.op_Implicit("OnlyRareJadebox");
			}

			public override LocalizationOption LoadLocalization()
			{
				return (LocalizationOption)(object)BepinexPlugin.JadeboxBatchLoc.AddEntity((EntityDefinition)(object)this);
			}

			public override JadeBoxConfig MakeConfig()
			{
				return ((JadeBoxTemplate)this).DefaultConfig();
			}
		}
	}
	public class PurchasePower
	{
		public sealed class PurchasePowerDef : JadeBoxTemplate
		{
			[EntityLogic(typeof(PurchasePowerDef))]
			public sealed class GetPurchasePower : JadeBox
			{
				protected override void OnGain(GameRunController gameRun)
				{
					((MonoBehaviour)Singleton<GameMaster>.Instance).StartCoroutine(GainExhibits(gameRun));
				}

				private IEnumerator GainExhibits(GameRunController gameRun)
				{
					HashSet<Type> exhibit = new HashSet<Type>
					{
						typeof(PortalGun),
						typeof(Huiyuanka)
					};
					foreach (Type ex in exhibit)
					{
						Debug.Log((object)("gaining: " + ex.Name + " was in pool: " + gameRun.ExhibitPool.Contains(ex)));
						yield return gameRun.GainExhibitRunner(Library.CreateExhibit(ex), false, (VisualSourceData)null);
					}
					gameRun.ExhibitPool.RemoveAll((Type e) => exhibit.Contains(e));
				}

				private static void Init(GameRunController gameRun)
				{
					gameRun.AdditionalRewardCardCount -= cardReduction;
				}

				protected override void OnAdded()
				{
					Init(((GameEntity)this).GameRun);
				}
			}

			private static int cardReduction = 2;

			public override IdContainer GetId()
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				//IL_000e: Unknown result type (might be due to invalid IL or missing references)
				return IdContainer.op_Implicit("GetPurchasePower");
			}

			public override JadeBoxConfig MakeConfig()
			{
				JadeBoxConfig val = ((JadeBoxTemplate)this).DefaultConfig();
				val.Value1 = cardReduction;
				return val;
			}

			public override LocalizationOption LoadLocalization()
			{
				return (LocalizationOption)(object)BepinexPlugin.JadeboxBatchLoc.AddEntity((EntityDefinition)(object)this);
			}
		}
	}
	public class RareMisfortune
	{
		public sealed class RareMisfortuneDef : JadeBoxTemplate
		{
			[EntityLogic(typeof(RareMisfortuneDef))]
			public sealed class RareMisfortuneJadebox : JadeBox
			{
				[HarmonyPatch]
				private class GameRunController_RollCards_Patch
				{
					private static IEnumerable<MethodBase> TargetMethods()
					{
						return (from m in AccessTools.GetDeclaredMethods(typeof(GameRunController))
							where m.Name == "RollCards"
							select m).ToList();
					}

					private static void Prefix(ref CardWeightTable weightTable, GameRunController __instance)
					{
						//IL_006c: Unknown result type (might be due to invalid IL or missing references)
						//IL_0072: Expected O, but got Unknown
						if (IsRareMisfortuneJadebox(__instance) && IsInCombatStation(__instance) && !IsInBattle(__instance))
						{
							int num = __instance.CardRng.NextInt(1, newRareChance);
							Debug.Log((object)("Random number for rare card: " + num));
							if (num == newRareChance)
							{
								weightTable = new CardWeightTable(RarityWeightTable.OnlyRare, weightTable.OwnerTable, weightTable.CardTypeTable);
							}
						}
					}
				}

				protected override void OnAdded()
				{
					((JadeBox)this).HandleGameRunEvent<CardsEventArgs>(((GameEntity)this).GameRun.DeckCardsAdded, (GameEventHandler<CardsEventArgs>)OnDeckCardAdded);
				}

				public void OnDeckCardAdded(CardsEventArgs args)
				{
					//IL_0016: Unknown result type (might be due to invalid IL or missing references)
					//IL_001c: Invalid comparison between Unknown and I4
					if ((int)((GameEntity)this).GameRun.BaseDeck.Last().Config.Rarity == 2 && IsInCombatStation(((GameEntity)this).GameRun) && !IsHinaTriggered(((GameEntity)this).GameRun))
					{
						RandomGen cardRng = ((GameEntity)this).GameRun.CardRng;
						((GameEntity)this).GameRun.AddDeckCard(GetRandomCurseCard(cardRng), true, (VisualSourceData)null);
					}
				}

				private static bool IsHinaTriggered(GameRunController gameRun)
				{
					bool result = false;
					foreach (Exhibit exhibit in gameRun.Player.Exhibits)
					{
						if (exhibit is ChuRenou && exhibit.Counter > 0)
						{
							int counter = exhibit.Counter;
							exhibit.Counter = counter - 1;
							result = true;
						}
					}
					return result;
				}

				private static bool IsInCombatStation(GameRunController gameRun)
				{
					//IL_001f: Unknown result type (might be due to invalid IL or missing references)
					//IL_0024: Unknown result type (might be due to invalid IL or missing references)
					//IL_0025: Unknown result type (might be due to invalid IL or missing references)
					//IL_0027: Invalid comparison between Unknown and I4
					//IL_0029: Unknown result type (might be due to invalid IL or missing references)
					//IL_002b: Invalid comparison between Unknown and I4
					if (gameRun == null || gameRun.CurrentStation == null)
					{
						return false;
					}
					StationType type = gameRun.CurrentStation.Type;
					return (int)type == 1 || (int)type == 2;
				}

				private static bool IsInBattle(GameRunController gameRun)
				{
					return gameRun.Battle != null && gameRun.Battle.AllAliveEnemies.Count() > 0;
				}

				private Card GetRandomCurseCard(RandomGen rng)
				{
					//IL_002e: Unknown result type (might be due to invalid IL or missing references)
					//IL_0034: Invalid comparison between Unknown and I4
					//IL_0038: Unknown result type (might be due to invalid IL or missing references)
					//IL_0053: Unknown result type (might be due to invalid IL or missing references)
					//IL_0059: Invalid comparison between Unknown and I4
					List<Type> list = new List<Type>();
					foreach (var (item, val) in Library.EnumerateCardTypes())
					{
						if ((int)val.Type == 8 && !((Enum)val.Keywords).HasFlag((Enum)(object)(Keyword)16) && (int)val.Rarity == 0)
						{
							list.Add(item);
						}
					}
					if (list.Count == 0)
					{
						Debug.Log((object)"No curse card in library found");
						return null;
					}
					return TypeFactory<Card>.CreateInstance(CollectionsExtensions.Sample<Type>((IEnumerable<Type>)list, rng));
				}

				public static bool IsRareMisfortuneJadebox(GameRunController run)
				{
					if (run == null)
					{
						return false;
					}
					IReadOnlyList<JadeBox> jadeBoxes = run.JadeBoxes;
					if (jadeBoxes != null && jadeBoxes.Count > 0 && run.JadeBoxes.Any((JadeBox jb) => jb is RareMisfortuneJadebox))
					{
						return true;
					}
					return false;
				}
			}

			private static int newRareChance = 5;

			public override IdContainer GetId()
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				//IL_000e: Unknown result type (might be due to invalid IL or missing references)
				return IdContainer.op_Implicit("RareMisfortuneJadebox");
			}

			public override LocalizationOption LoadLocalization()
			{
				return (LocalizationOption)(object)BepinexPlugin.JadeboxBatchLoc.AddEntity((EntityDefinition)(object)this);
			}

			public override JadeBoxConfig MakeConfig()
			{
				JadeBoxConfig val = ((JadeBoxTemplate)this).DefaultConfig();
				val.Value1 = newRareChance;
				val.Value2 = 100 / newRareChance;
				return val;
			}
		}
	}
	public class SellItAll
	{
		public sealed class SellItAllDef : JadeBoxTemplate
		{
			[EntityLogic(typeof(SellItAllDef))]
			public sealed class SellItAllJadebox : JadeBox
			{
				private class CoroutineExtender : IEnumerable
				{
					public IEnumerator target_enumerator;

					public List<IEnumerator> preItems = new List<IEnumerator>();

					public List<IEnumerator> postItems = new List<IEnumerator>();

					public List<IEnumerator> midItems = new List<IEnumerator>();

					public CoroutineExtender()
					{
					}

					public CoroutineExtender(IEnumerator target_enumerator)
					{
						this.target_enumerator = target_enumerator;
					}

					public IEnumerator GetEnumerator()
					{
						foreach (IEnumerator preItem in preItems)
						{
							yield return preItem;
						}
						int i = 0;
						while (target_enumerator.MoveNext())
						{
							yield return target_enumerator.Current;
							i++;
						}
						foreach (IEnumerator postItem in postItems)
						{
							yield return postItem;
						}
					}
				}

				[HarmonyPatch(typeof(Exhibit), "TriggerGain")]
				private class Exhibit_Patch
				{
					private static void Postfix(ref IEnumerator __result)
					{
						CoroutineExtender coroutineExtender = new CoroutineExtender(__result);
						coroutineExtender.postItems.Add(SellAllExhibits());
						__result = coroutineExtender.GetEnumerator();
					}

					private static IEnumerator SellAllExhibits()
					{
						if (!((Object)(object)Singleton<GameMaster>.Instance != (Object)null) || !IsSellItAllJadebox(Singleton<GameMaster>.Instance.CurrentGameRun))
						{
							yield break;
						}
						GameRunController run = Singleton<GameMaster>.Instance.CurrentGameRun;
						List<Exhibit> toRemove = new List<Exhibit>();
						foreach (Exhibit ex2 in run.Player.Exhibits)
						{
							if ((int)ex2.LosableType == 0)
							{
								GainMoneyWithNullcheck(run, GetExhibitPrice(ex2), triggerVisual: true, new VisualSourceData
								{
									SourceType = (VisualSourceType)7,
									Source = (GameEntity)(object)ex2
								});
								toRemove.Add(ex2);
							}
						}
						foreach (Exhibit ex in toRemove)
						{
							run.LoseExhibit(ex, true, true);
						}
					}
				}

				[HarmonyPatch]
				private class Stage_GetShopExhibit_Patch
				{
					private static IEnumerable<MethodBase> TargetMethods()
					{
						return (from m in AccessTools.GetDeclaredMethods(typeof(Stage))
							where m.Name == "GetShopExhibit"
							select m).ToList();
					}

					private static void Postfix(ref Exhibit __result)
					{
						GameRunController currentGameRun = Singleton<GameMaster>.Instance.CurrentGameRun;
						if (!IsSellItAllJadebox(currentGameRun) || !IsInShop(currentGameRun))
						{
							return;
						}
						int num = currentGameRun.ShopRng.NextInt(1, 100);
						Debug.Log((object)("Random number for shop exhibit: " + num));
						if (num <= shiningChance)
						{
							__result = currentGameRun.RollShiningExhibit(currentGameRun.ShinningExhibitRng, (Func<Exhibit>)currentGameRun.CurrentStation.Stage.GetSentinelExhibit, (Predicate<ExhibitConfig>)((ExhibitConfig config) => config != null && (config.Owner == null || (config.Owner != null && !config.Owner.Contains("Koishi") && !config.Owner.Contains("Alice")))));
						}
					}
				}

				[HarmonyPatch(typeof(ShopStation), "GetPrice", new Type[] { typeof(Exhibit) })]
				private class ShopStation_GetPrice_Patch
				{
					private static bool Prefix(ref Exhibit exhibit, ref int __result)
					{
						//IL_0023: Unknown result type (might be due to invalid IL or missing references)
						//IL_0029: Invalid comparison between Unknown and I4
						GameRunController currentGameRun = Singleton<GameMaster>.Instance.CurrentGameRun;
						if (IsSellItAllJadebox(currentGameRun) && IsInShop(currentGameRun) && (int)exhibit.Config.Rarity == 3)
						{
							float num = shiningPrice;
							float num2 = currentGameRun.ShopRng.NextFloat(-0.08f, 0f) + 1f;
							__result = Mathf.RoundToInt(num * num2);
							return false;
						}
						return true;
					}
				}

				private static bool IsInShop(GameRunController gameRun)
				{
					//IL_001f: Unknown result type (might be due to invalid IL or missing references)
					//IL_0024: Unknown result type (might be due to invalid IL or missing references)
					//IL_0025: Unknown result type (might be due to invalid IL or missing references)
					//IL_0027: Invalid comparison between Unknown and I4
					if (gameRun == null || gameRun.CurrentStation == null)
					{
						return false;
					}
					StationType type = gameRun.CurrentStation.Type;
					return (int)type == 5;
				}

				public static bool IsSellItAllJadebox(GameRunController run)
				{
					if (run == null)
					{
						return false;
					}
					IReadOnlyList<JadeBox> jadeBoxes = run.JadeBoxes;
					if (jadeBoxes != null && jadeBoxes.Count > 0 && run.JadeBoxes.Any((JadeBox jb) => jb is SellItAllJadebox))
					{
						return true;
					}
					return false;
				}

				private static int GetExhibitPrice(Exhibit exhibit)
				{
					//IL_0007: Unknown result type (might be due to invalid IL or missing references)
					//IL_000c: Unknown result type (might be due to invalid IL or missing references)
					//IL_000e: Unknown result type (might be due to invalid IL or missing references)
					//IL_0010: Unknown result type (might be due to invalid IL or missing references)
					//IL_0011: Unknown result type (might be due to invalid IL or missing references)
					//IL_0023: Expected I4, but got Unknown
					Rarity rarity = exhibit.Config.Rarity;
					Rarity val = rarity;
					float num = (int)val switch
					{
						0 => GlobalConfig.ExhibitPrices[0], 
						1 => GlobalConfig.ExhibitPrices[1], 
						2 => GlobalConfig.ExhibitPrices[2], 
						_ => throw new InvalidOperationException("exhibit rarity out of range."), 
					};
					float num2 = Singleton<GameMaster>.Instance.CurrentGameRun.ShopRng.NextFloat(-0.08f, 0f) + 1f;
					return Mathf.RoundToInt((float)Mathf.RoundToInt(num * num2) * 60f / 100f);
				}

				public static void GainMoneyWithNullcheck(GameRunController run, int money, bool triggerVisual = false, VisualSourceData sourceData = null)
				{
					//IL_0035: Unknown result type (might be due to invalid IL or missing references)
					//IL_003a: Unknown result type (might be due to invalid IL or missing references)
					//IL_0047: Expected O, but got Unknown
					if (run != null)
					{
						run.InternalGainMoney(money);
						IGameRunVisualTrigger visualTrigger = run.VisualTrigger;
						if (visualTrigger != null)
						{
							visualTrigger.OnGainMoney(money, triggerVisual, sourceData);
						}
						run.MoneyGained?.Execute(new GameEventArgs
						{
							CanCancel = false
						});
					}
				}
			}

			private static int shiningChance = 15;

			private static int shiningPrice = 500;

			public override IdContainer GetId()
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				//IL_000e: Unknown result type (might be due to invalid IL or missing references)
				return IdContainer.op_Implicit("SellItAllJadebox");
			}

			public override LocalizationOption LoadLocalization()
			{
				return (LocalizationOption)(object)BepinexPlugin.JadeboxBatchLoc.AddEntity((EntityDefinition)(object)this);
			}

			public override JadeBoxConfig MakeConfig()
			{
				JadeBoxConfig val = ((JadeBoxTemplate)this).DefaultConfig();
				val.Value1 = shiningChance;
				return val;
			}
		}
	}
	public class SmallDeck
	{
		public sealed class SmallDeckDef : JadeBoxTemplate
		{
			[EntityLogic(typeof(SmallDeckDef))]
			public sealed class SmallDeckJadebox : JadeBox
			{
				protected override void OnAdded()
				{
					((JadeBox)this).HandleGameRunEvent<CardsEventArgs>(((GameEntity)this).GameRun.DeckCardsAdded, (GameEventHandler<CardsEventArgs>)OnDeckCardAdded);
				}

				public void OnDeckCardAdded(CardsEventArgs args)
				{
					List<Card> list = new List<Card>();
					foreach (Card item in ((GameEntity)this).GameRun.BaseDeck)
					{
						if (((GameEntity)this).GameRun.BaseDeck.Count - list.Count > maxDeckSize && !item.Unremovable)
						{
							list.Add(item);
						}
					}
					foreach (Card item2 in list)
					{
						((GameEntity)this).GameRun.RemoveDeckCard(item2, true);
					}
				}
			}

			public static int maxDeckSize = 15;

			public override IdContainer GetId()
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				//IL_000e: Unknown result type (might be due to invalid IL or missing references)
				return IdContainer.op_Implicit("SmallDeckJadebox");
			}

			public override LocalizationOption LoadLocalization()
			{
				return (LocalizationOption)(object)BepinexPlugin.JadeboxBatchLoc.AddEntity((EntityDefinition)(object)this);
			}

			public override JadeBoxConfig MakeConfig()
			{
				JadeBoxConfig val = ((JadeBoxTemplate)this).DefaultConfig();
				val.Value1 = maxDeckSize;
				return val;
			}
		}
	}
	public class TreasureHuner
	{
		public sealed class TreasureHunterDef : JadeBoxTemplate
		{
			[EntityLogic(typeof(TreasureHunterDef))]
			public sealed class GetGetTreasureHuner : JadeBox
			{
				[HarmonyPatch(typeof(BossStation), "GenerateBossRewards")]
				private class BossStation_GenerateBossRewards_Patch
				{
					private static void Postfix(BossStation __instance)
					{
						IReadOnlyList<JadeBox> jadeBoxes = ((Station)__instance).GameRun._jadeBoxes;
						if (jadeBoxes == null || jadeBoxes.Count <= 0)
						{
							return;
						}
						foreach (JadeBox item in jadeBoxes)
						{
							if (item is GetGetTreasureHuner)
							{
								SetRewardList(((Station)__instance).GameRun);
								Debug.Log((object)("BossStation_GenerateBossRewards_Patch rewardList count: " + treasureRewardList.Count));
								__instance.BossRewards = treasureRewardList.ToArray();
								break;
							}
						}
					}
				}

				public static List<Exhibit> treasureRewardList = new List<Exhibit>
				{
					(Exhibit)(object)Library.CreateExhibit<FoyushiBo>(),
					(Exhibit)(object)Library.CreateExhibit<HuoshuPiyi>(),
					(Exhibit)(object)Library.CreateExhibit<LongjingYu>()
				};

				private static void SetRewardList(GameRunController run)
				{
					RandomGen adventureRng = run.AdventureRng;
					List<Exhibit> list = new List<Exhibit>
					{
						(Exhibit)(object)Library.CreateExhibit<FoyushiBo>(),
						(Exhibit)(object)Library.CreateExhibit<HuoshuPiyi>(),
						(Exhibit)(object)Library.CreateExhibit<LongjingYu>(),
						(Exhibit)(object)Library.CreateExhibit<PenglaiYuzhi>(),
						(Exhibit)(object)Library.CreateExhibit<YanZianbei>()
					};
					foreach (Exhibit item in run.Player.Exhibits)
					{
						Debug.Log((object)("player has exibit: " + ((GameEntity)item).Name));
						if (list.Find((Exhibit i) => ((GameEntity)i).Name == ((GameEntity)item).Name) != null)
						{
							Debug.Log((object)("removing exibit from reward list: " + ((GameEntity)item).Name));
							list.Remove(list.Find((Exhibit i) => ((GameEntity)i).Name == ((GameEntity)item).Name));
						}
					}
					Debug.Log((object)("after remove existing SetRewardList rewardList count: " + list.Count));
					if (list.Count > 3)
					{
						for (int j = 0; list.Count > 3 || j > 3; j++)
						{
							int index = adventureRng.NextInt(0, list.Count - 1);
							Debug.Log((object)("randomly removing at index: " + index));
							list.RemoveAt(index);
						}
					}
					else if (list.Count < 3)
					{
						for (int k = 0; list.Count < 3 || k > 3; k++)
						{
							list.Add(run.CurrentStage.GetEliteEnemyExhibit());
						}
					}
					treasureRewardList = list;
				}
			}

			public override IdContainer GetId()
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				//IL_000e: Unknown result type (might be due to invalid IL or missing references)
				return IdContainer.op_Implicit("GetGetTreasureHuner");
			}

			public override JadeBoxConfig MakeConfig()
			{
				return ((JadeBoxTemplate)this).DefaultConfig();
			}

			public override LocalizationOption LoadLocalization()
			{
				return (LocalizationOption)(object)BepinexPlugin.JadeboxBatchLoc.AddEntity((EntityDefinition)(object)this);
			}
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		internal IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}