BT22_047.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. //Kuwagamon
  5. namespace DCGO.CardEffects.BT22
  6. {
  7. public class BT22_047 : 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 On Play
  29. if (timing == EffectTiming.OnEnterFieldAnyone)
  30. {
  31. ActivateClass activateClass = new ActivateClass();
  32. activateClass.SetUpICardEffect("Suspend 1 of your opponent's Digimon.", CanUseCondition, card);
  33. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  34. cardEffects.Add(activateClass);
  35. string EffectDiscription()
  36. {
  37. return "[On Play] Suspend 1 of your opponent's Digimon. Then, if this Digimon's stack has 2 or more same-level cards, 1 of your opponent's Digimon can't unsuspend until their turn ends.";
  38. }
  39. bool CanSelectOpponentDigimonCondition(Permanent permanent)
  40. {
  41. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  42. }
  43. bool CanSelectPermanentCondition(Permanent permanent)
  44. {
  45. if (CardEffectCommons.IsExistOnBattleArea(card))
  46. {
  47. return card.PermanentOfThisCard().StackCards
  48. .Filter(x => !x.IsFlipped)
  49. .GroupBy(x => x.Level)
  50. .Any(g => g.Count() >= 2);
  51. }
  52. return false;
  53. }
  54. bool CanUseCondition(Hashtable hashtable)
  55. {
  56. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  57. }
  58. bool CanActivateCondition(Hashtable hashtable)
  59. {
  60. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  61. CardEffectCommons.HasMatchConditionPermanent(CanSelectOpponentDigimonCondition);
  62. }
  63. //Activate effect
  64. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  65. {
  66. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  67. selectPermanentEffect.SetUp(
  68. selectPlayer: card.Owner,
  69. canTargetCondition: CanSelectOpponentDigimonCondition,
  70. canTargetCondition_ByPreSelecetedList: null,
  71. canEndSelectCondition: null,
  72. maxCount: 1,
  73. canNoSelect: false,
  74. canEndNotMax: false,
  75. selectPermanentCoroutine: null,
  76. afterSelectPermanentCoroutine: null,
  77. mode: SelectPermanentEffect.Mode.Tap,
  78. cardEffect: activateClass);
  79. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  80. if (CanSelectPermanentCondition(card.PermanentOfThisCard()))
  81. {
  82. selectPermanentEffect.SetUp(
  83. selectPlayer: card.Owner,
  84. canTargetCondition: CanSelectOpponentDigimonCondition,
  85. canTargetCondition_ByPreSelecetedList: null,
  86. canEndSelectCondition: null,
  87. maxCount: 1,
  88. canNoSelect: false,
  89. canEndNotMax: false,
  90. selectPermanentCoroutine: null,
  91. afterSelectPermanentCoroutine: AfterSelectPermanentCoroutine,
  92. mode: SelectPermanentEffect.Mode.Custom,
  93. cardEffect: activateClass);
  94. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  95. }
  96. IEnumerator AfterSelectPermanentCoroutine(List<Permanent> permanents)
  97. {
  98. foreach (Permanent selectedPermanent in permanents)
  99. {
  100. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainCanNotUnsuspend(
  101. targetPermanent: selectedPermanent,
  102. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  103. activateClass: activateClass,
  104. condition: null,
  105. effectName: "Can't unsuspend"
  106. ));
  107. }
  108. yield return null;
  109. }
  110. }
  111. }
  112. #endregion
  113. #region When Digivolving
  114. if (timing == EffectTiming.OnEnterFieldAnyone)
  115. {
  116. ActivateClass activateClass = new ActivateClass();
  117. activateClass.SetUpICardEffect("Suspend 1 of your opponent's Digimon.", CanUseCondition, card);
  118. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  119. cardEffects.Add(activateClass);
  120. string EffectDiscription()
  121. {
  122. return "[When Digivolving] Suspend 1 of your opponent's Digimon. Then, if this Digimon's stack has 2 or more same-level cards, 1 of your opponent's Digimon can't unsuspend until their turn ends.";
  123. }
  124. bool CanSelectOpponentDigimonCondition(Permanent permanent)
  125. {
  126. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  127. }
  128. bool CanSelectPermanentCondition(Permanent permanent)
  129. {
  130. if (CardEffectCommons.IsExistOnBattleArea(card))
  131. {
  132. return permanent.StackCards
  133. .Filter(x => !x.IsFlipped)
  134. .GroupBy(x => x.Level)
  135. .Any(g => g.Count() >= 2);
  136. }
  137. return false;
  138. }
  139. bool CanUseCondition(Hashtable hashtable)
  140. {
  141. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  142. CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  143. }
  144. bool CanActivateCondition(Hashtable hashtable)
  145. {
  146. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  147. CardEffectCommons.HasMatchConditionPermanent(CanSelectOpponentDigimonCondition);
  148. }
  149. //Activate effect
  150. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  151. {
  152. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  153. selectPermanentEffect.SetUp(
  154. selectPlayer: card.Owner,
  155. canTargetCondition: CanSelectOpponentDigimonCondition,
  156. canTargetCondition_ByPreSelecetedList: null,
  157. canEndSelectCondition: null,
  158. maxCount: 1,
  159. canNoSelect: false,
  160. canEndNotMax: false,
  161. selectPermanentCoroutine: null,
  162. afterSelectPermanentCoroutine: null,
  163. mode: SelectPermanentEffect.Mode.Tap,
  164. cardEffect: activateClass);
  165. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  166. if (CanSelectPermanentCondition(card.PermanentOfThisCard()))
  167. {
  168. selectPermanentEffect.SetUp(
  169. selectPlayer: card.Owner,
  170. canTargetCondition: CanSelectOpponentDigimonCondition,
  171. canTargetCondition_ByPreSelecetedList: null,
  172. canEndSelectCondition: null,
  173. maxCount: 1,
  174. canNoSelect: false,
  175. canEndNotMax: false,
  176. selectPermanentCoroutine: null,
  177. afterSelectPermanentCoroutine: AfterSelectPermanentCoroutine,
  178. mode: SelectPermanentEffect.Mode.Custom,
  179. cardEffect: activateClass);
  180. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  181. }
  182. IEnumerator AfterSelectPermanentCoroutine(List<Permanent> permanents)
  183. {
  184. foreach (Permanent selectedPermanent in permanents)
  185. {
  186. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainCanNotUnsuspend(
  187. targetPermanent: selectedPermanent,
  188. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  189. activateClass: activateClass,
  190. condition: null,
  191. effectName: "Can't unsuspend"
  192. ));
  193. }
  194. yield return null;
  195. }
  196. }
  197. }
  198. #endregion
  199. #region ESS
  200. if (timing == EffectTiming.OnEndBattle)
  201. {
  202. ActivateClass activateClass = new ActivateClass();
  203. activateClass.SetUpICardEffect("Gain 1 memory", CanUseCondition, card);
  204. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  205. activateClass.SetHashString("Gain1_BT22-047");
  206. activateClass.SetIsInheritedEffect(true);
  207. cardEffects.Add(activateClass);
  208. string EffectDiscription()
  209. {
  210. return "[All Turns] [Once Per Turn] When this Digimon deletes your opponent's Digimon in battle, gain 1 memory.";
  211. }
  212. bool WinnerCondition(Permanent permanent) => permanent.cardSources.Contains(card);
  213. bool LoserCondition(Permanent permanent) => CardEffectCommons.IsOpponentPermanent(permanent, card);
  214. bool CanUseCondition(Hashtable hashtable)
  215. {
  216. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  217. CardEffectCommons.IsOwnerTurn(card) &&
  218. CardEffectCommons.CanTriggerWhenDeleteOpponentDigimonByBattle(hashtable: hashtable,
  219. winnerCondition: WinnerCondition, loserCondition: LoserCondition, isOnlyWinnerSurvive: false);
  220. }
  221. bool CanActivateCondition(Hashtable hashtable)
  222. {
  223. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  224. {
  225. return true;
  226. }
  227. return false;
  228. }
  229. IEnumerator ActivateCoroutine(Hashtable hashtable)
  230. {
  231. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(1, activateClass));
  232. }
  233. }
  234. #endregion
  235. return cardEffects;
  236. }
  237. }
  238. }