BT20_067.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. namespace DCGO.CardEffects.BT20
  5. {
  6. public class BT20_067 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region On Play
  12. if (timing == EffectTiming.OnEnterFieldAnyone)
  13. {
  14. ActivateClass activateClass = new ActivateClass();
  15. activateClass.SetUpICardEffect("Your 1 Digimon gains <Retaliation>", CanUseCondition, card);
  16. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  17. cardEffects.Add(activateClass);
  18. string EffectDiscription()
  19. {
  20. return
  21. "[On Play] 1 of your Digimon gains <Retaliation> (When this Digimon is deleted after losing a battle, delete the Digimon it was battling), until the end of your opponent's turn.";
  22. }
  23. bool CanSelectPermanentCondition(Permanent permanent)
  24. {
  25. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  26. }
  27. bool CanUseCondition(Hashtable hashtable)
  28. {
  29. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  30. }
  31. bool CanActivateCondition(Hashtable hashtable)
  32. {
  33. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  34. {
  35. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  36. {
  37. return true;
  38. }
  39. }
  40. return false;
  41. }
  42. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  43. {
  44. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  45. {
  46. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  47. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  48. selectPermanentEffect.SetUp(
  49. selectPlayer: card.Owner,
  50. canTargetCondition: CanSelectPermanentCondition,
  51. canTargetCondition_ByPreSelecetedList: null,
  52. canEndSelectCondition: null,
  53. maxCount: maxCount,
  54. canNoSelect: false,
  55. canEndNotMax: false,
  56. selectPermanentCoroutine: SelectPermanentCoroutine,
  57. afterSelectPermanentCoroutine: null,
  58. mode: SelectPermanentEffect.Mode.Custom,
  59. cardEffect: activateClass);
  60. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get <Retaliation>.",
  61. "The opponent is selecting 1 Digimon that will get <Retaliation>.");
  62. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  63. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  64. {
  65. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainRetaliation(
  66. targetPermanent: permanent,
  67. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  68. activateClass: activateClass));
  69. }
  70. }
  71. }
  72. }
  73. #endregion
  74. #region When Digivolving
  75. if (timing == EffectTiming.OnEnterFieldAnyone)
  76. {
  77. ActivateClass activateClass = new ActivateClass();
  78. activateClass.SetUpICardEffect("Your 1 Digimon gains <Retaliation>", CanUseCondition, card);
  79. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  80. cardEffects.Add(activateClass);
  81. string EffectDiscription()
  82. {
  83. return
  84. "[When Digivolving] 1 of your Digimon gains <Retaliation> (When this Digimon is deleted after losing a battle, delete the Digimon it was battling), until the end of your opponent's turn.";
  85. }
  86. bool CanSelectPermanentCondition(Permanent permanent)
  87. {
  88. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  89. }
  90. bool CanUseCondition(Hashtable hashtable)
  91. {
  92. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  93. }
  94. bool CanActivateCondition(Hashtable hashtable)
  95. {
  96. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  97. {
  98. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  99. {
  100. return true;
  101. }
  102. }
  103. return false;
  104. }
  105. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  106. {
  107. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  108. {
  109. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  110. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  111. selectPermanentEffect.SetUp(
  112. selectPlayer: card.Owner,
  113. canTargetCondition: CanSelectPermanentCondition,
  114. canTargetCondition_ByPreSelecetedList: null,
  115. canEndSelectCondition: null,
  116. maxCount: maxCount,
  117. canNoSelect: false,
  118. canEndNotMax: false,
  119. selectPermanentCoroutine: SelectPermanentCoroutine,
  120. afterSelectPermanentCoroutine: null,
  121. mode: SelectPermanentEffect.Mode.Custom,
  122. cardEffect: activateClass);
  123. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get <Retaliation>.",
  124. "The opponent is selecting 1 Digimon that will get <Retaliation>.");
  125. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  126. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  127. {
  128. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainRetaliation(
  129. targetPermanent: permanent,
  130. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  131. activateClass: activateClass));
  132. }
  133. }
  134. }
  135. }
  136. #endregion
  137. #region On Deletion - ESS
  138. if (timing == EffectTiming.OnDestroyedAnyone)
  139. {
  140. ActivateClass activateClass = new ActivateClass();
  141. activateClass.SetUpICardEffect("Trash 1 card from hand to delete 1 of your opponent's level 4 or lower Digimon",
  142. CanUseCondition, card);
  143. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription());
  144. activateClass.SetIsInheritedEffect(true);
  145. cardEffects.Add(activateClass);
  146. string EffectDescription()
  147. {
  148. return
  149. "[On Deletion] By trashing 1 card in your hand, delete 1 of your opponent's level 4 or lower Digimon.";
  150. }
  151. bool CanSelectOpponentPermanentCondition(Permanent permanent)
  152. {
  153. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card) &&
  154. permanent.IsDigimon &&
  155. permanent.TopCard.HasLevel &&
  156. permanent.Level <= 4;
  157. }
  158. bool CanUseCondition(Hashtable hashtable)
  159. {
  160. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  161. }
  162. bool CanActivateCondition(Hashtable hashtable)
  163. {
  164. return CardEffectCommons.CanActivateOnDeletion(card, activateClass) &&
  165. card.Owner.HandCards.Count >= 1;
  166. }
  167. IEnumerator ActivateCoroutine(Hashtable hashtable)
  168. {
  169. bool discarded = false;
  170. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  171. selectHandEffect.SetUp(
  172. canTargetCondition: _ => true,
  173. canTargetCondition_ByPreSelecetedList: null,
  174. canEndSelectCondition: null,
  175. canNoSelect: true,
  176. selectCardCoroutine: null,
  177. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  178. maxCount: 1,
  179. canEndNotMax: false,
  180. isShowOpponent: true,
  181. mode: SelectHandEffect.Mode.Discard,
  182. selectPlayer: card.Owner,
  183. cardEffect: activateClass);
  184. selectHandEffect.SetUpCustomMessage("Select 1 card to discard.",
  185. "The opponent is selecting 1 card to discard.");
  186. yield return StartCoroutine(selectHandEffect.Activate());
  187. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  188. {
  189. discarded = cardSources.Count > 0;
  190. yield return null;
  191. }
  192. if (discarded && CardEffectCommons.HasMatchConditionPermanent(CanSelectOpponentPermanentCondition))
  193. {
  194. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  195. selectPermanentEffect.SetUp(
  196. selectPlayer: card.Owner,
  197. canTargetCondition: CanSelectOpponentPermanentCondition,
  198. canTargetCondition_ByPreSelecetedList: null,
  199. canEndSelectCondition: null,
  200. maxCount: 1,
  201. canNoSelect: false,
  202. canEndNotMax: false,
  203. selectPermanentCoroutine: null,
  204. afterSelectPermanentCoroutine: null,
  205. mode: SelectPermanentEffect.Mode.Destroy,
  206. cardEffect: activateClass);
  207. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.",
  208. "The opponent is selecting 1 Digimon to delete.");
  209. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  210. }
  211. }
  212. }
  213. #endregion
  214. return cardEffects;
  215. }
  216. }
  217. }