HashtableSetting.cs 11 KB

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