BT23_063.cs 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. // Sangloupmon
  5. namespace DCGO.CardEffects.BT23
  6. {
  7. public class BT23_063 : 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.IsLevel3 && targetPermanent.TopCard.HasCSTraits;
  18. }
  19. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  20. permanentCondition: PermanentCondition,
  21. digivolutionCost: 2,
  22. ignoreDigivolutionRequirement: false,
  23. card: card,
  24. condition: null)
  25. );
  26. }
  27. #endregion
  28. #region When Attacking
  29. if (timing == EffectTiming.OnAllyAttack)
  30. {
  31. ActivateClass activateClass = new ActivateClass();
  32. activateClass.SetUpICardEffect("Digivolve this Digimon into [Undead] or [CS] Digimon", CanUseCondition, card);
  33. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  34. cardEffects.Add(activateClass);
  35. string EffectDiscription()
  36. {
  37. return "[When Attacking] This Digimon may digivolve into a Digimon card with the [Undead] or [CS] trait in the trash.";
  38. }
  39. bool CanSelectCardCondition(CardSource cardSource)
  40. {
  41. if (cardSource.IsDigimon)
  42. {
  43. if (cardSource.HasUndeadTraits || cardSource.HasCSTraits)
  44. {
  45. if (cardSource.CanPlayCardTargetFrame(card.PermanentOfThisCard().PermanentFrame, false, activateClass))
  46. {
  47. return true;
  48. }
  49. }
  50. }
  51. return false;
  52. }
  53. bool CanUseCondition(Hashtable hashtable)
  54. {
  55. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  56. }
  57. bool CanActivateCondition(Hashtable hashtable)
  58. {
  59. if (CardEffectCommons.IsExistOnBattleArea(card))
  60. {
  61. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  62. {
  63. return true;
  64. }
  65. }
  66. return false;
  67. }
  68. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  69. {
  70. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  71. targetPermanent: card.PermanentOfThisCard(),
  72. cardCondition: CanSelectCardCondition,
  73. payCost: true,
  74. reduceCostTuple: null,
  75. fixedCostTuple: null,
  76. ignoreDigivolutionRequirementFixedCost: -1,
  77. isHand: false,
  78. activateClass: activateClass,
  79. successProcess: null));
  80. }
  81. }
  82. #endregion
  83. #region When Attacking - ESS
  84. if (timing == EffectTiming.OnAllyAttack)
  85. {
  86. ActivateClass activateClass = new ActivateClass();
  87. activateClass.SetUpICardEffect("Digivolve 1 of your Digimon into [Undead] or [Dark Animal] Digimon in trash", CanUseCondition, card);
  88. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  89. activateClass.SetIsInheritedEffect(true);
  90. activateClass.SetHashString("BT23_063");
  91. cardEffects.Add(activateClass);
  92. string EffectDiscription()
  93. {
  94. 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.";
  95. }
  96. bool CanSelectDigiCardCondition(CardSource cardSource)
  97. {
  98. if (cardSource.IsDigimon)
  99. {
  100. if (cardSource.HasUndeadTraits || cardSource.HasDarkAnimalTraits)
  101. {
  102. return true;
  103. }
  104. }
  105. return false;
  106. }
  107. bool CanSelectPermanentCondition(Permanent permanent)
  108. {
  109. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  110. {
  111. // Loop thru the trash cards looking for a valid digi target
  112. foreach (CardSource cardSource in card.Owner.TrashCards)
  113. {
  114. // does it have undead or dark animal trait?
  115. if (CanSelectDigiCardCondition(cardSource))
  116. {
  117. // can this digimon digivolve into it?
  118. if (cardSource.CanPlayCardTargetFrame(permanent.PermanentFrame, true, activateClass))
  119. {
  120. return true;
  121. }
  122. }
  123. }
  124. }
  125. return false;
  126. }
  127. bool CanUseCondition(Hashtable hashtable)
  128. {
  129. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  130. }
  131. bool CanActivateCondition(Hashtable hashtable)
  132. {
  133. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  134. {
  135. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  136. {
  137. return true;
  138. }
  139. }
  140. return false;
  141. }
  142. IEnumerator ActivateCoroutine(Hashtable hashtable)
  143. {
  144. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  145. {
  146. Permanent selectedPermanent = null;
  147. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  148. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  149. selectPermanentEffect.SetUp(
  150. selectPlayer: card.Owner,
  151. canTargetCondition: CanSelectPermanentCondition,
  152. canTargetCondition_ByPreSelecetedList: null,
  153. canEndSelectCondition: null,
  154. maxCount: maxCount,
  155. canNoSelect: true,
  156. canEndNotMax: false,
  157. selectPermanentCoroutine: SelectPermanentCoroutine,
  158. afterSelectPermanentCoroutine: null,
  159. mode: SelectPermanentEffect.Mode.Custom,
  160. cardEffect: activateClass);
  161. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to digivolve.", "The opponent is selecting 1 Digimon to digivolve.");
  162. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  163. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  164. {
  165. selectedPermanent = permanent;
  166. yield return null;
  167. }
  168. if (selectedPermanent != null)
  169. {
  170. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  171. targetPermanent: selectedPermanent,
  172. cardCondition: CanSelectDigiCardCondition,
  173. payCost: true,
  174. reduceCostTuple: null,
  175. fixedCostTuple: null,
  176. ignoreDigivolutionRequirementFixedCost: -1,
  177. isHand: false,
  178. activateClass: activateClass,
  179. successProcess: null));
  180. }
  181. }
  182. }
  183. }
  184. #endregion
  185. return cardEffects;
  186. }
  187. }
  188. }