BT17_100.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT17
  6. {
  7. public class BT17_100 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Main - Option Effect
  13. if (timing == EffectTiming.OptionSkill)
  14. {
  15. ActivateClass activateClass = new ActivateClass();
  16. activateClass.SetUpICardEffect("Play 1 [Diaboromon] Token, Then, place this card as the bottom digivolution", CanUseCondition, card);
  17. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  18. cardEffects.Add(activateClass);
  19. string EffectDiscription()
  20. {
  21. return "[Main] Play 1 [Diaboromon] Token without paying the cost. Then, place this card as the bottom digivolution card of 1 of your [Diaboromon] without [Doomsday Clock] in its digivolution cards.";
  22. }
  23. bool IsDoomsdayClock(CardSource source)
  24. {
  25. return source.EqualsCardName("Doomsday Clock");
  26. }
  27. bool HasDiaboromonWithoutClock(Permanent permanent)
  28. {
  29. if(CardEffectCommons.IsOwnerPermanent(permanent, card))
  30. {
  31. if (permanent.IsDigimon)
  32. {
  33. if (!permanent.IsToken)
  34. {
  35. if (permanent.TopCard.ContainsCardName("Diaboromon"))
  36. {
  37. if (permanent.DigivolutionCards.Count(IsDoomsdayClock) == 0)
  38. {
  39. return true;
  40. }
  41. }
  42. }
  43. }
  44. }
  45. return false;
  46. }
  47. bool CanUseCondition(Hashtable hashtable)
  48. {
  49. return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  50. }
  51. IEnumerator ActivateCoroutine(Hashtable hashtable)
  52. {
  53. if (card.Owner.fieldCardFrames.Count((frame) => frame.IsEmptyFrame() && frame.IsBattleAreaFrame()) >= 1)
  54. {
  55. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayDiaboromonToken(activateClass));
  56. }
  57. if (CardEffectCommons.HasMatchConditionPermanent(HasDiaboromonWithoutClock))
  58. {
  59. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(HasDiaboromonWithoutClock));
  60. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  61. selectPermanentEffect.SetUp(
  62. selectPlayer: card.Owner,
  63. canTargetCondition: HasDiaboromonWithoutClock,
  64. canTargetCondition_ByPreSelecetedList: null,
  65. canEndSelectCondition: null,
  66. maxCount: maxCount,
  67. canNoSelect: false,
  68. canEndNotMax: false,
  69. selectPermanentCoroutine: SelectPermanentCoroutine,
  70. afterSelectPermanentCoroutine: null,
  71. mode: SelectPermanentEffect.Mode.Custom,
  72. cardEffect: activateClass);
  73. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get a digivolution card.", "The opponent is selecting 1 Digimon that will get a digivolution card.");
  74. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  75. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  76. {
  77. if (permanent != null)
  78. {
  79. yield return ContinuousController.instance.StartCoroutine(card.Owner.brainStormObject.CloseBrainstrorm(card));
  80. yield return ContinuousController.instance.StartCoroutine(permanent.AddDigivolutionCardsBottom(new List<CardSource>() { card }, activateClass));
  81. }
  82. }
  83. }
  84. }
  85. }
  86. #endregion
  87. #region Start of Your Turn
  88. if(timing == EffectTiming.OnStartTurn)
  89. {
  90. bool IsDoomsdayClock(Permanent permanent)
  91. {
  92. return permanent.TopCard.EqualsCardName("Doomsday Clock");
  93. }
  94. if (CardEffectCommons.MatchConditionOwnersPermanentCount(card, IsDoomsdayClock) >= 4)
  95. {
  96. card.Owner.Enemy.SetLose();
  97. }
  98. }
  99. #endregion
  100. #region All Turns - ESS
  101. if (timing == EffectTiming.WhenRemoveField)
  102. {
  103. ActivateClass activateClass = new ActivateClass();
  104. activateClass.SetUpICardEffect("Delete your 1 other Digimon to prevent this Digimon from leaving Battle Area", CanUseCondition, card);
  105. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  106. activateClass.SetIsInheritedEffect(true);
  107. activateClass.SetHashString("Substitute_BT14_056");
  108. cardEffects.Add(activateClass);
  109. string EffectDiscription()
  110. {
  111. return "[All Turns] When this Digimon would leave the battle area by an opponent's effect, by deleting 1 of your other [Diaboromon], prevent it from leaving.";
  112. }
  113. bool CanSelectPermanentCondition(Permanent permanent)
  114. {
  115. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
  116. {
  117. if (permanent != card.PermanentOfThisCard())
  118. {
  119. if (permanent.TopCard.EqualsCardName("Diaboromon"))
  120. {
  121. return true;
  122. }
  123. }
  124. }
  125. return false;
  126. }
  127. bool CanUseCondition(Hashtable hashtable)
  128. {
  129. if (CardEffectCommons.IsExistOnBattleArea(card))
  130. {
  131. if (CardEffectCommons.CanTriggerWhenRemoveField(hashtable, card))
  132. {
  133. if (CardEffectCommons.IsByEffect(hashtable, cardEffect => !CardEffectCommons.IsOwnerEffect(cardEffect, card)))
  134. {
  135. return true;
  136. }
  137. }
  138. }
  139. return false;
  140. }
  141. bool CanActivateCondition(Hashtable hashtable)
  142. {
  143. if (CardEffectCommons.IsExistOnBattleArea(card))
  144. {
  145. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  146. {
  147. return true;
  148. }
  149. }
  150. return false;
  151. }
  152. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  153. {
  154. Permanent thisCardPermanent = card.PermanentOfThisCard();
  155. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  156. {
  157. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  158. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  159. selectPermanentEffect.SetUp(
  160. selectPlayer: card.Owner,
  161. canTargetCondition: CanSelectPermanentCondition,
  162. canTargetCondition_ByPreSelecetedList: null,
  163. canEndSelectCondition: null,
  164. maxCount: maxCount,
  165. canNoSelect: true,
  166. canEndNotMax: false,
  167. selectPermanentCoroutine: SelectPermanentCoroutine,
  168. afterSelectPermanentCoroutine: null,
  169. mode: SelectPermanentEffect.Mode.Custom,
  170. cardEffect: activateClass);
  171. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to delete.", "The opponent is selecting 1 Digimon to delete.");
  172. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  173. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  174. {
  175. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(
  176. targetPermanents: new List<Permanent>() { permanent },
  177. activateClass: activateClass,
  178. successProcess: permanents => SuccessProcess(),
  179. failureProcess: null));
  180. IEnumerator SuccessProcess()
  181. {
  182. thisCardPermanent.willBeRemoveField = false;
  183. thisCardPermanent.HideDeleteEffect();
  184. thisCardPermanent.HideHandBounceEffect();
  185. thisCardPermanent.HideDeckBounceEffect();
  186. thisCardPermanent.HideWillRemoveFieldEffect();
  187. yield return null;
  188. }
  189. }
  190. }
  191. }
  192. }
  193. #endregion
  194. #region End of Opponent's Turn - ESS
  195. if (timing == EffectTiming.OnEndTurn)
  196. {
  197. ActivateClass activateClass = new ActivateClass();
  198. activateClass.SetUpICardEffect("Place 1 [Doomsday Clock] from digivolution cards", CanUseCondition, card);
  199. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDiscription());
  200. activateClass.SetIsInheritedEffect(true);
  201. activateClass.SetHashString("PlayCard_BT10_066");
  202. cardEffects.Add(activateClass);
  203. string EffectDiscription()
  204. {
  205. return "[End of Opponent's Turn] Place 1 [Doomsday Clock] from this Digimon's digivolution cards in the battle area.";
  206. }
  207. bool CanSelectCardCondition(CardSource cardSource)
  208. {
  209. return cardSource.EqualsCardName("Doomsday Clock");
  210. }
  211. bool CanUseCondition(Hashtable hashtable)
  212. {
  213. if (CardEffectCommons.IsExistOnBattleArea(card))
  214. {
  215. if (CardEffectCommons.IsOpponentTurn(card))
  216. {
  217. return true;
  218. }
  219. }
  220. return false;
  221. }
  222. bool CanActivateCondition(Hashtable hashtable)
  223. {
  224. if (CardEffectCommons.IsExistOnBattleArea(card))
  225. {
  226. if (card.PermanentOfThisCard().DigivolutionCards.Count(CanSelectCardCondition) >= 1)
  227. {
  228. return true;
  229. }
  230. }
  231. return false;
  232. }
  233. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  234. {
  235. if (CardEffectCommons.IsExistOnBattleArea(card))
  236. {
  237. Permanent selectedPermanent = card.PermanentOfThisCard();
  238. if (selectedPermanent.DigivolutionCards.Count(CanSelectCardCondition) >= 1)
  239. {
  240. int maxCount = Math.Min(1, selectedPermanent.DigivolutionCards.Count(CanSelectCardCondition));
  241. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  242. selectCardEffect.SetUp(
  243. canTargetCondition: CanSelectCardCondition,
  244. canTargetCondition_ByPreSelecetedList: null,
  245. canEndSelectCondition: null,
  246. canNoSelect: () => false,
  247. selectCardCoroutine: SelectCardCoroutine,
  248. afterSelectCardCoroutine: null,
  249. message: "Select 1 card to play.",
  250. maxCount: maxCount,
  251. canEndNotMax: false,
  252. isShowOpponent: true,
  253. mode: SelectCardEffect.Mode.Custom,
  254. root: SelectCardEffect.Root.Custom,
  255. customRootCardList: selectedPermanent.DigivolutionCards,
  256. canLookReverseCard: true,
  257. selectPlayer: card.Owner,
  258. cardEffect: activateClass);
  259. selectCardEffect.SetUpCustomMessage("Select 1 digivolution card to play.",
  260. "The opponent is selecting 1 digivolution card to play.");
  261. selectCardEffect.SetUpCustomMessage_ShowCard("Played Card");
  262. yield return StartCoroutine(selectCardEffect.Activate());
  263. IEnumerator SelectCardCoroutine(CardSource cardSource)
  264. {
  265. if (cardSource != null)
  266. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlaceDelayOptionCards(card: cardSource, cardEffect: activateClass));
  267. }
  268. }
  269. }
  270. }
  271. }
  272. #endregion
  273. #region Security Effect
  274. if (timing == EffectTiming.SecuritySkill)
  275. {
  276. ActivateClass activateClass = new ActivateClass();
  277. activateClass.SetUpICardEffect($"Add this card to hand", CanUseCondition, card);
  278. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  279. activateClass.SetIsSecurityEffect(true);
  280. cardEffects.Add(activateClass);
  281. string EffectDiscription()
  282. {
  283. return "[Security] Add this card to the hand";
  284. }
  285. bool CanUseCondition(Hashtable hashtable)
  286. {
  287. return CardEffectCommons.CanTriggerSecurityEffect(hashtable, card);
  288. }
  289. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  290. {
  291. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.AddThisCardToHand(card, activateClass));
  292. }
  293. }
  294. #endregion
  295. return cardEffects;
  296. }
  297. }
  298. }