BT17_074.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT17
  6. {
  7. public class BT17_074 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Alternate Digivolution
  13. if (timing == EffectTiming.None)
  14. {
  15. bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.TopCard.EqualsCardName("Morphomon");
  18. }
  19. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  20. permanentCondition: PermanentCondition,
  21. digivolutionCost: 2,
  22. ignoreDigivolutionRequirement: false,
  23. card: card,
  24. condition: null)
  25. );
  26. }
  27. #endregion
  28. #region When Digivolving
  29. if (timing == EffectTiming.OnEnterFieldAnyone)
  30. {
  31. ActivateClass activateClass = new ActivateClass();
  32. activateClass.SetUpICardEffect("Play white tamer or Eosmon", CanUseCondition, card);
  33. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  34. cardEffects.Add(activateClass);
  35. string EffectDiscription()
  36. {
  37. return "[When Digivolving] If it's your turn, you may play 1 white Tamer with a play cost of 4 or less or 1 level 5 or lower [Eosmon] from your hand by paying 2 cost. If this effect played, your opponent may play 1 Tamer card from their hand without paying the cost.";
  38. }
  39. bool CanSelectTamerOrEosmonCondition(CardSource cardSource)
  40. {
  41. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: true, cardEffect: activateClass,
  42. root: SelectCardEffect.Root.Hand, isBreedingArea: false, isPlayOption: false, fixedCost: 2))
  43. {
  44. if (cardSource.IsTamer && cardSource.HasCardColor(CardColor.White) && cardSource.GetCostItself <= 4)
  45. return true;
  46. if (cardSource.IsDigimon && cardSource.Level <= 5 && cardSource.EqualsCardName("Eosmon"))
  47. return true;
  48. }
  49. return false;
  50. }
  51. bool CanSelectTamerOpponentCondition(CardSource cardSource)
  52. {
  53. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass, root: SelectCardEffect.Root.Hand))
  54. if (cardSource.IsTamer)
  55. return true;
  56. return false;
  57. }
  58. bool CanUseCondition(Hashtable hashtable)
  59. {
  60. return (CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card));
  61. }
  62. bool CanActivateCondition(Hashtable hashtable)
  63. {
  64. return (CardEffectCommons.IsExistOnBattleArea(card) && CardEffectCommons.IsOwnerTurn(card));
  65. }
  66. IEnumerator ActivateCoroutine(Hashtable hashtable)
  67. {
  68. if (card.Owner.HandCards.Count(CanSelectTamerOrEosmonCondition) >= 1)
  69. {
  70. List<CardSource> selectedCards = new List<CardSource>();
  71. int maxCount = 1;
  72. bool hasSelectedCard = false;
  73. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  74. selectHandEffect.SetUp(
  75. selectPlayer: card.Owner,
  76. canTargetCondition: CanSelectTamerOrEosmonCondition,
  77. canTargetCondition_ByPreSelecetedList: null,
  78. canEndSelectCondition: null,
  79. maxCount: maxCount,
  80. canNoSelect: true,
  81. canEndNotMax: false,
  82. isShowOpponent: true,
  83. selectCardCoroutine: SelectCardCoroutine,
  84. afterSelectCardCoroutine: null,
  85. mode: SelectHandEffect.Mode.Custom,
  86. cardEffect: activateClass);
  87. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  88. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  89. yield return StartCoroutine(selectHandEffect.Activate());
  90. IEnumerator SelectCardCoroutine(CardSource cardSource)
  91. {
  92. selectedCards.Add(cardSource);
  93. hasSelectedCard = true;
  94. yield return null;
  95. }
  96. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  97. cardSources: selectedCards,
  98. activateClass: activateClass,
  99. payCost: true,
  100. isTapped: false,
  101. root: SelectCardEffect.Root.Hand,
  102. activateETB: true,
  103. fixedCost: 2));
  104. if (hasSelectedCard && card.Owner.Enemy.HandCards.Count > 0)
  105. {
  106. List<CardSource> selectedCardsOpponent = new List<CardSource>();
  107. SelectHandEffect selectHandEffectOpponent = GManager.instance.GetComponent<SelectHandEffect>();
  108. selectHandEffectOpponent.SetUp(
  109. selectPlayer: card.Owner.Enemy,
  110. canTargetCondition: CanSelectTamerOpponentCondition,
  111. canTargetCondition_ByPreSelecetedList: null,
  112. canEndSelectCondition: null,
  113. maxCount: maxCount,
  114. canNoSelect: true,
  115. canEndNotMax: false,
  116. isShowOpponent: true,
  117. selectCardCoroutine: SelectCardCoroutineOpponent,
  118. afterSelectCardCoroutine: null,
  119. mode: SelectHandEffect.Mode.Custom,
  120. cardEffect: activateClass);
  121. selectHandEffectOpponent.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  122. selectHandEffectOpponent.SetUpCustomMessage_ShowCard("Played Card");
  123. yield return StartCoroutine(selectHandEffectOpponent.Activate());
  124. IEnumerator SelectCardCoroutineOpponent(CardSource cardSource)
  125. {
  126. selectedCardsOpponent.Add(cardSource);
  127. yield return null;
  128. }
  129. if(selectedCardsOpponent.Count > 0)
  130. {
  131. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  132. cardSources: selectedCardsOpponent,
  133. activateClass: activateClass,
  134. payCost: false,
  135. isTapped: false,
  136. root: SelectCardEffect.Root.Hand,
  137. activateETB: true));
  138. }
  139. }
  140. }
  141. }
  142. }
  143. #endregion
  144. #region Inherited Effect - Opponent's Turn
  145. if (timing == EffectTiming.OnAllyAttack)
  146. {
  147. ActivateClass activateClass = new ActivateClass();
  148. activateClass.SetUpICardEffect("Switch attack target", CanUseCondition, card);
  149. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true,
  150. EffectDiscription());
  151. activateClass.SetIsInheritedEffect(true);
  152. activateClass.SetHashString("Eosmon_SwitchTarget_BT17_074");
  153. cardEffects.Add(activateClass);
  154. string EffectDiscription()
  155. {
  156. return (
  157. "[Opponent's Turn] [Once Per Turn] When an opponent's Digimon attacks, you may switch the attack target to 1 of your [Eosmon].");
  158. }
  159. bool IsOpponentAttacking(Permanent permanent)
  160. {
  161. return CardEffectCommons.IsOpponentPermanent(permanent, card);
  162. }
  163. bool CanSelectPermanentCondition(Permanent permanent)
  164. {
  165. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  166. if (permanent.TopCard.EqualsCardName("Eosmon"))
  167. return true;
  168. return false;
  169. }
  170. bool CanUseCondition(Hashtable hashtable)
  171. {
  172. return CardEffectCommons.CanTriggerOnPermanentAttack(hashtable, IsOpponentAttacking);
  173. }
  174. bool CanActivateCondition(Hashtable hashtable)
  175. {
  176. if (CardEffectCommons.IsExistOnBattleArea(card))
  177. return CardEffectCommons.IsOpponentTurn(card);
  178. return false;
  179. }
  180. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  181. {
  182. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  183. {
  184. int maxCount = Math.Min(1,
  185. CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  186. SelectPermanentEffect selectPermanentEffect =
  187. GManager.instance.GetComponent<SelectPermanentEffect>();
  188. selectPermanentEffect.SetUp(
  189. selectPlayer: card.Owner,
  190. canTargetCondition: CanSelectPermanentCondition,
  191. canTargetCondition_ByPreSelecetedList: null,
  192. canEndSelectCondition: null,
  193. maxCount: maxCount,
  194. canNoSelect: false,
  195. canEndNotMax: false,
  196. selectPermanentCoroutine: SelectPermanentCoroutine,
  197. afterSelectPermanentCoroutine: null,
  198. mode: SelectPermanentEffect.Mode.Custom,
  199. cardEffect: activateClass);
  200. selectPermanentEffect.SetUpCustomMessage("Select 1 card to be targeted by opponent's attack.", "Opponent is selecting a card to be targeted.");
  201. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  202. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  203. {
  204. yield return ContinuousController.instance.StartCoroutine(GManager.instance.attackProcess.SwitchDefender(
  205. activateClass,
  206. false,
  207. permanent));
  208. }
  209. }
  210. }
  211. }
  212. #endregion
  213. return cardEffects;
  214. }
  215. }
  216. }