BT18_066.cs 28 KB

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