EX9_020.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. using Photon.Pun;
  2. using System;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using UnityEngine;
  7. //CresGarurumon
  8. namespace DCGO.CardEffects.EX9
  9. {
  10. public class EX9_020 : CEntity_Effect
  11. {
  12. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  13. {
  14. List<ICardEffect> cardEffects = new List<ICardEffect>();
  15. #region Alternate Digivolution Requirement
  16. //Lv.5 w/[Greymon] in name or w/[DM] trait: Cost 3
  17. if (timing == EffectTiming.None)
  18. {
  19. static bool PermanentCondition(Permanent targetPermanent)
  20. {
  21. return (targetPermanent.TopCard.HasGarurumonName || targetPermanent.TopCard.HasDMTraits) && targetPermanent.TopCard.IsLevel5;
  22. }
  23. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  24. }
  25. #endregion
  26. #region Blast Digivolve
  27. if (timing == EffectTiming.OnCounterTiming)
  28. {
  29. cardEffects.Add(CardEffectFactory.BlastDigivolveEffect(card: card, condition: null));
  30. }
  31. #endregion
  32. #region Alliance/Blocker
  33. if (timing == EffectTiming.OnAllyAttack)
  34. {
  35. cardEffects.Add(CardEffectFactory.AllianceSelfEffect(isInheritedEffect: false, card: card, condition: null));
  36. }
  37. if (timing == EffectTiming.None)
  38. {
  39. cardEffects.Add(CardEffectFactory.BlockerSelfStaticEffect(
  40. isInheritedEffect: false,
  41. card: card,
  42. condition: null));
  43. }
  44. #endregion
  45. #region On Play/When Digivolving Shared
  46. bool CanSelectPermanentCondition(Permanent permanent)
  47. {
  48. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  49. {
  50. if (permanent.TopCard.HasLevel)
  51. {
  52. if (permanent.Level <= 5)
  53. {
  54. return true;
  55. }
  56. }
  57. }
  58. return false;
  59. }
  60. bool CanActivateSharedCondition(Hashtable hashtable)
  61. {
  62. if (CardEffectCommons.IsExistOnBattleArea(card))
  63. {
  64. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  65. {
  66. return true;
  67. }
  68. }
  69. return false;
  70. }
  71. #endregion
  72. #region On Play
  73. if (timing == EffectTiming.OnEnterFieldAnyone)
  74. {
  75. ActivateClass activateClass = new ActivateClass();
  76. activateClass.SetUpICardEffect("Return 1 level 5 or lower Digimon to hand", CanUseCondition, card);
  77. activateClass.SetUpActivateClass(CanActivateSharedCondition, ActivateCoroutine, -1, false, EffectDescription());
  78. cardEffects.Add(activateClass);
  79. string EffectDescription()
  80. {
  81. return "[On Play] Return 1 of your opponent's level 5 or lower Digimon to the bottom of the deck.";
  82. }
  83. bool CanUseCondition(Hashtable hashtable)
  84. {
  85. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  86. }
  87. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  88. {
  89. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  90. selectPermanentEffect.SetUp(
  91. selectPlayer: card.Owner,
  92. canTargetCondition: CanSelectPermanentCondition,
  93. canTargetCondition_ByPreSelecetedList: null,
  94. canEndSelectCondition: null,
  95. maxCount: 1,
  96. canNoSelect: false,
  97. canEndNotMax: false,
  98. selectPermanentCoroutine: null,
  99. afterSelectPermanentCoroutine: null,
  100. mode: SelectPermanentEffect.Mode.PutLibraryBottom,
  101. cardEffect: activateClass);
  102. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  103. }
  104. }
  105. #endregion
  106. #region When Digivolving
  107. if (timing == EffectTiming.OnEnterFieldAnyone)
  108. {
  109. ActivateClass activateClass = new ActivateClass();
  110. activateClass.SetUpICardEffect("Return 1 level 5 or lower Digimon to hand", CanUseCondition, card);
  111. activateClass.SetUpActivateClass(CanActivateSharedCondition, ActivateCoroutine, -1, false, EffectDescription());
  112. cardEffects.Add(activateClass);
  113. string EffectDescription()
  114. {
  115. return "[When Digivolving] Return 1 of your opponent's level 5 or lower Digimon to the bottom of the deck.";
  116. }
  117. bool CanUseCondition(Hashtable hashtable)
  118. {
  119. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  120. CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  121. }
  122. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  123. {
  124. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  125. selectPermanentEffect.SetUp(
  126. selectPlayer: card.Owner,
  127. canTargetCondition: CanSelectPermanentCondition,
  128. canTargetCondition_ByPreSelecetedList: null,
  129. canEndSelectCondition: null,
  130. maxCount: 1,
  131. canNoSelect: false,
  132. canEndNotMax: false,
  133. selectPermanentCoroutine: null,
  134. afterSelectPermanentCoroutine: null,
  135. mode: SelectPermanentEffect.Mode.PutLibraryBottom,
  136. cardEffect: activateClass);
  137. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  138. }
  139. }
  140. #endregion
  141. #region All Turns
  142. if (timing == EffectTiming.WhenRemoveField)
  143. {
  144. ActivateClass activateClass = new ActivateClass();
  145. activateClass.SetUpICardEffect("DNA into [Omnimon Alter-S]", CanUseCondition, card);
  146. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  147. cardEffects.Add(activateClass);
  148. string EffectDiscription()
  149. {
  150. return "[All Turns] When any of your level 6 Digimon would leave the battle area other than in battle, 2 of your Digimon may DNA digivolve into [Omnimon Alter-S] in the hand.";
  151. }
  152. bool WouldLeaveBattleArea(Permanent permanent)
  153. {
  154. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) &&
  155. permanent.TopCard.IsLevel6;
  156. }
  157. bool CanSelectDNACardCondition(CardSource cardSource)
  158. {
  159. return cardSource.IsDigimon &&
  160. cardSource.EqualsCardName("Omnimon Alter-S") &&
  161. cardSource.CanPlayJogress(true);
  162. }
  163. bool CanUseCondition(Hashtable hashtable)
  164. {
  165. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  166. {
  167. if (CardEffectCommons.CanTriggerWhenPermanentRemoveField(hashtable, WouldLeaveBattleArea))
  168. {
  169. if (!CardEffectCommons.IsByBattle(hashtable))
  170. {
  171. return true;
  172. }
  173. }
  174. }
  175. return false;
  176. }
  177. bool CanActivateCondition(Hashtable hashtable)
  178. {
  179. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  180. }
  181. IEnumerator ActivateCoroutine(Hashtable hashtable)
  182. {
  183. yield return ContinuousController.instance.StartCoroutine(
  184. CardEffectCommons.DNADigivolvePermanentsIntoHandOrTrashCard(
  185. CanSelectDNACardCondition,
  186. payCost: true,
  187. isHand: true,
  188. activateClass
  189. ));
  190. }
  191. }
  192. #endregion
  193. #region Your Turn - ESS
  194. if (timing == EffectTiming.None)
  195. {
  196. CanNotSwitchAttackTargetClass canNotSwitchAttackTargetClass = new CanNotSwitchAttackTargetClass();
  197. canNotSwitchAttackTargetClass.SetUpICardEffect("This Digimon's attack target can't change.", CanUseCondition, card);
  198. canNotSwitchAttackTargetClass.SetUpCanNotSwitchAttackTargetClass(PermanentCondition: PermanentCondition);
  199. canNotSwitchAttackTargetClass.SetIsInheritedEffect(true);
  200. cardEffects.Add(canNotSwitchAttackTargetClass);
  201. bool CanUseCondition(Hashtable hashtable)
  202. {
  203. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) && CardEffectCommons.IsOwnerTurn(card);
  204. }
  205. bool PermanentCondition(Permanent permanent)
  206. {
  207. return permanent != null && permanent.TopCard && permanent == card.PermanentOfThisCard();
  208. }
  209. }
  210. #endregion
  211. return cardEffects;
  212. }
  213. }
  214. }