BT22_051.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. //Okuwamon
  5. namespace DCGO.CardEffects.BT22
  6. {
  7. public class BT22_051 : 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.IsLevel4 && targetPermanent.TopCard.HasCSTraits;
  18. }
  19. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  20. permanentCondition: PermanentCondition,
  21. digivolutionCost: 3,
  22. ignoreDigivolutionRequirement: false,
  23. card: card,
  24. condition: null)
  25. );
  26. }
  27. #endregion
  28. #region Fortitude
  29. if (timing == EffectTiming.OnDestroyedAnyone)
  30. {
  31. cardEffects.Add(CardEffectFactory.FortitudeSelfEffect(isInheritedEffect: false, card: card, condition: null));
  32. }
  33. #endregion
  34. #region On Play/When Digivolving Shared
  35. bool OpponentsDigimon(Permanent permanent)
  36. {
  37. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  38. }
  39. bool OpponentsTappedDigimon(Permanent permanent)
  40. {
  41. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card) && permanent.IsSuspended;
  42. }
  43. bool IsMinDPSuspended(Permanent permanent)
  44. {
  45. return CardEffectCommons.IsMinDP(permanent, card.Owner.Enemy, OpponentsTappedDigimon);
  46. }
  47. bool CanSelectPermanentCondition(Permanent permanent)
  48. {
  49. if (CardEffectCommons.IsExistOnBattleArea(card))
  50. {
  51. return permanent.StackCards
  52. .Filter(x => !x.IsFlipped)
  53. .GroupBy(x => x.Level)
  54. .Any(g => g.Count() >= 2);
  55. }
  56. return false;
  57. }
  58. #endregion
  59. #region On Play
  60. if (timing == EffectTiming.OnEnterFieldAnyone)
  61. {
  62. ActivateClass activateClass = new ActivateClass();
  63. activateClass.SetUpICardEffect("Suspend 1 of your opponent's Digimon.", CanUseCondition, card);
  64. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  65. cardEffects.Add(activateClass);
  66. string EffectDiscription()
  67. {
  68. return "[On Play] Suspend 1 of your opponent's Digimon. Then, if this Digimon's stack has 2 or more same-level cards, return 1 of your opponent's suspended Digimon with the lowest DP to the hand.";
  69. }
  70. bool CanUseCondition(Hashtable hashtable)
  71. {
  72. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  73. }
  74. bool CanActivateCondition(Hashtable hashtable)
  75. {
  76. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  77. CardEffectCommons.HasMatchConditionPermanent(OpponentsDigimon);
  78. }
  79. //Activate effect
  80. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  81. {
  82. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  83. selectPermanentEffect.SetUp(
  84. selectPlayer: card.Owner,
  85. canTargetCondition: OpponentsDigimon,
  86. canTargetCondition_ByPreSelecetedList: null,
  87. canEndSelectCondition: null,
  88. maxCount: 1,
  89. canNoSelect: false,
  90. canEndNotMax: false,
  91. selectPermanentCoroutine: null,
  92. afterSelectPermanentCoroutine: null,
  93. mode: SelectPermanentEffect.Mode.Tap,
  94. cardEffect: activateClass);
  95. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  96. if (CanSelectPermanentCondition(card.PermanentOfThisCard()))
  97. {
  98. if (CardEffectCommons.HasMatchConditionPermanent(IsMinDPSuspended))
  99. {
  100. SelectPermanentEffect selectPermanentEffect1 = GManager.instance.GetComponent<SelectPermanentEffect>();
  101. selectPermanentEffect1.SetUp(
  102. selectPlayer: card.Owner,
  103. canTargetCondition: IsMinDPSuspended,
  104. canTargetCondition_ByPreSelecetedList: null,
  105. canEndSelectCondition: null,
  106. maxCount: 1,
  107. canNoSelect: false,
  108. canEndNotMax: false,
  109. selectPermanentCoroutine: null,
  110. afterSelectPermanentCoroutine: null,
  111. mode: SelectPermanentEffect.Mode.Bounce,
  112. cardEffect: activateClass);
  113. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect1.Activate());
  114. }
  115. }
  116. }
  117. }
  118. #endregion
  119. #region When Digivolving
  120. if (timing == EffectTiming.OnEnterFieldAnyone)
  121. {
  122. ActivateClass activateClass = new ActivateClass();
  123. activateClass.SetUpICardEffect("Suspend 1 of your opponent's Digimon.", CanUseCondition, card);
  124. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  125. cardEffects.Add(activateClass);
  126. string EffectDiscription()
  127. {
  128. return "[When Digivolving] Suspend 1 of your opponent's Digimon. Then, if this Digimon's stack has 2 or more same-level cards, return 1 of your opponent's suspended Digimon with the lowest DP to the hand.";
  129. }
  130. bool CanUseCondition(Hashtable hashtable)
  131. {
  132. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  133. CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  134. }
  135. bool CanActivateCondition(Hashtable hashtable)
  136. {
  137. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  138. CardEffectCommons.HasMatchConditionPermanent(OpponentsDigimon);
  139. }
  140. //Activate effect
  141. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  142. {
  143. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  144. selectPermanentEffect.SetUp(
  145. selectPlayer: card.Owner,
  146. canTargetCondition: OpponentsDigimon,
  147. canTargetCondition_ByPreSelecetedList: null,
  148. canEndSelectCondition: null,
  149. maxCount: 1,
  150. canNoSelect: false,
  151. canEndNotMax: false,
  152. selectPermanentCoroutine: null,
  153. afterSelectPermanentCoroutine: null,
  154. mode: SelectPermanentEffect.Mode.Tap,
  155. cardEffect: activateClass);
  156. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  157. if (CanSelectPermanentCondition(card.PermanentOfThisCard()))
  158. {
  159. if (CardEffectCommons.HasMatchConditionPermanent(IsMinDPSuspended))
  160. {
  161. SelectPermanentEffect selectPermanentEffect1 = GManager.instance.GetComponent<SelectPermanentEffect>();
  162. selectPermanentEffect1.SetUp(
  163. selectPlayer: card.Owner,
  164. canTargetCondition: IsMinDPSuspended,
  165. canTargetCondition_ByPreSelecetedList: null,
  166. canEndSelectCondition: null,
  167. maxCount: 1,
  168. canNoSelect: false,
  169. canEndNotMax: false,
  170. selectPermanentCoroutine: null,
  171. afterSelectPermanentCoroutine: null,
  172. mode: SelectPermanentEffect.Mode.Bounce,
  173. cardEffect: activateClass);
  174. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect1.Activate());
  175. }
  176. }
  177. }
  178. }
  179. #endregion
  180. #region ESS
  181. if (timing == EffectTiming.OnEndBattle)
  182. {
  183. ActivateClass activateClass = new ActivateClass();
  184. activateClass.SetUpICardEffect("Trash top security", CanUseCondition, card);
  185. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  186. activateClass.SetHashString("TrashSecurity_BT22-051");
  187. activateClass.SetIsInheritedEffect(true);
  188. cardEffects.Add(activateClass);
  189. string EffectDiscription()
  190. {
  191. return "[All Turns] [Once Per Turn] When this Digimon deletes your opponent's Digimon in battle, trash their top security card.";
  192. }
  193. bool WinnerCondition(Permanent permanent) => permanent.cardSources.Contains(card);
  194. bool LoserCondition(Permanent permanent) => CardEffectCommons.IsOpponentPermanent(permanent, card);
  195. bool CanUseCondition(Hashtable hashtable)
  196. {
  197. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  198. CardEffectCommons.CanTriggerWhenDeleteOpponentDigimonByBattle(hashtable: hashtable,
  199. winnerCondition: WinnerCondition, loserCondition: LoserCondition, isOnlyWinnerSurvive: false);
  200. }
  201. bool CanActivateCondition(Hashtable hashtable)
  202. {
  203. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  204. }
  205. IEnumerator ActivateCoroutine(Hashtable hashtable)
  206. {
  207. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  208. player: card.Owner.Enemy,
  209. destroySecurityCount: 1,
  210. cardEffect: activateClass,
  211. fromTop: true).DestroySecurity());
  212. }
  213. }
  214. #endregion
  215. return cardEffects;
  216. }
  217. }
  218. }