BT23_012.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. // Garudamon
  5. namespace DCGO.CardEffects.BT23
  6. {
  7. public class BT23_012 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Alternative Digivolution Condition
  13. if (timing == EffectTiming.None)
  14. {
  15. bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.TopCard.HasCSTraits
  18. && targetPermanent.TopCard.HasLevel
  19. && targetPermanent.TopCard.IsLevel4;
  20. }
  21. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  22. permanentCondition: PermanentCondition,
  23. digivolutionCost: 3,
  24. ignoreDigivolutionRequirement: false,
  25. card: card,
  26. condition: null)
  27. );
  28. }
  29. #endregion
  30. #region OP/WD Shared
  31. bool SharedCanSelectPermanentCondition(Permanent permanent)
  32. {
  33. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  34. }
  35. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  36. {
  37. if (CardEffectCommons.HasMatchConditionPermanent(SharedCanSelectPermanentCondition))
  38. {
  39. Permanent selectedPermament = null;
  40. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(SharedCanSelectPermanentCondition));
  41. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  42. selectPermanentEffect.SetUp(
  43. selectPlayer: card.Owner,
  44. canTargetCondition: SharedCanSelectPermanentCondition,
  45. canTargetCondition_ByPreSelecetedList: null,
  46. canEndSelectCondition: null,
  47. maxCount: maxCount,
  48. canNoSelect: false,
  49. canEndNotMax: false,
  50. selectPermanentCoroutine: SelectPermanentCoroutine,
  51. afterSelectPermanentCoroutine: null,
  52. mode: SelectPermanentEffect.Mode.Custom,
  53. cardEffect: activateClass);
  54. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  55. {
  56. selectedPermament = permanent;
  57. yield return null;
  58. }
  59. selectPermanentEffect.SetUpCustomMessage("Select 1 digimon to gain Raid", "Your opponent is selecting 1 digimon to gain Raid");
  60. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  61. if (selectedPermament != null) yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainRaid(
  62. targetPermanent: selectedPermament,
  63. effectDuration: EffectDuration.UntilEachTurnEnd,
  64. activateClass: activateClass));
  65. }
  66. }
  67. #endregion
  68. #region On Play
  69. if (timing == EffectTiming.OnEnterFieldAnyone)
  70. {
  71. ActivateClass activateClass = new ActivateClass();
  72. activateClass.SetUpICardEffect("Give 1 digimon Raid", CanUseCondition, card);
  73. activateClass.SetUpActivateClass(CanActivateCondition, hashtable => SharedActivateCoroutine(hashtable, activateClass), -1, false, EffectDiscription());
  74. cardEffects.Add(activateClass);
  75. string EffectDiscription()
  76. {
  77. return "[On Play] 1 of your Digimon gains <Raid> for the turn.";
  78. }
  79. bool CanUseCondition(Hashtable hashtable)
  80. {
  81. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  82. && CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  83. }
  84. bool CanActivateCondition(Hashtable hashtable)
  85. {
  86. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  87. && CardEffectCommons.HasMatchConditionPermanent(SharedCanSelectPermanentCondition);
  88. }
  89. }
  90. #endregion
  91. #region When Digivolving
  92. if (timing == EffectTiming.OnEnterFieldAnyone)
  93. {
  94. ActivateClass activateClass = new ActivateClass();
  95. activateClass.SetUpICardEffect("Give 1 digimon Raid", CanUseCondition, card);
  96. activateClass.SetUpActivateClass(CanActivateCondition, hashtable => SharedActivateCoroutine(hashtable, activateClass), -1, false, EffectDiscription());
  97. cardEffects.Add(activateClass);
  98. string EffectDiscription()
  99. {
  100. return "[When Digivolving] 1 of your Digimon gains <Raid> for the turn.";
  101. }
  102. bool CanUseCondition(Hashtable hashtable)
  103. {
  104. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  105. && CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  106. }
  107. bool CanActivateCondition(Hashtable hashtable)
  108. {
  109. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  110. && CardEffectCommons.HasMatchConditionPermanent(SharedCanSelectPermanentCondition);
  111. }
  112. }
  113. #endregion
  114. #region OD/ESS-OD Shared
  115. bool SharedCanSelectCardCondition(CardSource cardSource, ActivateClass activateClass)
  116. {
  117. return cardSource.IsDigimon
  118. && cardSource.HasLevel && cardSource.Level <= 4
  119. && (cardSource.HasCSTraits || cardSource.HasAvianBeastAnimalTraits)
  120. && CardEffectCommons.CanPlayAsNewPermanent(cardSource, false, activateClass);
  121. }
  122. IEnumerator SharedActivateCoroutine1(Hashtable hashtable, ActivateClass activateClass)
  123. {
  124. if (CardEffectCommons.HasMatchConditionOwnersHand(card, cs => SharedCanSelectCardCondition(cs, activateClass)))
  125. {
  126. CardSource selectedCard = null;
  127. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOwnersCardCountInHand(card, cs => SharedCanSelectCardCondition(cs, activateClass)));
  128. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  129. selectHandEffect.SetUp(
  130. selectPlayer: card.Owner,
  131. canTargetCondition: cs => SharedCanSelectCardCondition(cs, activateClass),
  132. canTargetCondition_ByPreSelecetedList: null,
  133. canEndSelectCondition: null,
  134. maxCount: maxCount,
  135. canNoSelect: true,
  136. canEndNotMax: false,
  137. isShowOpponent: true,
  138. selectCardCoroutine: SelectCardCoroutine,
  139. afterSelectCardCoroutine: null,
  140. mode: SelectHandEffect.Mode.Custom,
  141. cardEffect: activateClass);
  142. IEnumerator SelectCardCoroutine(CardSource cardSource)
  143. {
  144. selectedCard = cardSource;
  145. yield return null;
  146. }
  147. selectHandEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  148. selectHandEffect.SetUpCustomMessage_ShowCard("Played Card");
  149. yield return ContinuousController.instance.StartCoroutine(selectHandEffect.Activate());
  150. if (selectedCard != null) yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  151. cardSources: new List<CardSource>() { selectedCard },
  152. activateClass: activateClass,
  153. payCost: false,
  154. isTapped: false,
  155. root: SelectCardEffect.Root.Hand,
  156. activateETB: true));
  157. }
  158. }
  159. #endregion
  160. #region On Deletion
  161. if (timing == EffectTiming.OnDestroyedAnyone)
  162. {
  163. ActivateClass activateClass = new ActivateClass();
  164. activateClass.SetUpICardEffect("Play 1 level 4 or lower digimon from hand", CanUseCondition, card);
  165. activateClass.SetUpActivateClass(CanActivateCondition, hashtable => SharedActivateCoroutine1(hashtable, activateClass), -1, true, EffectDiscription());
  166. cardEffects.Add(activateClass);
  167. string EffectDiscription()
  168. {
  169. return "[On Deletion] You may play 1 level 4 or lower Digimon card with the [CS] trait or [Avian], [Bird], [Beast], [Animal] or [Sovereign] in any of its traits (other than [Sea Animal]) from your hand without paying the cost.";
  170. }
  171. bool CanUseCondition(Hashtable hashtable)
  172. {
  173. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  174. }
  175. bool CanActivateCondition(Hashtable hashtable)
  176. {
  177. return CardEffectCommons.CanActivateOnDeletion(card, activateClass)
  178. && CardEffectCommons.HasMatchConditionOwnersHand(card, cs => SharedCanSelectCardCondition(cs, activateClass));
  179. }
  180. }
  181. #endregion
  182. #region ESS - On Deletion
  183. if (timing == EffectTiming.OnDestroyedAnyone)
  184. {
  185. ActivateClass activateClass = new ActivateClass();
  186. activateClass.SetUpICardEffect("Play 1 level 4 or lower digimon from hand", CanUseCondition, card);
  187. activateClass.SetUpActivateClass(CanActivateCondition, hashtable => SharedActivateCoroutine1(hashtable, activateClass), -1, true, EffectDiscription());
  188. activateClass.SetIsInheritedEffect(true);
  189. cardEffects.Add(activateClass);
  190. string EffectDiscription()
  191. {
  192. return "[On Deletion] You may play 1 level 4 or lower Digimon card with the [CS] trait or [Avian], [Bird], [Beast], [Animal] or [Sovereign] in any of its traits (other than [Sea Animal]) from your hand without paying the cost.";
  193. }
  194. bool CanUseCondition(Hashtable hashtable)
  195. {
  196. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  197. }
  198. bool CanActivateCondition(Hashtable hashtable)
  199. {
  200. return CardEffectCommons.CanActivateOnDeletion(card, activateClass)
  201. && CardEffectCommons.HasMatchConditionOwnersHand(card, cs => SharedCanSelectCardCondition(cs, activateClass));
  202. }
  203. }
  204. #endregion
  205. return cardEffects;
  206. }
  207. }
  208. }