ST22_08.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. //ST22 Offensive Plug-in V
  6. namespace DCGO.CardEffects.ST22
  7. {
  8. public class ST22_08 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. switch (timing)
  14. {
  15. case EffectTiming.None:
  16. cardEffects.Add(IgnoreColorCondition(card));
  17. cardEffects.Add(LinkCondition(card));
  18. break;
  19. case EffectTiming.OnDeclaration:
  20. cardEffects.Add(LinkAction(card));
  21. break;
  22. case EffectTiming.OnEndTurn:
  23. cardEffects.Add(EndOfTurnLinkedEffect(card));
  24. break;
  25. case EffectTiming.SecuritySkill:
  26. cardEffects.Add(SecurityEffect(card));
  27. break;
  28. case EffectTiming.OptionSkill:
  29. cardEffects.Add(MainEffect(card));
  30. break;
  31. }
  32. return cardEffects;
  33. }
  34. IgnoreColorConditionClass IgnoreColorCondition(CardSource card)
  35. {
  36. IgnoreColorConditionClass ignoreColorConditionClass = new IgnoreColorConditionClass();
  37. ignoreColorConditionClass.SetUpICardEffect("Ignore color requirements", CanUseCondition, card);
  38. ignoreColorConditionClass.SetUpIgnoreColorConditionClass(cardCondition: CardCondition);
  39. bool CanUseCondition(Hashtable hashtable)
  40. {
  41. return CardEffectCommons.HasMatchConditionOwnersPermanent(card, (permanent) => permanent.IsTamer);
  42. }
  43. bool CardCondition(CardSource cardSource)
  44. {
  45. return cardSource == card;
  46. }
  47. return ignoreColorConditionClass;
  48. }
  49. ActivateClass SecurityEffect(CardSource card)
  50. {
  51. ActivateClass activateClass = new ActivateClass();
  52. activateClass.SetUpICardEffect($"Delete opponent's lowest DP Digimon and add this card to hand", CanUseCondition, card);
  53. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  54. activateClass.SetIsSecurityEffect(true);
  55. string EffectDiscription()
  56. => "[Security] Delete 1 of your opponent's Digimon with the lowest DP. Then, add this card to the hand.";
  57. bool CanUseCondition(Hashtable hashtable)
  58. {
  59. return CardEffectCommons.CanTriggerSecurityEffect(hashtable, card);
  60. }
  61. bool CanSelectPermanentCondition(Permanent permanent)
  62. => CardEffectCommons.IsMinDP(permanent, card.Owner.Enemy);
  63. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  64. {
  65. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  66. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  67. selectPermanentEffect.SetUp(
  68. selectPlayer: card.Owner,
  69. canTargetCondition: CanSelectPermanentCondition,
  70. canTargetCondition_ByPreSelecetedList: null,
  71. canEndSelectCondition: null,
  72. maxCount: maxCount,
  73. canNoSelect: false,
  74. canEndNotMax: false,
  75. selectPermanentCoroutine: null,
  76. afterSelectPermanentCoroutine: null,
  77. mode: SelectPermanentEffect.Mode.Destroy,
  78. cardEffect: activateClass);
  79. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  80. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.AddThisCardToHand(card, activateClass));
  81. }
  82. return activateClass;
  83. }
  84. ActivateClass MainEffect(CardSource card)
  85. {
  86. ActivateClass activateClass = new ActivateClass();
  87. activateClass.SetUpICardEffect(card.BaseENGCardNameFromEntity, CanUseCondition, card);
  88. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  89. string EffectDiscription()
  90. => "[Main] You may link this card to 1 of your Digimon without paying the cost. Then, delete 1 of your opponent's Digimon with as much or less DP as 1 of your Digimon.";
  91. bool CanUseCondition(Hashtable hashtable)
  92. => CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  93. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  94. {
  95. #region Select Digimon To Link
  96. bool CanLinkToPermanentCondition(Permanent permanent)
  97. {
  98. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card) &&
  99. card.CanLinkToTargetPermanent(permanent, false);
  100. }
  101. if (CardEffectCommons.HasMatchConditionPermanent(CanLinkToPermanentCondition))
  102. {
  103. Permanent selectedPermanent = null;
  104. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  105. selectPermanentEffect.SetUp(
  106. selectPlayer: card.Owner,
  107. canTargetCondition: CanLinkToPermanentCondition,
  108. canTargetCondition_ByPreSelecetedList: null,
  109. canEndSelectCondition: null,
  110. maxCount: 1,
  111. canNoSelect: true,
  112. canEndNotMax: false,
  113. selectPermanentCoroutine: SelectPermanentToLinkCoroutine,
  114. afterSelectPermanentCoroutine: null,
  115. mode: SelectPermanentEffect.Mode.Custom,
  116. cardEffect: activateClass);
  117. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to link.", "The opponent is selecting 1 Digimon to link.");
  118. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  119. IEnumerator SelectPermanentToLinkCoroutine(Permanent permanent)
  120. {
  121. selectedPermanent = permanent;
  122. yield return null;
  123. }
  124. if (selectedPermanent != null)
  125. {
  126. yield return ContinuousController.instance.StartCoroutine(selectedPermanent.AddLinkCard(card, activateClass));
  127. }
  128. }
  129. #endregion
  130. #region Delete Digimon Setup
  131. Permanent selectedOwnerDigimon = null;
  132. List<Permanent> ownerDigimonList = card.Owner.GetBattleAreaDigimons();
  133. List<Permanent> opponentDigimonList = card.Owner.Enemy.GetBattleAreaDigimons();
  134. int highestDp = ownerDigimonList.Count > 0 ? ownerDigimonList.Max(x => x.DP) : -1;
  135. bool CanSelectOwnerDigimon(Permanent permanent)
  136. => CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  137. bool CanSelectOpponentDigimon(Permanent permanent)
  138. {
  139. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card) &&
  140. permanent.DP <= selectedOwnerDigimon.DP;
  141. }
  142. #endregion
  143. #region Select Digimon to Compare
  144. // Comparing to our highest DP is just used as a fast way to check if there is a least 1 valid selection.
  145. if (ownerDigimonList.Count > 0 && opponentDigimonList.Any(x => x.DP <= highestDp))
  146. {
  147. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  148. selectPermanentEffect.SetUp(
  149. selectPlayer: card.Owner,
  150. canTargetCondition: CanSelectOwnerDigimon,
  151. canTargetCondition_ByPreSelecetedList: null,
  152. canEndSelectCondition: null,
  153. maxCount: 1,
  154. canNoSelect: false,
  155. canEndNotMax: false,
  156. selectPermanentCoroutine: SelectPermanentCoroutine,
  157. afterSelectPermanentCoroutine: null,
  158. mode: SelectPermanentEffect.Mode.Custom,
  159. cardEffect: activateClass);
  160. selectPermanentEffect.SetUpCustomMessage("Select 1 of your Digimon.", "The opponent is selecting 1 Digimon");
  161. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  162. {
  163. selectedOwnerDigimon = permanent;
  164. yield return null;
  165. }
  166. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  167. }
  168. #endregion
  169. #region Select Digimon To Delete
  170. if (selectedOwnerDigimon != null && opponentDigimonList.Any(x => x.DP <= selectedOwnerDigimon.DP))
  171. {
  172. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  173. selectPermanentEffect.SetUp(
  174. selectPlayer: card.Owner,
  175. canTargetCondition: CanSelectOpponentDigimon,
  176. canTargetCondition_ByPreSelecetedList: null,
  177. canEndSelectCondition: null,
  178. maxCount: 1,
  179. canNoSelect: false,
  180. canEndNotMax: false,
  181. selectPermanentCoroutine: null,
  182. afterSelectPermanentCoroutine: null,
  183. mode: SelectPermanentEffect.Mode.Destroy,
  184. cardEffect: activateClass);
  185. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.", "The opponent is selecting 1 Digimon to delete");
  186. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  187. }
  188. #endregion
  189. }
  190. return activateClass;
  191. }
  192. ActivateClass LinkAction(CardSource card)
  193. {
  194. return CardEffectFactory.LinkEffect(card);
  195. }
  196. AddLinkConditionClass LinkCondition(CardSource card)
  197. {
  198. static bool PermanentCondition(Permanent targetPermanent)
  199. {
  200. return targetPermanent.TopCard.HasLevel && targetPermanent.Level >= 3;
  201. }
  202. return CardEffectFactory.AddSelfLinkConditionStaticEffect(permanentCondition: PermanentCondition, linkCost: 2, card: card);
  203. }
  204. ActivateClass EndOfTurnLinkedEffect(CardSource card)
  205. {
  206. ActivateClass activateClass = new ActivateClass();
  207. activateClass.SetUpICardEffect("This digimon may attack", CanUseCondition, card);
  208. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  209. activateClass.SetIsLinkedEffect(true);
  210. activateClass.SetHashString("EOT_ST22_08");
  211. string EffectDiscription() => "[End of Your Turn] this Digimon may attack.";
  212. bool CanUseCondition(Hashtable hashtable)
  213. {
  214. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  215. }
  216. bool CanActivateCondition(Hashtable hashtable)
  217. {
  218. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  219. card.PermanentOfThisCard().CanAttack(activateClass);
  220. }
  221. IEnumerator ActivateCoroutine(Hashtable hashtable)
  222. {
  223. if (CardEffectCommons.IsExistOnBattleArea(card))
  224. {
  225. if (card.PermanentOfThisCard().TopCard.PermanentOfThisCard().CanAttack(activateClass))
  226. {
  227. SelectAttackEffect selectAttackEffect = GManager.instance.GetComponent<SelectAttackEffect>();
  228. selectAttackEffect.SetUp(
  229. attacker: card.PermanentOfThisCard().TopCard.PermanentOfThisCard(),
  230. canAttackPlayerCondition: () => true,
  231. defenderCondition: (permanent) => true,
  232. cardEffect: activateClass);
  233. yield return ContinuousController.instance.StartCoroutine(selectAttackEffect.Activate());
  234. }
  235. }
  236. }
  237. return activateClass;
  238. }
  239. }
  240. }