BT24_027.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. // Lanamon
  6. namespace DCGO.CardEffects.BT24
  7. {
  8. public class BT24_027 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Digivolution Condition
  14. if (timing == EffectTiming.None)
  15. {
  16. bool PermanentCondition(Permanent targetPermanent)
  17. {
  18. return targetPermanent.TopCard.EqualsCardName("Calmaramon");
  19. }
  20. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 0, ignoreDigivolutionRequirement: false, card: card, condition: null));
  21. }
  22. if (timing == EffectTiming.None)
  23. {
  24. bool PermanentCondition(Permanent targetPermanent)
  25. {
  26. return (targetPermanent.TopCard.IsLevel3 && targetPermanent.TopCard.HasTSTraits);
  27. }
  28. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 2, ignoreDigivolutionRequirement: false, card: card, condition: null));
  29. }
  30. #endregion
  31. #region Decode <[Calmaramon]>
  32. if (timing == EffectTiming.WhenRemoveField)
  33. {
  34. bool SourceCondition(CardSource source)
  35. {
  36. return source.EqualsCardName("Calmaramon");
  37. }
  38. string[] decodeStrings = { "(Calmaramon)", "Calmaramon" };
  39. cardEffects.Add(CardEffectFactory.DecodeSelfEffect(card: card, isInheritedEffect: false, decodeStrings: decodeStrings, sourceCondition: SourceCondition, condition: null));
  40. }
  41. #endregion
  42. #region OP/WD Shared
  43. string EffectDescriptionShared(string tag)
  44. {
  45. return $"[{tag}] By placing 1 level 4 or lower blue [TS] trait Digimon card from your hand as this Digimon's bottom digivolution card, 1 of your blue [TS] trait Digimon can't be deleted in battle until your opponent's turn ends.";
  46. }
  47. bool CanSelectCardCondition(CardSource source)
  48. {
  49. return source.IsDigimon
  50. && source.EqualsTraits("TS")
  51. && source.HasLevel && source.Level <= 4
  52. && source.HasCardColor(CardColor.Blue);
  53. }
  54. bool CanSelectPermanentCondition(Permanent permanent)
  55. {
  56. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  57. && permanent.TopCard.EqualsTraits("TS")
  58. && permanent.TopCard.CardColors.Contains(CardColor.Blue);
  59. }
  60. bool CanActivateConditionShared(Hashtable hashtable)
  61. {
  62. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  63. && CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition);
  64. }
  65. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  66. {
  67. if (CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition))
  68. {
  69. #region Select Hand Card
  70. CardSource selectedCard = null;
  71. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOwnersCardCountInHand(card, CanSelectCardCondition));
  72. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  73. selectHandEffect.SetUp(
  74. selectPlayer: card.Owner,
  75. canTargetCondition: CanSelectCardCondition,
  76. canTargetCondition_ByPreSelecetedList: null,
  77. canEndSelectCondition: null,
  78. maxCount: maxCount,
  79. canNoSelect: true,
  80. canEndNotMax: false,
  81. isShowOpponent: true,
  82. selectCardCoroutine: SelectCardCoroutine,
  83. afterSelectCardCoroutine: null,
  84. mode: SelectHandEffect.Mode.Custom,
  85. cardEffect: activateClass);
  86. IEnumerator SelectCardCoroutine(CardSource cardSource)
  87. {
  88. selectedCard = cardSource;
  89. yield return null;
  90. }
  91. selectHandEffect.SetUpCustomMessage("Select 1 card to add as digivolution card,", "The opponent is selecting 1 card to add as digivolution card,");
  92. selectHandEffect.SetUpCustomMessage_ShowCard("Selected Card");
  93. yield return StartCoroutine(selectHandEffect.Activate());
  94. #endregion
  95. #region Select Digimon to gain effect
  96. if (selectedCard != null)
  97. {
  98. Permanent selectedPermanent = card.PermanentOfThisCard();
  99. if (selectedPermanent != null && selectedCard != null)
  100. {
  101. yield return ContinuousController.instance.StartCoroutine(selectedPermanent.AddDigivolutionCardsBottom(new List<CardSource>() { selectedCard }, activateClass));
  102. var selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  103. selectPermanentEffect.SetUp(
  104. selectPlayer: card.Owner,
  105. canTargetCondition: CanSelectPermanentCondition,
  106. canTargetCondition_ByPreSelecetedList: null,
  107. canEndSelectCondition: null,
  108. maxCount: 1,
  109. canNoSelect: false,
  110. canEndNotMax: false,
  111. selectPermanentCoroutine: SelectPermanentCoroutine,
  112. afterSelectPermanentCoroutine: null,
  113. mode: SelectPermanentEffect.Mode.Custom,
  114. cardEffect: activateClass);
  115. selectPermanentEffect.SetUpCustomMessage(
  116. "Select 1 Digimon that will get effects.",
  117. "The opponent is selecting 1 Digimon that will get effects.");
  118. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  119. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  120. {
  121. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainCanNotBeDeletedByBattle(
  122. targetPermanent: permanent,
  123. canNotBeDestroyedByBattleCondition: CanNotBeDestroyedByBattleCondition,
  124. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  125. activateClass: activateClass,
  126. effectName: "Can't be deleted in battle"));
  127. bool CanNotBeDestroyedByBattleCondition(Permanent permanent1, Permanent attackingPermanent, Permanent defendingPermanent, CardSource defendingCard)
  128. {
  129. return permanent1 == attackingPermanent || permanent1 == defendingPermanent;
  130. }
  131. }
  132. }
  133. }
  134. #endregion
  135. }
  136. }
  137. #endregion
  138. #region On Play
  139. if (timing == EffectTiming.OnEnterFieldAnyone)
  140. {
  141. ActivateClass activateClass = new ActivateClass();
  142. activateClass.SetUpICardEffect("By tucking, 1 digimon can't be deleted by battle", CanUseCondition, card);
  143. activateClass.SetUpActivateClass(CanActivateConditionShared, hash => SharedActivateCoroutine(hash, activateClass), -1, true, EffectDescriptionShared("On Play"));
  144. cardEffects.Add(activateClass);
  145. bool CanUseCondition(Hashtable hashtable)
  146. {
  147. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  148. && CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  149. }
  150. }
  151. #endregion
  152. #region When Digivolving
  153. if (timing == EffectTiming.OnEnterFieldAnyone)
  154. {
  155. ActivateClass activateClass = new ActivateClass();
  156. activateClass.SetUpICardEffect("By tucking, 1 digimon can't be deleted by battle", CanUseCondition, card);
  157. activateClass.SetUpActivateClass(CanActivateConditionShared, hash => SharedActivateCoroutine(hash, activateClass), -1, true, EffectDescriptionShared("When Digivolving"));
  158. cardEffects.Add(activateClass);
  159. bool CanUseCondition(Hashtable hashtable)
  160. {
  161. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  162. && CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  163. }
  164. }
  165. #endregion
  166. #region Inherited
  167. if (timing == EffectTiming.OnAllyAttack)
  168. {
  169. ActivateClass activateClass = new ActivateClass();
  170. activateClass.SetUpICardEffect("Draw 1 card", CanUseCondition, card);
  171. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDescription());
  172. activateClass.SetHashString("Draw_BT24_027");
  173. activateClass.SetIsInheritedEffect(true);
  174. cardEffects.Add(activateClass);
  175. string EffectDescription()
  176. {
  177. return "[When Attacking][Once Per Turn] If you have 7 or fewer cards in your hand, <Draw 1>.";
  178. }
  179. bool CanUseCondition(Hashtable hashtable)
  180. {
  181. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  182. }
  183. bool CanActivateCondition(Hashtable hashtable)
  184. {
  185. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  186. && card.Owner.HandCards.Count <= 7;
  187. }
  188. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  189. {
  190. yield return ContinuousController.instance.StartCoroutine(new DrawClass(card.Owner, 1, activateClass).Draw());
  191. }
  192. }
  193. #endregion
  194. return cardEffects;
  195. }
  196. }
  197. }