FistofAthena_BT18_099.cs 16 KB

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