BT22_024.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. // MarineBullmon
  5. namespace DCGO.CardEffects.BT22
  6. {
  7. public class BT22_024 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Decode
  13. if (timing == EffectTiming.WhenRemoveField)
  14. {
  15. bool SourceCondition(CardSource source)
  16. {
  17. return source.IsDigimon
  18. && source.HasLevel && source.IsLevel4
  19. && (source.ContainsTraits("Aqua") || source.ContainsTraits("Sea Animal"));
  20. }
  21. string[] decodeStrings = { "(Lv.4 w/[Aqua]/[Sea Animal] trait)", "Level 4 Digimon card with [Aqua] or [Sea Animal] " };
  22. cardEffects.Add(CardEffectFactory.DecodeSelfEffect(card: card, isInheritedEffect: false, decodeStrings: decodeStrings, sourceCondition: SourceCondition, condition: null));
  23. }
  24. #endregion
  25. #region Hand Main
  26. if (timing == EffectTiming.OnDeclaration)
  27. {
  28. ActivateClass activateClass = new ActivateClass();
  29. activateClass.SetUpICardEffect("Place 1 [Shellmon] from trash under 1 [Sangomon], to digivolve for 3", CanUseCondition, card);
  30. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  31. cardEffects.Add(activateClass);
  32. string EffectDiscription()
  33. {
  34. return "[Hand] [Main] If you have [Yao Qinglan], by placing 1 [Shellmon] from your trash as any of your [Sangomon]'s bottom digivolution card, it digivolves into this card for a digivolution cost of 3, ignoring digivolution requirements.";
  35. }
  36. bool CanUseCondition(Hashtable hashtable)
  37. {
  38. return CardEffectCommons.IsExistOnHand(card)
  39. && CardEffectCommons.IsOwnerTurn(card)
  40. && CardEffectCommons.HasMatchConditionOwnersPermanent(card, IsYaoQinglan)
  41. && CardEffectCommons.HasMatchConditionOwnersPermanent(card, IsSangomon)
  42. && CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, IsShellmon);
  43. }
  44. bool IsYaoQinglan(Permanent permanent)
  45. {
  46. return permanent.IsTamer && permanent.TopCard.EqualsCardName("Yao Qinglan");
  47. }
  48. bool IsSangomon(Permanent permanent)
  49. {
  50. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) &&
  51. permanent.TopCard.EqualsCardName("Sangomon");
  52. }
  53. bool IsShellmon(CardSource source)
  54. {
  55. return source.IsDigimon && source.EqualsCardName("Shellmon");
  56. }
  57. bool IsMarineBullmon(CardSource cardSource)
  58. {
  59. return CardEffectCommons.IsExistOnHand(cardSource) && cardSource == card;
  60. }
  61. IEnumerator ActivateCoroutine(Hashtable hashtable)
  62. {
  63. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, IsYaoQinglan))
  64. {
  65. Permanent sangomon = null;
  66. CardSource shellmon = null;
  67. #region Select Shellmon From Trash
  68. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOwnersCardCountInTrash(card, IsShellmon));
  69. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  70. selectCardEffect.SetUp(
  71. canTargetCondition: IsShellmon,
  72. canTargetCondition_ByPreSelecetedList: null,
  73. canEndSelectCondition: null,
  74. canNoSelect: () => false,
  75. selectCardCoroutine: SelectCardCoroutine,
  76. afterSelectCardCoroutine: null,
  77. message: "Select 1 [Shellmon] to add as digivolution source",
  78. maxCount: maxCount,
  79. canEndNotMax: false,
  80. isShowOpponent: true,
  81. mode: SelectCardEffect.Mode.Custom,
  82. root: SelectCardEffect.Root.Trash,
  83. customRootCardList: null,
  84. canLookReverseCard: true,
  85. selectPlayer: card.Owner,
  86. cardEffect: activateClass);
  87. IEnumerator SelectCardCoroutine(CardSource cardSource)
  88. {
  89. shellmon = cardSource;
  90. yield return null;
  91. }
  92. selectCardEffect.SetUpCustomMessage("Select 1 [Shellmon] to add as digivolution source.", "The opponent is selecting 1 [Shellmon] to add as digivolution source.");
  93. yield return StartCoroutine(selectCardEffect.Activate());
  94. #endregion
  95. if (shellmon != null)
  96. {
  97. #region Select Sangomon Permanent
  98. int maxCount1 = Math.Min(1, CardEffectCommons.MatchConditionOwnersPermanentCount(card, IsSangomon));
  99. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  100. selectPermanentEffect.SetUp(
  101. selectPlayer: card.Owner,
  102. canTargetCondition: IsSangomon,
  103. canTargetCondition_ByPreSelecetedList: null,
  104. canEndSelectCondition: null,
  105. maxCount: maxCount1,
  106. canNoSelect: false,
  107. canEndNotMax: false,
  108. selectPermanentCoroutine: SelectPermanentCoroutine,
  109. afterSelectPermanentCoroutine: null,
  110. mode: SelectPermanentEffect.Mode.Custom,
  111. cardEffect: activateClass);
  112. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  113. {
  114. sangomon = permanent;
  115. yield return null;
  116. }
  117. selectPermanentEffect.SetUpCustomMessage("Select 1 [Sangomon] to add digivolution sources.", "The opponent is selecting 1 [Sangomon] to add digivolution sources.");
  118. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  119. #endregion
  120. if (sangomon != null)
  121. {
  122. yield return ContinuousController.instance.StartCoroutine(sangomon.AddDigivolutionCardsBottom(new List<CardSource>() { shellmon }, activateClass));
  123. if (sangomon.DigivolutionCards.Contains(shellmon))
  124. {
  125. #region Digivolve into MarineBullmon
  126. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  127. sangomon,
  128. IsMarineBullmon,
  129. payCost: true,
  130. reduceCostTuple: null,
  131. fixedCostTuple: null,
  132. ignoreDigivolutionRequirementFixedCost: 3,
  133. isHand: true,
  134. activateClass: activateClass,
  135. successProcess: null,
  136. ignoreSelection:true,
  137. failedProcess:FailureProcess(),
  138. isOptional: false));
  139. #endregion
  140. }
  141. IEnumerator FailureProcess()
  142. {
  143. List<IDiscardHand> discardHands = new List<IDiscardHand>() { new IDiscardHand(card, null) };
  144. yield return ContinuousController.instance.StartCoroutine(new IDiscardHands(discardHands, null).DiscardHands());
  145. }
  146. }
  147. }
  148. }
  149. }
  150. }
  151. #endregion
  152. #region ESS
  153. if (timing == EffectTiming.OnEndAttack)
  154. {
  155. ActivateClass activateClass = new ActivateClass();
  156. activateClass.SetUpICardEffect("Play 1 level 4 or lower [Aqua]/[Sea Animal] digimon from sources", CanUseCondition, card);
  157. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  158. activateClass.SetHashString("BT22_024_OnEndAttack");
  159. activateClass.SetIsInheritedEffect(true);
  160. cardEffects.Add(activateClass);
  161. string EffectDiscription()
  162. {
  163. return "[End of Attack] [Once Per Turn] You may play 1 level 4 or lower Digimon card with [Aqua] or [Sea Animal] in any of its traits from this Digimon's digivolution cards without paying the cost.";
  164. }
  165. bool CanUseCondition(Hashtable hashtable)
  166. {
  167. return CardEffectCommons.CanTriggerOnEndAttack(hashtable, card);
  168. }
  169. bool CanActivateCondition(Hashtable hashtable)
  170. {
  171. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  172. && card.PermanentOfThisCard().DigivolutionCards.Filter(x => CanSelectCardCondition(x)).Count >= 1;
  173. }
  174. bool CanSelectCardCondition(CardSource source)
  175. {
  176. return source.IsDigimon
  177. && source.HasLevel && source.Level <= 4
  178. && (source.ContainsTraits("Sea Animal") || source.ContainsTraits("Aqua"));
  179. }
  180. IEnumerator ActivateCoroutine(Hashtable hashtable)
  181. {
  182. if (card.PermanentOfThisCard().DigivolutionCards.Filter(x => CanSelectCardCondition(x)).Count >= 1)
  183. {
  184. CardSource selectedCard = null;
  185. #region Select Digimon From Digivolution Cards
  186. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  187. selectCardEffect.SetUp(
  188. canTargetCondition: CanSelectCardCondition,
  189. canTargetCondition_ByPreSelecetedList: null,
  190. canEndSelectCondition: null,
  191. canNoSelect: () => true,
  192. selectCardCoroutine: SelectCardCoroutine,
  193. afterSelectCardCoroutine: null,
  194. message: "Select 1 digimon to play",
  195. maxCount: 1,
  196. canEndNotMax: false,
  197. isShowOpponent: true,
  198. mode: SelectCardEffect.Mode.Custom,
  199. root: SelectCardEffect.Root.Custom,
  200. customRootCardList: card.PermanentOfThisCard().DigivolutionCards,
  201. canLookReverseCard: true,
  202. selectPlayer: card.Owner,
  203. cardEffect: activateClass);
  204. IEnumerator SelectCardCoroutine(CardSource cardSource)
  205. {
  206. selectedCard = cardSource;
  207. yield return null;
  208. }
  209. selectCardEffect.SetUpCustomMessage("Select 1 digimon to play.", "The opponent is selecting 1 digimon to play.");
  210. selectCardEffect.SetUpCustomMessage_ShowCard("Selected Card");
  211. yield return StartCoroutine(selectCardEffect.Activate());
  212. #endregion
  213. if (selectedCard != null) yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: new List<CardSource>() { selectedCard }, activateClass: activateClass, payCost: false, isTapped: false, root: SelectCardEffect.Root.DigivolutionCards, activateETB: true));
  214. }
  215. }
  216. }
  217. #endregion
  218. return cardEffects;
  219. }
  220. }
  221. }