BT25_013.cs 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  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. bool CanSelectCardCondition(CardSource cardSource)
  60. {
  61. return cardSource.IsDigimon
  62. && cardSource.HasIliadTraits
  63. && (cardSource.HasCardColor(CardColor.Red, isDigimonOnly: true)
  64. || cardSource.HasCardColor(CardColor.Blue, isDigimonOnly: true));
  65. }
  66. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  67. {
  68. int maxCount = Math.Min(1, card.Owner.TrashCards.Count(CanSelectCardCondition));
  69. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  70. selectCardEffect.SetUp(
  71. canTargetCondition: CanSelectCardCondition,
  72. canTargetCondition_ByPreSelecetedList: null,
  73. canEndSelectCondition: null,
  74. canNoSelect: () => true,
  75. selectCardCoroutine: null,
  76. afterSelectCardCoroutine: null,
  77. message: "Select 1 card to add to your hand.",
  78. maxCount: maxCount,
  79. canEndNotMax: false,
  80. isShowOpponent: true,
  81. mode: SelectCardEffect.Mode.AddHand,
  82. root: SelectCardEffect.Root.Trash,
  83. customRootCardList: null,
  84. canLookReverseCard: true,
  85. selectPlayer: card.Owner,
  86. cardEffect: activateClass);
  87. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  88. }
  89. }
  90. }
  91. }
  92. #endregion
  93. #region Your Turn
  94. if (timing == EffectTiming.OnEnterFieldAnyone)
  95. {
  96. ActivateClass activateClass = new ActivateClass();
  97. activateClass.SetUpICardEffect("Digivolve into [Flaremon] in hand for 1 less", CanUseCondition, card);
  98. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  99. activateClass.SetIsSkippable(true);
  100. cardEffects.Add(activateClass);
  101. 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.";
  102. bool CanUseCondition(Hashtable hashtable)
  103. {
  104. return CardEffectCommons.IsExistOnBattleArea(card)
  105. && CardEffectCommons.IsOwnerTurn(card)
  106. && (CardEffectCommons.CanTriggerOnPermanentPlay(hashtable, PermanentCondition)
  107. || CardEffectCommons.CanTriggerWhenPermanentDigivolving(hashtable, PermanentCondition));
  108. }
  109. bool CanActivateCondition(Hashtable hashtable)
  110. {
  111. return CardEffectCommons.IsExistOnBattleArea(card)
  112. && CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition)
  113. && HasValidColor(hashtable);
  114. }
  115. bool HasValidColor(Hashtable hashtable)
  116. {
  117. List<Hashtable> hashtables = CardEffectCommons.GetHashtablesFromHashtable(hashtable);
  118. return hashtables.Map(CardEffectCommons.GetPermanentFromHashtable).Any(HasCorrectColorPermanent);
  119. }
  120. bool HasCorrectColorPermanent(Permanent permanent)
  121. {
  122. return PermanentCondition(permanent)
  123. && permanent.TopCard.CardColors.Contains(CardColor.Blue);
  124. }
  125. bool PermanentCondition(Permanent permanent)
  126. {
  127. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  128. }
  129. bool CanSelectCardCondition(CardSource cardSource)
  130. {
  131. return cardSource.EqualsCardName("Flaremon");
  132. }
  133. IEnumerator ActivateCoroutine(Hashtable hashtable)
  134. {
  135. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  136. targetPermanent: card.PermanentOfThisCard(),
  137. cardCondition: CanSelectCardCondition,
  138. payCost: true,
  139. reduceCostTuple: (reduceCost: 1, reduceCostCardCondition: null),
  140. fixedCostTuple: null,
  141. ignoreDigivolutionRequirementFixedCost: -1,
  142. isHand: true,
  143. activateClass: activateClass,
  144. successProcess: null));
  145. }
  146. }
  147. #endregion
  148. #region Inherit
  149. if (timing == EffectTiming.None)
  150. {
  151. bool Condition()
  152. {
  153. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  154. && CardEffectCommons.IsOwnerTurn(card);
  155. }
  156. cardEffects.Add(CardEffectFactory.ChangeSelfDPStaticEffect(
  157. changeValue: 2000,
  158. isInheritedEffect: true,
  159. card: card,
  160. condition: Condition));
  161. }
  162. #endregion
  163. return cardEffects;
  164. }
  165. }
  166. }