EX4_057.cs 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.EX4
  6. {
  7. public class EX4_057 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. if (timing == EffectTiming.None)
  13. {
  14. bool PermanentCondition(Permanent targetPermanent)
  15. {
  16. return targetPermanent.TopCard.CardColors.Contains(CardColor.Green) && targetPermanent.TopCard.CardColors.Count == 2 && targetPermanent.TopCard.HasLevel && targetPermanent.Level == 4;
  17. }
  18. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  19. }
  20. if (timing == EffectTiming.OnAllyAttack)
  21. {
  22. cardEffects.Add(CardEffectFactory.AllianceSelfEffect(isInheritedEffect: false, card: card, condition: null));
  23. }
  24. if (timing == EffectTiming.OnEndAttack)
  25. {
  26. ActivateClass activateClass = new ActivateClass();
  27. activateClass.SetUpICardEffect("Play 1 green level 3 Digimon from trash", CanUseCondition, card);
  28. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  29. cardEffects.Add(activateClass);
  30. string EffectDiscription()
  31. {
  32. return "[End of Attack] You may play 1 green level 3 Digimon card from your trash without paying the cost.";
  33. }
  34. bool CanSelectCardCondition(CardSource cardSource)
  35. {
  36. if (cardSource != null)
  37. {
  38. if (cardSource.IsDigimon)
  39. {
  40. if (cardSource.Owner == card.Owner)
  41. {
  42. if (cardSource.HasCardColor(CardColor.Green))
  43. {
  44. if (cardSource.Level == 3)
  45. {
  46. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  47. {
  48. if (cardSource.HasLevel)
  49. {
  50. return true;
  51. }
  52. }
  53. }
  54. }
  55. }
  56. }
  57. }
  58. return false;
  59. }
  60. bool CanUseCondition(Hashtable hashtable)
  61. {
  62. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  63. }
  64. bool CanActivateCondition(Hashtable hashtable)
  65. {
  66. if (CardEffectCommons.IsExistOnBattleArea(card))
  67. {
  68. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  69. {
  70. return true;
  71. }
  72. }
  73. return false;
  74. }
  75. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  76. {
  77. if (isExistOnField(card))
  78. {
  79. if (card.Owner.GetBattleAreaDigimons().Contains(card.PermanentOfThisCard()))
  80. {
  81. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, (cardSource) => CanSelectCardCondition(cardSource)))
  82. {
  83. int maxCount = Math.Min(1, card.Owner.TrashCards.Count((cardSource) => CanSelectCardCondition(cardSource)));
  84. List<CardSource> selectedCards = new List<CardSource>();
  85. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  86. selectCardEffect.SetUp(
  87. canTargetCondition: CanSelectCardCondition,
  88. canTargetCondition_ByPreSelecetedList: null,
  89. canEndSelectCondition: null,
  90. canNoSelect: () => true,
  91. selectCardCoroutine: SelectCardCoroutine,
  92. afterSelectCardCoroutine: null,
  93. message: "Select 1 card to play.",
  94. maxCount: maxCount,
  95. canEndNotMax: false,
  96. isShowOpponent: true,
  97. mode: SelectCardEffect.Mode.Custom,
  98. root: SelectCardEffect.Root.Trash,
  99. customRootCardList: null,
  100. canLookReverseCard: true,
  101. selectPlayer: card.Owner,
  102. cardEffect: activateClass);
  103. selectCardEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  104. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  105. yield return StartCoroutine(selectCardEffect.Activate());
  106. IEnumerator SelectCardCoroutine(CardSource cardSource)
  107. {
  108. selectedCards.Add(cardSource);
  109. yield return null;
  110. }
  111. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false, root: SelectCardEffect.Root.Trash, activateETB: true));
  112. }
  113. }
  114. }
  115. }
  116. }
  117. if (timing == EffectTiming.OnEndAttack)
  118. {
  119. ActivateClass activateClass = new ActivateClass();
  120. activateClass.SetUpICardEffect("Return 1 card from trash to hand", CanUseCondition, card);
  121. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  122. activateClass.SetIsInheritedEffect(true);
  123. activateClass.SetHashString("Salvage_EX4_057");
  124. cardEffects.Add(activateClass);
  125. string EffectDiscription()
  126. {
  127. return "[End of Attack][Once Per Turn] If you have another suspended Digimon in play, return 1 green Digimon card from your trash to your hand.";
  128. }
  129. bool CanSelectCardCondition(CardSource cardSource)
  130. {
  131. if (cardSource.IsDigimon)
  132. {
  133. if (cardSource.HasCardColor(CardColor.Green))
  134. {
  135. return true;
  136. }
  137. }
  138. return false;
  139. }
  140. bool CanUseCondition(Hashtable hashtable)
  141. {
  142. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  143. }
  144. bool CanActivateCondition(Hashtable hashtable)
  145. {
  146. if (CardEffectCommons.IsExistOnBattleArea(card))
  147. {
  148. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  149. {
  150. return true;
  151. }
  152. }
  153. return false;
  154. }
  155. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  156. {
  157. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  158. {
  159. int maxCount = Math.Min(1, card.Owner.TrashCards.Count(CanSelectCardCondition));
  160. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  161. selectCardEffect.SetUp(
  162. canTargetCondition: CanSelectCardCondition,
  163. canTargetCondition_ByPreSelecetedList: null,
  164. canEndSelectCondition: null,
  165. canNoSelect: () => false,
  166. selectCardCoroutine: null,
  167. afterSelectCardCoroutine: null,
  168. message: "Select 1 card to add to your hand.",
  169. maxCount: maxCount,
  170. canEndNotMax: false,
  171. isShowOpponent: true,
  172. mode: SelectCardEffect.Mode.AddHand,
  173. root: SelectCardEffect.Root.Trash,
  174. customRootCardList: null,
  175. canLookReverseCard: true,
  176. selectPlayer: card.Owner,
  177. cardEffect: activateClass);
  178. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  179. }
  180. }
  181. }
  182. return cardEffects;
  183. }
  184. }
  185. }