HashtableSetting.cs 11 KB

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