BT20_080.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. namespace DCGO.CardEffects.BT20
  4. {
  5. public class BT20_080 : CEntity_Effect
  6. {
  7. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  8. {
  9. List<ICardEffect> cardEffects = new List<ICardEffect>();
  10. #region Alt Digivolve Cost
  11. if (timing == EffectTiming.None)
  12. {
  13. bool PermanentCondition(Permanent targetPermanent)
  14. {
  15. return targetPermanent.TopCard.EqualsCardName("Soloogarmon") ||
  16. (targetPermanent.TopCard.IsLevel5 &&
  17. targetPermanent.TopCard.HasSeekersTraits);
  18. }
  19. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  20. permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false,
  21. card: card, condition: null));
  22. }
  23. #endregion
  24. #region Scapegoat
  25. if (timing == EffectTiming.WhenPermanentWouldBeDeleted)
  26. {
  27. cardEffects.Add(CardEffectFactory.ScapegoatSelfEffect(isInheritedEffect: false, card: card, condition: null, effectName: "<Scapegoat>", effectDiscription: null));
  28. }
  29. #endregion
  30. #region When Digivolving
  31. if (timing == EffectTiming.OnEnterFieldAnyone)
  32. {
  33. ActivateClass activateClass = new ActivateClass();
  34. activateClass.SetUpICardEffect("Play 1 Digimon from trash", CanUseCondition, card);
  35. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  36. cardEffects.Add(activateClass);
  37. string EffectDiscription()
  38. {
  39. return "[When Digivolving] You may play 1 level 4 or lower [SoC] or [SEEKERS] trait Digimon from your trash without paying the cost.";
  40. }
  41. bool CanSelectCard(CardSource source)
  42. {
  43. return source.HasLevel && source.Level <= 4 &&
  44. !source.IsDigiEgg &&
  45. (source.HasSocTraits || source.HasSeekersTraits) &&
  46. CardEffectCommons.CanPlayAsNewPermanent(source, false, activateClass, SelectCardEffect.Root.Trash);
  47. }
  48. bool CanUseCondition(Hashtable hashtable)
  49. {
  50. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  51. CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  52. }
  53. bool CanActivateCondition(Hashtable hashtable)
  54. {
  55. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  56. CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCard);
  57. }
  58. IEnumerator ActivateCoroutine(Hashtable hashtable)
  59. {
  60. List<CardSource> selectedCards = new List<CardSource>();
  61. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  62. selectCardEffect.SetUp(
  63. canTargetCondition: CanSelectCard,
  64. canTargetCondition_ByPreSelecetedList: null,
  65. canEndSelectCondition: null,
  66. canNoSelect: () => true,
  67. selectCardCoroutine: SelectCardCoroutine,
  68. afterSelectCardCoroutine: null,
  69. message: "Select 1 card to play.",
  70. maxCount: 1,
  71. canEndNotMax: false,
  72. isShowOpponent: true,
  73. mode: SelectCardEffect.Mode.Custom,
  74. root: SelectCardEffect.Root.Trash,
  75. customRootCardList: null,
  76. canLookReverseCard: true,
  77. selectPlayer: card.Owner,
  78. cardEffect: activateClass);
  79. selectCardEffect.SetUpCustomMessage("Select 1 card to play.",
  80. "The opponent is selecting 1 card to play.");
  81. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  82. yield return StartCoroutine(selectCardEffect.Activate());
  83. IEnumerator SelectCardCoroutine(CardSource cardSource)
  84. {
  85. selectedCards.Add(cardSource);
  86. yield return null;
  87. }
  88. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  89. cardSources: selectedCards,
  90. activateClass: activateClass,
  91. payCost: false,
  92. isTapped: false,
  93. root: SelectCardEffect.Root.Trash,
  94. activateETB: true));
  95. }
  96. }
  97. #endregion
  98. #region All Turns
  99. if (timing == EffectTiming.OnAddDigivolutionCards)
  100. {
  101. ActivateClass activateClass = new ActivateClass();
  102. activateClass.SetUpICardEffect("Activate effect, then attack", CanUseCondition, card);
  103. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  104. cardEffects.Add(activateClass);
  105. string EffectDiscription()
  106. {
  107. return "[All Turns] When Tamer cards are placed in this Digimon's digivolution cards, activate 1 of this Digimon's [When Digivolving] effects. Then, 1 of your Digimon may attack a player.";
  108. }
  109. bool IsYourDigimon(Permanent permanent)
  110. {
  111. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  112. }
  113. bool CanUseCondition(Hashtable hashtable)
  114. {
  115. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  116. CardEffectCommons.CanTriggerOnAddDigivolutionCard(
  117. hashtable: hashtable,
  118. permanentCondition: permanent => permanent == card.PermanentOfThisCard(),
  119. cardEffectCondition: null,
  120. cardCondition: cardSource =>
  121. cardSource.IsTamer);
  122. }
  123. bool CanActivateCondition(Hashtable hashtable)
  124. {
  125. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  126. CardEffectCommons.HasMatchConditionPermanent(IsYourDigimon);
  127. }
  128. IEnumerator ActivateCoroutine(Hashtable hashtable)
  129. {
  130. List<ICardEffect> candidateEffects = card.PermanentOfThisCard().EffectList(EffectTiming.OnEnterFieldAnyone)
  131. .Clone()
  132. .Filter(cardEffect => cardEffect != null && cardEffect is ActivateICardEffect && !cardEffect.IsSecurityEffect && cardEffect.IsWhenDigivolving);
  133. if (candidateEffects.Count >= 1)
  134. {
  135. ICardEffect selectedEffect = null;
  136. if (candidateEffects.Count == 1)
  137. {
  138. selectedEffect = candidateEffects[0];
  139. }
  140. else
  141. {
  142. List<SkillInfo> skillInfos = candidateEffects
  143. .Map(cardEffect => new SkillInfo(cardEffect, null, EffectTiming.None));
  144. List<CardSource> cardSources = candidateEffects
  145. .Map(cardEffect => cardEffect.EffectSourceCard);
  146. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  147. selectCardEffect.SetUp(
  148. canTargetCondition: (cardSource) => true,
  149. canTargetCondition_ByPreSelecetedList: null,
  150. canEndSelectCondition: null,
  151. canNoSelect: () => false,
  152. selectCardCoroutine: null,
  153. afterSelectCardCoroutine: null,
  154. message: "Select 1 effect to activate.",
  155. maxCount: 1,
  156. canEndNotMax: false,
  157. isShowOpponent: false,
  158. mode: SelectCardEffect.Mode.Custom,
  159. root: SelectCardEffect.Root.Custom,
  160. customRootCardList: cardSources,
  161. canLookReverseCard: true,
  162. selectPlayer: card.Owner,
  163. cardEffect: activateClass);
  164. selectCardEffect.SetNotShowCard();
  165. selectCardEffect.SetUpSkillInfos(skillInfos);
  166. selectCardEffect.SetUpAfterSelectIndexCoroutine(AfterSelectIndexCoroutine);
  167. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  168. IEnumerator AfterSelectIndexCoroutine(List<int> selectedIndexes)
  169. {
  170. if (selectedIndexes.Count == 1)
  171. {
  172. selectedEffect = candidateEffects[selectedIndexes[0]];
  173. yield return null;
  174. }
  175. }
  176. }
  177. if (selectedEffect != null)
  178. {
  179. Hashtable effectHashtable = CardEffectCommons.WhenDigivolvingCheckHashtableOfCard(selectedEffect.EffectSourceCard);
  180. if (!selectedEffect.IsDisabled)
  181. {
  182. yield return ContinuousController.instance.StartCoroutine(
  183. ((ActivateICardEffect)selectedEffect).Activate_Optional_Effect_Execute(effectHashtable));
  184. }
  185. }
  186. }
  187. if (CardEffectCommons.HasMatchConditionPermanent(IsYourDigimon))
  188. {
  189. Permanent selectedPermanent = null;
  190. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  191. selectPermanentEffect.SetUp(
  192. selectPlayer: card.Owner,
  193. canTargetCondition: IsYourDigimon,
  194. canTargetCondition_ByPreSelecetedList: null,
  195. canEndSelectCondition: null,
  196. maxCount: 1,
  197. canNoSelect: true,
  198. canEndNotMax: false,
  199. selectPermanentCoroutine: SelectPermanentCoroutine,
  200. afterSelectPermanentCoroutine: null,
  201. mode: SelectPermanentEffect.Mode.Custom,
  202. cardEffect: activateClass);
  203. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will attack.", "The opponent is selecting 1 Digimon that will attack.");
  204. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  205. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  206. {
  207. selectedPermanent = permanent;
  208. yield return null;
  209. }
  210. if (selectedPermanent != null)
  211. {
  212. if (selectedPermanent.CanAttack(activateClass))
  213. {
  214. SelectAttackEffect selectAttackEffect = GManager.instance.GetComponent<SelectAttackEffect>();
  215. selectAttackEffect.SetUp(
  216. attacker: selectedPermanent,
  217. canAttackPlayerCondition: () => true,
  218. defenderCondition: (permanent) => false,
  219. cardEffect: activateClass);
  220. yield return ContinuousController.instance.StartCoroutine(selectAttackEffect.Activate());
  221. }
  222. }
  223. }
  224. }
  225. }
  226. #endregion
  227. #region All Turns - ESS
  228. if (timing == EffectTiming.OnDestroyedAnyone)
  229. {
  230. ActivateClass activateClass = new ActivateClass();
  231. activateClass.SetUpICardEffect("Trash opponent's top security", CanUseCondition, card);
  232. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  233. activateClass.SetHashString("TrashSecurity_BT20-080");
  234. activateClass.SetIsInheritedEffect(true);
  235. cardEffects.Add(activateClass);
  236. string EffectDiscription()
  237. {
  238. return "[All Turns] [Once Per Turn] When any of your opponent's Digimon are deleted, if this Digimon has [Fenriloogamon] in its name, trash your opponent's top security card.";
  239. }
  240. bool IsOpponentsDigimon(Permanent permanent)
  241. {
  242. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  243. }
  244. bool CanUseCondition(Hashtable hashtable)
  245. {
  246. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  247. CardEffectCommons.CanTriggerOnPermanentDeleted(hashtable, IsOpponentsDigimon, activateClass); }
  248. bool CanActivateCondition(Hashtable hashtable)
  249. {
  250. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  251. card.PermanentOfThisCard().TopCard.ContainsCardName("Fenriloogamon") &&
  252. card.Owner.Enemy.SecurityCards.Count >= 1;
  253. }
  254. IEnumerator ActivateCoroutine(Hashtable hashtable)
  255. {
  256. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  257. player: card.Owner.Enemy,
  258. destroySecurityCount: 1,
  259. cardEffect: activateClass,
  260. fromTop: true).DestroySecurity());
  261. }
  262. }
  263. #endregion
  264. return cardEffects;
  265. }
  266. }
  267. }