BT23_062.cs 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. // Dracmon
  5. namespace DCGO.CardEffects.BT23
  6. {
  7. public class BT23_062 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Alternative Digivolution Condition
  13. if (timing == EffectTiming.None)
  14. {
  15. bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.TopCard.IsLevel2 && targetPermanent.TopCard.HasCSTraits;
  18. }
  19. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  20. permanentCondition: PermanentCondition,
  21. digivolutionCost: 0,
  22. ignoreDigivolutionRequirement: false,
  23. card: card,
  24. condition: null)
  25. );
  26. }
  27. #endregion
  28. #region Start of Your Main Phase
  29. if (timing == EffectTiming.OnStartMainPhase)
  30. {
  31. ActivateClass activateClass = new ActivateClass();
  32. activateClass.SetUpICardEffect("Trash 1 card from hand to gain 1 memory", CanUseCondition, card);
  33. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  34. cardEffects.Add(activateClass);
  35. string EffectDiscription()
  36. {
  37. return "[Start of Your Main Phase] By trashing 1 card with the [Undead], [Dark Animal], or [CS] trait from your hand, gain 1 memory.";
  38. }
  39. bool CanSelectCardCondition(CardSource cardSource)
  40. {
  41. return cardSource.HasDarkAnimalTraits ||
  42. cardSource.HasUndeadTraits ||
  43. cardSource.HasCSTraits;
  44. }
  45. bool CanUseCondition(Hashtable hashtable)
  46. {
  47. if (CardEffectCommons.IsExistOnBattleArea(card))
  48. {
  49. if (CardEffectCommons.IsOwnerTurn(card))
  50. {
  51. return true;
  52. }
  53. }
  54. return false;
  55. }
  56. bool CanActivateCondition(Hashtable hashtable)
  57. {
  58. if (CardEffectCommons.IsExistOnBattleArea(card))
  59. {
  60. if (card.Owner.HandCards.Count >= 1)
  61. {
  62. return true;
  63. }
  64. }
  65. return false;
  66. }
  67. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  68. {
  69. if (card.Owner.HandCards.Some(CanSelectCardCondition))
  70. {
  71. bool discarded = false;
  72. int discardCount = 1;
  73. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  74. selectHandEffect.SetUp(
  75. selectPlayer: card.Owner,
  76. canTargetCondition: CanSelectCardCondition,
  77. canTargetCondition_ByPreSelecetedList: null,
  78. canEndSelectCondition: null,
  79. maxCount: discardCount,
  80. canNoSelect: true,
  81. canEndNotMax: false,
  82. isShowOpponent: true,
  83. selectCardCoroutine: null,
  84. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  85. mode: SelectHandEffect.Mode.Discard,
  86. cardEffect: activateClass);
  87. yield return StartCoroutine(selectHandEffect.Activate());
  88. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  89. {
  90. if (cardSources.Count >= 1)
  91. {
  92. discarded = true;
  93. yield return null;
  94. }
  95. }
  96. if (discarded)
  97. {
  98. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(1, activateClass));
  99. }
  100. }
  101. }
  102. }
  103. #endregion
  104. #region When Attacking - ESS
  105. if (timing == EffectTiming.OnAllyAttack)
  106. {
  107. ActivateClass activateClass = new ActivateClass();
  108. activateClass.SetUpICardEffect("Digivolve 1 of your Digimon into [Undead] or [Dark Animal] Digimon in trash", CanUseCondition, card);
  109. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  110. activateClass.SetIsInheritedEffect(true);
  111. activateClass.SetHashString("WA_BT23-062");
  112. cardEffects.Add(activateClass);
  113. string EffectDiscription()
  114. {
  115. return "[When Attacking][Once Per Turn] 1 of your Digimon may digivolve into a Digimon card with the [Undead] or [Dark Animal] trait in the trash.";
  116. }
  117. bool CanSelectDigiCardCondition(CardSource cardSource)
  118. {
  119. if (cardSource.IsDigimon)
  120. {
  121. if (cardSource.HasUndeadTraits || cardSource.HasDarkAnimalTraits)
  122. {
  123. return true;
  124. }
  125. }
  126. return false;
  127. }
  128. bool CanSelectPermanentCondition(Permanent permanent)
  129. {
  130. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  131. {
  132. foreach (CardSource cardSource in card.Owner.TrashCards)
  133. {
  134. if (CanSelectDigiCardCondition(cardSource))
  135. {
  136. if (cardSource.CanPlayCardTargetFrame(permanent.PermanentFrame, true, activateClass))
  137. {
  138. return true;
  139. }
  140. }
  141. }
  142. }
  143. return false;
  144. }
  145. bool CanUseCondition(Hashtable hashtable)
  146. {
  147. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  148. }
  149. bool CanActivateCondition(Hashtable hashtable)
  150. {
  151. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  152. {
  153. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  154. {
  155. return true;
  156. }
  157. }
  158. return false;
  159. }
  160. IEnumerator ActivateCoroutine(Hashtable hashtable)
  161. {
  162. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  163. {
  164. Permanent selectedPermanent = null;
  165. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  166. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  167. selectPermanentEffect.SetUp(
  168. selectPlayer: card.Owner,
  169. canTargetCondition: CanSelectPermanentCondition,
  170. canTargetCondition_ByPreSelecetedList: null,
  171. canEndSelectCondition: null,
  172. maxCount: maxCount,
  173. canNoSelect: true,
  174. canEndNotMax: false,
  175. selectPermanentCoroutine: SelectPermanentCoroutine,
  176. afterSelectPermanentCoroutine: null,
  177. mode: SelectPermanentEffect.Mode.Custom,
  178. cardEffect: activateClass);
  179. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to digivolve.", "The opponent is selecting 1 Digimon to digivolve.");
  180. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  181. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  182. {
  183. selectedPermanent = permanent;
  184. yield return null;
  185. }
  186. if (selectedPermanent != null)
  187. {
  188. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  189. targetPermanent: selectedPermanent,
  190. cardCondition: CanSelectDigiCardCondition,
  191. payCost: true,
  192. reduceCostTuple: null,
  193. fixedCostTuple: null,
  194. ignoreDigivolutionRequirementFixedCost: -1,
  195. isHand: false,
  196. activateClass: activateClass,
  197. successProcess: null));
  198. }
  199. }
  200. }
  201. }
  202. #endregion
  203. return cardEffects;
  204. }
  205. }
  206. }