ST17_07.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using System.Linq;
  5. using Photon;
  6. using System;
  7. using Photon.Pun;
  8. namespace DCGO.CardEffects.ST17
  9. {
  10. public class ST17_07 : CEntity_Effect
  11. {
  12. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  13. {
  14. List<ICardEffect> cardEffects = new List<ICardEffect>();
  15. #region Digivolution Condition
  16. if (timing == EffectTiming.None)
  17. {
  18. bool PermanentCondition(Permanent targetPermanent)
  19. {
  20. if ((targetPermanent.TopCard.ContainsCardName("Gargomon") && targetPermanent.Level == 4) || (targetPermanent.TopCard.ContainsCardName("Rapidmon") && targetPermanent.Level == 4))
  21. {
  22. return true;
  23. }
  24. return false;
  25. }
  26. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  27. }
  28. #endregion
  29. #region On Play
  30. if (timing == EffectTiming.OnEnterFieldAnyone)
  31. {
  32. ActivateClass activateClass = new ActivateClass();
  33. activateClass.SetUpICardEffect("De-Digivolve 1 on 1 Digimon and gain effects.", CanUseCondition, card);
  34. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  35. cardEffects.Add(activateClass);
  36. string EffectDiscription()
  37. {
  38. return "[On Play] [De-Digivolve] 1 of your opponent's Digimon. Then, if you have a green Tamer, until the end of your opponent's turn, your opponent's effects can't delete this Digimon or return it to the hand or deck.";
  39. }
  40. bool CanSelectPermanentCondition(Permanent permanent)
  41. {
  42. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  43. }
  44. bool CanUseCondition(Hashtable hashtable)
  45. {
  46. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  47. }
  48. bool CanActivateCondition(Hashtable hashtable)
  49. {
  50. if (CardEffectCommons.IsExistOnBattleArea(card))
  51. {
  52. return true;
  53. }
  54. return false;
  55. }
  56. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  57. {
  58. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  59. {
  60. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  61. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  62. selectPermanentEffect.SetUp(
  63. selectPlayer: card.Owner,
  64. canTargetCondition: CanSelectPermanentCondition,
  65. canTargetCondition_ByPreSelecetedList: null,
  66. canEndSelectCondition: CanEndSelectCondition,
  67. maxCount: maxCount,
  68. canNoSelect: false,
  69. canEndNotMax: false,
  70. selectPermanentCoroutine: SelectPermanentCoroutine,
  71. afterSelectPermanentCoroutine: null,
  72. mode: SelectPermanentEffect.Mode.Custom,
  73. cardEffect: activateClass);
  74. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to De-Digivolve.", "The opponent is selecting 1 Digimon to De-Digivolve.");
  75. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  76. bool CanEndSelectCondition(List<Permanent> permanents)
  77. {
  78. if (permanents.Count <= 0)
  79. {
  80. return false;
  81. }
  82. return true;
  83. }
  84. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  85. {
  86. Permanent selectedPermanent = permanent;
  87. if (selectedPermanent != null)
  88. {
  89. yield return ContinuousController.instance.StartCoroutine(new IDegeneration(selectedPermanent, 1, activateClass).Degeneration());
  90. }
  91. yield return null;
  92. }
  93. }
  94. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, (permanent) => permanent.TopCard.CardColors.Contains(CardColor.Green) && permanent.IsTamer))
  95. {
  96. bool CardEffectCondition(ICardEffect cardEffect)
  97. {
  98. return CardEffectCommons.IsOpponentEffect(cardEffect, card);
  99. }
  100. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainCanNotBeDeletedByEffect(
  101. targetPermanent: card.PermanentOfThisCard(),
  102. cardEffectCondition: CardEffectCondition,
  103. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  104. activateClass: activateClass,
  105. effectName: "Can't be deleted by opponent's effects"));
  106. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainCanNotReturnToHand(
  107. targetPermanent: card.PermanentOfThisCard(),
  108. cardEffectCondition: CardEffectCondition,
  109. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  110. activateClass: activateClass,
  111. effectName: "Can't return to hand by opponent's effects"));
  112. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainCanNotReturnToDeck(
  113. targetPermanent: card.PermanentOfThisCard(),
  114. cardEffectCondition: CardEffectCondition,
  115. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  116. activateClass: activateClass,
  117. effectName: "Can't return to deck by opponent's effects"));
  118. }
  119. }
  120. }
  121. #endregion
  122. #region When Digivolving
  123. if (timing == EffectTiming.OnEnterFieldAnyone)
  124. {
  125. ActivateClass activateClass = new ActivateClass();
  126. activateClass.SetUpICardEffect("De-Digivolve 1 on 1 Digimon and gain effects.", CanUseCondition, card);
  127. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  128. cardEffects.Add(activateClass);
  129. string EffectDiscription()
  130. {
  131. return "[When Digivolving] [De-Digivolve] 1 of your opponent's Digimon. Then, if you have a green Tamer, until the end of your opponent's turn, your opponent's effects can't delete this Digimon or return it to the hand or deck.";
  132. }
  133. bool CanSelectPermanentCondition(Permanent permanent)
  134. {
  135. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  136. }
  137. bool CanUseCondition(Hashtable hashtable)
  138. {
  139. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  140. }
  141. bool CanActivateCondition(Hashtable hashtable)
  142. {
  143. if (CardEffectCommons.IsExistOnBattleArea(card))
  144. {
  145. return true;
  146. }
  147. return false;
  148. }
  149. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  150. {
  151. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  152. {
  153. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  154. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  155. selectPermanentEffect.SetUp(
  156. selectPlayer: card.Owner,
  157. canTargetCondition: CanSelectPermanentCondition,
  158. canTargetCondition_ByPreSelecetedList: null,
  159. canEndSelectCondition: CanEndSelectCondition,
  160. maxCount: maxCount,
  161. canNoSelect: false,
  162. canEndNotMax: false,
  163. selectPermanentCoroutine: SelectPermanentCoroutine,
  164. afterSelectPermanentCoroutine: null,
  165. mode: SelectPermanentEffect.Mode.Custom,
  166. cardEffect: activateClass);
  167. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to De-Digivolve.", "The opponent is selecting 1 Digimon to De-Digivolve.");
  168. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  169. bool CanEndSelectCondition(List<Permanent> permanents)
  170. {
  171. if (permanents.Count <= 0)
  172. {
  173. return false;
  174. }
  175. return true;
  176. }
  177. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  178. {
  179. Permanent selectedPermanent = permanent;
  180. if (selectedPermanent != null)
  181. {
  182. yield return ContinuousController.instance.StartCoroutine(new IDegeneration(selectedPermanent, 1, activateClass).Degeneration());
  183. }
  184. yield return null;
  185. }
  186. }
  187. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, (permanent) => permanent.TopCard.CardColors.Contains(CardColor.Green) && permanent.IsTamer))
  188. {
  189. bool CardEffectCondition(ICardEffect cardEffect)
  190. {
  191. return CardEffectCommons.IsOpponentEffect(cardEffect, card);
  192. }
  193. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainCanNotBeDeletedByEffect(
  194. targetPermanent: card.PermanentOfThisCard(),
  195. cardEffectCondition: CardEffectCondition,
  196. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  197. activateClass: activateClass,
  198. effectName: "Can't be deleted by opponent's effects"));
  199. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainCanNotReturnToHand(
  200. targetPermanent: card.PermanentOfThisCard(),
  201. cardEffectCondition: CardEffectCondition,
  202. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  203. activateClass: activateClass,
  204. effectName: "Can't return to hand by opponent's effects"));
  205. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainCanNotReturnToDeck(
  206. targetPermanent: card.PermanentOfThisCard(),
  207. cardEffectCondition: CardEffectCondition,
  208. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  209. activateClass: activateClass,
  210. effectName: "Can't return to deck by opponent's effects"));
  211. }
  212. }
  213. }
  214. #endregion
  215. #region Inherit
  216. if (timing == EffectTiming.OnEndBattle)
  217. {
  218. ActivateClass activateClass = new ActivateClass();
  219. activateClass.SetUpICardEffect("Trash the top card of opponent's security", CanUseCondition, card);
  220. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  221. activateClass.SetIsInheritedEffect(true);
  222. activateClass.SetHashString("TrashSecurity_ST17_07");
  223. cardEffects.Add(activateClass);
  224. string EffectDiscription()
  225. {
  226. return "[All Turns][Once Per Turn] When this Digimon deletes an opponent's Digimon in battle, trash the top card of your opponent's security stack.";
  227. }
  228. bool CanUseCondition(Hashtable hashtable)
  229. {
  230. if (CardEffectCommons.IsExistOnBattleArea(card))
  231. {
  232. bool WinnerCondition(Permanent permanent) => permanent.cardSources.Contains(card);
  233. bool LoserCondition(Permanent permanent) => CardEffectCommons.IsOpponentPermanent(permanent, card);
  234. if (CardEffectCommons.CanTriggerWhenDeleteOpponentDigimonByBattle(hashtable: hashtable, winnerCondition: WinnerCondition, loserCondition: LoserCondition, isOnlyWinnerSurvive: false))
  235. {
  236. return true;
  237. }
  238. }
  239. return false;
  240. }
  241. bool CanActivateCondition(Hashtable hashtable)
  242. {
  243. if (CardEffectCommons.IsExistOnBattleArea(card))
  244. {
  245. return true;
  246. }
  247. return false;
  248. }
  249. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  250. {
  251. yield return ContinuousController.instance.StartCoroutine(new IDestroySecurity(
  252. player: card.Owner.Enemy,
  253. destroySecurityCount: 1,
  254. cardEffect: activateClass,
  255. fromTop: true).DestroySecurity());
  256. }
  257. }
  258. #endregion
  259. return cardEffects;
  260. }
  261. }
  262. }