EX4_059.cs 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. // Cherubimon
  4. namespace DCGO.CardEffects.EX4
  5. {
  6. public class EX4_059 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region Alt Evo
  12. if (timing == EffectTiming.None)
  13. {
  14. bool PermanentCondition(Permanent targetPermanent)
  15. {
  16. return targetPermanent.TopCard.CardColors.Contains(CardColor.Green)
  17. && targetPermanent.TopCard.CardColors.Count == 2;
  18. }
  19. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(level: 5, permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  20. }
  21. #endregion
  22. #region Alliance
  23. if (timing == EffectTiming.OnAllyAttack)
  24. {
  25. cardEffects.Add(CardEffectFactory.AllianceSelfEffect(isInheritedEffect: false, card: card, condition: null));
  26. }
  27. #endregion
  28. #region When Digivolving
  29. if (timing == EffectTiming.OnEnterFieldAnyone)
  30. {
  31. ActivateClass activateClass = new ActivateClass();
  32. activateClass.SetUpICardEffect("This Digimon and your 1 Digimon gains effects", CanUseCondition, card);
  33. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  34. cardEffects.Add(activateClass);
  35. string EffectDescription()
  36. {
  37. return "[When Digivolving] Until the end of your opponent's turn, this Digimon and 1 of your level 5 or lower Digimon gain \"[On Deletion] You may play this card without paying the cost.\"";
  38. }
  39. bool CanSelectPermanentCondition(Permanent permanent)
  40. {
  41. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  42. && permanent.TopCard.HasLevel
  43. && permanent.Level <= 5;
  44. }
  45. bool CanUseCondition(Hashtable hashtable)
  46. {
  47. return CardEffectCommons.IsExistOnBattleAreaTrigger(card, activateClass)
  48. && CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  49. }
  50. bool CanActivateCondition(Hashtable hashtable)
  51. {
  52. return CardEffectCommons.IsExistOnBattleAreaActivate(card, activateClass);
  53. }
  54. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  55. {
  56. List<Permanent> selectedPermanents = new List<Permanent>() { card.PermanentOfThisCard() };
  57. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  58. {
  59. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  60. selectPermanentEffect.SetUp(
  61. selectPlayer: card.Owner,
  62. canTargetCondition: CanSelectPermanentCondition,
  63. canTargetCondition_ByPreSelecetedList: null,
  64. canEndSelectCondition: null,
  65. maxCount: 1,
  66. canNoSelect: false,
  67. canEndNotMax: false,
  68. selectPermanentCoroutine: SelectPermanentCoroutine,
  69. afterSelectPermanentCoroutine: null,
  70. mode: SelectPermanentEffect.Mode.Custom,
  71. cardEffect: activateClass);
  72. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get effects.", "The opponent is selecting 1 Digimon that will get effects.");
  73. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  74. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  75. {
  76. selectedPermanents.Add(permanent);
  77. yield return null;
  78. }
  79. }
  80. foreach (Permanent selectedPermanent in selectedPermanents)
  81. {
  82. if (selectedPermanent != null)
  83. {
  84. CardSource topCard = null;
  85. ActivateClass activateClass1 = new ActivateClass();
  86. activateClass1.SetUpICardEffect("Play this card from trash", CanUseCondition1, selectedPermanent.TopCard);
  87. activateClass1.SetUpActivateClass(CanActivateCondition1, ActivateCoroutine1, -1, true, EffectDescription1());
  88. activateClass1.SetEffectSourcePermanent(selectedPermanent);
  89. CardEffectCommons.AddEffectToPermanent(targetPermanent: selectedPermanent, effectDuration: EffectDuration.UntilOpponentTurnEnd, card: card, cardEffect: activateClass1, timing: EffectTiming.OnDestroyedAnyone);
  90. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateBuffEffect(selectedPermanent));
  91. string EffectDescription1()
  92. {
  93. return "[On Deletion] You may play this card without paying the cost.";
  94. }
  95. bool CanUseCondition1(Hashtable hashtable1)
  96. {
  97. if (CardEffectCommons.CanTriggerOnPermanentDeleted(hashtable1, (permanent) => permanent == selectedPermanent, activateClass1))
  98. {
  99. topCard = selectedPermanent.TopCard;
  100. if (!topCard.CanNotBeAffected(activateClass))
  101. {
  102. return true;
  103. }
  104. }
  105. return false;
  106. }
  107. bool CanActivateCondition1(Hashtable hashtable1)
  108. {
  109. return CardEffectCommons.CanActivateOnDeletion(topCard, activateClass1)
  110. && CardEffectCommons.CanPlayAsNewPermanent(cardSource: topCard, payCost: false, cardEffect: activateClass1);
  111. }
  112. IEnumerator ActivateCoroutine1(Hashtable _hashtable1)
  113. {
  114. if (topCard != null)
  115. {
  116. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  117. cardSources: new List<CardSource>() { topCard },
  118. activateClass: activateClass1,
  119. payCost: false,
  120. isTapped: false,
  121. root: SelectCardEffect.Root.Trash,
  122. activateETB: true));
  123. }
  124. }
  125. }
  126. }
  127. }
  128. }
  129. #endregion
  130. return cardEffects;
  131. }
  132. }
  133. }