EX8_055.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace DCGO.CardEffects.EX8
  5. {
  6. public class EX8_055 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region Fragment
  12. if (timing == EffectTiming.WhenPermanentWouldBeDeleted)
  13. {
  14. string EffectDiscription()
  15. {
  16. return "<Fragment <3>> (When this Digimon would be deleted, by trashing any 3 of its digivolution cards, it isn’t deleted.)";
  17. }
  18. cardEffects.Add(CardEffectFactory.FragmentSelfEffect(isInheritedEffect: false, card: card, condition: null, trashValue: 3, effectName: "Fragment <3>", effectDiscription: EffectDiscription()));
  19. }
  20. #endregion
  21. #region When Digivolving
  22. if (timing == EffectTiming.OnEnterFieldAnyone)
  23. {
  24. ActivateClass activateClass = new ActivateClass();
  25. activateClass.SetUpICardEffect("By trashing 3 sources, Unsuspend and gain Security A. +1", CanUseCondition, card);
  26. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  27. cardEffects.Add(activateClass);
  28. string EffectDiscription()
  29. {
  30. return "[When Digivolving] By trashing any 3 [Mineral] or [Rock] trait cards from any of your Digimon's digivolution cards, this Digimon unsuspends, and it gains <Security A. +1> for the turn.";
  31. }
  32. bool HasProperTrait(CardSource source)
  33. {
  34. return !source.CanNotTrashFromDigivolutionCards(activateClass) &&
  35. (source.EqualsTraits("Mineral") || source.EqualsTraits("Rock"));
  36. }
  37. bool HasProperAmountOfSources()
  38. {
  39. int totalSourceCount = 0;
  40. foreach (Permanent permanent in card.Owner.GetBattleAreaDigimons())
  41. {
  42. totalSourceCount += permanent.DigivolutionCards.Count(HasProperTrait);
  43. }
  44. return totalSourceCount >= 3;
  45. }
  46. bool CanSelectPermanentCondition(Permanent permanent)
  47. {
  48. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  49. return permanent.DigivolutionCards.Count(HasProperTrait) >= 1;
  50. return false;
  51. }
  52. bool CanUseCondition(Hashtable hashtable)
  53. {
  54. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  55. }
  56. bool CanActivateCondition(Hashtable hashtable)
  57. {
  58. if (CardEffectCommons.IsExistOnBattleArea(card))
  59. return HasProperAmountOfSources();
  60. return false;
  61. }
  62. IEnumerator ActivateCoroutine(Hashtable hashtable)
  63. {
  64. int trashedCount = 0;
  65. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.SelectTrashDigivolutionCards(
  66. permanentCondition: CanSelectPermanentCondition,
  67. cardCondition: HasProperTrait,
  68. maxCount: 3,
  69. canNoTrash: false,
  70. isFromOnly1Permanent: false,
  71. activateClass: activateClass,
  72. afterSelectionCoroutine: AfterTrashedCards
  73. ));
  74. IEnumerator AfterTrashedCards(Permanent permanent, List<CardSource> cards)
  75. {
  76. trashedCount = cards.Count;
  77. yield return null;
  78. }
  79. if (trashedCount == 3)
  80. {
  81. yield return ContinuousController.instance.StartCoroutine(new IUnsuspendPermanents(new List<Permanent>() { card.PermanentOfThisCard() }, activateClass).Unsuspend());
  82. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonSAttack(targetPermanent: card.PermanentOfThisCard(), changeValue: 1, effectDuration: EffectDuration.UntilEachTurnEnd, activateClass: activateClass));
  83. }
  84. }
  85. }
  86. #endregion
  87. #region When Attacking
  88. if (timing == EffectTiming.OnAllyAttack)
  89. {
  90. ActivateClass activateClass = new ActivateClass();
  91. activateClass.SetUpICardEffect("By trashing 3 sources, Unsuspend and gain Security A. +1", CanUseCondition, card);
  92. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  93. cardEffects.Add(activateClass);
  94. string EffectDiscription()
  95. {
  96. return "[When Attacking] By trashing any 3 [Mineral] or [Rock] trait cards from any of your Digimon's digivolution cards, this Digimon unsuspends, and it gains <Security A. +1> for the turn.";
  97. }
  98. bool HasProperTrait(CardSource source)
  99. {
  100. return !source.CanNotTrashFromDigivolutionCards(activateClass) &&
  101. (source.EqualsTraits("Mineral") || source.EqualsTraits("Rock"));
  102. }
  103. bool HasProperAmountOfSources()
  104. {
  105. int totalSourceCount = 0;
  106. foreach (Permanent permanent in card.Owner.GetBattleAreaDigimons())
  107. {
  108. totalSourceCount += permanent.DigivolutionCards.Count(HasProperTrait);
  109. }
  110. return totalSourceCount >= 3;
  111. }
  112. bool CanSelectPermanentCondition(Permanent permanent)
  113. {
  114. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  115. return permanent.DigivolutionCards.Count(HasProperTrait) >= 1;
  116. return false;
  117. }
  118. bool CanUseCondition(Hashtable hashtable)
  119. {
  120. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  121. }
  122. bool CanActivateCondition(Hashtable hashtable)
  123. {
  124. if (CardEffectCommons.IsExistOnBattleArea(card))
  125. return HasProperAmountOfSources();
  126. return false;
  127. }
  128. IEnumerator ActivateCoroutine(Hashtable hashtable)
  129. {
  130. int trashedCount = 0;
  131. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.SelectTrashDigivolutionCards(
  132. permanentCondition: CanSelectPermanentCondition,
  133. cardCondition: HasProperTrait,
  134. maxCount: 3,
  135. canNoTrash: false,
  136. isFromOnly1Permanent: false,
  137. activateClass: activateClass,
  138. afterSelectionCoroutine: AfterTrashedCards
  139. ));
  140. IEnumerator AfterTrashedCards(Permanent permanent, List<CardSource> cards)
  141. {
  142. trashedCount = cards.Count;
  143. yield return null;
  144. }
  145. if (trashedCount == 3)
  146. {
  147. yield return ContinuousController.instance.StartCoroutine(new IUnsuspendPermanents(new List<Permanent>() { card.PermanentOfThisCard() }, activateClass).Unsuspend());
  148. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonSAttack(targetPermanent: card.PermanentOfThisCard(), changeValue: 1, effectDuration: EffectDuration.UntilEachTurnEnd, activateClass: activateClass));
  149. }
  150. }
  151. }
  152. #endregion
  153. #region End of your Turn
  154. if (timing == EffectTiming.OnEndTurn)
  155. {
  156. ActivateClass activateClass = new ActivateClass();
  157. activateClass.SetUpICardEffect("Place 3 cards from trash as bottom sources", CanUseCondition, card);
  158. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  159. activateClass.SetHashString("EOT_EX8_055");
  160. cardEffects.Add(activateClass);
  161. string EffectDiscription()
  162. {
  163. return "[End of Your Turn] [Once Per Turn] You may place up to 3 [Mineral] or [Rock] cards from your trash as this Digimon's bottom digivolution cards.";
  164. }
  165. bool HasProperTrait(CardSource source)
  166. {
  167. return source.EqualsTraits("Mineral") || source.EqualsTraits("Rock");
  168. }
  169. bool CanUseCondition(Hashtable hashtable)
  170. {
  171. return CardEffectCommons.IsOwnerTurn(card) &&
  172. CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  173. CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, HasProperTrait);
  174. }
  175. bool CanActivateCondition(Hashtable hashtable)
  176. {
  177. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  178. CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, HasProperTrait);
  179. }
  180. IEnumerator ActivateCoroutine(Hashtable hashtable)
  181. {
  182. List<CardSource> selectedCards = new List<CardSource>();
  183. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  184. selectCardEffect.SetUp(
  185. canTargetCondition: HasProperTrait,
  186. canTargetCondition_ByPreSelecetedList: null,
  187. canEndSelectCondition: CanEndSelectCondition,
  188. canNoSelect: () => true,
  189. selectCardCoroutine: SelectCardCoroutine,
  190. afterSelectCardCoroutine: null,
  191. message: "Select [Mineral] or [Rock] to place on bottom of digivolution cards\n(cards will be placed so that cards with lower numbers are on top).",
  192. maxCount: 3,
  193. canEndNotMax: true,
  194. isShowOpponent: true,
  195. mode: SelectCardEffect.Mode.Custom,
  196. root: SelectCardEffect.Root.Trash,
  197. customRootCardList: null,
  198. canLookReverseCard: true,
  199. selectPlayer: card.Owner,
  200. cardEffect: activateClass);
  201. selectCardEffect.SetUpCustomMessage_ShowCard("Digivolution Card");
  202. selectCardEffect.SetUpCustomMessage("Select [Mineral] or [Rock] to place on bottom of digivolution cards.", "The opponent is selecting [Mineral] or [Rock] to place on bottom of digivolution cards.");
  203. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  204. bool CanEndSelectCondition(List<CardSource> cardSources)
  205. {
  206. if (CardEffectCommons.HasNoElement(cardSources))
  207. {
  208. return false;
  209. }
  210. return true;
  211. }
  212. IEnumerator SelectCardCoroutine(CardSource cardSource)
  213. {
  214. selectedCards.Add(cardSource);
  215. yield return null;
  216. }
  217. if (selectedCards.Count >= 1)
  218. {
  219. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsBottom(selectedCards, activateClass));
  220. }
  221. }
  222. }
  223. #endregion
  224. return cardEffects;
  225. }
  226. }
  227. }