BT17_049.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System;
  4. namespace DCGO.CardEffects.BT17
  5. {
  6. public class BT17_049 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region Alternate Digivolution
  12. if (timing == EffectTiming.None)
  13. {
  14. bool PermanentCondition(Permanent targetPermanent)
  15. {
  16. return targetPermanent.TopCard.EqualsCardName("Turuiemon") || targetPermanent.TopCard.EqualsCardName("Wendigomon");
  17. }
  18. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  19. }
  20. #endregion
  21. #region Alliance
  22. if (timing == EffectTiming.OnAllyAttack)
  23. {
  24. cardEffects.Add(CardEffectFactory.AllianceSelfEffect(isInheritedEffect: false, card: card, condition: null));
  25. }
  26. #endregion
  27. #region When Digivolving
  28. if (timing == EffectTiming.OnEnterFieldAnyone)
  29. {
  30. ActivateClass activateClass = new ActivateClass();
  31. activateClass.SetUpICardEffect("Play 1 Green/Yellow Level 3", CanUseCondition, card);
  32. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  33. cardEffects.Add(activateClass);
  34. string EffectDiscription()
  35. {
  36. return "[When Digivolving] You may play 1 green or yellow level 3 Digimon card from your trash without paying the cost.";
  37. }
  38. bool CanPlayCondition(CardSource source)
  39. {
  40. if (source.IsDigimon)
  41. {
  42. if(source.HasLevel && source.Level == 3)
  43. {
  44. if(source.HasCardColor(CardColor.Green) || source.HasCardColor(CardColor.Yellow))
  45. {
  46. if (CardEffectCommons.CanPlayAsNewPermanent(source, false, activateClass))
  47. {
  48. return true;
  49. }
  50. }
  51. }
  52. }
  53. return false;
  54. }
  55. bool CanUseCondition(Hashtable hashtable)
  56. {
  57. if(CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card))
  58. {
  59. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanPlayCondition))
  60. {
  61. return true;
  62. }
  63. }
  64. return false;
  65. }
  66. bool CanActivateCondition(Hashtable hashtable)
  67. {
  68. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  69. }
  70. IEnumerator ActivateCoroutine(Hashtable hashtable)
  71. {
  72. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  73. selectCardEffect.SetUp(
  74. canTargetCondition: CanPlayCondition,
  75. canTargetCondition_ByPreSelecetedList: null,
  76. canEndSelectCondition: null,
  77. canNoSelect: () => true,
  78. selectCardCoroutine: null,
  79. afterSelectCardCoroutine: SelectCardCoroutine,
  80. message: "Select 1 card to play.",
  81. maxCount: 1,
  82. canEndNotMax: false,
  83. isShowOpponent: true,
  84. mode: SelectCardEffect.Mode.Custom,
  85. root: SelectCardEffect.Root.Trash,
  86. customRootCardList: null,
  87. canLookReverseCard: true,
  88. selectPlayer: card.Owner,
  89. cardEffect: activateClass);
  90. selectCardEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  91. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  92. yield return StartCoroutine(selectCardEffect.Activate());
  93. IEnumerator SelectCardCoroutine(List<CardSource> cardSources)
  94. {
  95. if(cardSources.Count > 0)
  96. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  97. cardSources: cardSources,
  98. activateClass: activateClass,
  99. payCost: false,
  100. isTapped: false,
  101. root: SelectCardEffect.Root.Trash,
  102. activateETB: true));
  103. }
  104. }
  105. }
  106. #endregion
  107. #region End of Attack - ESS
  108. if (timing == EffectTiming.OnEndAttack)
  109. {
  110. ActivateClass activateClass = new ActivateClass();
  111. activateClass.SetUpICardEffect("By deleting 1 digimon, Play 1 from trash", CanUseCondition, card);
  112. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  113. activateClass.SetIsInheritedEffect(true);
  114. activateClass.SetHashString("EndofAttack_BT17_049");
  115. cardEffects.Add(activateClass);
  116. string EffectDiscription()
  117. {
  118. return "[End of Attack] [Once Per Turn] By deleting 1 of your other suspended Digimon, you may play 1 level 3 Digimon card with the [Beast] trait from your trash without paying the cost.";
  119. }
  120. bool CanPlayCondition(CardSource source)
  121. {
  122. if (source.IsDigimon)
  123. {
  124. if (source.HasLevel && source.Level == 3)
  125. {
  126. if (source.CardTraits.Contains("Beast"))
  127. {
  128. if (CardEffectCommons.CanPlayAsNewPermanent(source, false, activateClass))
  129. {
  130. return true;
  131. }
  132. }
  133. }
  134. }
  135. return false;
  136. }
  137. bool IsDeletableDigimon(Permanent permanent)
  138. {
  139. if(CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  140. {
  141. if(permanent != card.PermanentOfThisCard())
  142. {
  143. return permanent.IsSuspended;
  144. }
  145. }
  146. return false;
  147. }
  148. bool CanUseCondition(Hashtable hashtable)
  149. {
  150. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  151. }
  152. bool CanActivateCondition(Hashtable hashtable)
  153. {
  154. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  155. }
  156. IEnumerator ActivateCoroutine(Hashtable hashtable)
  157. {
  158. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(IsDeletableDigimon));
  159. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  160. selectPermanentEffect.SetUp(
  161. selectPlayer: card.Owner,
  162. canTargetCondition: IsDeletableDigimon,
  163. canTargetCondition_ByPreSelecetedList: null,
  164. canEndSelectCondition: null,
  165. maxCount: maxCount,
  166. canNoSelect: true,
  167. canEndNotMax: false,
  168. selectPermanentCoroutine: null,
  169. afterSelectPermanentCoroutine: SelectPermanentCoroutine,
  170. mode: SelectPermanentEffect.Mode.Custom,
  171. cardEffect: activateClass);
  172. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to suspend.", "The opponent is selecting 1 Digimon to suspend.");
  173. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  174. IEnumerator SelectPermanentCoroutine(List<Permanent> permanents)
  175. {
  176. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(
  177. targetPermanents: permanents,
  178. activateClass: activateClass,
  179. successProcess: permanents => SuccessProcess(),
  180. failureProcess: null));
  181. }
  182. IEnumerator SuccessProcess()
  183. {
  184. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  185. selectCardEffect.SetUp(
  186. canTargetCondition: CanPlayCondition,
  187. canTargetCondition_ByPreSelecetedList: null,
  188. canEndSelectCondition: null,
  189. canNoSelect: () => true,
  190. selectCardCoroutine: null,
  191. afterSelectCardCoroutine: SelectCardCoroutine,
  192. message: "Select 1 card to play.",
  193. maxCount: 1,
  194. canEndNotMax: false,
  195. isShowOpponent: true,
  196. mode: SelectCardEffect.Mode.Custom,
  197. root: SelectCardEffect.Root.Trash,
  198. customRootCardList: null,
  199. canLookReverseCard: true,
  200. selectPlayer: card.Owner,
  201. cardEffect: activateClass);
  202. selectCardEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  203. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  204. yield return StartCoroutine(selectCardEffect.Activate());
  205. }
  206. IEnumerator SelectCardCoroutine(List<CardSource> cardSources)
  207. {
  208. if (cardSources.Count > 0)
  209. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  210. cardSources: cardSources,
  211. activateClass: activateClass,
  212. payCost: false,
  213. isTapped: false,
  214. root: SelectCardEffect.Root.Trash,
  215. activateETB: true));
  216. }
  217. }
  218. }
  219. #endregion
  220. return cardEffects;
  221. }
  222. }
  223. }