BT17_037.cs 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT17
  6. {
  7. public class BT17_037 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Your Turn
  13. if (timing == EffectTiming.None)
  14. {
  15. bool Condition()
  16. {
  17. if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
  18. {
  19. if (CardEffectCommons.IsOwnerTurn(card))
  20. {
  21. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, (permanent) => permanent.IsSuspended && permanent.IsTamer))
  22. {
  23. return true;
  24. }
  25. }
  26. }
  27. return false;
  28. }
  29. cardEffects.Add(CardEffectFactory.ChangeSelfDPStaticEffect(changeValue: 3000, isInheritedEffect: false, card: card, condition: Condition));
  30. }
  31. if (timing == EffectTiming.OnDetermineDoSecurityCheck)
  32. {
  33. bool Condition()
  34. {
  35. if (CardEffectCommons.IsExistOnBattleArea(card))
  36. {
  37. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, (permanent) => permanent.IsSuspended && permanent.IsTamer))
  38. {
  39. return true;
  40. }
  41. }
  42. return false;
  43. }
  44. cardEffects.Add(CardEffectFactory.PierceSelfEffect(isInheritedEffect: false, card: card, condition: Condition));
  45. }
  46. #endregion
  47. #region When Digivolving/When Attacking Shared
  48. string EffectSharedDiscription1()
  49. {
  50. return "[When Digivolving] By suspending 1 of your yellow Tamers, 1 of your opponent's Digimon gets -3000 DP for the turn.";
  51. }
  52. string EffectSharedDiscription2()
  53. {
  54. return "[When Attacking] By suspending 1 of your yellow Tamers, 1 of your opponent's Digimon gets -3000 DP for the turn.";
  55. }
  56. bool CanSelectPermanentConditionShared1(Permanent permanent)
  57. {
  58. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card))
  59. {
  60. if (permanent.IsTamer && permanent.TopCard.CardColors.Contains(CardColor.Yellow))
  61. {
  62. return true;
  63. }
  64. }
  65. return false;
  66. }
  67. bool CanSelectPermanentConditionShared2(Permanent permanent)
  68. {
  69. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  70. }
  71. bool CanActivateSharedCondition(Hashtable hashtable)
  72. {
  73. if (CardEffectCommons.IsExistOnBattleArea(card))
  74. {
  75. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentConditionShared1))
  76. {
  77. return true;
  78. }
  79. }
  80. return false;
  81. }
  82. #endregion
  83. #region When Digivolving
  84. if (timing == EffectTiming.OnEnterFieldAnyone)
  85. {
  86. ActivateClass activateClass = new ActivateClass();
  87. activateClass.SetUpICardEffect("Suspend a Tamer to give -3000 DP", CanUseCondition, card);
  88. activateClass.SetUpActivateClass(CanActivateSharedCondition, ActivateCoroutine, -1, true, EffectSharedDiscription1());
  89. cardEffects.Add(activateClass);
  90. bool CanUseCondition(Hashtable hashtable)
  91. {
  92. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  93. }
  94. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  95. {
  96. Permanent selectedPermanent = null;
  97. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentConditionShared1))
  98. {
  99. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentConditionShared1));
  100. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  101. selectPermanentEffect.SetUp(
  102. selectPlayer: card.Owner,
  103. canTargetCondition: CanSelectPermanentConditionShared1,
  104. canTargetCondition_ByPreSelecetedList: null,
  105. canEndSelectCondition: null,
  106. maxCount: maxCount,
  107. canNoSelect: true,
  108. canEndNotMax: false,
  109. selectPermanentCoroutine: SelectPermanentCoroutine,
  110. afterSelectPermanentCoroutine: null,
  111. mode: SelectPermanentEffect.Mode.Custom,
  112. cardEffect: activateClass);
  113. selectPermanentEffect.SetUpCustomMessage("Select 1 your Yellow Tamers to suspend.", "The opponent is selecting 1 Tamer to suspend.");
  114. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  115. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  116. {
  117. selectedPermanent = permanent;
  118. yield return null;
  119. }
  120. }
  121. if (selectedPermanent != null)
  122. {
  123. if (selectedPermanent.TopCard != null)
  124. {
  125. if (!selectedPermanent.TopCard.CanNotBeAffected(activateClass))
  126. {
  127. if (!selectedPermanent.IsSuspended && selectedPermanent.CanSuspend)
  128. {
  129. Permanent suspendTargetPermanent = selectedPermanent;
  130. yield return ContinuousController.instance.StartCoroutine(new SuspendPermanentsClass(new List<Permanent>() { suspendTargetPermanent }, CardEffectCommons.CardEffectHashtable(activateClass)).Tap());
  131. if (suspendTargetPermanent.TopCard != null)
  132. {
  133. if (suspendTargetPermanent.IsSuspended)
  134. {
  135. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentConditionShared2))
  136. {
  137. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentConditionShared2));
  138. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  139. selectPermanentEffect.SetUp(
  140. selectPlayer: card.Owner,
  141. canTargetCondition: CanSelectPermanentConditionShared2,
  142. canTargetCondition_ByPreSelecetedList: null,
  143. canEndSelectCondition: null,
  144. maxCount: maxCount,
  145. canNoSelect: false,
  146. canEndNotMax: false,
  147. selectPermanentCoroutine: SelectPermanentCoroutine,
  148. afterSelectPermanentCoroutine: null,
  149. mode: SelectPermanentEffect.Mode.Custom,
  150. cardEffect: activateClass);
  151. selectPermanentEffect.SetUpCustomMessage(customMessageArray: CardEffectCommons.customPermanentMessageArray_ChangeDP(changeValue: -3000, maxCount: maxCount));
  152. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  153. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  154. {
  155. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(
  156. targetPermanent: permanent,
  157. changeValue: -3000,
  158. effectDuration: EffectDuration.UntilEachTurnEnd,
  159. activateClass: activateClass));
  160. }
  161. }
  162. }
  163. }
  164. }
  165. }
  166. }
  167. }
  168. }
  169. }
  170. #endregion
  171. #region When Attacking
  172. if (timing == EffectTiming.OnAllyAttack)
  173. {
  174. ActivateClass activateClass = new ActivateClass();
  175. activateClass.SetUpICardEffect("Suspend a Tamer to give -3000 DP", CanUseCondition, card);
  176. activateClass.SetUpActivateClass(CanActivateSharedCondition, ActivateCoroutine, -1, true, EffectSharedDiscription2());
  177. cardEffects.Add(activateClass);
  178. bool CanUseCondition(Hashtable hashtable)
  179. {
  180. return CardEffectCommons.CanTriggerOnAttack(hashtable, card);
  181. }
  182. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  183. {
  184. Permanent selectedPermanent = null;
  185. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentConditionShared1))
  186. {
  187. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentConditionShared1));
  188. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  189. selectPermanentEffect.SetUp(
  190. selectPlayer: card.Owner,
  191. canTargetCondition: CanSelectPermanentConditionShared1,
  192. canTargetCondition_ByPreSelecetedList: null,
  193. canEndSelectCondition: null,
  194. maxCount: maxCount,
  195. canNoSelect: true,
  196. canEndNotMax: false,
  197. selectPermanentCoroutine: SelectPermanentCoroutine,
  198. afterSelectPermanentCoroutine: null,
  199. mode: SelectPermanentEffect.Mode.Custom,
  200. cardEffect: activateClass);
  201. selectPermanentEffect.SetUpCustomMessage("Select 1 your Yellow Tamers to suspend.", "The opponent is selecting 1 Tamer to suspend.");
  202. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  203. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  204. {
  205. selectedPermanent = permanent;
  206. yield return null;
  207. }
  208. }
  209. if (selectedPermanent != null)
  210. {
  211. if (selectedPermanent.TopCard != null)
  212. {
  213. if (!selectedPermanent.TopCard.CanNotBeAffected(activateClass))
  214. {
  215. if (!selectedPermanent.IsSuspended && selectedPermanent.CanSuspend)
  216. {
  217. Permanent suspendTargetPermanent = selectedPermanent;
  218. yield return ContinuousController.instance.StartCoroutine(new SuspendPermanentsClass(new List<Permanent>() { suspendTargetPermanent }, CardEffectCommons.CardEffectHashtable(activateClass)).Tap());
  219. if (suspendTargetPermanent.TopCard != null)
  220. {
  221. if (suspendTargetPermanent.IsSuspended)
  222. {
  223. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentConditionShared2))
  224. {
  225. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentConditionShared2));
  226. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  227. selectPermanentEffect.SetUp(
  228. selectPlayer: card.Owner,
  229. canTargetCondition: CanSelectPermanentConditionShared2,
  230. canTargetCondition_ByPreSelecetedList: null,
  231. canEndSelectCondition: null,
  232. maxCount: maxCount,
  233. canNoSelect: false,
  234. canEndNotMax: false,
  235. selectPermanentCoroutine: SelectPermanentCoroutine,
  236. afterSelectPermanentCoroutine: null,
  237. mode: SelectPermanentEffect.Mode.Custom,
  238. cardEffect: activateClass);
  239. selectPermanentEffect.SetUpCustomMessage(customMessageArray: CardEffectCommons.customPermanentMessageArray_ChangeDP(changeValue: -3000, maxCount: maxCount));
  240. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  241. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  242. {
  243. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(
  244. targetPermanent: permanent,
  245. changeValue: -3000,
  246. effectDuration: EffectDuration.UntilEachTurnEnd,
  247. activateClass: activateClass));
  248. }
  249. }
  250. }
  251. }
  252. }
  253. }
  254. }
  255. }
  256. }
  257. }
  258. #endregion
  259. #region Inherit
  260. if (timing == EffectTiming.OnDestroyedAnyone)
  261. {
  262. ActivateClass activateClass = new ActivateClass();
  263. activateClass.SetUpICardEffect("Place 1 [Marcus Damon] on the top of security from trash", CanUseCondition, card);
  264. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDiscription());
  265. activateClass.SetIsInheritedEffect(true);
  266. activateClass.SetHashString("AddSecurity_BT17_037_inherited");
  267. cardEffects.Add(activateClass);
  268. string EffectDiscription()
  269. {
  270. return "[All Turns][Once Per Turn] When one of your yellow or red Tamers is deleted, place 1 [Marcus Damon] from your trash on top of your security stack.";
  271. }
  272. bool CanSelectCardCondition(CardSource cardSource)
  273. {
  274. if (cardSource.IsTamer && cardSource.HasCardColor(CardColor.Yellow) || cardSource.IsTamer && cardSource.HasCardColor(CardColor.Red))
  275. {
  276. return true;
  277. }
  278. return false;
  279. }
  280. bool PermanentCondition(Permanent permanent)
  281. {
  282. if (CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card))
  283. {
  284. if (permanent.IsTamer)
  285. {
  286. return true;
  287. }
  288. }
  289. return false;
  290. }
  291. bool CanUseCondition(Hashtable hashtable)
  292. {
  293. if (CardEffectCommons.IsExistOnBattleArea(card))
  294. {
  295. if (CardEffectCommons.CanTriggerOnPermanentDeleted(hashtable, PermanentCondition, activateClass))
  296. {
  297. return true;
  298. }
  299. }
  300. return false;
  301. }
  302. bool CanActivateCondition(Hashtable hashtable)
  303. {
  304. if (CardEffectCommons.IsExistOnBattleArea(card))
  305. {
  306. return true;
  307. }
  308. return false;
  309. }
  310. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  311. {
  312. if (card.Owner.CanAddSecurity(activateClass))
  313. {
  314. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  315. {
  316. int maxCount = Math.Min(1, card.Owner.TrashCards.Count((cardSource) => CanSelectCardCondition(cardSource)));
  317. List<CardSource> selectedCards = new List<CardSource>();
  318. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  319. selectCardEffect.SetUp(
  320. canTargetCondition: CanSelectCardCondition,
  321. canTargetCondition_ByPreSelecetedList: null,
  322. canEndSelectCondition: null,
  323. canNoSelect: () => false,
  324. selectCardCoroutine: SelectCardCoroutine,
  325. afterSelectCardCoroutine: null,
  326. message: "Select 1 [Marcus Damon] to add to security.",
  327. maxCount: maxCount,
  328. canEndNotMax: false,
  329. isShowOpponent: true,
  330. mode: SelectCardEffect.Mode.Custom,
  331. root: SelectCardEffect.Root.Trash,
  332. customRootCardList: null,
  333. canLookReverseCard: true,
  334. selectPlayer: card.Owner,
  335. cardEffect: activateClass);
  336. selectCardEffect.SetUpCustomMessage("Select 1 card to add to security.", "The opponent is selecting 1 card to add to security.");
  337. selectCardEffect.SetUpCustomMessage_ShowCard("Security Card");
  338. yield return StartCoroutine(selectCardEffect.Activate());
  339. IEnumerator SelectCardCoroutine(CardSource cardSource)
  340. {
  341. selectedCards.Add(cardSource);
  342. yield return null;
  343. }
  344. if (selectedCards.Count >= 1)
  345. {
  346. foreach (CardSource selectedCard in selectedCards)
  347. {
  348. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddSecurityCard(selectedCard));
  349. }
  350. }
  351. }
  352. }
  353. }
  354. }
  355. #endregion
  356. return cardEffects;
  357. }
  358. }
  359. }