BT24_047.cs 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System;
  5. // Kokatorimon
  6. namespace DCGO.CardEffects.BT24
  7. {
  8. public class BT24_047 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Shared OP/WD
  14. string SharedEffectName = "May suspend, if your traited digimon it may unsuspend, if do it may attack.";
  15. string SharedEffectDescription(string tag) => $"[{tag}] You may suspend 1 Digimon. If this effect suspended your Digimon, 1 of your Digimon with [Avian] or [Bird] in any of its traits or the [Vortex Warriors] trait unsuspends. If this effect unsuspended, that Digimon may attack.";
  16. bool SharedCanActivateCondition(Hashtable hashtable)
  17. {
  18. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  19. }
  20. bool CanSelectSuspendPermanentCondition(Permanent permanent)
  21. {
  22. return CardEffectCommons.IsPermanentExistsOnBattleAreaDigimon(permanent);
  23. }
  24. bool CanSelectUnsuspendPermanentCondition(Permanent permanent)
  25. {
  26. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  27. && (permanent.TopCard.ContainsTraits("Avian")
  28. || permanent.TopCard.ContainsTraits("Bird")
  29. || permanent.TopCard.EqualsTraits("Vortex Warriors"));
  30. }
  31. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  32. {
  33. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectSuspendPermanentCondition))
  34. {
  35. Permanent selectedPermanent = null;
  36. bool ownDigimon = false;
  37. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  38. selectPermanentEffect.SetUp(
  39. selectPlayer: card.Owner,
  40. canTargetCondition: CanSelectSuspendPermanentCondition,
  41. canTargetCondition_ByPreSelecetedList: null,
  42. canEndSelectCondition: null,
  43. maxCount: 1,
  44. canNoSelect: true,
  45. canEndNotMax: false,
  46. selectPermanentCoroutine: SelectPermanentCoroutine,
  47. afterSelectPermanentCoroutine: null,
  48. mode: SelectPermanentEffect.Mode.Custom,
  49. cardEffect: activateClass);
  50. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  51. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  52. {
  53. selectedPermanent = permanent;
  54. yield return null;
  55. }
  56. if (selectedPermanent != null &&
  57. selectedPermanent.TopCard &&
  58. !selectedPermanent.TopCard.CanNotBeAffected(activateClass) &&
  59. !selectedPermanent.IsSuspended && selectedPermanent.CanSuspend)
  60. {
  61. yield return ContinuousController.instance.StartCoroutine(
  62. new SuspendPermanentsClass(new List<Permanent>() { selectedPermanent },
  63. CardEffectCommons.CardEffectHashtable(activateClass)).Tap());
  64. ownDigimon = selectedPermanent.IsSuspended &&
  65. CardEffectCommons.IsOwnerPermanent(selectedPermanent, card);
  66. }
  67. if (ownDigimon)
  68. {
  69. bool unsuspend = false;
  70. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectUnsuspendPermanentCondition));
  71. selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  72. selectPermanentEffect.SetUp(
  73. selectPlayer: card.Owner,
  74. canTargetCondition: CanSelectUnsuspendPermanentCondition,
  75. canTargetCondition_ByPreSelecetedList: null,
  76. canEndSelectCondition: null,
  77. maxCount: maxCount,
  78. canNoSelect: false,
  79. canEndNotMax: false,
  80. selectPermanentCoroutine: SelectPermanentCoroutine1,
  81. afterSelectPermanentCoroutine: null,
  82. mode: SelectPermanentEffect.Mode.Custom,
  83. cardEffect: activateClass);
  84. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  85. IEnumerator SelectPermanentCoroutine1(Permanent permanent)
  86. {
  87. selectedPermanent = permanent;
  88. yield return null;
  89. }
  90. if (selectedPermanent != null &&
  91. selectedPermanent.TopCard &&
  92. !selectedPermanent.TopCard.CanNotBeAffected(activateClass) &&
  93. selectedPermanent.IsSuspended)
  94. {
  95. yield return ContinuousController.instance.StartCoroutine(
  96. new IUnsuspendPermanents(new List<Permanent>() { selectedPermanent },
  97. activateClass).Unsuspend());
  98. unsuspend = !selectedPermanent.IsSuspended;
  99. }
  100. if(unsuspend && selectedPermanent.CanAttack(activateClass))
  101. {
  102. SelectAttackEffect selectAttackEffect = GManager.instance.GetComponent<SelectAttackEffect>();
  103. selectAttackEffect.SetUp(
  104. attacker: selectedPermanent,
  105. canAttackPlayerCondition: () => true,
  106. defenderCondition: _ => true,
  107. cardEffect: activateClass);
  108. yield return ContinuousController.instance.StartCoroutine(selectAttackEffect.Activate());
  109. }
  110. }
  111. }
  112. }
  113. #endregion
  114. #region On Play
  115. if (timing == EffectTiming.OnEnterFieldAnyone)
  116. {
  117. ActivateClass activateClass = new ActivateClass();
  118. activateClass.SetUpICardEffect(SharedEffectName, CanUseCondition, card);
  119. activateClass.SetUpActivateClass(SharedCanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), -1, true, SharedEffectDescription("On Play"));
  120. cardEffects.Add(activateClass);
  121. bool CanUseCondition(Hashtable hashtable)
  122. {
  123. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  124. && CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  125. }
  126. }
  127. #endregion
  128. #region When Digivolving
  129. if (timing == EffectTiming.OnEnterFieldAnyone)
  130. {
  131. ActivateClass activateClass = new ActivateClass();
  132. activateClass.SetUpICardEffect(SharedEffectName, CanUseCondition, card);
  133. activateClass.SetUpActivateClass(SharedCanActivateCondition, hash => SharedActivateCoroutine(hash, activateClass), -1, true, SharedEffectDescription("When Digivolving"));
  134. cardEffects.Add(activateClass);
  135. bool CanUseCondition(Hashtable hashtable)
  136. {
  137. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  138. && CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  139. }
  140. }
  141. #endregion
  142. #region All Turns - ESS
  143. if (timing == EffectTiming.OnEndBattle)
  144. {
  145. ActivateClass activateClass = new ActivateClass();
  146. activateClass.SetUpICardEffect("Memory +1", CanUseCondition, card);
  147. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDescription());
  148. activateClass.SetIsInheritedEffect(true);
  149. activateClass.SetHashString("BT24_047_Inherited");
  150. cardEffects.Add(activateClass);
  151. string EffectDescription()
  152. {
  153. return "[All Turns] [Once Per Turn] When this Digimon deletes your opponent's Digimon in battle, gain 1 memory.";
  154. }
  155. bool WinnerCondition(Permanent permanent) => permanent.cardSources.Contains(card);
  156. bool LoserCondition(Permanent permanent) => CardEffectCommons.IsOpponentPermanent(permanent, card);
  157. bool CanUseCondition(Hashtable hashtable)
  158. {
  159. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  160. CardEffectCommons.CanTriggerWhenDeleteOpponentDigimonByBattle(hashtable: hashtable,
  161. winnerCondition: WinnerCondition, loserCondition: LoserCondition, isOnlyWinnerSurvive: false);
  162. }
  163. bool CanActivateCondition(Hashtable hashtable)
  164. {
  165. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  166. }
  167. IEnumerator ActivateCoroutine(Hashtable hashtable)
  168. {
  169. yield return ContinuousController.instance.StartCoroutine(card.Owner.AddMemory(1, activateClass));
  170. }
  171. }
  172. #endregion
  173. return cardEffects;
  174. }
  175. }
  176. }