HashtableSetting.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  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. };
  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 when a card would be linked
  163. public static Hashtable WouldLinkHashtable(CardSource card, Permanent targetPermanent, SelectCardEffect.Root root, ICardEffect cardEffect)
  164. {
  165. Hashtable hashtable = new Hashtable()
  166. {
  167. {"Card", card},
  168. {"Root", root},
  169. {"CardEffect", cardEffect},
  170. {"Permanent", targetPermanent},
  171. };
  172. return hashtable;
  173. }
  174. #endregion
  175. #region Hashtable used when check whether the card can trigger [On Play] effect
  176. public static Hashtable OnPlayCheckHashtableOfCard(CardSource cardSource)
  177. {
  178. return new Hashtable()
  179. {
  180. {"isEvolution", false},
  181. {
  182. "hashtables", new List<Hashtable>()
  183. {
  184. new Hashtable()
  185. {
  186. {"Permanent", new Permanent(new List<CardSource>(){cardSource} ) },
  187. }
  188. }
  189. },
  190. };
  191. }
  192. #endregion
  193. #region Hashtable used when check whether the card can trigger [When Digivolving] effect
  194. public static Hashtable WhenDigivolvingCheckHashtableOfCard(CardSource cardSource)
  195. {
  196. return new Hashtable()
  197. {
  198. {"isEvolution", true},
  199. {
  200. "hashtables", new List<Hashtable>()
  201. {
  202. new Hashtable()
  203. {
  204. {"Permanent", new Permanent(new List<CardSource>(){cardSource} ) },
  205. }
  206. }
  207. },
  208. };
  209. }
  210. #endregion
  211. #region Hashtable used when check whether the card can trigger option [Main] effect
  212. public static Hashtable OptionMainCheckHashtable(CardSource cardSource)
  213. {
  214. return new Hashtable()
  215. {
  216. {"Card", cardSource },
  217. };
  218. }
  219. #endregion
  220. #region Hashtable used when check whether the permanent can trigger [On Play] effect
  221. public static Hashtable OnPlayCheckHashtableOfPermanent(Permanent permanent)
  222. {
  223. return new Hashtable()
  224. {
  225. {"isEvolution", false},
  226. {
  227. "hashtables", new List<Hashtable>()
  228. {
  229. new Hashtable()
  230. {
  231. {"Permanent", permanent },
  232. }
  233. }
  234. },
  235. };
  236. }
  237. #endregion
  238. #region Hashtable used when check whether the permanent can trigger [When Digivolving] effect
  239. public static Hashtable WhenDigivolutionCheckHashtableOfPermanent(Permanent permanent)
  240. {
  241. return new Hashtable()
  242. {
  243. {"isEvolution", true},
  244. {
  245. "hashtables", new List<Hashtable>()
  246. {
  247. new Hashtable()
  248. {
  249. {"Permanent", permanent },
  250. }
  251. }
  252. },
  253. };
  254. }
  255. #endregion
  256. #region Hashtable used when check whether the card can trigger [When Attacking] effect
  257. public static Hashtable OnAttackCheckHashtableOfCard(CardSource cardSource, ICardEffect cardEffect)
  258. {
  259. return new Hashtable()
  260. {
  261. {"AttackingPermanent", cardSource.PermanentOfThisCard() ?? new Permanent(new List<CardSource>(){cardSource} )},
  262. {"CardEffect", cardEffect},
  263. };
  264. }
  265. #endregion
  266. #region Hashtable used when check whether the permanent can trigger [When Attacking] effect
  267. public static Hashtable OnAttackCheckHashtableOfPermanent(Permanent attackingPermanent, ICardEffect cardEffect)
  268. {
  269. return new Hashtable()
  270. {
  271. {"AttackingPermanent", attackingPermanent},
  272. {"CardEffect", cardEffect},
  273. };
  274. }
  275. #endregion
  276. #region Hashtable used when check whether the permanent would remove field effect
  277. public static Hashtable WhenDigivolutionCardWouldDiscardedCheckHashtable(Permanent targetPermanent, List<CardSource> cardSources, ICardEffect cardEffect)
  278. {
  279. Hashtable hashtable = new Hashtable()
  280. {
  281. {"CardEffect", cardEffect},
  282. {"Permanent", targetPermanent},
  283. {"DiscardedCards", cardSources},
  284. };
  285. return hashtable;
  286. }
  287. #endregion
  288. }