BT18_099.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. namespace DCGO.CardEffects.BT18
  4. {
  5. public class BT18_099 : CEntity_Effect
  6. {
  7. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  8. {
  9. List<ICardEffect> cardEffects = new List<ICardEffect>();
  10. #region Ignore color requirements
  11. if (timing == EffectTiming.None)
  12. {
  13. IgnoreColorConditionClass ignoreColorConditionClass = new IgnoreColorConditionClass();
  14. ignoreColorConditionClass.SetUpICardEffect("Ignore color requirements", CanUseCondition, card);
  15. ignoreColorConditionClass.SetUpIgnoreColorConditionClass(cardCondition: CardCondition);
  16. cardEffects.Add(ignoreColorConditionClass);
  17. bool CanUseCondition(Hashtable hashtable)
  18. {
  19. return CardEffectCommons.HasMatchConditionOwnersPermanent(card,
  20. permanent =>
  21. permanent.IsDigimon &&
  22. permanent.TopCard.HasText("Knightmon"));
  23. }
  24. bool CardCondition(CardSource cardSource)
  25. {
  26. return cardSource == card;
  27. }
  28. }
  29. #endregion
  30. #region Main Effect
  31. if (timing == EffectTiming.OptionSkill)
  32. {
  33. ActivateClass activateClass = new ActivateClass();
  34. activateClass.SetUpICardEffect("1 opponent's Digimon will attack during their next main phase",
  35. CanUseCondition, card);
  36. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDescription());
  37. cardEffects.Add(activateClass);
  38. string EffectDescription()
  39. {
  40. return
  41. "[Main] 1 of your opponent's Digimon gains \"[Start of Your Main Phase] This Digimon attacks.\" until the end of their turn. Then, place this card in the battle area.";
  42. }
  43. bool CanUseCondition(Hashtable hashtable)
  44. {
  45. return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  46. }
  47. bool CanSelectPermanentCondition(Permanent permanent)
  48. {
  49. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  50. }
  51. IEnumerator ActivateCoroutine(Hashtable hashtable)
  52. {
  53. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  54. {
  55. Permanent selectedPermanent = null;
  56. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  57. selectPermanentEffect.SetUp(
  58. selectPlayer: card.Owner,
  59. canTargetCondition: CanSelectPermanentCondition,
  60. canTargetCondition_ByPreSelecetedList: null,
  61. canEndSelectCondition: null,
  62. maxCount: 1,
  63. canNoSelect: false,
  64. canEndNotMax: false,
  65. selectPermanentCoroutine: SelectPermanentCoroutine,
  66. afterSelectPermanentCoroutine: null,
  67. mode: SelectPermanentEffect.Mode.Custom,
  68. cardEffect: activateClass);
  69. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get effects.",
  70. "The opponent is selecting 1 Digimon that will get effects.");
  71. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  72. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  73. {
  74. selectedPermanent = permanent;
  75. yield return null;
  76. }
  77. if (selectedPermanent != null)
  78. {
  79. ActivateClass activateClassDebuff = new ActivateClass();
  80. activateClassDebuff.SetUpICardEffect("Attack with this Digimon", CanUseConditionDebuff,
  81. selectedPermanent.TopCard);
  82. activateClassDebuff.SetUpActivateClass(CanActivateConditionDebuff, ActivateCoroutineDebuff, -1, false,
  83. EffectDescriptionDebuff());
  84. activateClassDebuff.SetEffectSourcePermanent(selectedPermanent);
  85. selectedPermanent.UntilOwnerTurnEndEffects.Add(GetCardEffect);
  86. if (!selectedPermanent.TopCard.CanNotBeAffected(activateClass))
  87. {
  88. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>()
  89. .CreateDebuffEffect(selectedPermanent));
  90. }
  91. string EffectDescriptionDebuff()
  92. {
  93. return "[Start of Your Main Phase] Attack with this Digimon.";
  94. }
  95. bool CanUseConditionDebuff(Hashtable hashtable1)
  96. {
  97. return CardEffectCommons.IsPermanentExistsOnBattleAreaDigimon(selectedPermanent) &&
  98. selectedPermanent.TopCard.Owner.GetBattleAreaDigimons().Contains(selectedPermanent) &&
  99. GManager.instance.turnStateMachine.gameContext.TurnPlayer == selectedPermanent.TopCard.Owner;
  100. }
  101. bool CanActivateConditionDebuff(Hashtable hashtable1)
  102. {
  103. return CardEffectCommons.IsPermanentExistsOnBattleAreaDigimon(selectedPermanent) &&
  104. !selectedPermanent.TopCard.CanNotBeAffected(activateClass) &&
  105. selectedPermanent.CanAttack(activateClassDebuff);
  106. }
  107. IEnumerator ActivateCoroutineDebuff(Hashtable hashtableDebuff)
  108. {
  109. if (CardEffectCommons.IsPermanentExistsOnBattleArea(selectedPermanent) &&
  110. selectedPermanent.CanAttack(activateClassDebuff))
  111. {
  112. SelectAttackEffect selectAttackEffect =
  113. GManager.instance.GetComponent<SelectAttackEffect>();
  114. selectAttackEffect.SetUp(
  115. attacker: selectedPermanent,
  116. canAttackPlayerCondition: () => true,
  117. defenderCondition: _ => true,
  118. cardEffect: activateClassDebuff);
  119. selectAttackEffect.SetCanNotSelectNotAttack();
  120. yield return ContinuousController.instance.StartCoroutine(selectAttackEffect.Activate());
  121. }
  122. }
  123. ICardEffect GetCardEffect(EffectTiming timingDebuff)
  124. {
  125. return timingDebuff == EffectTiming.OnStartMainPhase ? activateClassDebuff : null;
  126. }
  127. }
  128. }
  129. yield return ContinuousController.instance.StartCoroutine(
  130. CardEffectCommons.PlaceDelayOptionCards(card: card, cardEffect: activateClass));
  131. }
  132. }
  133. #endregion
  134. #region Delay Effect
  135. if (timing == EffectTiming.OnAttackTargetChanged)
  136. {
  137. ActivateClass activateClass = new ActivateClass();
  138. activateClass.SetUpICardEffect(
  139. "1 of your Digimon gains <Piercing> and <Security Attack +1> and until the end of your turn",
  140. CanUseCondition, card);
  141. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, true, EffectDescription());
  142. activateClass.SetHashString("GivePiercingAndSecurityAttack_BT18_099");
  143. cardEffects.Add(activateClass);
  144. string EffectDescription()
  145. {
  146. return
  147. "[All Turns] When an attack target is switched, [Delay] • 1 of your Digimon gains <Piercing> and <Security Attack +1> and until the end of your turn.";
  148. }
  149. bool CanUseCondition(Hashtable hashtable)
  150. {
  151. return CardEffectCommons.CanDeclareOptionDelayEffect(card) &&
  152. CardEffectCommons.CanTriggerOnPermanentAttackTargetSwitch(hashtable, _ => true);
  153. }
  154. bool IsOwnerPermanentCondition(Permanent permanent)
  155. {
  156. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  157. }
  158. IEnumerator ActivateCoroutine(Hashtable hashtable)
  159. {
  160. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(
  161. targetPermanents: new List<Permanent>() { card.PermanentOfThisCard() },
  162. activateClass: activateClass,
  163. successProcess: permanents => SuccessProcess(),
  164. failureProcess: null));
  165. }
  166. IEnumerator SuccessProcess()
  167. {
  168. if (CardEffectCommons.HasMatchConditionPermanent(IsOwnerPermanentCondition))
  169. {
  170. Permanent selectedPermanent = null;
  171. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  172. selectPermanentEffect.SetUp(
  173. selectPlayer: card.Owner,
  174. canTargetCondition: IsOwnerPermanentCondition,
  175. canTargetCondition_ByPreSelecetedList: null,
  176. canEndSelectCondition: null,
  177. maxCount: 1,
  178. canNoSelect: false,
  179. canEndNotMax: false,
  180. selectPermanentCoroutine: SelectPermanentCoroutine,
  181. afterSelectPermanentCoroutine: null,
  182. mode: SelectPermanentEffect.Mode.Custom,
  183. cardEffect: activateClass);
  184. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will gain <Piercing> and <Security Attack +1>.",
  185. "The opponent is selecting 1 Digimon that will gain <Piercing> and <Security Attack +1>.");
  186. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  187. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  188. {
  189. selectedPermanent = permanent;
  190. yield return null;
  191. }
  192. if (selectedPermanent != null)
  193. {
  194. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainPierce(
  195. targetPermanent: selectedPermanent,
  196. effectDuration: EffectDuration.UntilOwnerTurnEnd,
  197. activateClass: activateClass));
  198. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonSAttack(
  199. targetPermanent: selectedPermanent,
  200. changeValue: 1,
  201. effectDuration: EffectDuration.UntilOwnerTurnEnd,
  202. activateClass: activateClass));
  203. }
  204. }
  205. }
  206. }
  207. #endregion
  208. #region Security Effect
  209. if (timing == EffectTiming.SecuritySkill)
  210. {
  211. ActivateClass activateClass = new ActivateClass();
  212. activateClass.SetUpICardEffect($"Play a Digimon from trash without paying the cost, then add this card to hand",
  213. CanUseCondition, card);
  214. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDescription());
  215. activateClass.SetIsSecurityEffect(true);
  216. cardEffects.Add(activateClass);
  217. string EffectDescription()
  218. {
  219. return
  220. "[Security] You may play 1 level 5 or lower Digimon card with [Knightmon] in its text from your trash without paying the cost. Then, place this card in the battle area.";
  221. }
  222. bool CanUseCondition(Hashtable hashtable)
  223. {
  224. return CardEffectCommons.CanTriggerSecurityEffect(hashtable, card);
  225. }
  226. bool CanSelectCardCondition(CardSource cardSource)
  227. {
  228. return cardSource.IsDigimon && cardSource.HasLevel && cardSource.Level <= 5 &&
  229. cardSource.HasText("Knightmon");
  230. }
  231. IEnumerator ActivateCoroutine(Hashtable hashtable)
  232. {
  233. List<CardSource> selectedCards = new List<CardSource>();
  234. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  235. selectCardEffect.SetUp(
  236. canTargetCondition: CanSelectCardCondition,
  237. canTargetCondition_ByPreSelecetedList: null,
  238. canEndSelectCondition: null,
  239. canNoSelect: () => true,
  240. selectCardCoroutine: SelectCardCoroutine,
  241. afterSelectCardCoroutine: null,
  242. message: "Select 1 card to play.",
  243. maxCount: 1,
  244. canEndNotMax: false,
  245. isShowOpponent: true,
  246. mode: SelectCardEffect.Mode.Custom,
  247. root: SelectCardEffect.Root.Trash,
  248. customRootCardList: null,
  249. canLookReverseCard: true,
  250. selectPlayer: card.Owner,
  251. cardEffect: activateClass);
  252. selectCardEffect.SetUpCustomMessage("Select 1 card to play.", "The opponent is selecting 1 card to play.");
  253. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  254. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  255. IEnumerator SelectCardCoroutine(CardSource cardSource)
  256. {
  257. selectedCards.Add(cardSource);
  258. yield return null;
  259. }
  260. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(
  261. cardSources: selectedCards, activateClass: activateClass, payCost: false, isTapped: false,
  262. root: SelectCardEffect.Root.Trash, activateETB: true));
  263. yield return ContinuousController.instance.StartCoroutine(
  264. CardEffectCommons.PlaceDelayOptionCards(card: card, cardEffect: activateClass));
  265. }
  266. }
  267. #endregion
  268. return cardEffects;
  269. }
  270. }
  271. }