BT21_045.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. namespace DCGO.CardEffects.BT21
  5. {
  6. public class BT21_045 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region Alternative Digivolution Condition
  12. if (timing == EffectTiming.None)
  13. {
  14. bool PermanentCondition(Permanent targetPermanent)
  15. {
  16. return (targetPermanent.TopCard.ContainsCardName("RizeGreymon") || targetPermanent.TopCard.EqualsTraits("Hero")) && targetPermanent.TopCard.HasLevel && targetPermanent.TopCard.Level == 5;
  17. }
  18. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  19. }
  20. #endregion
  21. #region Raid
  22. if (timing == EffectTiming.OnAllyAttack)
  23. {
  24. cardEffects.Add(CardEffectFactory.RaidSelfEffect(isInheritedEffect: false, card: card, condition: null));
  25. }
  26. #endregion
  27. #region When Digivolving
  28. if (timing == EffectTiming.OnEnterFieldAnyone)
  29. {
  30. ActivateClass activateClass = new ActivateClass();
  31. activateClass.SetUpICardEffect("Delete 1 Digimon with 9000 DP or less", CanUseCondition, card);
  32. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  33. activateClass.SetHashString("Delete_BT21_045");
  34. cardEffects.Add(activateClass);
  35. string EffectDiscription()
  36. {
  37. return "[When Digivolving][Once Per Turn] You may delete 1 of your opponent's Digimon with 9000 DP or less.";
  38. }
  39. bool CanSelectPermanentCondition(Permanent permanent)
  40. {
  41. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  42. {
  43. if (permanent.DP <= card.Owner.MaxDP_DeleteEffect(9000, activateClass))
  44. {
  45. return true;
  46. }
  47. }
  48. return false;
  49. }
  50. bool CanUseCondition(Hashtable hashtable)
  51. {
  52. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) && CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  53. }
  54. bool CanActivateCondition(Hashtable hashtable)
  55. {
  56. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  57. {
  58. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  59. {
  60. return true;
  61. }
  62. }
  63. return false;
  64. }
  65. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  66. {
  67. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  68. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  69. selectPermanentEffect.SetUp(
  70. selectPlayer: card.Owner,
  71. canTargetCondition: CanSelectPermanentCondition,
  72. canTargetCondition_ByPreSelecetedList: null,
  73. canEndSelectCondition: null,
  74. maxCount: maxCount,
  75. canNoSelect: false,
  76. canEndNotMax: false,
  77. selectPermanentCoroutine: null,
  78. afterSelectPermanentCoroutine: null,
  79. mode: SelectPermanentEffect.Mode.Destroy,
  80. cardEffect: activateClass);
  81. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  82. }
  83. }
  84. #endregion
  85. #region When Attacking
  86. if (timing == EffectTiming.OnAllyAttack)
  87. {
  88. ActivateClass activateClass = new ActivateClass();
  89. activateClass.SetUpICardEffect("Delete 1 Digimon with 9000 DP or less", CanUseCondition, card);
  90. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  91. activateClass.SetHashString("Delete_BT21_045");
  92. cardEffects.Add(activateClass);
  93. string EffectDiscription()
  94. {
  95. return "[When Attacking][Once Per Turn] You may delete 1 of your opponent's Digimon with 9000 DP or less.";
  96. }
  97. bool CanSelectPermanentCondition(Permanent permanent)
  98. {
  99. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card))
  100. {
  101. if (permanent.DP <= card.Owner.MaxDP_DeleteEffect(9000, activateClass))
  102. {
  103. return true;
  104. }
  105. }
  106. return false;
  107. }
  108. bool CanUseCondition(Hashtable hashtable)
  109. {
  110. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  111. }
  112. bool CanActivateCondition(Hashtable hashtable)
  113. {
  114. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  115. {
  116. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  117. {
  118. return true;
  119. }
  120. }
  121. return false;
  122. }
  123. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  124. {
  125. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  126. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  127. selectPermanentEffect.SetUp(
  128. selectPlayer: card.Owner,
  129. canTargetCondition: CanSelectPermanentCondition,
  130. canTargetCondition_ByPreSelecetedList: null,
  131. canEndSelectCondition: null,
  132. maxCount: maxCount,
  133. canNoSelect: false,
  134. canEndNotMax: false,
  135. selectPermanentCoroutine: null,
  136. afterSelectPermanentCoroutine: null,
  137. mode: SelectPermanentEffect.Mode.Destroy,
  138. cardEffect: activateClass);
  139. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  140. }
  141. }
  142. #endregion
  143. #region Second When Attacking
  144. if (timing == EffectTiming.OnAllyAttack)
  145. {
  146. ActivateClass activateClass = new ActivateClass();
  147. activateClass.SetUpICardEffect("Suspend one tamer to gain Security Attack +1 and +3000 DP", CanUseCondition, card);
  148. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  149. activateClass.SetHashString("Suspend_BT21_045");
  150. cardEffects.Add(activateClass);
  151. string EffectDiscription()
  152. {
  153. return "[When Attacking][Once Per Turn] By suspending 1 of your yellow or red Tamers, this Digimon gains <Security Attack +1> and +3000 DP for the turn.";
  154. }
  155. bool CanSelectPermanentCondition(Permanent permanent)
  156. {
  157. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card))
  158. {
  159. if (permanent.IsTamer && permanent.TopCard.CardColors.Contains(CardColor.Yellow) ||
  160. permanent.IsTamer && permanent.TopCard.CardColors.Contains(CardColor.Red))
  161. {
  162. return true;
  163. }
  164. }
  165. return false;
  166. }
  167. bool CanUseCondition(Hashtable hashtable)
  168. {
  169. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  170. }
  171. bool CanActivateCondition(Hashtable hashtable)
  172. {
  173. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  174. {
  175. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  176. {
  177. return true;
  178. }
  179. }
  180. return false;
  181. }
  182. IEnumerator ActivateCoroutine(Hashtable hashtable)
  183. {
  184. Permanent selectedPermanent = null;
  185. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  186. {
  187. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  188. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  189. selectPermanentEffect.SetUp(
  190. selectPlayer: card.Owner,
  191. canTargetCondition: CanSelectPermanentCondition,
  192. canTargetCondition_ByPreSelecetedList: null,
  193. canEndSelectCondition: null,
  194. maxCount: maxCount,
  195. canNoSelect: true,
  196. canEndNotMax: false,
  197. selectPermanentCoroutine: SelectPermanentCoroutine,
  198. afterSelectPermanentCoroutine: null,
  199. mode: SelectPermanentEffect.Mode.Custom,
  200. cardEffect: activateClass);
  201. selectPermanentEffect.SetUpCustomMessage("Select 1 your Yellow or Red Tamers to suspend.", "The opponent is selecting 1 Tamer to suspend.");
  202. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  203. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  204. {
  205. selectedPermanent = permanent;
  206. yield return null;
  207. }
  208. }
  209. if (selectedPermanent != null)
  210. {
  211. if (selectedPermanent.TopCard != null)
  212. {
  213. if (!selectedPermanent.TopCard.CanNotBeAffected(activateClass))
  214. {
  215. if (!selectedPermanent.IsSuspended && selectedPermanent.CanSuspend)
  216. {
  217. Permanent suspendTargetPermanent = selectedPermanent;
  218. yield return ContinuousController.instance.StartCoroutine(new SuspendPermanentsClass(new List<Permanent>() { suspendTargetPermanent }, CardEffectCommons.CardEffectHashtable(activateClass)).Tap());
  219. if (suspendTargetPermanent.TopCard != null)
  220. {
  221. if (suspendTargetPermanent.IsSuspended)
  222. {
  223. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonSAttack(targetPermanent: card.PermanentOfThisCard(), changeValue: 1, effectDuration: EffectDuration.UntilEachTurnEnd, activateClass: activateClass));
  224. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(targetPermanent: card.PermanentOfThisCard(), changeValue: 3000, effectDuration: EffectDuration.UntilEachTurnEnd, activateClass: activateClass));
  225. }
  226. }
  227. }
  228. }
  229. }
  230. }
  231. }
  232. }
  233. #endregion
  234. return cardEffects;
  235. }
  236. }
  237. }