EX6_043.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace DCGO.CardEffects.EX6
  5. {
  6. public class EX6_043 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region Start of Main Phase
  12. if (timing == EffectTiming.OnStartMainPhase)
  13. {
  14. ActivateClass activateClass = new ActivateClass();
  15. activateClass.SetUpICardEffect("Play 1 Diaboromon Token", CanUseCondition, card);
  16. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  17. cardEffects.Add(activateClass);
  18. string EffectDiscription()
  19. {
  20. return "[Start of Your Main Phase] You may play 1 [Diaboromon] (Digimon | 14 Cost | Level 6 | White | Mega | Unknown | Unidentified | DP3000) Token without paying the cost.";
  21. }
  22. bool CanUseCondition(Hashtable hashtable)
  23. {
  24. return CardEffectCommons.IsOwnerTurn(card);
  25. }
  26. bool CanActivateCondition(Hashtable hashtable)
  27. {
  28. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  29. {
  30. if (card.Owner.fieldCardFrames.Count((frame) => frame.IsEmptyFrame()) >= 1)
  31. {
  32. return true;
  33. }
  34. }
  35. return false;
  36. }
  37. IEnumerator ActivateCoroutine(Hashtable hashtable)
  38. {
  39. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayDiaboromonToken(activateClass));
  40. }
  41. }
  42. #endregion
  43. #region When Digivolving
  44. if (timing == EffectTiming.OnEnterFieldAnyone)
  45. {
  46. ActivateClass activateClass = new ActivateClass();
  47. activateClass.SetUpICardEffect("Play 1 Diaboromon Token", CanUseCondition, card);
  48. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  49. cardEffects.Add(activateClass);
  50. string EffectDiscription()
  51. {
  52. return "[When Digivolving] You may play 1 [Diaboromon] (Digimon | 14 Cost | Level 6 | White | Mega | Unknown | Unidentified | DP3000) Token without paying the cost.";
  53. }
  54. bool CanUseCondition(Hashtable hashtable)
  55. {
  56. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable,card);
  57. }
  58. bool CanActivateCondition(Hashtable hashtable)
  59. {
  60. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  61. {
  62. if (card.Owner.fieldCardFrames.Count((frame) => frame.IsEmptyFrame()) >= 1)
  63. {
  64. return true;
  65. }
  66. }
  67. return false;
  68. }
  69. IEnumerator ActivateCoroutine(Hashtable hashtable)
  70. {
  71. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayDiaboromonToken(activateClass));
  72. }
  73. }
  74. #endregion
  75. #region All Turns
  76. if (timing == EffectTiming.OnEnterFieldAnyone)
  77. {
  78. ActivateClass activateClass = new ActivateClass();
  79. activateClass.SetUpICardEffect("Activate 1 [When Digivolving] effect", CanUseCondition, card);
  80. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  81. activateClass.SetHashString("PlayToken_EX6_043");
  82. cardEffects.Add(activateClass);
  83. string EffectDiscription()
  84. {
  85. return "[All Turns] [Once Per Turn] When an opponent's Digimon is played, you may activate 1 of this Digimon's [When Digivolving] effects.";
  86. }
  87. bool IsOpponentDigimon(Permanent permanent)
  88. {
  89. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  90. }
  91. bool CanUseCondition(Hashtable hashtable)
  92. {
  93. if(CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  94. return CardEffectCommons.CanTriggerOnPermanentPlay(hashtable, IsOpponentDigimon);
  95. return false;
  96. }
  97. bool CanActivateCondition(Hashtable hashtable)
  98. {
  99. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  100. }
  101. IEnumerator ActivateCoroutine(Hashtable hashtable)
  102. {
  103. List<ICardEffect> candidateEffects = card.PermanentOfThisCard().EffectList(EffectTiming.OnEnterFieldAnyone)
  104. .Clone()
  105. .Filter(cardEffect => cardEffect != null && cardEffect is ActivateICardEffect && !cardEffect.IsSecurityEffect && cardEffect.IsWhenDigivolving);
  106. if (candidateEffects.Count >= 1)
  107. {
  108. ICardEffect selectedEffect = null;
  109. if (candidateEffects.Count == 1)
  110. {
  111. selectedEffect = candidateEffects[0];
  112. }
  113. else
  114. {
  115. List<SkillInfo> skillInfos = candidateEffects
  116. .Map(cardEffect => new SkillInfo(cardEffect, null, EffectTiming.None));
  117. List<CardSource> cardSources = candidateEffects
  118. .Map(cardEffect => cardEffect.EffectSourceCard);
  119. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  120. selectCardEffect.SetUp(
  121. canTargetCondition: (cardSource) => true,
  122. canTargetCondition_ByPreSelecetedList: null,
  123. canEndSelectCondition: null,
  124. canNoSelect: () => false,
  125. selectCardCoroutine: null,
  126. afterSelectCardCoroutine: null,
  127. message: "Select 1 effect to activate.",
  128. maxCount: 1,
  129. canEndNotMax: false,
  130. isShowOpponent: false,
  131. mode: SelectCardEffect.Mode.Custom,
  132. root: SelectCardEffect.Root.Custom,
  133. customRootCardList: cardSources,
  134. canLookReverseCard: true,
  135. selectPlayer: card.Owner,
  136. cardEffect: activateClass);
  137. selectCardEffect.SetNotShowCard();
  138. selectCardEffect.SetUpSkillInfos(skillInfos);
  139. selectCardEffect.SetUpAfterSelectIndexCoroutine(AfterSelectIndexCoroutine);
  140. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  141. IEnumerator AfterSelectIndexCoroutine(List<int> selectedIndexes)
  142. {
  143. if (selectedIndexes.Count == 1)
  144. {
  145. selectedEffect = candidateEffects[selectedIndexes[0]];
  146. yield return null;
  147. }
  148. }
  149. }
  150. if (selectedEffect != null)
  151. {
  152. if (!selectedEffect.IsDisabled)
  153. {
  154. Hashtable effectHashtable =
  155. CardEffectCommons.WhenDigivolvingCheckHashtableOfCard(selectedEffect.EffectSourceCard);
  156. selectedEffect.SetIsDigimonEffect(true);
  157. yield return ContinuousController.instance.StartCoroutine(
  158. ((ActivateICardEffect)selectedEffect).Activate_Optional_Effect_Execute(effectHashtable));
  159. }
  160. }
  161. }
  162. }
  163. }
  164. if (timing == EffectTiming.None)
  165. {
  166. bool CanUseCondition()
  167. {
  168. return CardEffectCommons.IsExistOnBattleArea(card);
  169. }
  170. bool PermanentCondition(Permanent permanent)
  171. {
  172. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  173. {
  174. if (permanent != card.PermanentOfThisCard())
  175. {
  176. if (permanent.TopCard.ContainsCardName("Diaboromon"))
  177. {
  178. return true;
  179. }
  180. }
  181. }
  182. return false;
  183. }
  184. cardEffects.Add(CardEffectFactory.BlockerStaticEffect(
  185. permanentCondition: PermanentCondition,
  186. isInheritedEffect: false,
  187. card: card,
  188. condition: CanUseCondition
  189. ));
  190. cardEffects.Add(CardEffectFactory.JammingStaticEffect(
  191. permanentCondition: PermanentCondition,
  192. isInheritedEffect: false,
  193. card: card,
  194. condition: CanUseCondition
  195. ));
  196. }
  197. #endregion
  198. return cardEffects;
  199. }
  200. }
  201. }