BT15_065.cs 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. namespace DCGO.CardEffects.BT15
  6. {
  7. public class BT15_065 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Alternate Digivolution Requirement
  13. if (timing == EffectTiming.None)
  14. {
  15. static bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.TopCard.ContainsCardName("Numemon") && targetPermanent.TopCard.HasLevel && targetPermanent.TopCard.Level == 4;
  18. }
  19. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  20. }
  21. #endregion
  22. #region On Play - Place a card under this Digimon to gain effects.
  23. if (timing == EffectTiming.OnEnterFieldAnyone)
  24. {
  25. ActivateClass activateClass = new ActivateClass();
  26. activateClass.SetUpICardEffect("Place a card under this Digimon to gain effects.", CanUseCondition, card);
  27. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  28. activateClass.SetHashString("CantAttack_BT15_065");
  29. cardEffects.Add(activateClass);
  30. string EffectDiscription()
  31. {
  32. return "[On Play] By placing 1 card with [Numemon] in it's name from your trash as this Digimon's bottom digivolution card, all of your opponent's Digimon with a play cost of 5 or less can't attack players until the end of your opponent's turn.";
  33. }
  34. bool CanSelectCardCondition(CardSource cardSource)
  35. {
  36. return cardSource.ContainsCardName("Numemon");
  37. }
  38. bool CanUseCondition(Hashtable hashtable)
  39. {
  40. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  41. }
  42. bool CanActivateCondition(Hashtable hashtable)
  43. {
  44. if (CardEffectCommons.IsExistOnBattleArea(card))
  45. {
  46. if (!card.PermanentOfThisCard().IsToken)
  47. {
  48. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  49. {
  50. return true;
  51. }
  52. }
  53. }
  54. return false;
  55. }
  56. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  57. {
  58. if (CardEffectCommons.IsExistOnBattleArea(card))
  59. {
  60. bool added = false;
  61. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  62. {
  63. List<CardSource> selectedCards = new List<CardSource>();
  64. int maxCount = 1;
  65. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  66. selectCardEffect.SetUp(
  67. canTargetCondition: CanSelectCardCondition,
  68. canTargetCondition_ByPreSelecetedList: null,
  69. canEndSelectCondition: null,
  70. canNoSelect: () => true,
  71. selectCardCoroutine: SelectCardCoroutine,
  72. afterSelectCardCoroutine: null,
  73. message: "Select 1 card to place on bottom of digivolution cards.",
  74. maxCount: maxCount,
  75. canEndNotMax: false,
  76. isShowOpponent: true,
  77. mode: SelectCardEffect.Mode.Custom,
  78. root: SelectCardEffect.Root.Trash,
  79. customRootCardList: null,
  80. canLookReverseCard: true,
  81. selectPlayer: card.Owner,
  82. cardEffect: activateClass);
  83. selectCardEffect.SetUpCustomMessage_ShowCard("Digivolution Card");
  84. selectCardEffect.SetUpCustomMessage("Select 1 card to place on bottom of digivolution cards.", "The opponent is selecting 1 card to place on bottom of digivolution cards.");
  85. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  86. IEnumerator SelectCardCoroutine(CardSource cardSource)
  87. {
  88. selectedCards.Add(cardSource);
  89. yield return null;
  90. }
  91. if (selectedCards.Count >= 1)
  92. {
  93. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsBottom(selectedCards, activateClass));
  94. added = true;
  95. }
  96. }
  97. if (added)
  98. {
  99. bool AttackerCondition(Permanent Attacker)
  100. {
  101. if (CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(Attacker, card))
  102. {
  103. if (Attacker.TopCard.GetCostItself <= 5)
  104. {
  105. if (Attacker.TopCard.HasPlayCost)
  106. {
  107. return true;
  108. }
  109. }
  110. }
  111. return false;
  112. }
  113. bool DefenderCondition(Permanent Defender)
  114. {
  115. return Defender == null;
  116. }
  117. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainCanNotAttackPlayerEffect(
  118. attackerCondition: AttackerCondition,
  119. defenderCondition: DefenderCondition,
  120. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  121. activateClass: activateClass,
  122. effectName: "Can't Attack"));
  123. }
  124. }
  125. }
  126. }
  127. #endregion
  128. #region On Play - Trash 1 card from hand to DeDigivolve an opponent's Digimon.
  129. if (timing == EffectTiming.OnEnterFieldAnyone)
  130. {
  131. ActivateClass activateClass = new ActivateClass();
  132. activateClass.SetUpICardEffect("Trash 1 card from hand to DeDigivolve an opponent's Digimon.", CanUseCondition, card);
  133. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  134. activateClass.SetHashString("DeDigivolve_BT15_065");
  135. cardEffects.Add(activateClass);
  136. string EffectDiscription()
  137. {
  138. return "[On Play] By trashing 1 card with [Numemon] in it's name in your hand or from the bottom of this Digimon's digivolution cards, [De-Digivolve 1] 1 of your opponent's Digimon.";
  139. }
  140. bool CanSelectCardCondition(CardSource cardSource)
  141. {
  142. if (cardSource.ContainsCardName("Numemon"))
  143. {
  144. return true;
  145. }
  146. return false;
  147. }
  148. bool CanSelectPermanentCondition(Permanent permanent)
  149. {
  150. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  151. }
  152. bool CanUseCondition(Hashtable hashtable)
  153. {
  154. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  155. }
  156. bool CanActivateCondition(Hashtable hashtable)
  157. {
  158. if (CardEffectCommons.IsExistOnBattleArea(card))
  159. {
  160. if (card.Owner.HandCards.Count >= 1)
  161. {
  162. return true;
  163. }
  164. if(card.PermanentOfThisCard().DigivolutionCards.Count(CanSelectCardCondition) >= 1)
  165. {
  166. return true;
  167. }
  168. }
  169. return false;
  170. }
  171. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  172. {
  173. bool canSelectHand = card.Owner.HandCards.Count(CanSelectCardCondition) >= 1;
  174. bool canSelectDigivolutionCards = CardEffectCommons.IsExistOnBattleArea(card)
  175. && card.PermanentOfThisCard().DigivolutionCards.Count(CanSelectCardCondition) >= 1;
  176. if (canSelectHand || canSelectDigivolutionCards)
  177. {
  178. if (canSelectHand && canSelectDigivolutionCards)
  179. {
  180. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  181. {
  182. new SelectionElement<bool>(message: $"From hand", value : true, spriteIndex: 0),
  183. new SelectionElement<bool>(message: $"From digivolution cards", value : false, spriteIndex: 1),
  184. };
  185. string selectPlayerMessage = "From which area do you play a card?";
  186. string notSelectPlayerMessage = "The opponent is choosing from which area to play a card.";
  187. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  188. }
  189. else
  190. {
  191. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  192. }
  193. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  194. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  195. bool discarded = false;
  196. int discardCount = 1;
  197. if (fromHand)
  198. {
  199. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  200. selectHandEffect.SetUp(
  201. selectPlayer: card.Owner,
  202. canTargetCondition: CanSelectCardCondition,
  203. canTargetCondition_ByPreSelecetedList: null,
  204. canEndSelectCondition: null,
  205. maxCount: discardCount,
  206. canNoSelect: true,
  207. canEndNotMax: false,
  208. isShowOpponent: true,
  209. selectCardCoroutine: null,
  210. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  211. mode: SelectHandEffect.Mode.Discard,
  212. cardEffect: activateClass);
  213. yield return StartCoroutine(selectHandEffect.Activate());
  214. }
  215. else
  216. {
  217. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  218. selectCardEffect.SetUp(
  219. canTargetCondition: CanSelectCardCondition,
  220. canTargetCondition_ByPreSelecetedList: null,
  221. canEndSelectCondition: null,
  222. canNoSelect: () => true,
  223. selectCardCoroutine: null,
  224. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  225. message: "Select 1 card to trash.",
  226. maxCount: discardCount,
  227. canEndNotMax: false,
  228. isShowOpponent: true,
  229. mode: SelectCardEffect.Mode.Discard,
  230. root: SelectCardEffect.Root.Custom,
  231. customRootCardList: card.PermanentOfThisCard().DigivolutionCards,
  232. canLookReverseCard: false,
  233. selectPlayer: card.Owner,
  234. cardEffect: activateClass);
  235. selectCardEffect.SetUpCustomMessage("Select 1 digivolution card to trash.", "The opponent is selecting 1 digivolution card to trash.");
  236. yield return StartCoroutine(selectCardEffect.Activate());
  237. }
  238. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  239. {
  240. if (cardSources.Count >= 1)
  241. {
  242. discarded = true;
  243. yield return null;
  244. }
  245. }
  246. if (discarded)
  247. {
  248. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  249. {
  250. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  251. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  252. selectPermanentEffect.SetUp(
  253. selectPlayer: card.Owner,
  254. canTargetCondition: CanSelectPermanentCondition,
  255. canTargetCondition_ByPreSelecetedList: null,
  256. canEndSelectCondition: null,
  257. maxCount: maxCount,
  258. canNoSelect: false,
  259. canEndNotMax: false,
  260. selectPermanentCoroutine: SelectPermanentCoroutine,
  261. afterSelectPermanentCoroutine: null,
  262. mode: SelectPermanentEffect.Mode.Custom,
  263. cardEffect: activateClass);
  264. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to De-Digivolve.", "The opponent is selecting 1 Digimon to De-Digivolve.");
  265. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  266. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  267. {
  268. Permanent selectedPermanent = permanent;
  269. yield return ContinuousController.instance.StartCoroutine(new IDegeneration(selectedPermanent, 1, activateClass).Degeneration());
  270. }
  271. }
  272. }
  273. }
  274. }
  275. }
  276. #endregion
  277. #region When Digivolving - Trash 1 card from hand to DeDigivolve an opponent's Digimon.
  278. if (timing == EffectTiming.OnEnterFieldAnyone)
  279. {
  280. ActivateClass activateClass = new ActivateClass();
  281. activateClass.SetUpICardEffect("Trash 1 card from hand to DeDigivolve an opponent's Digimon.", CanUseCondition, card);
  282. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  283. activateClass.SetHashString("DeDigivolve_BT15_065");
  284. cardEffects.Add(activateClass);
  285. string EffectDiscription()
  286. {
  287. return "[When Digivolving] By trashing 1 card with [Numemon] in it's name in your hand or from the bottom of this Digimon's digivolution cards, [De-Digivolve 1] 1 of your opponent's Digimon.";
  288. }
  289. bool CanSelectCardCondition(CardSource cardSource)
  290. {
  291. if (cardSource.ContainsCardName("Numemon"))
  292. {
  293. return true;
  294. }
  295. return false;
  296. }
  297. bool CanSelectPermanentCondition(Permanent permanent)
  298. {
  299. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  300. }
  301. bool CanUseCondition(Hashtable hashtable)
  302. {
  303. return CardEffectCommons.CanTriggerWhenDigivolving(hashtable, card);
  304. }
  305. bool CanActivateCondition(Hashtable hashtable)
  306. {
  307. if (CardEffectCommons.IsExistOnBattleArea(card))
  308. {
  309. if (card.Owner.HandCards.Count >= 1)
  310. {
  311. return true;
  312. }
  313. }
  314. return false;
  315. }
  316. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  317. {
  318. bool canSelectHand = card.Owner.HandCards.Count(CanSelectCardCondition) >= 1;
  319. bool canSelectDigivolutionCards = CardEffectCommons.IsExistOnBattleArea(card)
  320. && card.PermanentOfThisCard().DigivolutionCards.Count(CanSelectCardCondition) >= 1;
  321. if (canSelectHand || canSelectDigivolutionCards)
  322. {
  323. if (canSelectHand && canSelectDigivolutionCards)
  324. {
  325. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  326. {
  327. new SelectionElement<bool>(message: $"From hand", value : true, spriteIndex: 0),
  328. new SelectionElement<bool>(message: $"From digivolution cards", value : false, spriteIndex: 1),
  329. };
  330. string selectPlayerMessage = "From which area do you play a card?";
  331. string notSelectPlayerMessage = "The opponent is choosing from which area to play a card.";
  332. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  333. }
  334. else
  335. {
  336. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  337. }
  338. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  339. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  340. bool discarded = false;
  341. int discardCount = 1;
  342. if (fromHand)
  343. {
  344. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  345. selectHandEffect.SetUp(
  346. selectPlayer: card.Owner,
  347. canTargetCondition: CanSelectCardCondition,
  348. canTargetCondition_ByPreSelecetedList: null,
  349. canEndSelectCondition: null,
  350. maxCount: discardCount,
  351. canNoSelect: true,
  352. canEndNotMax: false,
  353. isShowOpponent: true,
  354. selectCardCoroutine: null,
  355. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  356. mode: SelectHandEffect.Mode.Discard,
  357. cardEffect: activateClass);
  358. yield return StartCoroutine(selectHandEffect.Activate());
  359. }
  360. else
  361. {
  362. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  363. selectCardEffect.SetUp(
  364. canTargetCondition: CanSelectCardCondition,
  365. canTargetCondition_ByPreSelecetedList: null,
  366. canEndSelectCondition: null,
  367. canNoSelect: () => true,
  368. selectCardCoroutine: null,
  369. afterSelectCardCoroutine: AfterSelectCardCoroutine,
  370. message: "Select 1 card to trash.",
  371. maxCount: discardCount,
  372. canEndNotMax: false,
  373. isShowOpponent: true,
  374. mode: SelectCardEffect.Mode.Discard,
  375. root: SelectCardEffect.Root.Custom,
  376. customRootCardList: card.PermanentOfThisCard().DigivolutionCards,
  377. canLookReverseCard: true,
  378. selectPlayer: card.Owner,
  379. cardEffect: activateClass);
  380. selectCardEffect.SetUpCustomMessage("Select 1 digivolution card to trash.", "The opponent is selecting 1 digivolution card to trash.");
  381. yield return StartCoroutine(selectCardEffect.Activate());
  382. }
  383. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  384. {
  385. if (cardSources.Count >= 1)
  386. {
  387. discarded = true;
  388. yield return null;
  389. }
  390. }
  391. if (discarded)
  392. {
  393. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  394. {
  395. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(CanSelectPermanentCondition));
  396. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  397. selectPermanentEffect.SetUp(
  398. selectPlayer: card.Owner,
  399. canTargetCondition: CanSelectPermanentCondition,
  400. canTargetCondition_ByPreSelecetedList: null,
  401. canEndSelectCondition: null,
  402. maxCount: maxCount,
  403. canNoSelect: false,
  404. canEndNotMax: false,
  405. selectPermanentCoroutine: SelectPermanentCoroutine,
  406. afterSelectPermanentCoroutine: null,
  407. mode: SelectPermanentEffect.Mode.Custom,
  408. cardEffect: activateClass);
  409. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to De-Digivolve.", "The opponent is selecting 1 Digimon to De-Digivolve.");
  410. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  411. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  412. {
  413. Permanent selectedPermanent = permanent;
  414. yield return ContinuousController.instance.StartCoroutine(new IDegeneration(selectedPermanent, 1, activateClass).Degeneration());
  415. }
  416. }
  417. }
  418. }
  419. }
  420. }
  421. #endregion
  422. #region Your Turn - When you have a [Monzaemon] or [Numemon] in play, this Digimon gains Security Atk +1.
  423. if (timing == EffectTiming.None)
  424. {
  425. bool Condition()
  426. {
  427. if (CardEffectCommons.IsExistOnBattleArea(card))
  428. {
  429. if (CardEffectCommons.IsOwnerTurn(card))
  430. {
  431. if (card.PermanentOfThisCard().TopCard.ContainsCardName("Monzaemon") || card.PermanentOfThisCard().TopCard.ContainsCardName("Numemon"))
  432. {
  433. return true;
  434. }
  435. }
  436. }
  437. return false;
  438. }
  439. cardEffects.Add(CardEffectFactory.ChangeSelfSAttackStaticEffect(changeValue: 1, isInheritedEffect: true, card: card, condition: Condition));
  440. }
  441. #endregion
  442. return cardEffects;
  443. }
  444. }
  445. }