EX10_043.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. //EX10 Sakusimon
  6. namespace DCGO.CardEffects.EX10
  7. {
  8. public class EX10_043 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Static Effects
  14. #region Stnd Appmon Alternative Digivolution Requirement
  15. if (timing == EffectTiming.None)
  16. {
  17. bool PermanentCondition(Permanent targetPermanent)
  18. {
  19. return targetPermanent.TopCard.HasStandardAppTraits;
  20. }
  21. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 2, ignoreDigivolutionRequirement: false, card: card, condition: null));
  22. }
  23. #endregion
  24. #region Link Condition
  25. if (timing == EffectTiming.None)
  26. {
  27. static bool PermanentCondition(Permanent targetPermanent)
  28. {
  29. return targetPermanent.TopCard.HasAppmonTraits;
  30. }
  31. cardEffects.Add(CardEffectFactory.AddSelfLinkConditionStaticEffect(permanentCondition: PermanentCondition, linkCost: 2, card: card));
  32. }
  33. #endregion
  34. #region Link
  35. if (timing == EffectTiming.OnDeclaration)
  36. {
  37. cardEffects.Add(CardEffectFactory.LinkEffect(card));
  38. }
  39. #endregion
  40. #endregion
  41. #region On Play/When Digivolving shared
  42. bool CanSelectPermanentOPWDCondition(Permanent permanent)
  43. {
  44. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  45. {
  46. if (permanent.Level == 3)
  47. {
  48. if (permanent.TopCard.HasLevel)
  49. {
  50. return true;
  51. }
  52. }
  53. }
  54. return false;
  55. }
  56. bool CanActivateConditionShared(Hashtable hashtable)
  57. {
  58. if (CardEffectCommons.IsExistOnBattleArea(card))
  59. {
  60. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentOPWDCondition))
  61. {
  62. return true;
  63. }
  64. }
  65. return false;
  66. }
  67. #endregion
  68. #region On Play
  69. if (timing == EffectTiming.OnEnterFieldAnyone)
  70. {
  71. ActivateClass activateClass = new ActivateClass();
  72. activateClass.SetUpICardEffect("Delete 1 level 3 Digimon", CanUseCondition, card);
  73. activateClass.SetUpActivateClass(CanActivateConditionShared, ActivateCoroutine, -1, false, EffectDescription());
  74. cardEffects.Add(activateClass);
  75. string EffectDescription()
  76. {
  77. return "[On Play] Delete 1 of your opponent's level 3 Digimon.";
  78. }
  79. bool CanUseCondition(Hashtable hashtable)
  80. {
  81. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  82. }
  83. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  84. {
  85. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentOPWDCondition))
  86. {
  87. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentOPWDCondition));
  88. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  89. selectPermanentEffect.SetUp(
  90. selectPlayer: card.Owner,
  91. canTargetCondition: CanSelectPermanentOPWDCondition,
  92. canTargetCondition_ByPreSelecetedList: null,
  93. canEndSelectCondition: null,
  94. maxCount: maxCount,
  95. canNoSelect: false,
  96. canEndNotMax: false,
  97. selectPermanentCoroutine: null,
  98. afterSelectPermanentCoroutine: null,
  99. mode: SelectPermanentEffect.Mode.Destroy,
  100. cardEffect: activateClass);
  101. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  102. }
  103. }
  104. }
  105. #endregion
  106. #region When Digivolving
  107. if (timing == EffectTiming.OnEnterFieldAnyone)
  108. {
  109. ActivateClass activateClass = new ActivateClass();
  110. activateClass.SetUpICardEffect("Delete 1 level 3 Digimon", CanUseCondition, card);
  111. activateClass.SetUpActivateClass(CanActivateConditionShared, ActivateCoroutine, -1, false, EffectDescription());
  112. cardEffects.Add(activateClass);
  113. string EffectDescription()
  114. {
  115. return "[When Digivolving] Delete 1 of your opponent's level 3 Digimon.";
  116. }
  117. bool CanUseCondition(Hashtable hashtable)
  118. {
  119. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  120. }
  121. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  122. {
  123. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentOPWDCondition))
  124. {
  125. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentOPWDCondition));
  126. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  127. selectPermanentEffect.SetUp(
  128. selectPlayer: card.Owner,
  129. canTargetCondition: CanSelectPermanentOPWDCondition,
  130. canTargetCondition_ByPreSelecetedList: null,
  131. canEndSelectCondition: null,
  132. maxCount: maxCount,
  133. canNoSelect: false,
  134. canEndNotMax: false,
  135. selectPermanentCoroutine: null,
  136. afterSelectPermanentCoroutine: null,
  137. mode: SelectPermanentEffect.Mode.Destroy,
  138. cardEffect: activateClass);
  139. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  140. }
  141. }
  142. }
  143. #endregion
  144. #region All Turns
  145. if (timing == EffectTiming.OnLinkCardDiscarded)
  146. {
  147. ActivateClass activateClass = new ActivateClass();
  148. activateClass.SetUpICardEffect("Gain +1 Memory", CanUseCondition, card);
  149. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDescription());
  150. activateClass.SetHashString("GainMemory_EX10-043");
  151. cardEffects.Add(activateClass);
  152. string EffectDescription()
  153. {
  154. return "[All turns] [Once Per Turn] When effects trash any of this Digimon's link cards, gain 1 memory.";
  155. }
  156. bool CanUseCondition(Hashtable hashtable)
  157. {
  158. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  159. CardEffectCommons.CanTriggerOnTrashLinkedCard(hashtable, perm => perm == card.PermanentOfThisCard(), cardEffect => cardEffect != null, source => source != null);
  160. }
  161. bool CanActivateCondition(Hashtable hashtable)
  162. {
  163. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  164. }
  165. IEnumerator ActivateCoroutine(Hashtable hashtable)
  166. {
  167. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(1, activateClass));
  168. }
  169. }
  170. #endregion
  171. #region Link - When Attacking
  172. if (timing == EffectTiming.OnAllyAttack)
  173. {
  174. ActivateClass activateClass = new ActivateClass();
  175. activateClass.SetUpICardEffect("Trash to delete", CanUseCondition, card);
  176. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  177. activateClass.SetIsLinkedEffect(true);
  178. cardEffects.Add(activateClass);
  179. string EffectDescription() => "[When Attacking] By trashing 1 of this Digimon's link cards, delete 1 of your opponent's level 4 or lower Digimon.";
  180. bool CanUseCondition(Hashtable hashtable)
  181. {
  182. return CardEffectCommons.IsExistLinked(card)
  183. && CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  184. }
  185. bool CanActivateCondition(Hashtable hashtable)
  186. {
  187. return CardEffectCommons.IsExistLinked(card) &&
  188. !card.PermanentOfThisCard().HasNoLinkCards;
  189. }
  190. bool CanSelectPermanentCondition(Permanent permanent)
  191. {
  192. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card) && permanent.Level <= 4;
  193. }
  194. IEnumerator ActivateCoroutine(Hashtable hashtable)
  195. {
  196. Permanent thisCardPermament = card.PermanentOfThisCard();
  197. CardSource selectedCard = null;
  198. #region Select Link Card
  199. int maxCount = Math.Min(1, thisCardPermament.LinkedCards.Count);
  200. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  201. selectCardEffect.SetUp(
  202. canTargetCondition: _ => true,
  203. canTargetCondition_ByPreSelecetedList: null,
  204. canEndSelectCondition: null,
  205. canNoSelect: () => true,
  206. selectCardCoroutine: SelectCardCoroutine,
  207. afterSelectCardCoroutine: null,
  208. message: "Select 1 linked card to trash.",
  209. maxCount: maxCount,
  210. canEndNotMax: false,
  211. isShowOpponent: true,
  212. mode: SelectCardEffect.Mode.Custom,
  213. root: SelectCardEffect.Root.Custom,
  214. customRootCardList: thisCardPermament.LinkedCards,
  215. canLookReverseCard: true,
  216. selectPlayer: card.Owner,
  217. cardEffect: activateClass);
  218. IEnumerator SelectCardCoroutine(CardSource cardSource)
  219. {
  220. selectedCard = cardSource;
  221. yield return null;
  222. }
  223. selectCardEffect.SetUpCustomMessage("Select 1 linked card to trash.", "The opponent is selecting 1 linked card to trash.");
  224. yield return StartCoroutine(selectCardEffect.Activate());
  225. #endregion
  226. if (selectedCard != null) yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.TrashLinkCardsAndProcessAccordingToResult(
  227. targetPermanent: thisCardPermament,
  228. targetLinkCards: new List<CardSource>() { selectedCard },
  229. activateClass: activateClass,
  230. successProcess: SuccessProcess,
  231. failureProcess: null));
  232. IEnumerator SuccessProcess(List<CardSource> trashedLinkCards)
  233. {
  234. if (trashedLinkCards.Any())
  235. {
  236. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  237. {
  238. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  239. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  240. selectPermanentEffect.SetUp(
  241. selectPlayer: card.Owner,
  242. canTargetCondition: CanSelectPermanentCondition,
  243. canTargetCondition_ByPreSelecetedList: null,
  244. canEndSelectCondition: null,
  245. maxCount: maxCount,
  246. canNoSelect: true,
  247. canEndNotMax: false,
  248. selectPermanentCoroutine: null,
  249. afterSelectPermanentCoroutine: null,
  250. mode: SelectPermanentEffect.Mode.Destroy,
  251. cardEffect: activateClass);
  252. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  253. }
  254. }
  255. }
  256. }
  257. }
  258. #endregion
  259. return cardEffects;
  260. }
  261. }
  262. }