HashtableSetting.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  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] 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. };
  138. return hashtableOfPermanent;
  139. });
  140. hashtable.Add("hashtables", hashtables);
  141. return hashtable;
  142. }
  143. #endregion
  144. #region Hashtable used when check whether the permanent would enter the field" effect
  145. public static Hashtable WouldEnterFieldHashtable(bool payCost, CardSource card, SelectCardEffect.Root root, bool isEvolution, PlayCardClass playCardClass,
  146. ICardEffect cardEffect, bool isJogress, List<Permanent> targetPermanents)
  147. {
  148. Hashtable hashtable = new Hashtable()
  149. {
  150. {"PayCost", payCost},
  151. {"Card", card},
  152. {"Root", root},
  153. {"isEvolution", isEvolution},
  154. {"PlayCardClass", playCardClass},
  155. {"CardEffect", cardEffect},
  156. {"isJogress", isJogress},
  157. {"Permanents", targetPermanents},
  158. };
  159. return hashtable;
  160. }
  161. #endregion
  162. #region Hashtable used when check whether the card can trigger [On Play] effect
  163. public static Hashtable OnPlayCheckHashtableOfCard(CardSource cardSource)
  164. {
  165. return new Hashtable()
  166. {
  167. {"isEvolution", false},
  168. {
  169. "hashtables", new List<Hashtable>()
  170. {
  171. new Hashtable()
  172. {
  173. {"Permanent", new Permanent(new List<CardSource>(){cardSource} ) },
  174. }
  175. }
  176. },
  177. };
  178. }
  179. #endregion
  180. #region Hashtable used when check whether the card can trigger [When Digivolving] effect
  181. public static Hashtable WhenDigivolvingCheckHashtableOfCard(CardSource cardSource)
  182. {
  183. return new Hashtable()
  184. {
  185. {"isEvolution", true},
  186. {
  187. "hashtables", new List<Hashtable>()
  188. {
  189. new Hashtable()
  190. {
  191. {"Permanent", new Permanent(new List<CardSource>(){cardSource} ) },
  192. }
  193. }
  194. },
  195. };
  196. }
  197. #endregion
  198. #region Hashtable used when check whether the card can trigger option [Main] effect
  199. public static Hashtable OptionMainCheckHashtable(CardSource cardSource)
  200. {
  201. return new Hashtable()
  202. {
  203. {"Card", cardSource },
  204. };
  205. }
  206. #endregion
  207. #region Hashtable used when check whether the permanent can trigger [On Play] effect
  208. public static Hashtable OnPlayCheckHashtableOfPermanent(Permanent permanent)
  209. {
  210. return new Hashtable()
  211. {
  212. {"isEvolution", false},
  213. {
  214. "hashtables", new List<Hashtable>()
  215. {
  216. new Hashtable()
  217. {
  218. {"Permanent", permanent },
  219. }
  220. }
  221. },
  222. };
  223. }
  224. #endregion
  225. #region Hashtable used when check whether the permanent can trigger [When Digivolving] effect
  226. public static Hashtable WhenDigivolutionCheckHashtableOfPermanent(Permanent permanent)
  227. {
  228. return new Hashtable()
  229. {
  230. {"isEvolution", true},
  231. {
  232. "hashtables", new List<Hashtable>()
  233. {
  234. new Hashtable()
  235. {
  236. {"Permanent", permanent },
  237. }
  238. }
  239. },
  240. };
  241. }
  242. #endregion
  243. #region Hashtable used when check whether the card can trigger [When Attacking] effect
  244. public static Hashtable OnAttackCheckHashtableOfCard(CardSource cardSource, ICardEffect cardEffect)
  245. {
  246. return new Hashtable()
  247. {
  248. {"AttackingPermanent", cardSource.PermanentOfThisCard() ?? new Permanent(new List<CardSource>(){cardSource} )},
  249. {"CardEffect", cardEffect},
  250. };
  251. }
  252. #endregion
  253. #region Hashtable used when check whether the permanent can trigger [When Attacking] effect
  254. public static Hashtable OnAttackCheckHashtableOfPermanent(Permanent attackingPermanent, ICardEffect cardEffect)
  255. {
  256. return new Hashtable()
  257. {
  258. {"AttackingPermanent", attackingPermanent},
  259. {"CardEffect", cardEffect},
  260. };
  261. }
  262. #endregion
  263. #region Hashtable used when check whether the permanent would remove field effect
  264. public static Hashtable WhenDigivolutionCardWouldDiscardedCheckHashtable(Permanent targetPermanent, List<CardSource> cardSources, ICardEffect cardEffect)
  265. {
  266. Hashtable hashtable = new Hashtable()
  267. {
  268. {"CardEffect", cardEffect},
  269. {"Permanent", targetPermanent},
  270. {"DiscardedCards", cardSources},
  271. };
  272. return hashtable;
  273. }
  274. #endregion
  275. }