EX10_014.cs 15 KB

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