BT12_057.cs 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. namespace DCGO.CardEffects.BT12
  5. {
  6. public class BT12_057 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. if (timing == EffectTiming.None)
  12. {
  13. bool PermanentCondition(Permanent targetPermanent)
  14. {
  15. return targetPermanent.TopCard.HasSaveText && targetPermanent.TopCard.HasLevel && targetPermanent.TopCard.Level == 5;
  16. }
  17. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  18. permanentCondition: PermanentCondition,
  19. digivolutionCost: 9,
  20. ignoreDigivolutionRequirement: false,
  21. card: card,
  22. condition: null));
  23. }
  24. if (timing == EffectTiming.OnEnterFieldAnyone)
  25. {
  26. ActivateClass activateClass = new ActivateClass();
  27. activateClass.SetUpICardEffect("Suspend Digimon and Tamer, and gain Memory", CanUseCondition, card);
  28. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  29. cardEffects.Add(activateClass);
  30. string EffectDiscription()
  31. {
  32. return "[When Digivolving] Suspend all Digimon except this one, and suspend all of you and your opponent's Tamers. Then, for every 2 suspended Digimon and Tamers, gain 1 memory.";
  33. }
  34. bool CanSelectPermanentCondition(Permanent permanent)
  35. {
  36. if (CardEffectCommons.IsPermanentExistsOnBattleArea(permanent))
  37. {
  38. if (permanent != card.PermanentOfThisCard())
  39. {
  40. if (!permanent.TopCard.CanNotBeAffected(activateClass))
  41. {
  42. if (permanent.IsDigimon)
  43. {
  44. return true;
  45. }
  46. if (permanent.IsTamer)
  47. {
  48. return true;
  49. }
  50. }
  51. }
  52. }
  53. return false;
  54. }
  55. bool PermanentCondition(Permanent permanent)
  56. {
  57. if (CardEffectCommons.IsPermanentExistsOnBattleArea(permanent))
  58. {
  59. if (permanent.IsSuspended)
  60. {
  61. if (permanent.IsDigimon || permanent.IsTamer)
  62. {
  63. return true;
  64. }
  65. }
  66. }
  67. return false;
  68. }
  69. bool CanUseCondition(Hashtable hashtable)
  70. {
  71. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  72. }
  73. bool CanActivateCondition(Hashtable hashtable)
  74. {
  75. if (CardEffectCommons.IsExistOnBattleArea(card))
  76. {
  77. return true;
  78. }
  79. return false;
  80. }
  81. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  82. {
  83. List<Permanent> suspendTargetPermanents =
  84. GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer
  85. .Map(player => player.GetBattleAreaPermanents().Filter(CanSelectPermanentCondition))
  86. .Flat();
  87. yield return ContinuousController.instance.StartCoroutine(new SuspendPermanentsClass(suspendTargetPermanents, CardEffectCommons.CardEffectHashtable(activateClass)).Tap());
  88. int permanentCount = CardEffectCommons.MatchConditionPermanentCount(PermanentCondition);
  89. int gainMemory = permanentCount / 2;
  90. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(gainMemory, activateClass));
  91. }
  92. }
  93. if (timing == EffectTiming.None)
  94. {
  95. bool PermanentCondition(Permanent permanent)
  96. {
  97. if (CardEffectCommons.IsPermanentExistsOnBattleArea(permanent))
  98. {
  99. if (permanent != card.PermanentOfThisCard())
  100. {
  101. if (permanent.IsDigimon || permanent.IsTamer)
  102. {
  103. return true;
  104. }
  105. }
  106. }
  107. return false;
  108. }
  109. bool CanUseCondition()
  110. {
  111. return CardEffectCommons.IsExistOnBattleArea(card);
  112. }
  113. string effectName = "All Digimon and Tamer other than this Digimon can't unsuspend";
  114. cardEffects.Add(CardEffectFactory.CantUnsuspendStaticEffect(
  115. permanentCondition: PermanentCondition,
  116. isInheritedEffect: false,
  117. card: card, condition: CanUseCondition,
  118. effectName: effectName));
  119. }
  120. if (timing == EffectTiming.OnAllyAttack)
  121. {
  122. ActivateClass activateClass = new ActivateClass();
  123. activateClass.SetUpICardEffect("Suspend 1 Digimon or Tamer and trash opponent's security", CanUseCondition, card);
  124. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  125. cardEffects.Add(activateClass);
  126. string EffectDiscription()
  127. {
  128. return "[When Attacking] Suspend 1 of your opponent's Digimon or Tamers. Then, trash 1 card from the top of your opponent's security stack for every 5 suspended Digimon and Tamers.";
  129. }
  130. bool CanSelectPermanentCondition(Permanent permanent)
  131. {
  132. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleArea(permanent, card))
  133. {
  134. if (permanent.IsDigimon || permanent.IsTamer)
  135. {
  136. return true;
  137. }
  138. }
  139. return false;
  140. }
  141. bool PermanentCondition(Permanent permanent)
  142. {
  143. if (CardEffectCommons.IsPermanentExistsOnBattleArea(permanent))
  144. {
  145. if (permanent.IsSuspended)
  146. {
  147. if (permanent.IsDigimon || permanent.IsTamer)
  148. {
  149. return true;
  150. }
  151. }
  152. }
  153. return false;
  154. }
  155. bool CanUseCondition(Hashtable hashtable)
  156. {
  157. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  158. }
  159. bool CanActivateCondition(Hashtable hashtable)
  160. {
  161. if (CardEffectCommons.IsExistOnBattleArea(card))
  162. {
  163. return true;
  164. }
  165. return false;
  166. }
  167. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  168. {
  169. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  170. {
  171. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  172. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  173. selectPermanentEffect.SetUp(
  174. selectPlayer: card.Owner,
  175. canTargetCondition: CanSelectPermanentCondition,
  176. canTargetCondition_ByPreSelecetedList: null,
  177. canEndSelectCondition: null,
  178. maxCount: maxCount,
  179. canNoSelect: false,
  180. canEndNotMax: false,
  181. selectPermanentCoroutine: null,
  182. afterSelectPermanentCoroutine: null,
  183. mode: SelectPermanentEffect.Mode.Tap,
  184. cardEffect: activateClass);
  185. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  186. }
  187. int permanentCount = CardEffectCommons.MatchConditionPermanentCount(PermanentCondition);
  188. int trashCount = permanentCount / 5;
  189. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  190. player: card.Owner.Enemy,
  191. destroySecurityCount: trashCount,
  192. cardEffect: activateClass,
  193. fromTop: true).DestroySecurity());
  194. }
  195. }
  196. return cardEffects;
  197. }
  198. }
  199. }