EX8_051.cs 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. namespace DCGO.CardEffects.EX8
  4. {
  5. public class EX8_051 : CEntity_Effect
  6. {
  7. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  8. {
  9. List<ICardEffect> cardEffects = new List<ICardEffect>();
  10. #region Collision
  11. if (timing == EffectTiming.OnCounterTiming)
  12. {
  13. cardEffects.Add(CardEffectFactory.CollisionSelfStaticEffect(false, card, null));
  14. }
  15. #endregion
  16. #region Piercing
  17. if (timing == EffectTiming.OnDetermineDoSecurityCheck)
  18. {
  19. cardEffects.Add(CardEffectFactory.PierceSelfEffect(isInheritedEffect: false, card: card, condition: null));
  20. }
  21. #endregion
  22. #region Fragment
  23. if (timing == EffectTiming.WhenPermanentWouldBeDeleted)
  24. {
  25. string EffectDiscription()
  26. {
  27. return "<Fragment <3>> (When this Digimon would be deleted, by trashing any 3 of its digivolution cards, it isn’t deleted.)";
  28. }
  29. cardEffects.Add(CardEffectFactory.FragmentSelfEffect(isInheritedEffect: false, card: card, condition: null, trashValue: 3, effectName: "Fragment <3>", effectDiscription: EffectDiscription()));
  30. }
  31. #endregion
  32. #region Trash Source - ESS
  33. if (timing == EffectTiming.OnDigivolutionCardDiscarded)
  34. {
  35. ActivateClass activateClass = new ActivateClass();
  36. activateClass.SetUpICardEffect("De-Digivolve 1", CanUseCondition, card);
  37. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  38. activateClass.SetIsInheritedEffect(true);
  39. cardEffects.Add(activateClass);
  40. string EffectDiscription()
  41. {
  42. return "When effects trash this card from digivolution cards of a [Mineral] or [Rock] trait Digimon, <De-Digivolve 1> 1 of your opponent's Digimon.";
  43. }
  44. bool CanSelectOpponentsDigimon(Permanent permanent)
  45. {
  46. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  47. }
  48. bool CanUseCondition(Hashtable hashtable)
  49. {
  50. Permanent trashedPermanent = CardEffectCommons.GetPermanentFromHashtable(hashtable);
  51. return (trashedPermanent.TopCard.ContainsTraits("Mineral") || trashedPermanent.TopCard.ContainsTraits("Rock")) &&
  52. CardEffectCommons.CanTriggerOnTrashSelfDigivolutionCard(hashtable, cardEffect => cardEffect != null, card);
  53. }
  54. bool CanActivateCondition(Hashtable hashtable)
  55. {
  56. if (CardEffectCommons.IsExistOnTrash(card))
  57. {
  58. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, CanSelectOpponentsDigimon))
  59. {
  60. return true;
  61. }
  62. }
  63. return false;
  64. }
  65. IEnumerator ActivateCoroutine(Hashtable hashtable)
  66. {
  67. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  68. selectPermanentEffect.SetUp(
  69. selectPlayer: card.Owner,
  70. canTargetCondition: CanSelectOpponentsDigimon,
  71. canTargetCondition_ByPreSelecetedList: null,
  72. canEndSelectCondition: null,
  73. maxCount: 1,
  74. canNoSelect: false,
  75. canEndNotMax: false,
  76. selectPermanentCoroutine: SelectPermanentCoroutine,
  77. afterSelectPermanentCoroutine: null,
  78. mode: SelectPermanentEffect.Mode.Custom,
  79. cardEffect: activateClass);
  80. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to De-Digivolve.", "The opponent is selecting 1 Digimon to De-Digivolve.");
  81. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  82. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  83. {
  84. yield return ContinuousController.instance.StartCoroutine(new IDegeneration(permanent, 1, activateClass).Degeneration());
  85. }
  86. }
  87. }
  88. #endregion
  89. return cardEffects;
  90. }
  91. }
  92. }