HashtableSetting.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  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)
  57. {
  58. Hashtable hashtable = new Hashtable()
  59. {
  60. {"CardEffect", cardEffect},
  61. {"Permanents", permanents},
  62. {"battle", battle}
  63. };
  64. return hashtable;
  65. }
  66. #endregion
  67. #region Hashtable used when check whether the permanent can activate [On Deletion] or "Permanent returned to hand" effect
  68. public static Hashtable OnDeletionHashtable(List<Permanent> permanents, ICardEffect cardEffect, IBattle battle, bool isDPZero)
  69. {
  70. Hashtable hashtable = new Hashtable();
  71. if (cardEffect != null)
  72. {
  73. hashtable.Add("CardEffect", cardEffect);
  74. }
  75. if (battle != null)
  76. {
  77. hashtable.Add("battle", battle);
  78. }
  79. if (isDPZero)
  80. {
  81. hashtable.Add("DPZero", isDPZero);
  82. }
  83. List<Hashtable> hashtables = permanents
  84. .Clone()
  85. .Filter(permanent => permanent != null && permanent.TopCard != null)
  86. .Map(permanent =>
  87. {
  88. List<CardSource> cardSources = permanent.cardSources.Clone();
  89. List<string> cardNames = permanent.TopCard.CardNames.Clone();
  90. List<CardColor> cardColors = permanent.TopCard.CardColors.Clone();
  91. Hashtable hashtableOfPermanent = new Hashtable()
  92. {
  93. {"Permanent", permanent},
  94. {"TopCard", permanent.TopCard},
  95. {"CardSources", cardSources},
  96. {"CardNames", cardNames},
  97. {"CardColors", cardColors},
  98. {"HasSaveText", permanent.TopCard.HasSaveText},
  99. {"Level", permanent.TopCard.Level},
  100. };
  101. return hashtableOfPermanent;
  102. });
  103. hashtable.Add("hashtables", hashtables);
  104. return hashtable;
  105. }
  106. #endregion
  107. #region Hashtable used when check whether the permanent can activate [On Play] [When Digivolving] or "Permanent enters the field" effect
  108. public static Hashtable OnEnterFieldHashtable(List<OnEnterFieldHashtableParams> hashtableParams, bool isEvolution, bool isJogress, int digiXrosCount,
  109. ICardEffect cardEffect)
  110. {
  111. Hashtable hashtable = new Hashtable()
  112. {
  113. {"isEvolution", isEvolution},
  114. {"isJogress", isJogress},
  115. {"DigiXrosCount", digiXrosCount },
  116. {"isFromDigimonDigivolutionCards", hashtableParams.Some(param => param.IsFromDigimonDigivolutionCards)}
  117. };
  118. if (cardEffect != null)
  119. {
  120. hashtable.Add("CardEffect", cardEffect);
  121. }
  122. List<Hashtable> hashtables = hashtableParams
  123. .Clone()
  124. .Filter(hashtableParam => hashtableParam != null)
  125. .Map(hashtableParam =>
  126. {
  127. Hashtable hashtableOfPermanent = new Hashtable()
  128. {
  129. {"Permanent", hashtableParam.Permanent},
  130. {"evoRoots", hashtableParam.EvoRoots.Clone()},
  131. {"evoRootTops", hashtableParam.EvoRootTops.Clone()},
  132. {"Root", hashtableParam.Root},
  133. {"oldLevels", hashtableParam.OldLevels.Clone()},
  134. };
  135. return hashtableOfPermanent;
  136. });
  137. hashtable.Add("hashtables", hashtables);
  138. return hashtable;
  139. }
  140. #endregion
  141. #region Hashtable used when check whether the permanent would enter the field" effect
  142. public static Hashtable WouldEnterFieldHashtable(bool payCost, CardSource card, SelectCardEffect.Root root, bool isEvolution, PlayCardClass playCardClass,
  143. ICardEffect cardEffect, bool isJogress, List<Permanent> targetPermanents)
  144. {
  145. Hashtable hashtable = new Hashtable()
  146. {
  147. {"PayCost", payCost},
  148. {"Card", card},
  149. {"Root", root},
  150. {"isEvolution", isEvolution},
  151. {"PlayCardClass", playCardClass},
  152. {"CardEffect", cardEffect},
  153. {"isJogress", isJogress},
  154. {"Permanents", targetPermanents},
  155. };
  156. return hashtable;
  157. }
  158. #endregion
  159. #region Hashtable used when check whether the card can trigger [On Play] effect
  160. public static Hashtable OnPlayCheckHashtableOfCard(CardSource cardSource)
  161. {
  162. return new Hashtable()
  163. {
  164. {"isEvolution", false},
  165. {
  166. "hashtables", new List<Hashtable>()
  167. {
  168. new Hashtable()
  169. {
  170. {"Permanent", new Permanent(new List<CardSource>(){cardSource} ) },
  171. }
  172. }
  173. },
  174. };
  175. }
  176. #endregion
  177. #region Hashtable used when check whether the card can trigger [When Digivolving] effect
  178. public static Hashtable WhenDigivolvingCheckHashtableOfCard(CardSource cardSource)
  179. {
  180. return new Hashtable()
  181. {
  182. {"isEvolution", true},
  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 option [Main] effect
  196. public static Hashtable OptionMainCheckHashtable(CardSource cardSource)
  197. {
  198. return new Hashtable()
  199. {
  200. {"Card", cardSource },
  201. };
  202. }
  203. #endregion
  204. #region Hashtable used when check whether the permanent can trigger [On Play] effect
  205. public static Hashtable OnPlayCheckHashtableOfPermanent(Permanent permanent)
  206. {
  207. return new Hashtable()
  208. {
  209. {"isEvolution", false},
  210. {
  211. "hashtables", new List<Hashtable>()
  212. {
  213. new Hashtable()
  214. {
  215. {"Permanent", permanent },
  216. }
  217. }
  218. },
  219. };
  220. }
  221. #endregion
  222. #region Hashtable used when check whether the permanent can trigger [When Digivolving] effect
  223. public static Hashtable WhenDigivolutionCheckHashtableOfPermanent(Permanent permanent)
  224. {
  225. return new Hashtable()
  226. {
  227. {"isEvolution", true},
  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 card can trigger [When Attacking] effect
  241. public static Hashtable OnAttackCheckHashtableOfCard(CardSource cardSource, ICardEffect cardEffect)
  242. {
  243. return new Hashtable()
  244. {
  245. {"AttackingPermanent", cardSource.PermanentOfThisCard() ?? new Permanent(new List<CardSource>(){cardSource} )},
  246. {"CardEffect", cardEffect},
  247. };
  248. }
  249. #endregion
  250. #region Hashtable used when check whether the permanent can trigger [When Attacking] effect
  251. public static Hashtable OnAttackCheckHashtableOfPermanent(Permanent attackingPermanent, ICardEffect cardEffect)
  252. {
  253. return new Hashtable()
  254. {
  255. {"AttackingPermanent", attackingPermanent},
  256. {"CardEffect", cardEffect},
  257. };
  258. }
  259. #endregion
  260. #region Hashtable used when check whether the permanent would remove field effect
  261. public static Hashtable WhenDigivolutionCardWouldDiscardedCheckHashtable(Permanent targetPermanent, List<CardSource> cardSources, ICardEffect cardEffect)
  262. {
  263. Hashtable hashtable = new Hashtable()
  264. {
  265. {"CardEffect", cardEffect},
  266. {"Permanent", targetPermanent},
  267. {"DiscardedCards", cardSources},
  268. };
  269. return hashtable;
  270. }
  271. #endregion
  272. }