HashtableSetting.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public partial class CardEffectCommons
  5. {
  6. public static Hashtable CardEffectHashtable(ICardEffect cardEffect) => new Hashtable() { { "CardEffect", cardEffect } };
  7. #region Hashtable used when check whether the permanent can trigger [Pierce]
  8. public static Hashtable PierceCheckHashtableOfPermanent(Permanent permanent)
  9. {
  10. Hashtable hashtable = new Hashtable();
  11. if (permanent != null)
  12. {
  13. if (permanent.TopCard != null)
  14. {
  15. CardSource opponentCard = GManager.instance.turnStateMachine.gameContext.ActiveCardList.Find(cardSource => cardSource.Owner == permanent.TopCard.Owner.Enemy);
  16. if (opponentCard != null)
  17. {
  18. IBattle battle = new IBattle(null, null, null);
  19. hashtable.Add("battle", battle);
  20. Hashtable battleHashtable = new Hashtable();
  21. Permanent WinnerPermanent = new Permanent(permanent.cardSources);
  22. battleHashtable.Add("WinnerPermanents", new List<Permanent>() { WinnerPermanent });
  23. battleHashtable.Add("WinnerPermanents_real", new List<Permanent>() { WinnerPermanent });
  24. Permanent LoserPermanent = new Permanent(new List<CardSource>() { opponentCard });
  25. battleHashtable.Add("LoserPermanents", new List<Permanent>() { LoserPermanent });
  26. Permanent LoserPermanents_real = new Permanent(new List<CardSource>() { opponentCard }) { IsDestroyedByBattle = true };
  27. battleHashtable.Add("LoserPermanents_real", new List<Permanent>() { LoserPermanents_real });
  28. battle.hashtable = battleHashtable;
  29. }
  30. }
  31. }
  32. return hashtable;
  33. }
  34. #endregion
  35. #region Hashtable used when check whether the permanent can trigger [On Deletion] effect
  36. public static Hashtable OnDeletionCheckHashtableOfPermanent(Permanent permanent)
  37. {
  38. Hashtable hashtable = new Hashtable();
  39. if (permanent != null)
  40. {
  41. if (permanent.TopCard != null)
  42. {
  43. List<Hashtable> hashtables = new List<Hashtable>();
  44. Hashtable hashtable1 = new Hashtable()
  45. {
  46. {"Permanent", new Permanent(permanent.cardSources)}
  47. };
  48. hashtables.Add(hashtable1);
  49. hashtable.Add("hashtables", hashtables);
  50. }
  51. }
  52. return hashtable;
  53. }
  54. #endregion
  55. #region Hashtable used when check whether the permanent would remove field effect
  56. public static Hashtable WhenPermanentWouldRemoveFieldCheckHashtable(List<Permanent> permanents, ICardEffect cardEffect, IBattle battle, bool isDigixros = false)
  57. {
  58. Hashtable hashtable = new Hashtable()
  59. {
  60. {"CardEffect", cardEffect},
  61. {"Permanents", permanents},
  62. {"battle", battle},
  63. {"digixros", isDigixros}
  64. };
  65. return hashtable;
  66. }
  67. #endregion
  68. #region Hashtable used when check whether the permanent can activate [On Deletion], "Permanent leaves" or "Permanent returned to hand" effect
  69. public static Hashtable OnDeletionHashtable(List<Permanent> permanents, ICardEffect cardEffect, IBattle battle, bool isDPZero)
  70. {
  71. Hashtable hashtable = new Hashtable();
  72. if (cardEffect != null)
  73. {
  74. hashtable.Add("CardEffect", cardEffect);
  75. }
  76. if (battle != null)
  77. {
  78. hashtable.Add("battle", battle);
  79. }
  80. if (isDPZero)
  81. {
  82. hashtable.Add("DPZero", isDPZero);
  83. }
  84. List<Hashtable> hashtables = permanents
  85. .Clone()
  86. .Filter(permanent => permanent != null && permanent.TopCard != null)
  87. .Map(permanent =>
  88. {
  89. List<CardSource> cardSources = permanent.cardSources.Clone();
  90. List<string> cardNames = permanent.TopCard.CardNames.Clone();
  91. List<CardColor> cardColors = permanent.TopCard.CardColors.Clone();
  92. Hashtable hashtableOfPermanent = new Hashtable()
  93. {
  94. {"Permanent", permanent},
  95. {"TopCard", permanent.TopCard},
  96. {"CardSources", cardSources},
  97. {"DigivolutionSources", permanent.DigivolutionCards.Clone()},
  98. {"CardNames", cardNames},
  99. {"CardColors", cardColors},
  100. {"HasSaveText", permanent.TopCard.HasSaveText},
  101. {"Level", permanent.TopCard.Level},
  102. };
  103. return hashtableOfPermanent;
  104. });
  105. hashtable.Add("hashtables", hashtables);
  106. return hashtable;
  107. }
  108. #endregion
  109. #region Hashtable used when check whether the permanent can activate [On Play] [When Digivolving] or "Permanent enters the field" effect
  110. public static Hashtable OnEnterFieldHashtable(List<OnEnterFieldHashtableParams> hashtableParams, bool isEvolution, bool isJogress, int digiXrosCount, int assemblyCount,
  111. ICardEffect cardEffect)
  112. {
  113. Hashtable hashtable = new Hashtable()
  114. {
  115. {"isEvolution", isEvolution},
  116. {"isJogress", isJogress},
  117. {"DigiXrosCount", digiXrosCount },
  118. {"AssemblyCount", assemblyCount },
  119. {"isFromDigimonDigivolutionCards", hashtableParams.Some(param => param.IsFromDigimonDigivolutionCards)}
  120. };
  121. if (cardEffect != null)
  122. {
  123. hashtable.Add("CardEffect", cardEffect);
  124. }
  125. List<Hashtable> hashtables = hashtableParams
  126. .Clone()
  127. .Filter(hashtableParam => hashtableParam != null)
  128. .Map(hashtableParam =>
  129. {
  130. Hashtable hashtableOfPermanent = new Hashtable()
  131. {
  132. {"Permanent", hashtableParam.Permanent},
  133. {"evoRoots", hashtableParam.EvoRoots.Clone()},
  134. {"evoRootTops", hashtableParam.EvoRootTops.Clone()},
  135. {"Root", hashtableParam.Root},
  136. {"oldLevels", hashtableParam.OldLevels.Clone()},
  137. {"DigiXrosCount", hashtableParam.DigixrosCount},
  138. {"AssemblyCount", hashtableParam.AssemblyCount}
  139. };
  140. return hashtableOfPermanent;
  141. });
  142. hashtable.Add("hashtables", hashtables);
  143. return hashtable;
  144. }
  145. #endregion
  146. #region Hashtable used when check whether the permanent would enter the field" effect
  147. public static Hashtable WouldEnterFieldHashtable(bool payCost, CardSource card, SelectCardEffect.Root root, bool isEvolution, PlayCardClass playCardClass,
  148. ICardEffect cardEffect, bool isJogress, List<Permanent> targetPermanents)
  149. {
  150. Hashtable hashtable = new Hashtable()
  151. {
  152. {"PayCost", payCost},
  153. {"Card", card},
  154. {"Root", root},
  155. {"isEvolution", isEvolution},
  156. {"PlayCardClass", playCardClass},
  157. {"CardEffect", cardEffect},
  158. {"isJogress", isJogress},
  159. {"Permanents", targetPermanents},
  160. };
  161. return hashtable;
  162. }
  163. #endregion
  164. #region Hashtable when a card would be linked
  165. public static Hashtable WouldLinkHashtable(CardSource card, Permanent targetPermanent, SelectCardEffect.Root root, ICardEffect cardEffect)
  166. {
  167. Hashtable hashtable = new Hashtable()
  168. {
  169. {"Card", card},
  170. {"Root", root},
  171. {"CardEffect", cardEffect},
  172. {"Permanent", targetPermanent},
  173. };
  174. return hashtable;
  175. }
  176. #endregion
  177. #region Hashtable used when check whether the card can trigger [On Play] effect
  178. public static Hashtable OnPlayCheckHashtableOfCard(CardSource cardSource)
  179. {
  180. return new Hashtable()
  181. {
  182. {"isEvolution", false},
  183. {
  184. "hashtables", new List<Hashtable>()
  185. {
  186. new Hashtable()
  187. {
  188. {"Permanent", new Permanent(new List<CardSource>(){cardSource} ) },
  189. }
  190. }
  191. },
  192. };
  193. }
  194. #endregion
  195. #region Hashtable used when check whether the card can trigger [When Digivolving] effect
  196. public static Hashtable WhenDigivolvingCheckHashtableOfCard(CardSource cardSource)
  197. {
  198. return new Hashtable()
  199. {
  200. {"isEvolution", true},
  201. {
  202. "hashtables", new List<Hashtable>()
  203. {
  204. new Hashtable()
  205. {
  206. {"Permanent", new Permanent(new List<CardSource>(){cardSource} ) },
  207. }
  208. }
  209. },
  210. };
  211. }
  212. #endregion
  213. #region Hashtable used when check whether the card can trigger option [Main] effect
  214. public static Hashtable OptionMainCheckHashtable(CardSource cardSource)
  215. {
  216. return new Hashtable()
  217. {
  218. {"Card", cardSource },
  219. };
  220. }
  221. #endregion
  222. #region Hashtable used when check whether the permanent can trigger [On Play] effect
  223. public static Hashtable OnPlayCheckHashtableOfPermanent(Permanent permanent)
  224. {
  225. return new Hashtable()
  226. {
  227. {"isEvolution", false},
  228. {
  229. "hashtables", new List<Hashtable>()
  230. {
  231. new Hashtable()
  232. {
  233. {"Permanent", permanent },
  234. }
  235. }
  236. },
  237. };
  238. }
  239. #endregion
  240. #region Hashtable used when check whether the permanent can trigger [When Digivolving] effect
  241. public static Hashtable WhenDigivolutionCheckHashtableOfPermanent(Permanent permanent)
  242. {
  243. return new Hashtable()
  244. {
  245. {"isEvolution", true},
  246. {
  247. "hashtables", new List<Hashtable>()
  248. {
  249. new Hashtable()
  250. {
  251. {"Permanent", permanent },
  252. }
  253. }
  254. },
  255. };
  256. }
  257. #endregion
  258. #region Hashtable used when check whether the card can trigger [When Attacking] effect
  259. public static Hashtable OnAttackCheckHashtableOfCard(CardSource cardSource, ICardEffect cardEffect)
  260. {
  261. return new Hashtable()
  262. {
  263. {"AttackingPermanent", cardSource.PermanentOfThisCard() ?? new Permanent(new List<CardSource>(){cardSource} )},
  264. {"CardEffect", cardEffect},
  265. };
  266. }
  267. #endregion
  268. #region Hashtable used when check whether the permanent can trigger [When Attacking] effect
  269. public static Hashtable OnAttackCheckHashtableOfPermanent(Permanent attackingPermanent, ICardEffect cardEffect)
  270. {
  271. return new Hashtable()
  272. {
  273. {"AttackingPermanent", attackingPermanent},
  274. {"CardEffect", cardEffect},
  275. };
  276. }
  277. #endregion
  278. #region Hashtable used when check whether the permanent would remove field effect
  279. public static Hashtable WhenDigivolutionCardWouldDiscardedCheckHashtable(Permanent targetPermanent, List<CardSource> cardSources, ICardEffect cardEffect)
  280. {
  281. Hashtable hashtable = new Hashtable()
  282. {
  283. {"CardEffect", cardEffect},
  284. {"Permanent", targetPermanent},
  285. {"DiscardedCards", cardSources},
  286. };
  287. return hashtable;
  288. }
  289. #endregion
  290. }