EX8_012.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.EX8
  6. {
  7. public class EX8_012 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Digivolution Condition
  13. if (timing == EffectTiming.None)
  14. {
  15. bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.TopCard.EqualsCardName("Growlmon");
  18. }
  19. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  20. permanentCondition: PermanentCondition,
  21. digivolutionCost: 0,
  22. ignoreDigivolutionRequirement: false,
  23. card: card, condition: null)
  24. );
  25. }
  26. #endregion
  27. #region When Digivolving
  28. if (timing == EffectTiming.OnEnterFieldAnyone)
  29. {
  30. ActivateClass activateClass = new ActivateClass();
  31. activateClass.SetUpICardEffect("Draw 1 and trash 1 card from hand. Then this Digimon gains On Deletion.", CanUseCondition, card);
  32. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  33. cardEffects.Add(activateClass);
  34. string EffectDiscription()
  35. {
  36. return "[When Digivolving] <Draw 1> and trash 1 card in your hand. Then, if [Growlmon] or [X Antibody] is in this Digimon's digivolution cards, until the end of your opponent's turn, this Digimon gains \"<On Deletion> You may play 1 card with [Guilmon] in its name from your trash without paying the cost.\"";
  37. }
  38. bool CanUseCondition(Hashtable hashtable)
  39. {
  40. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  41. {
  42. if (CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card))
  43. {
  44. return true;
  45. }
  46. }
  47. return false;
  48. }
  49. bool CanActivateCondition(Hashtable hashtable)
  50. {
  51. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  52. }
  53. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  54. {
  55. if (card.Owner.LibraryCards.Count >= 1)
  56. yield return ContinuousController.instance.StartCoroutine(new DrawClass(card.Owner, 1, activateClass).Draw());
  57. if (card.Owner.HandCards.Count >= 1)
  58. {
  59. int discardCount = 1;
  60. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  61. selectHandEffect.SetUp(
  62. selectPlayer: card.Owner,
  63. canTargetCondition: (cardSource) => true,
  64. canTargetCondition_ByPreSelecetedList: null,
  65. canEndSelectCondition: null,
  66. maxCount: discardCount,
  67. canNoSelect: false,
  68. canEndNotMax: false,
  69. isShowOpponent: true,
  70. selectCardCoroutine: null,
  71. afterSelectCardCoroutine: null,
  72. mode: SelectHandEffect.Mode.Discard,
  73. cardEffect: activateClass);
  74. yield return StartCoroutine(selectHandEffect.Activate());
  75. }
  76. if (card.PermanentOfThisCard().DigivolutionCards.Count((cardSource) => (cardSource.EqualsCardName("Growlmon") || cardSource.EqualsCardName("X Antibody"))) >= 1)
  77. {
  78. Permanent selectedPermanent = card.PermanentOfThisCard();
  79. CardSource _topCard = selectedPermanent.TopCard;
  80. ActivateClass activateClass1 = new ActivateClass();
  81. activateClass1.SetUpICardEffect("Play 1 [Guilmon] from trash", CanUseCondition1, selectedPermanent.TopCard);
  82. activateClass1.SetUpActivateClass(CanActivateCondition1, ActivateCoroutine1, -1, true, EffectDiscription1());
  83. activateClass1.SetEffectSourcePermanent(selectedPermanent);
  84. CardEffectCommons.AddEffectToPermanent(targetPermanent: selectedPermanent, effectDuration: EffectDuration.UntilOpponentTurnEnd, card: card, cardEffect: activateClass1, timing: EffectTiming.OnDestroyedAnyone);
  85. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateBuffEffect(selectedPermanent));
  86. string EffectDiscription1()
  87. {
  88. return "[On Deletion] You may play 1 card with [Guilmon] in its name from your trash without paying the cost.";
  89. }
  90. bool CanSelectCardCondition(CardSource cardSource)
  91. {
  92. if (cardSource.ContainsCardName("Guilmon"))
  93. {
  94. if (CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass))
  95. {
  96. return true;
  97. }
  98. }
  99. return false;
  100. }
  101. bool CanUseCondition1(Hashtable hashtable1)
  102. {
  103. if (CardEffectCommons.IsPermanentExistsOnBattleAreaDigimon(selectedPermanent))
  104. {
  105. if (CardEffectCommons.CanTriggerOnPermanentDeleted(hashtable1, (permanent) => permanent == selectedPermanent, activateClass))
  106. {
  107. if (!selectedPermanent.TopCard.CanNotBeAffected(activateClass))
  108. {
  109. return true;
  110. }
  111. }
  112. }
  113. return false;
  114. }
  115. bool CanActivateCondition1(Hashtable hashtable1)
  116. {
  117. if (CardEffectCommons.IsTopCardInTrashOnDeletion(hashtable1))
  118. {
  119. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(_topCard, CanSelectCardCondition))
  120. {
  121. return true;
  122. }
  123. }
  124. return false;
  125. }
  126. IEnumerator ActivateCoroutine1(Hashtable _hashtable1)
  127. {
  128. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(_topCard, (cardSource) => CanSelectCardCondition(cardSource)))
  129. {
  130. int maxCount = Math.Min(1, _topCard.Owner.TrashCards.Count((cardSource) => CanSelectCardCondition(cardSource)));
  131. List<CardSource> selectedCards = new List<CardSource>();
  132. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  133. selectCardEffect.SetUp(
  134. canTargetCondition: CanSelectCardCondition,
  135. canTargetCondition_ByPreSelecetedList: null,
  136. canEndSelectCondition: null,
  137. canNoSelect: () => true,
  138. selectCardCoroutine: SelectCardCoroutine,
  139. afterSelectCardCoroutine: null,
  140. message: "Select 1 card with [Guilmon] in its name to play.",
  141. maxCount: maxCount,
  142. canEndNotMax: false,
  143. isShowOpponent: true,
  144. mode: SelectCardEffect.Mode.Custom,
  145. root: SelectCardEffect.Root.Trash,
  146. customRootCardList: null,
  147. canLookReverseCard: true,
  148. selectPlayer: _topCard.Owner,
  149. cardEffect: activateClass);
  150. selectCardEffect.SetUpCustomMessage("Select 1 card with [Guilmon] in its name to play.", "The opponent is selecting 1 card to play.");
  151. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  152. yield return StartCoroutine(selectCardEffect.Activate());
  153. IEnumerator SelectCardCoroutine(CardSource cardSource)
  154. {
  155. selectedCards.Add(cardSource);
  156. yield return null;
  157. }
  158. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: selectedCards, activateClass: activateClass1, payCost: false, isTapped: false, root: SelectCardEffect.Root.Trash, activateETB: true));
  159. }
  160. }
  161. }
  162. }
  163. }
  164. #endregion
  165. #region Inherit
  166. if (timing == EffectTiming.OnDestroyedAnyone)
  167. {
  168. ActivateClass activateClass = new ActivateClass();
  169. activateClass.SetUpICardEffect("Memory +1", CanUseCondition, card);
  170. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  171. activateClass.SetIsInheritedEffect(true);
  172. activateClass.SetHashString("Memory+1_EX8_012");
  173. cardEffects.Add(activateClass);
  174. string EffectDiscription()
  175. {
  176. return "[Your Turn][Once Per Turn] When any of your opponent's Digimon is deleted, gain 1 memory.";
  177. }
  178. bool PermanentCondition(Permanent permanent)
  179. {
  180. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  181. }
  182. bool CanUseCondition(Hashtable hashtable)
  183. {
  184. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  185. {
  186. if (CardEffectCommons.IsOwnerTurn(card))
  187. {
  188. if (CardEffectCommons.CanTriggerOnPermanentDeleted(hashtable, PermanentCondition, activateClass))
  189. {
  190. return true;
  191. }
  192. }
  193. }
  194. return false;
  195. }
  196. bool CanActivateCondition(Hashtable hashtable)
  197. {
  198. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  199. {
  200. return true;
  201. }
  202. return false;
  203. }
  204. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  205. {
  206. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(1, activateClass));
  207. }
  208. }
  209. #endregion
  210. return cardEffects;
  211. }
  212. }
  213. }