BT16_025.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace DCGO.CardEffects.BT16
  5. {
  6. public class BT16_025 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. List<PartitionCondition> partitionConditions = new List<PartitionCondition>();
  12. partitionConditions.Add(new PartitionCondition(4, CardColor.Blue));
  13. partitionConditions.Add(new PartitionCondition(4, CardColor.Green));
  14. #region Partition - Inherited
  15. if (timing == EffectTiming.WhenRemoveField)
  16. {
  17. cardEffects.Add(CardEffectFactory.PartitionSelfEffect
  18. (isInheritedEffect: false,
  19. card: card,
  20. condition: null,
  21. cardSourceConditions: partitionConditions));
  22. cardEffects.Add(CardEffectFactory.PartitionSelfEffect
  23. (isInheritedEffect: true,
  24. card: card,
  25. condition: null,
  26. cardSourceConditions: partitionConditions));
  27. }
  28. #endregion
  29. #region DNA
  30. if (timing == EffectTiming.None)
  31. {
  32. AddJogressConditionClass addJogressConditionClass = new AddJogressConditionClass();
  33. addJogressConditionClass.SetUpICardEffect($"DNA Digivolution", CanUseCondition, card);
  34. addJogressConditionClass.SetUpAddJogressConditionClass(getJogressCondition: GetJogress);
  35. addJogressConditionClass.SetNotShowUI(true);
  36. cardEffects.Add(addJogressConditionClass);
  37. bool CanUseCondition(Hashtable hashtable)
  38. {
  39. return true;
  40. }
  41. JogressCondition GetJogress(CardSource cardSource)
  42. {
  43. if (cardSource == card)
  44. {
  45. bool PermanentCondition1(Permanent permanent)
  46. {
  47. if (permanent != null)
  48. {
  49. if (permanent.TopCard != null)
  50. {
  51. if (permanent.TopCard.Owner == card.Owner)
  52. {
  53. if (permanent.IsDigimon)
  54. {
  55. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  56. {
  57. if (permanent.TopCard.CardColors.Contains(CardColor.Blue))
  58. {
  59. if (permanent.Levels_ForJogress(card).Contains(4))
  60. {
  61. return true;
  62. }
  63. }
  64. }
  65. }
  66. }
  67. }
  68. }
  69. return false;
  70. }
  71. bool PermanentCondition2(Permanent permanent)
  72. {
  73. if (permanent != null)
  74. {
  75. if (permanent.TopCard != null)
  76. {
  77. if (permanent.TopCard.Owner == card.Owner)
  78. {
  79. if (permanent.IsDigimon)
  80. {
  81. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  82. {
  83. if (permanent.TopCard.CardColors.Contains(CardColor.Green))
  84. {
  85. if (permanent.Levels_ForJogress(card).Contains(4))
  86. {
  87. return true;
  88. }
  89. }
  90. }
  91. }
  92. }
  93. }
  94. }
  95. return false;
  96. }
  97. JogressConditionElement[] elements = new JogressConditionElement[]
  98. {
  99. new JogressConditionElement(PermanentCondition1, "a level 4 Blue Digimon"),
  100. new JogressConditionElement(PermanentCondition2, "a level 4 Green Digimon"),
  101. };
  102. JogressCondition jogressCondition = new JogressCondition(elements, 0);
  103. return jogressCondition;
  104. }
  105. return null;
  106. }
  107. }
  108. #endregion
  109. #region When Digivolving
  110. if (timing == EffectTiming.OnEnterFieldAnyone)
  111. {
  112. ActivateClass activateClass = new ActivateClass();
  113. activateClass.SetUpICardEffect("Suspend all your opponent's digimon", CanUseCondition, card);
  114. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  115. cardEffects.Add(activateClass);
  116. string EffectDiscription()
  117. {
  118. return "[When Digivolving] Suspend all of your opponent's Digimon with as many or fewer digivolution cards as this Digimon. Then, if DNA digivolving, none of your opponent's Digimon can unsuspend until the end of their turn.";
  119. }
  120. bool PermanentCondition(Permanent permanent)
  121. {
  122. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  123. {
  124. if (!permanent.TopCard.CanNotBeAffected(activateClass))
  125. {
  126. return true;
  127. }
  128. }
  129. return false;
  130. }
  131. bool CanUseCondition(Hashtable hashtable)
  132. {
  133. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  134. }
  135. bool CanActivateCondition(Hashtable hashtable)
  136. {
  137. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  138. }
  139. IEnumerator ActivateCoroutine(Hashtable hashtable)
  140. {
  141. List<Permanent> oppenentDigimon = card.Owner.Enemy.GetBattleAreaDigimons();
  142. List<Permanent> opponentSuspendable = oppenentDigimon.Where(permanent =>
  143. permanent.DigivolutionCards.Count <= card.PermanentOfThisCard().DigivolutionCards.Count &&
  144. PermanentCondition(permanent)).ToList();
  145. yield return ContinuousController.instance.StartCoroutine(new SuspendPermanentsClass(opponentSuspendable, hashtable).Tap());
  146. if (CardEffectCommons.IsJogress(hashtable))
  147. {
  148. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainCanNotUnsuspendPlayerEffect(
  149. permanentCondition: PermanentCondition,
  150. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  151. activateClass: activateClass,
  152. isOnlyActivePhase: false,
  153. effectName: "Your Digimon can't unsuspend"));
  154. }
  155. yield return null;
  156. }
  157. }
  158. #endregion
  159. #region When Attacking
  160. if (timing == EffectTiming.OnAllyAttack)
  161. {
  162. ActivateClass activateClass = new ActivateClass();
  163. activateClass.SetUpICardEffect("Suspend 1 opponent's digimon or unsuspend this digimon", CanUseCondition, card);
  164. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  165. activateClass.SetHashString("WhenAttacking_BT16_025");
  166. cardEffects.Add(activateClass);
  167. string EffectDiscription()
  168. {
  169. return "[When Attacking] [Once Per Turn] Suspend 1 of your opponent's unsuspended Digimon. If this effect didn't suspend, unsuspend this Digimon.";
  170. }
  171. bool CanSelectPermanentCondition(Permanent permanent)
  172. {
  173. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  174. {
  175. if (!permanent.TopCard.CanNotBeAffected(activateClass))
  176. {
  177. if (!permanent.IsSuspended && permanent.CanSuspend)
  178. {
  179. return true;
  180. }
  181. }
  182. }
  183. return false;
  184. }
  185. bool CanUseCondition(Hashtable hashtable)
  186. {
  187. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  188. }
  189. bool CanActivateCondition(Hashtable hashtable)
  190. {
  191. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  192. }
  193. IEnumerator ActivateCoroutine(Hashtable hashtable)
  194. {
  195. Permanent selectedPermanent = null;
  196. bool suspendedPermanent = false;
  197. if (CardEffectCommons.HasMatchConditionOpponentsPermanent(card, CanSelectPermanentCondition))
  198. {
  199. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  200. selectPermanentEffect.SetUp(
  201. selectPlayer: card.Owner,
  202. canTargetCondition_ByPreSelecetedList: null,
  203. canTargetCondition: CanSelectPermanentCondition,
  204. canEndSelectCondition: null,
  205. maxCount: 1,
  206. canNoSelect: false,
  207. canEndNotMax: false,
  208. selectPermanentCoroutine: SelectPermanentCoroutine,
  209. afterSelectPermanentCoroutine: null,
  210. mode: SelectPermanentEffect.Mode.Tap,
  211. cardEffect: activateClass);
  212. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to suspend.", "The opponent is selecting 1 Digimon to suspend.");
  213. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  214. }
  215. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  216. {
  217. selectedPermanent = permanent;
  218. suspendedPermanent = true;
  219. yield return null;
  220. }
  221. if (!suspendedPermanent)
  222. {
  223. yield return ContinuousController.instance.StartCoroutine(new IUnsuspendPermanents(new List<Permanent>() { card.PermanentOfThisCard() }, activateClass).Unsuspend());
  224. }
  225. }
  226. }
  227. #endregion
  228. return cardEffects;
  229. }
  230. }
  231. }