EX8_037.cs 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace DCGO.CardEffects.EX8
  5. {
  6. public class EX8_037 : 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 Conditions
  12. if (timing == EffectTiming.None)
  13. {
  14. static bool PermanentCondition(Permanent targetPermanent)
  15. {
  16. return targetPermanent.TopCard.ContainsCardName("Sakuyamon")
  17. && targetPermanent.TopCard.HasLevel
  18. && targetPermanent.TopCard.Level == 6
  19. && !targetPermanent.TopCard.HasXAntibodyTraits;
  20. }
  21. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 1, ignoreDigivolutionRequirement: false, card: card, condition: null));
  22. }
  23. #endregion
  24. #region When Digivolving
  25. if (timing == EffectTiming.OnEnterFieldAnyone)
  26. {
  27. ActivateClass activateClass = new ActivateClass();
  28. activateClass.SetUpICardEffect("Play a Token", CanUseCondition, card);
  29. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  30. cardEffects.Add(activateClass);
  31. string EffectDescription()
  32. {
  33. return "[When Digivolving] If [Sakuyamon] or [X Antibody] is in this Digimon's digivolution cards, play 1 [Uka-no-Mitama] (Digimon/Yellow/9000 DP/<Rush>) Token.";
  34. }
  35. bool CanUseCondition(Hashtable hashtable)
  36. {
  37. if(CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  38. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  39. return false;
  40. }
  41. bool CanActivateCondition(Hashtable hashtable)
  42. {
  43. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  44. }
  45. bool CanActivateTokenEffectCondition(Hashtable hashtable)
  46. {
  47. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  48. {
  49. if (card.PermanentOfThisCard().DigivolutionCards.Count((cardSource) => cardSource.EqualsCardName("Sakuyamon") || cardSource.EqualsCardName("X Antibody") || cardSource.EqualsCardName("XAntibody")) >= 1)
  50. {
  51. return true;
  52. }
  53. }
  54. return false;
  55. }
  56. IEnumerator ActivateCoroutine(Hashtable hashtable)
  57. {
  58. if (CanActivateTokenEffectCondition(hashtable))
  59. {
  60. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayUkaNoMitama(activateClass));
  61. }
  62. }
  63. }
  64. #endregion
  65. #region Your Turn
  66. if (timing == EffectTiming.OnAllyAttack)
  67. {
  68. ActivateClass activateClass = new ActivateClass();
  69. activateClass.SetUpICardEffect("Play 1 single-color option card", CanUseCondition, card);
  70. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true,
  71. EffectDescription());
  72. activateClass.SetHashString("PlayOption_EX8_037");
  73. cardEffects.Add(activateClass);
  74. string EffectDescription()
  75. {
  76. return "[Your Turn] [Once Per Turn] When any of your Digimon attack, you may use 1 single-color Option card with a cost of 5 or less from your hand without paying the cost. If you did, 1 of your Digimon unsuspends.";
  77. }
  78. bool PermanentCondition(Permanent permanent)
  79. {
  80. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  81. }
  82. bool CanSelectOptionCard(CardSource cardSource)
  83. {
  84. return cardSource.OptionCardColors.Count == 1
  85. && cardSource.GetCostItself <= 5
  86. && !cardSource.CanNotPlayThisOption;
  87. }
  88. bool CanUseCondition(Hashtable hashtable)
  89. {
  90. if (CardEffectCommons.IsExistOnBattleArea(card))
  91. {
  92. if (CardEffectCommons.IsOwnerTurn(card))
  93. {
  94. if (CardEffectCommons.CanTriggerOnPermanentAttack(hashtable, PermanentCondition))
  95. {
  96. return true;
  97. }
  98. }
  99. }
  100. return false;
  101. }
  102. bool CanActivateCondition(Hashtable hashtable)
  103. {
  104. if (CardEffectCommons.IsExistOnBattleArea(card))
  105. {
  106. return true;
  107. }
  108. return false;
  109. }
  110. bool CanSelectYourSuspendedDigimon(Permanent permanent)
  111. {
  112. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) &&
  113. permanent.IsDigimon && permanent.IsSuspended;
  114. }
  115. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  116. {
  117. if (card.Owner.HandCards.Count(CanSelectOptionCard) >= 1)
  118. {
  119. bool played = false;
  120. List<CardSource> selectedCards = new List<CardSource>();
  121. int maxCount = 1;
  122. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  123. selectHandEffect.SetUp(
  124. selectPlayer: card.Owner,
  125. canTargetCondition: CanSelectOptionCard,
  126. canTargetCondition_ByPreSelecetedList: null,
  127. canEndSelectCondition: null,
  128. maxCount: maxCount,
  129. canNoSelect: true,
  130. canEndNotMax: false,
  131. isShowOpponent: true,
  132. selectCardCoroutine: SelectCardCoroutine,
  133. afterSelectCardCoroutine: null,
  134. mode: SelectHandEffect.Mode.Custom,
  135. cardEffect: activateClass);
  136. selectHandEffect.SetUpCustomMessage(
  137. "Select 1 option card to use.",
  138. "The opponent is selecting 1 option card to use.");
  139. selectHandEffect.SetUpCustomMessage_ShowCard("Used Card");
  140. yield return StartCoroutine(selectHandEffect.Activate());
  141. IEnumerator SelectCardCoroutine(CardSource cardSource)
  142. {
  143. selectedCards.Add(cardSource);
  144. yield return null;
  145. }
  146. yield return ContinuousController.instance.StartCoroutine(
  147. CardEffectCommons.PlayOptionCards(
  148. cardSources: selectedCards,
  149. activateClass: activateClass,
  150. payCost: false,
  151. root: SelectCardEffect.Root.Hand));
  152. if (selectedCards.Any())
  153. {
  154. played = true;
  155. }
  156. if (played)
  157. {
  158. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectYourSuspendedDigimon))
  159. {
  160. SelectPermanentEffect selectPermanentEffect =
  161. GManager.instance.GetComponent<SelectPermanentEffect>();
  162. selectPermanentEffect.SetUp(
  163. selectPlayer: card.Owner,
  164. canTargetCondition_ByPreSelecetedList: null,
  165. canTargetCondition: CanSelectYourSuspendedDigimon,
  166. canEndSelectCondition: null,
  167. maxCount: 1,
  168. canNoSelect: false,
  169. canEndNotMax: false,
  170. selectPermanentCoroutine: null,
  171. afterSelectPermanentCoroutine: null,
  172. mode: SelectPermanentEffect.Mode.UnTap,
  173. cardEffect: activateClass);
  174. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to unsuspend.",
  175. "The opponent is selecting 1 Digimon to unsuspend.");
  176. yield return ContinuousController.instance.StartCoroutine(
  177. selectPermanentEffect.Activate());
  178. }
  179. }
  180. }
  181. }
  182. }
  183. #endregion
  184. return cardEffects;
  185. }
  186. }
  187. }