BT25_013.cs 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. // Firamon
  6. namespace DCGO.CardEffects.BT25
  7. {
  8. public class BT25_013 : 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.HasTSTraits;
  19. }
  20. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(level: 3, permanentCondition: PermanentCondition, digivolutionCost: 2, ignoreDigivolutionRequirement: false, card: card, condition: null));
  21. }
  22. #endregion
  23. #region Shared OP/WD
  24. string SharedEffectName = "May trash 1 card to recover 1 red or blue [Iliad] trait Digimon card from trash";
  25. CardEffectFactory.ActivateClassesForSharedEffects
  26. (ref cardEffects, timing, card,
  27. SharedEffectName,
  28. SharedActivateCoroutine,
  29. SharedEffectDescription,
  30. optional: false,
  31. isSkippable: true,
  32. onPlay: true,
  33. whenDigivolving: true);
  34. string SharedEffectDescription(string tag)
  35. {
  36. return $"[{tag}] By trashing 1 card in your hand, you may return 1 red or blue [Iliad] trait Digimon card from your trash to the hand.";
  37. }
  38. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  39. {
  40. if (card.Owner.HandCards.Count >= 1)
  41. {
  42. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  43. selectHandEffect.SetUp(
  44. selectPlayer: card.Owner,
  45. canTargetCondition: _ => true,
  46. canTargetCondition_ByPreSelecetedList: null,
  47. canEndSelectCondition: null,
  48. maxCount: 1,
  49. canNoSelect: true,
  50. canEndNotMax: false,
  51. isShowOpponent: true,
  52. selectCardCoroutine: null,
  53. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  54. mode: SelectHandEffect.Mode.Discard,
  55. cardEffect: activateClass);
  56. yield return StartCoroutine(selectHandEffect.Activate());
  57. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  58. {
  59. if (cardSources.Count > 0)
  60. {
  61. bool CanSelectCardCondition(CardSource cardSource)
  62. {
  63. return cardSource.IsDigimon
  64. && cardSource.HasIliadTraits
  65. && (cardSource.HasCardColor(CardColor.Red, isDigimonOnly: true)
  66. || cardSource.HasCardColor(CardColor.Blue, isDigimonOnly: true));
  67. }
  68. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  69. {
  70. int maxCount = Math.Min(1, card.Owner.TrashCards.Count(CanSelectCardCondition));
  71. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  72. selectCardEffect.SetUp(
  73. canTargetCondition: CanSelectCardCondition,
  74. canTargetCondition_ByPreSelecetedList: null,
  75. canEndSelectCondition: null,
  76. canNoSelect: () => true,
  77. selectCardCoroutine: null,
  78. afterSelectCardCoroutine: null,
  79. message: "Select 1 card to add to your hand.",
  80. maxCount: maxCount,
  81. canEndNotMax: false,
  82. isShowOpponent: true,
  83. mode: SelectCardEffect.Mode.AddHand,
  84. root: SelectCardEffect.Root.Trash,
  85. customRootCardList: null,
  86. canLookReverseCard: true,
  87. selectPlayer: card.Owner,
  88. cardEffect: activateClass);
  89. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  90. }
  91. }
  92. }
  93. }
  94. }
  95. #endregion
  96. #region Your Turn
  97. if (timing == EffectTiming.OnEnterFieldAnyone)
  98. {
  99. ActivateClass activateClass = new ActivateClass();
  100. activateClass.SetUpICardEffect("Digivolve into [Flaremon] in hand for 1 less", CanUseCondition, card);
  101. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  102. activateClass.SetIsSkippable(true);
  103. cardEffects.Add(activateClass);
  104. string EffectDescription() => "[Your Turn] When your Digimon are played or digivolve, if any of them are blue, this Digimon may digivolve into [Flaremon] in the hand with the cost reduced by 1.";
  105. bool CanUseCondition(Hashtable hashtable)
  106. {
  107. return CardEffectCommons.IsExistOnBattleArea(card)
  108. && CardEffectCommons.IsOwnerTurn(card)
  109. && (CardEffectCommons.CanTriggerOnPermanentPlay(hashtable, PermanentCondition)
  110. || CardEffectCommons.CanTriggerWhenPermanentDigivolving(hashtable, PermanentCondition));
  111. }
  112. bool CanActivateCondition(Hashtable hashtable)
  113. {
  114. return CardEffectCommons.IsExistOnBattleArea(card)
  115. && CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition)
  116. && HasValidColor(hashtable);
  117. }
  118. bool HasValidColor(Hashtable hashtable)
  119. {
  120. List<Hashtable> hashtables = CardEffectCommons.GetHashtablesFromHashtable(hashtable);
  121. return hashtables.Map(CardEffectCommons.GetPermanentFromHashtable).Any(HasCorrectColorPermanent);
  122. }
  123. bool HasCorrectColorPermanent(Permanent permanent)
  124. {
  125. return PermanentCondition(permanent)
  126. && permanent.TopCard.CardColors.Contains(CardColor.Blue);
  127. }
  128. bool PermanentCondition(Permanent permanent)
  129. {
  130. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  131. }
  132. bool CanSelectCardCondition(CardSource cardSource)
  133. {
  134. return cardSource.EqualsCardName("Flaremon");
  135. }
  136. IEnumerator ActivateCoroutine(Hashtable hashtable)
  137. {
  138. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  139. targetPermanent: card.PermanentOfThisCard(),
  140. cardCondition: CanSelectCardCondition,
  141. payCost: true,
  142. reduceCostTuple: (reduceCost: 1, reduceCostCardCondition: null),
  143. fixedCostTuple: null,
  144. ignoreDigivolutionRequirementFixedCost: -1,
  145. isHand: true,
  146. activateClass: activateClass,
  147. successProcess: null));
  148. }
  149. }
  150. #endregion
  151. #region Inherit
  152. if (timing == EffectTiming.None)
  153. {
  154. bool Condition()
  155. {
  156. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  157. && CardEffectCommons.IsOwnerTurn(card);
  158. }
  159. cardEffects.Add(CardEffectFactory.ChangeSelfDPStaticEffect(
  160. changeValue: 2000,
  161. isInheritedEffect: true,
  162. card: card,
  163. condition: Condition));
  164. }
  165. #endregion
  166. return cardEffects;
  167. }
  168. }
  169. }