EX10_025.cs 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. //Sunarizamon
  6. namespace DCGO.CardEffects.EX10
  7. {
  8. public class EX10_025 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region On Play
  14. if (timing == EffectTiming.OnEnterFieldAnyone)
  15. {
  16. ActivateClass activateClass = new ActivateClass();
  17. activateClass.SetUpICardEffect("Place 2 as bottom digivolution sources", CanUseCondition, card);
  18. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  19. cardEffects.Add(activateClass);
  20. string EffectDiscription()
  21. {
  22. return "[On Play] You may place 2 cards with the [Mineral] or [Rock] trait from your trash as 1 of your [Mineral] or [Rock] trait Digimon's bottom digivolution cards.";
  23. }
  24. bool CanUseCondition(Hashtable hashtable)
  25. {
  26. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  27. && CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  28. }
  29. bool CanActivateCondition(Hashtable hashtable)
  30. {
  31. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  32. && CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, IsRockOrMineral)
  33. && CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition);
  34. }
  35. bool IsRockOrMineral(CardSource source)
  36. {
  37. return source.EqualsTraits("Rock") || source.EqualsTraits("Mineral");
  38. }
  39. bool CanSelectPermanentCondition(Permanent permanent)
  40. {
  41. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  42. && IsRockOrMineral(permanent.TopCard);
  43. }
  44. IEnumerator ActivateCoroutine(Hashtable hashtable)
  45. {
  46. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, IsRockOrMineral))
  47. {
  48. List<CardSource> selectedCards = new List<CardSource>();
  49. int maxCount = Math.Min(2, CardEffectCommons.MatchConditionOwnersCardCountInTrash(card, IsRockOrMineral));
  50. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  51. selectCardEffect.SetUp(
  52. canTargetCondition: IsRockOrMineral,
  53. canTargetCondition_ByPreSelecetedList: null,
  54. canEndSelectCondition: null,
  55. canNoSelect: () => true,
  56. selectCardCoroutine: SelectCardCoroutine,
  57. afterSelectCardCoroutine: null,
  58. message: "Select cards to place as the bottom digivolution sources",
  59. maxCount: maxCount,
  60. canEndNotMax: false,
  61. isShowOpponent: false,
  62. mode: SelectCardEffect.Mode.Custom,
  63. root: SelectCardEffect.Root.Trash,
  64. customRootCardList: null,
  65. canLookReverseCard: true,
  66. selectPlayer: card.Owner,
  67. cardEffect: activateClass);
  68. IEnumerator SelectCardCoroutine(CardSource cardSource)
  69. {
  70. selectedCards.Add(cardSource);
  71. yield return null;
  72. }
  73. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  74. if (selectedCards.Any())
  75. {
  76. Permanent selectedPermanent = null;
  77. int maxCount1 = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  78. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  79. selectPermanentEffect.SetUp(
  80. selectPlayer: card.Owner,
  81. canTargetCondition: CanSelectPermanentCondition,
  82. canTargetCondition_ByPreSelecetedList: null,
  83. canEndSelectCondition: null,
  84. maxCount: maxCount1,
  85. canNoSelect: true,
  86. canEndNotMax: false,
  87. selectPermanentCoroutine: SelectPermanentCoroutine,
  88. afterSelectPermanentCoroutine: null,
  89. mode: SelectPermanentEffect.Mode.Custom,
  90. cardEffect: activateClass);
  91. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  92. {
  93. selectedPermanent = permanent;
  94. yield return null;
  95. }
  96. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will gain digivolution cards.", "The opponent is selecting 1 Digimon that will gain digivolution cards.");
  97. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  98. if (selectedPermanent != null)
  99. {
  100. yield return ContinuousController.instance.StartCoroutine(selectedPermanent.AddDigivolutionCardsBottom(selectedCards, activateClass));
  101. }
  102. }
  103. }
  104. }
  105. }
  106. #endregion
  107. #region ESS
  108. if (timing == EffectTiming.OnDigivolutionCardDiscarded)
  109. {
  110. ActivateClass activateClass = new ActivateClass();
  111. activateClass.SetUpICardEffect("Delete 4 cost or less Digimon", CanUseCondition, card);
  112. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  113. activateClass.SetIsInheritedEffect(true);
  114. cardEffects.Add(activateClass);
  115. string EffectDiscription()
  116. {
  117. return "When effects trash this card from a [Mineral] or [Rock] trait Digimon's digivolution cards, delete 1 of your opponent's Digimon with a play cost of 4 or less.";
  118. }
  119. bool CanSelectOpponentsDigimon(Permanent permanent)
  120. {
  121. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  122. return permanent.TopCard.HasPlayCost && permanent.TopCard.GetCostItself <= 4;
  123. return false;
  124. }
  125. bool CanUseCondition(Hashtable hashtable)
  126. {
  127. Permanent trashedPermanent = CardEffectCommons.GetPermanentFromHashtable(hashtable);
  128. return (trashedPermanent.TopCard.EqualsTraits("Mineral") || trashedPermanent.TopCard.EqualsTraits("Rock")) &&
  129. CardEffectCommons.CanTriggerOnTrashSelfDigivolutionCard(hashtable, cardEffect => cardEffect != null, card);
  130. }
  131. bool CanActivateCondition(Hashtable hashtable)
  132. {
  133. if (CardEffectCommons.IsExistOnTrash(card))
  134. {
  135. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, CanSelectOpponentsDigimon))
  136. {
  137. return true;
  138. }
  139. }
  140. return false;
  141. }
  142. IEnumerator ActivateCoroutine(Hashtable hashtable)
  143. {
  144. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  145. selectPermanentEffect.SetUp(
  146. selectPlayer: card.Owner,
  147. canTargetCondition: CanSelectOpponentsDigimon,
  148. canTargetCondition_ByPreSelecetedList: null,
  149. canEndSelectCondition: null,
  150. maxCount: 1,
  151. canNoSelect: false,
  152. canEndNotMax: false,
  153. selectPermanentCoroutine: null,
  154. afterSelectPermanentCoroutine: null,
  155. mode: SelectPermanentEffect.Mode.Destroy,
  156. cardEffect: activateClass);
  157. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  158. }
  159. }
  160. #endregion
  161. return cardEffects;
  162. }
  163. }
  164. }