BT16_015.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT16
  6. {
  7. public class BT16_015 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Digivolution Condition
  13. if (timing == EffectTiming.None)
  14. {
  15. bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.TopCard.CardNames.Contains("Phoenixmon");
  18. }
  19. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 2, ignoreDigivolutionRequirement: false, card: card, condition: null));
  20. }
  21. #endregion
  22. # region When Digivolving
  23. if (timing == EffectTiming.OnEnterFieldAnyone)
  24. {
  25. cardEffects.Add(CardEffectFactory.BlitzSelfEffect(isInheritedEffect: false, card: card, condition: null, isWhenDigivolving: true));
  26. }
  27. #endregion
  28. #region Your Turn
  29. if (timing == EffectTiming.AfterEffectsActivate || timing == EffectTiming.OnStartTurn || timing == EffectTiming.OnEnterFieldAnyone || timing == EffectTiming.OnDigivolutionCardDiscarded)
  30. {
  31. ActivateClass activateClass = new ActivateClass();
  32. activateClass.SetUpICardEffect("Add [End of Attack] to all of this Digimon's [On Deletion] effects.", CanUseCondition, card);
  33. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  34. activateClass.SetIsBackgroundProcess(true);
  35. activateClass.SetIsDigimonEffect(true);
  36. cardEffects.Add(activateClass);
  37. string EffectDiscription()
  38. {
  39. return "[Your Turn] While [Phoenixmon] or [X Antibody] is in this Digimon's digivolution cards, attach [End of Attack] to all of this Digimon's [On Deletion] effects.";
  40. }
  41. bool CanUseCondition(Hashtable hashtable)
  42. {
  43. return CardEffectCommons.IsOwnerTurn(card);
  44. }
  45. bool CanActivateCondition(Hashtable hashtable)
  46. {
  47. if (CardEffectCommons.IsExistOnBattleArea(card))
  48. {
  49. if (card.PermanentOfThisCard().DigivolutionCards.Count((cardSource) => cardSource.CardNames.Contains("Phoenixmon") || cardSource.EqualsCardName("X Antibody")) >= 1)
  50. {
  51. return true;
  52. }
  53. }
  54. return false;
  55. }
  56. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  57. {
  58. List<ICardEffect> onDeletionEffects = card.PermanentOfThisCard().EffectList(EffectTiming.OnDestroyedAnyone).Where(x => x.IsOnDeletion && !x.IsSecurityEffect).ToList();
  59. List<Func<EffectTiming, ICardEffect>> onEndAttackEffects = card.PermanentOfThisCard().UntilOwnerTurnEndEffects.Where(x => x(EffectTiming.OnEndAttack).HashString.StartsWith("EndOfAttack")).ToList();
  60. List<ICardEffect> effectsToAdd = new List<ICardEffect>();
  61. foreach (ICardEffect deletionEffect in onDeletionEffects)
  62. {
  63. List<bool> foundMatchingEffect = onEndAttackEffects.Select(x => x(EffectTiming.OnEndAttack).HashString.EndsWith(deletionEffect.EffectSourceCard.CardID)).ToList();
  64. if (foundMatchingEffect.Count == 0)
  65. effectsToAdd.Add(deletionEffect);
  66. }
  67. foreach (ICardEffect endOfAttackEffect in effectsToAdd)
  68. {
  69. ActivateClass activateEndofAttack = new ActivateClass();
  70. activateEndofAttack.SetUpICardEffect(endOfAttackEffect.EffectName, CanUseEndOfAttackCondition, card);
  71. activateEndofAttack.SetUpActivateClass(CanActivateEndOfAttackCondition, ActivateEndOfAttackCoroutine, endOfAttackEffect.MaxCountPerTurn, endOfAttackEffect.IsOptional, endOfAttackEffect.EffectDiscription);
  72. activateEndofAttack.SetIsInheritedEffect(endOfAttackEffect.IsInheritedEffect);
  73. activateEndofAttack.SetHashString($"EndOfAttack_{endOfAttackEffect.EffectSourceCard.CardID}");
  74. activateEndofAttack.SetEffectSourceCard(endOfAttackEffect.EffectSourceCard);
  75. activateEndofAttack.SetEffectSourcePermanent(card.PermanentOfThisCard());
  76. activateEndofAttack.SetIsDigimonEffect(true);
  77. bool CanUseEndOfAttackCondition(Hashtable hashtable1)
  78. {
  79. if (card.PermanentOfThisCard().TopCard != card)
  80. return false;
  81. if (card.PermanentOfThisCard().DigivolutionCards.Count((cardSource) => cardSource.CardNames.Contains("Phoenixmon") || cardSource.EqualsCardName("X Antibody")) == 0)
  82. return false;
  83. return CardEffectCommons.CanTriggerOnEndAttack(hashtable1, card);
  84. }
  85. bool CanActivateEndOfAttackCondition(Hashtable hashtable1)
  86. {
  87. return CardEffectCommons.IsExistOnBattleArea(card);
  88. }
  89. IEnumerator ActivateEndOfAttackCoroutine(Hashtable hashtable)
  90. {
  91. yield return ContinuousController.instance.StartCoroutine(((ActivateICardEffect)endOfAttackEffect).Activate(hashtable));
  92. }
  93. CardEffectCommons.AddEffectToPermanent(
  94. targetPermanent: card.PermanentOfThisCard(),
  95. effectDuration: EffectDuration.UntilOwnerTurnEnd,
  96. card: card,
  97. cardEffect: activateEndofAttack,
  98. timing: EffectTiming.OnEndAttack);
  99. }
  100. yield return null;
  101. }
  102. }
  103. #endregion
  104. #region On Deletion
  105. if (timing == EffectTiming.OnDestroyedAnyone)
  106. {
  107. ActivateClass activateClass = new ActivateClass();
  108. activateClass.SetUpICardEffect("Play 1 digimon, delete 1 digimon", CanUseCondition, card);
  109. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  110. cardEffects.Add(activateClass);
  111. string EffectDiscription()
  112. {
  113. return "[On Deletion] You may play 1 11000 DP or lower red Digimon card with [Avian], [Bird], [Beast], [Animal], or [Sovereign], other than [Sea Animal] in one of its traits from your hand without paying the cost. Delete 1 of your opponent's Digimon with as much or less DP as the Digimon this effect played.";
  114. }
  115. bool CanPlayTargetCondition(CardSource cardSource)
  116. {
  117. if (cardSource.CardKinds.Contains(CardKind.Digimon))
  118. {
  119. if (cardSource.HasDP && cardSource.CardDP <= 11000)
  120. {
  121. if (cardSource.HasCardColor(CardColor.Red))
  122. {
  123. if (cardSource.HasAvianBeastAnimalTraits)
  124. {
  125. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource, false, activateClass))
  126. return true;
  127. }
  128. }
  129. }
  130. }
  131. return false;
  132. }
  133. bool CanUseCondition(Hashtable hashtable)
  134. {
  135. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  136. }
  137. bool CanActivateCondition(Hashtable hashtable)
  138. {
  139. return CardEffectCommons.CanActivateOnDeletion(card, activateClass);
  140. }
  141. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  142. {
  143. CardSource cardToPlay = null;
  144. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  145. selectHandEffect.SetUp(
  146. selectPlayer: card.Owner,
  147. canTargetCondition: CanPlayTargetCondition,
  148. canTargetCondition_ByPreSelecetedList: null,
  149. canEndSelectCondition: null,
  150. maxCount: 1,
  151. canNoSelect: true,
  152. canEndNotMax: false,
  153. isShowOpponent: false,
  154. selectCardCoroutine: SelectCardCoroutine,
  155. afterSelectCardCoroutine: null,
  156. mode: SelectHandEffect.Mode.Custom,
  157. cardEffect: activateClass);
  158. yield return ContinuousController.instance.StartCoroutine(selectHandEffect.Activate());
  159. IEnumerator SelectCardCoroutine(CardSource cardSource)
  160. {
  161. cardToPlay = cardSource;
  162. yield return null;
  163. }
  164. if (cardToPlay != null)
  165. {
  166. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  167. cardSources: new List<CardSource> { cardToPlay },
  168. activateClass: activateClass,
  169. payCost: false,
  170. isTapped: false,
  171. root: SelectCardEffect.Root.Hand,
  172. activateETB: true));
  173. if (CardEffectCommons.HasMatchConditionPermanent(CanDestroyTargetCondition))
  174. {
  175. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  176. selectPermanentEffect.SetUp(
  177. selectPlayer: card.Owner,
  178. canTargetCondition: CanDestroyTargetCondition,
  179. canTargetCondition_ByPreSelecetedList: null,
  180. canEndSelectCondition: null,
  181. maxCount: 1,
  182. canNoSelect: false,
  183. canEndNotMax: false,
  184. selectPermanentCoroutine: null,
  185. afterSelectPermanentCoroutine: null,
  186. mode: SelectPermanentEffect.Mode.Destroy,
  187. cardEffect: activateClass);
  188. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  189. }
  190. bool CanDestroyTargetCondition(Permanent permanent)
  191. {
  192. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  193. {
  194. if (permanent.TopCard.HasDP && permanent.DP <= cardToPlay.PermanentOfThisCard().DP)
  195. {
  196. return true;
  197. }
  198. }
  199. return false;
  200. }
  201. }
  202. }
  203. }
  204. #endregion
  205. return cardEffects;
  206. }
  207. }
  208. }