BT11_041.cs 27 KB

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