BT22_077.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. //Dianamon
  5. namespace DCGO.CardEffects.BT22
  6. {
  7. public class BT22_077 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Alternate Digivolution Requirement
  13. if (timing == EffectTiming.None)
  14. {
  15. bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. if (targetPermanent.TopCard.HasLightFangOrNightClawTraits || targetPermanent.TopCard.HasCSTraits)
  18. {
  19. if (targetPermanent.TopCard.HasLevel)
  20. {
  21. if (targetPermanent.Level == 5)
  22. {
  23. return true;
  24. }
  25. }
  26. }
  27. return false;
  28. }
  29. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  30. }
  31. #endregion
  32. #region Iceclad
  33. if (timing == EffectTiming.None)
  34. {
  35. cardEffects.Add(CardEffectFactory.IcecladSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  36. }
  37. #endregion
  38. #region Blocker
  39. if (timing == EffectTiming.None)
  40. {
  41. cardEffects.Add(CardEffectFactory.BlockerSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  42. }
  43. #endregion
  44. #region When Digivolving
  45. if (timing == EffectTiming.OnEnterFieldAnyone)
  46. {
  47. ActivateClass activateClass = new ActivateClass();
  48. activateClass.SetUpICardEffect("Trash 4 sources, then return 1 digimon.", CanUseCondition, card);
  49. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  50. cardEffects.Add(activateClass);
  51. string EffectDiscription()
  52. {
  53. return "[When Digivolving] If this Digimon's stack has 2 or more same-level cards, trash any 4 digivolution cards from your opponent's Digimon. Then, return 1 of your opponent's Digimon with 1 or fewer digivolution cards to the bottom of the deck.";
  54. }
  55. bool CanSelectPermanentCondition(Permanent permanent)
  56. {
  57. if (CardEffectCommons.IsExistOnBattleArea(card))
  58. {
  59. return permanent.StackCards
  60. .Filter(x => !x.IsFlipped)
  61. .GroupBy(x => x.Level)
  62. .Any(g => g.Count() >= 2);
  63. }
  64. return false;
  65. }
  66. bool OpponentsDigimon(Permanent permanent)
  67. {
  68. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  69. }
  70. bool ReturnOpponentsDigimon(Permanent permanent)
  71. {
  72. return OpponentsDigimon(permanent) &&
  73. permanent.DigivolutionCards.Count <= 1;
  74. }
  75. bool CanSelectCardCondition(CardSource cardSource)
  76. {
  77. return !cardSource.CanNotTrashFromDigivolutionCards(activateClass);
  78. }
  79. bool CanUseCondition(Hashtable hashtable)
  80. {
  81. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  82. CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  83. }
  84. bool CanActivateCondition(Hashtable hashtable)
  85. {
  86. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  87. }
  88. //Activate effect
  89. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  90. {
  91. if (CanSelectPermanentCondition(card.PermanentOfThisCard()))
  92. {
  93. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.SelectTrashDigivolutionCards(
  94. permanentCondition: OpponentsDigimon,
  95. cardCondition: CanSelectCardCondition,
  96. maxCount: 4,
  97. canNoTrash: false,
  98. isFromOnly1Permanent: false,
  99. activateClass: activateClass
  100. ));
  101. }
  102. if (CardEffectCommons.HasMatchConditionPermanent(ReturnOpponentsDigimon))
  103. {
  104. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  105. selectPermanentEffect.SetUp(
  106. selectPlayer: card.Owner,
  107. canTargetCondition: ReturnOpponentsDigimon,
  108. canTargetCondition_ByPreSelecetedList: null,
  109. canEndSelectCondition: null,
  110. maxCount: 1,
  111. canNoSelect: false,
  112. canEndNotMax: false,
  113. selectPermanentCoroutine: null,
  114. afterSelectPermanentCoroutine: null,
  115. mode: SelectPermanentEffect.Mode.PutLibraryBottom,
  116. cardEffect: activateClass);
  117. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  118. }
  119. }
  120. }
  121. #endregion
  122. #region End of Turn - OPT
  123. if (timing == EffectTiming.OnEndTurn)
  124. {
  125. ActivateClass activateClass = new ActivateClass();
  126. activateClass.SetUpICardEffect("Unsuspend", CanUseCondition, card);
  127. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  128. activateClass.SetHashString("Unsuspend_BT22-077");
  129. cardEffects.Add(activateClass);
  130. string EffectDiscription()
  131. {
  132. return "[End of Your Turn] [Once Per Turn] 1 of your Digimon may unsuspend.";
  133. }
  134. bool CanSelectPermanentCondition(Permanent permanent)
  135. {
  136. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  137. }
  138. bool CanUseCondition(Hashtable hashtable)
  139. {
  140. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  141. CardEffectCommons.IsOwnerTurn(card);
  142. }
  143. bool CanActivateCondition(Hashtable hashtable)
  144. {
  145. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  146. CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition);
  147. }
  148. IEnumerator ActivateCoroutine(Hashtable hashtable)
  149. {
  150. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  151. selectPermanentEffect.SetUp(
  152. selectPlayer: card.Owner,
  153. canTargetCondition: CanSelectPermanentCondition,
  154. canTargetCondition_ByPreSelecetedList: null,
  155. canEndSelectCondition: null,
  156. maxCount: 1,
  157. canNoSelect: true,
  158. canEndNotMax: false,
  159. selectPermanentCoroutine: null,
  160. afterSelectPermanentCoroutine: null,
  161. mode: SelectPermanentEffect.Mode.UnTap,
  162. cardEffect: activateClass);
  163. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to unsuspend.", "The opponent is selecting 1 Digimon to unsuspend.");
  164. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  165. }
  166. }
  167. #endregion
  168. #region End of Turn - ESS - OPT
  169. if (timing == EffectTiming.OnEndTurn)
  170. {
  171. ActivateClass activateClass = new ActivateClass();
  172. activateClass.SetUpICardEffect("Unsuspend", CanUseCondition, card);
  173. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  174. activateClass.SetHashString("UnsuspendESS_BT22-077");
  175. activateClass.SetIsInheritedEffect(true);
  176. cardEffects.Add(activateClass);
  177. string EffectDiscription()
  178. {
  179. return "[End of Your Turn] [Once Per Turn] 1 of your Digimon may unsuspend.";
  180. }
  181. bool CanSelectPermanentCondition(Permanent permanent)
  182. {
  183. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  184. }
  185. bool CanUseCondition(Hashtable hashtable)
  186. {
  187. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  188. CardEffectCommons.IsOwnerTurn(card);
  189. }
  190. bool CanActivateCondition(Hashtable hashtable)
  191. {
  192. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  193. CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition);
  194. }
  195. IEnumerator ActivateCoroutine(Hashtable hashtable)
  196. {
  197. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  198. selectPermanentEffect.SetUp(
  199. selectPlayer: card.Owner,
  200. canTargetCondition: CanSelectPermanentCondition,
  201. canTargetCondition_ByPreSelecetedList: null,
  202. canEndSelectCondition: null,
  203. maxCount: 1,
  204. canNoSelect: true,
  205. canEndNotMax: false,
  206. selectPermanentCoroutine: null,
  207. afterSelectPermanentCoroutine: null,
  208. mode: SelectPermanentEffect.Mode.UnTap,
  209. cardEffect: activateClass);
  210. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to unsuspend.", "The opponent is selecting 1 Digimon to unsuspend.");
  211. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  212. }
  213. }
  214. #endregion
  215. return cardEffects;
  216. }
  217. }
  218. }