EX4_059.cs 9.8 KB

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