BT24_028.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. // Divermon
  6. namespace DCGO.CardEffects.BT24
  7. {
  8. public class BT24_028 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Alt Digivolution Condition
  14. if (timing == EffectTiming.None)
  15. {
  16. static bool PermanentCondition(Permanent targetPermanent)
  17. {
  18. return targetPermanent.TopCard.IsLevel4
  19. && (targetPermanent.TopCard.HasAquaTraits || targetPermanent.TopCard.HasTSTraits);
  20. }
  21. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  22. }
  23. #endregion
  24. #region OP/WD Shared
  25. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  26. {
  27. bool CardCondition(CardSource card)
  28. {
  29. return card.IsDigimon
  30. && card.HasLevel && card.Level <= 5
  31. && card.HasCardColor(CardColor.Blue)
  32. && card.HasTSTraits;
  33. }
  34. bool validHandCard = CardEffectCommons.HasMatchConditionOwnersHand(card, CardCondition);
  35. if (validHandCard)
  36. {
  37. CardSource selectedCard = null;
  38. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  39. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOwnersCardCountInHand(card, CardCondition));
  40. selectHandEffect.SetUp(
  41. selectPlayer: card.Owner,
  42. canTargetCondition: CardCondition,
  43. canTargetCondition_ByPreSelecetedList: null,
  44. canEndSelectCondition: null,
  45. maxCount: maxCount,
  46. canNoSelect: true,
  47. canEndNotMax: false,
  48. isShowOpponent: true,
  49. selectCardCoroutine: SelectCardCoroutine,
  50. afterSelectCardCoroutine: null,
  51. mode: SelectHandEffect.Mode.Custom,
  52. cardEffect: activateClass);
  53. IEnumerator SelectCardCoroutine(CardSource cardSource)
  54. {
  55. selectedCard = cardSource;
  56. yield return null;
  57. }
  58. selectHandEffect.SetUpCustomMessage("Select 1 card to place as digivolution source.", "The opponent is selecting 1 card to place as digivolution source.");
  59. selectHandEffect.SetUpCustomMessage_ShowCard("Selected Card");
  60. yield return ContinuousController.instance.StartCoroutine(selectHandEffect.Activate());
  61. if (selectedCard != null) yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsBottom(
  62. addedDigivolutionCards: new List<CardSource>() { selectedCard },
  63. cardEffect: activateClass));
  64. if (card.PermanentOfThisCard().DigivolutionCards.Contains(selectedCard))
  65. {
  66. bool CanNotBeDestroyedByBattleCondition(Permanent permanent, Permanent AttackingPermanent, Permanent DefendingPermanent, CardSource DefendingCard)
  67. {
  68. if (permanent == AttackingPermanent)
  69. {
  70. return true;
  71. }
  72. if (permanent == DefendingPermanent)
  73. {
  74. return true;
  75. }
  76. return false;
  77. }
  78. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainBlocker(
  79. targetPermanent: card.PermanentOfThisCard(),
  80. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  81. activateClass: activateClass));
  82. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainCanNotBeDeletedByBattle(
  83. targetPermanent: card.PermanentOfThisCard(),
  84. canNotBeDestroyedByBattleCondition: CanNotBeDestroyedByBattleCondition,
  85. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  86. activateClass: activateClass,
  87. effectName: "Cannot be destroyed by battle"));
  88. }
  89. }
  90. }
  91. #endregion
  92. #region On Play
  93. if (timing == EffectTiming.OnEnterFieldAnyone)
  94. {
  95. ActivateClass activateClass = new ActivateClass();
  96. activateClass.SetUpICardEffect("By placing 1 level 5 or lower [TS digimon] as bottom source card, gain battle immunity & <Blocker>", CanUseCondition, card);
  97. activateClass.SetUpActivateClass(CanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), -1, false, EffectDescription());
  98. cardEffects.Add(activateClass);
  99. string EffectDescription()
  100. {
  101. return "[On Play] By placing 1 level 5 or lower blue [TS] trait Digimon card from your hand as this Digimon's bottom digivolution card, until your opponent's turn ends, this Digimon can't be deleted in battle and gains <Blocker>";
  102. }
  103. bool CanUseCondition(Hashtable hashtable)
  104. {
  105. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  106. && CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  107. }
  108. bool CanActivateCondition(Hashtable hashtable)
  109. {
  110. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  111. }
  112. }
  113. #endregion
  114. #region When Digivolving
  115. if (timing == EffectTiming.OnEnterFieldAnyone)
  116. {
  117. ActivateClass activateClass = new ActivateClass();
  118. activateClass.SetUpICardEffect("By placing 1 level 5 or lower [TS digimon] as bottom source card, gain battle immunity & <Blocker>", CanUseCondition, card);
  119. activateClass.SetUpActivateClass(CanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), -1, false, EffectDescription());
  120. cardEffects.Add(activateClass);
  121. string EffectDescription()
  122. {
  123. return "[When Digivolving] By placing 1 level 5 or lower blue [TS] trait Digimon card from your hand as this Digimon's bottom digivolution card, until your opponent's turn ends, this Digimon can't be deleted in battle and gains <Blocker>";
  124. }
  125. bool CanUseCondition(Hashtable hashtable)
  126. {
  127. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  128. && CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  129. }
  130. bool CanActivateCondition(Hashtable hashtable)
  131. {
  132. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  133. }
  134. }
  135. #endregion
  136. #region Your Turn
  137. if (timing == EffectTiming.OnUnTappedAnyone)
  138. {
  139. ActivateClass activateClass = new ActivateClass();
  140. activateClass.SetUpICardEffect("You may digivolve into [Neptunemon]", CanUseCondition, card);
  141. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  142. cardEffects.Add(activateClass);
  143. string EffectDescription()
  144. {
  145. return "[Your Turn] When this Digimon unsuspends, it may digivolve into [Neptunemon] in the hand without paying the cost.";
  146. }
  147. bool CanUseCondition(Hashtable hashtable)
  148. {
  149. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  150. && CardEffectCommons.CanTriggerWhenSelfPermanentUnsuspends(hashtable, card);
  151. }
  152. bool CanActivateCondition(Hashtable hashtable)
  153. {
  154. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  155. && CardEffectCommons.IsOwnerTurn(card)
  156. && CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition);
  157. }
  158. bool CanSelectCardCondition(CardSource cardSource)
  159. {
  160. return cardSource.EqualsCardName("Neptunemon");
  161. }
  162. IEnumerator ActivateCoroutine(Hashtable hashtable)
  163. {
  164. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  165. targetPermanent: card.PermanentOfThisCard(),
  166. cardCondition: CanSelectCardCondition,
  167. payCost: false,
  168. reduceCostTuple: null,
  169. fixedCostTuple: null,
  170. ignoreDigivolutionRequirementFixedCost: -1,
  171. isHand: true, activateClass: activateClass,
  172. successProcess: null));
  173. }
  174. }
  175. #endregion
  176. #region ESS
  177. if (timing == EffectTiming.OnAllyAttack)
  178. {
  179. ActivateClass activateClass = new ActivateClass();
  180. activateClass.SetUpICardEffect("Play 1 level 4 or lower blue [TS] digimon in digivolution sources", CanUseCondition, card);
  181. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDescription());
  182. activateClass.SetHashString("BT24_028_ESS");
  183. activateClass.SetIsInheritedEffect(true);
  184. cardEffects.Add(activateClass);
  185. string EffectDescription()
  186. {
  187. return "[When Attacking] [Once Per Turn] You may play 1 level 4 or lower blue Digimon card with the [TS] trait from this Digimon's digivolution cards without paying the cost.";
  188. }
  189. bool CanUseCondition(Hashtable hashtable)
  190. {
  191. return CardEffectCommons.IsExistOnBattleArea(card)
  192. && CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  193. }
  194. bool CanActivateCondition(Hashtable hashtable)
  195. {
  196. return CardEffectCommons.IsExistOnBattleArea(card);
  197. }
  198. bool CardCondition(CardSource cardSource)
  199. {
  200. return cardSource.IsDigimon
  201. && cardSource.HasCardColor(CardColor.Blue)
  202. && cardSource.HasLevel && cardSource.Level <= 4
  203. && CardEffectCommons.CanPlayAsNewPermanent(cardSource, false, activateClass, root: SelectCardEffect.Root.DigivolutionCards);
  204. }
  205. IEnumerator ActivateCoroutine(Hashtable hashtable)
  206. {
  207. var hasValidSourceCards = card.PermanentOfThisCard().DigivolutionCards.Exists(CardCondition);
  208. if (hasValidSourceCards)
  209. {
  210. CardSource selectedCard = null;
  211. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  212. int maxCount = Math.Min(1, card.PermanentOfThisCard().DigivolutionCards.Count(CardCondition));
  213. selectCardEffect.SetUp(
  214. canTargetCondition: CardCondition,
  215. canTargetCondition_ByPreSelecetedList: null,
  216. canEndSelectCondition: null,
  217. canNoSelect: () => true,
  218. selectCardCoroutine: SelectCardCoroutine,
  219. afterSelectCardCoroutine: null,
  220. message: "Select 1 card to play from digivolution source.",
  221. maxCount: maxCount,
  222. canEndNotMax: false,
  223. isShowOpponent: true,
  224. mode: SelectCardEffect.Mode.Custom,
  225. root: SelectCardEffect.Root.DigivolutionCards,
  226. customRootCardList: card.PermanentOfThisCard().DigivolutionCards,
  227. canLookReverseCard: true,
  228. selectPlayer: card.Owner,
  229. cardEffect: activateClass);
  230. IEnumerator SelectCardCoroutine(CardSource cardSource)
  231. {
  232. selectedCard = cardSource;
  233. yield return null;
  234. }
  235. selectCardEffect.SetUpCustomMessage("Select 1 card to play from digivolution source.", "The opponent is selecting 1 card to play from digivolution source.");
  236. selectCardEffect.SetUpCustomMessage_ShowCard("Selected Card");
  237. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  238. if (selectedCard != null) yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  239. cardSources: new List<CardSource>() { selectedCard },
  240. activateClass: activateClass,
  241. payCost: false,
  242. isTapped: false,
  243. root: SelectCardEffect.Root.DigivolutionCards,
  244. activateETB: true));
  245. }
  246. }
  247. }
  248. #endregion
  249. return cardEffects;
  250. }
  251. }
  252. }