BT20_055.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. namespace DCGO.CardEffects.BT20
  5. {
  6. public class BT20_055 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region Security - End of Opponents Turn
  12. if (timing == EffectTiming.OnEndTurn)
  13. {
  14. ActivateClass activateClass = new ActivateClass();
  15. activateClass.SetUpICardEffect("Play this card", CanUseCondition, card);
  16. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  17. cardEffects.Add(activateClass);
  18. string EffectDiscription()
  19. {
  20. return "(Security) [End of Opponent's Turn] Play this card without paying the cost.";
  21. }
  22. bool CanUseCondition(Hashtable hashtable)
  23. {
  24. return CardEffectCommons.IsOpponentTurn(card);
  25. }
  26. bool CanActivateCondition(Hashtable hashtable)
  27. {
  28. return CardEffectCommons.IsExistInSecurity(card) &&
  29. CardEffectCommons.CanPlayAsNewPermanent(card, false, activateClass, SelectCardEffect.Root.Security);
  30. }
  31. IEnumerator ActivateCoroutine(Hashtable hashtable)
  32. {
  33. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(cardSources: new List<CardSource>() { card }, activateClass: activateClass, payCost: false, isTapped: false, root: SelectCardEffect.Root.Security, activateETB: true));
  34. }
  35. }
  36. #endregion
  37. #region On Play
  38. if (timing == EffectTiming.OnEnterFieldAnyone)
  39. {
  40. ActivateClass activateClass = new ActivateClass();
  41. activateClass.SetUpICardEffect("<De-Digivolve 2> 1 opponent's Digimon, flip their security card face up, then delete 1 Digimon", CanUseCondition, card);
  42. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  43. cardEffects.Add(activateClass);
  44. string EffectDiscription()
  45. {
  46. return "[On Play] <De-Digivolve 2> 1 of your opponent's Digimon and flip your opponent's top face-down security card face up. Then, delete 1 of their Digimon with 1 or fewer digivolution cards.";
  47. }
  48. bool DedigivolveTarget(Permanent permanent)
  49. {
  50. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  51. }
  52. bool DeletionTarget(Permanent permanent)
  53. {
  54. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card) &&
  55. permanent.DigivolutionCards.Count <= 1;
  56. }
  57. bool CanUseCondition(Hashtable hashtable)
  58. {
  59. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  60. }
  61. bool CanActivateCondition(Hashtable hashtable)
  62. {
  63. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  64. }
  65. IEnumerator ActivateCoroutine(Hashtable hashtable)
  66. {
  67. if (CardEffectCommons.HasMatchConditionPermanent(DedigivolveTarget))
  68. {
  69. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  70. selectPermanentEffect.SetUp(
  71. selectPlayer: card.Owner,
  72. canTargetCondition: DedigivolveTarget,
  73. canTargetCondition_ByPreSelecetedList: null,
  74. canEndSelectCondition: null,
  75. maxCount: 1,
  76. canNoSelect: false,
  77. canEndNotMax: false,
  78. selectPermanentCoroutine: SelectedDedigivolveTarget,
  79. afterSelectPermanentCoroutine: null,
  80. mode: SelectPermanentEffect.Mode.Custom,
  81. cardEffect: activateClass);
  82. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to De-Digivolve.", "The opponent is selecting 1 Digimon to De-Digivolve.");
  83. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  84. IEnumerator SelectedDedigivolveTarget(Permanent target)
  85. {
  86. yield return ContinuousController.instance.StartCoroutine(new IDegeneration(target, 2, activateClass).Degeneration());
  87. }
  88. }
  89. if(card.Owner.Enemy.SecurityCards.Count(source => source.IsFlipped) > 0)
  90. {
  91. foreach (CardSource source in card.Owner.Enemy.SecurityCards)
  92. {
  93. if (!source.IsFlipped)
  94. continue;
  95. source.SetFace();
  96. GManager.OnSecurityStackChanged?.Invoke(card.Owner.Enemy);
  97. break;
  98. }
  99. }
  100. if (CardEffectCommons.HasMatchConditionPermanent(DeletionTarget))
  101. {
  102. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  103. selectPermanentEffect.SetUp(
  104. selectPlayer: card.Owner,
  105. canTargetCondition: DeletionTarget,
  106. canTargetCondition_ByPreSelecetedList: null,
  107. canEndSelectCondition: null,
  108. maxCount: 1,
  109. canNoSelect: false,
  110. canEndNotMax: false,
  111. selectPermanentCoroutine: null,
  112. afterSelectPermanentCoroutine: null,
  113. mode: SelectPermanentEffect.Mode.Destroy,
  114. cardEffect: activateClass);
  115. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.", "The opponent is selecting 1 Digimon to delete.");
  116. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  117. }
  118. }
  119. }
  120. #endregion
  121. #region When Digivolving
  122. if (timing == EffectTiming.OnEnterFieldAnyone)
  123. {
  124. ActivateClass activateClass = new ActivateClass();
  125. activateClass.SetUpICardEffect("<De-Digivolve 2> 1 opponent's Digimon, flip their security card face up, then delete 1 Digimon", CanUseCondition, card);
  126. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  127. cardEffects.Add(activateClass);
  128. string EffectDiscription()
  129. {
  130. return "[When Digivolving] <De-Digivolve 2> 1 of your opponent's Digimon and flip your opponent's top face-down security card face up. Then, delete 1 of their Digimon with 1 or fewer digivolution cards.";
  131. }
  132. bool DedigivolveTarget(Permanent permanent)
  133. {
  134. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  135. }
  136. bool DeletionTarget(Permanent permanent)
  137. {
  138. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card) &&
  139. permanent.DigivolutionCards.Count <= 1;
  140. }
  141. bool CanUseCondition(Hashtable hashtable)
  142. {
  143. return CardEffectCommons.IsExistOnBattleAreaDigimon(card) &&
  144. CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  145. }
  146. bool CanActivateCondition(Hashtable hashtable)
  147. {
  148. return CardEffectCommons.IsExistOnBattleAreaDigimon(card);
  149. }
  150. IEnumerator ActivateCoroutine(Hashtable hashtable)
  151. {
  152. if (CardEffectCommons.HasMatchConditionPermanent(DedigivolveTarget))
  153. {
  154. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  155. selectPermanentEffect.SetUp(
  156. selectPlayer: card.Owner,
  157. canTargetCondition: DedigivolveTarget,
  158. canTargetCondition_ByPreSelecetedList: null,
  159. canEndSelectCondition: null,
  160. maxCount: 1,
  161. canNoSelect: false,
  162. canEndNotMax: false,
  163. selectPermanentCoroutine: SelectedDedigivolveTarget,
  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. IEnumerator SelectedDedigivolveTarget(Permanent target)
  170. {
  171. yield return ContinuousController.instance.StartCoroutine(new IDegeneration(target, 2, activateClass).Degeneration());
  172. }
  173. }
  174. if (card.Owner.Enemy.SecurityCards.Count(source => source.IsFlipped) > 0)
  175. {
  176. foreach (CardSource source in card.Owner.Enemy.SecurityCards)
  177. {
  178. if (!source.IsFlipped)
  179. continue;
  180. yield return ContinuousController.instance.StartCoroutine(new IFlipSecurity(source).FlipFaceUp());
  181. break;
  182. }
  183. }
  184. if (CardEffectCommons.HasMatchConditionPermanent(DeletionTarget))
  185. {
  186. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  187. selectPermanentEffect.SetUp(
  188. selectPlayer: card.Owner,
  189. canTargetCondition: DeletionTarget,
  190. canTargetCondition_ByPreSelecetedList: null,
  191. canEndSelectCondition: null,
  192. maxCount: 1,
  193. canNoSelect: false,
  194. canEndNotMax: false,
  195. selectPermanentCoroutine: null,
  196. afterSelectPermanentCoroutine: null,
  197. mode: SelectPermanentEffect.Mode.Destroy,
  198. cardEffect: activateClass);
  199. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.", "The opponent is selecting 1 Digimon to delete.");
  200. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  201. }
  202. }
  203. }
  204. #endregion
  205. #region Your Turn
  206. if (timing == EffectTiming.OnSecurityCheck)
  207. {
  208. ActivateClass activateClass = new ActivateClass();
  209. activateClass.SetUpICardEffect("Place top card face up as bottom security", CanUseCondition, card);
  210. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  211. cardEffects.Add(activateClass);
  212. string EffectDiscription()
  213. {
  214. return "[Your Turn] When your Digimon check face-up security cards, you may place this Digimon's top stacked card face up as the bottom security card.";
  215. }
  216. bool CanUseCondition(Hashtable hashtable)
  217. {
  218. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  219. && CardEffectCommons.IsOwnerTurn(card)
  220. && CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(CardEffectCommons.GetAttackerFromHashtable(hashtable), card)
  221. && !CardEffectCommons.GetCardFromHashtable(hashtable).IsFlipped;
  222. }
  223. bool CanActivateCondition(Hashtable hashtable)
  224. {
  225. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  226. && card.PermanentOfThisCard().DigivolutionCards.Count > 0;
  227. }
  228. IEnumerator ActivateCoroutine(Hashtable hashtable)
  229. {
  230. // Place this card face up as the bottom security card
  231. if (card.Owner.CanAddSecurity(activateClass))
  232. {
  233. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddSecurityCard(
  234. card, toTop: false, faceUp: true));
  235. }
  236. }
  237. }
  238. #endregion
  239. return cardEffects;
  240. }
  241. }
  242. }