BT21_073.cs 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. //BT21_073 Charismon
  5. namespace DCGO.CardEffects.BT21
  6. {
  7. public class BT21_073 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Alternative Digivolution Condition - Sup.
  13. if (timing == EffectTiming.None)
  14. {
  15. bool PermanentCondition(Permanent targetPermanent)
  16. {
  17. return targetPermanent.TopCard.EqualsTraits("Sup.");
  18. }
  19. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(permanentCondition: PermanentCondition, digivolutionCost: 4, ignoreDigivolutionRequirement: false, card: card, condition: null));
  20. }
  21. #endregion
  22. #region Appfusion
  23. if (timing == EffectTiming.None)
  24. {
  25. AddAppFusionConditionClass addAppFusionConditionClass = new AddAppFusionConditionClass();
  26. addAppFusionConditionClass.SetUpICardEffect($"App Fusion", CanUseCondition, card);
  27. addAppFusionConditionClass.SetUpAddAppFusionConditionClass(getAppFusionCondition: GetAppFusion);
  28. addAppFusionConditionClass.SetNotShowUI(true);
  29. cardEffects.Add(addAppFusionConditionClass);
  30. bool CanUseCondition(Hashtable hashtable)
  31. {
  32. return true;
  33. }
  34. AppFusionCondition GetAppFusion(CardSource cardSource)
  35. {
  36. string[] validCards = { "Sociamon", "Gossipmon" };
  37. if (cardSource == card)
  38. {
  39. bool linkCondition(CardSource source)
  40. {
  41. foreach (string name in validCards)
  42. {
  43. if (source.EqualsCardName(name))
  44. {
  45. foreach(string otherName in validCards)
  46. {
  47. if(otherName != name && source.PermanentOfThisCard().TopCard.EqualsCardName(otherName))
  48. {
  49. return true;
  50. }
  51. }
  52. }
  53. }
  54. return false;
  55. }
  56. bool digimonCondition(Permanent permanent)
  57. {
  58. if (!card.CanNotEvolve(permanent))
  59. {
  60. foreach(string name in validCards)
  61. {
  62. if (permanent.TopCard.EqualsCardName(name))
  63. {
  64. return true;
  65. }
  66. }
  67. }
  68. return false;
  69. }
  70. AppFusionCondition AppFusionCondition = new AppFusionCondition(
  71. linkedCondition: linkCondition,
  72. selectLinkMessage: "1 [Sociamon] or [Gossipmon]",
  73. digimonCondition: digimonCondition,
  74. selectDigimonMessage: "1 [Sociamon] or [Gossipmon]",
  75. cost: 0);
  76. return AppFusionCondition;
  77. }
  78. return null;
  79. }
  80. }
  81. #endregion
  82. #region Blocker
  83. if (timing == EffectTiming.None)
  84. {
  85. cardEffects.Add(CardEffectFactory.BlockerSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  86. }
  87. #endregion
  88. #region On Play/When Digivolving shared
  89. bool CanLinkCondition(CardSource cardSource)
  90. {
  91. return cardSource.HasLevel && cardSource.Level <= 4 && cardSource.CanLinkToTargetPermanent(card.PermanentOfThisCard(), false);
  92. }
  93. bool CanActivateConditionShared(Hashtable hashtable)
  94. {
  95. return isExistOnField(card) &&
  96. (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanLinkCondition) ||
  97. card.PermanentOfThisCard().DigivolutionCards.Exists(CanLinkCondition));
  98. }
  99. #endregion
  100. #region On Play
  101. if(timing == EffectTiming.OnEnterFieldAnyone)
  102. {
  103. ActivateClass activateClass = new ActivateClass();
  104. activateClass.SetUpICardEffect("Link from trash or sources", CanUseCondition, card);
  105. activateClass.SetUpActivateClass(CanActivateConditionShared, ActivateCoroutine, -1, true, EffectDescription());
  106. cardEffects.Add(activateClass);
  107. string EffectDescription()
  108. {
  109. return "[On Play] You may link 1 level 4 or lower Digimon card from your trash or this Digimon's digivolution cards to this Digimon without paying the cost.";
  110. }
  111. bool CanUseCondition(Hashtable hashtable)
  112. {
  113. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  114. }
  115. IEnumerator ActivateCoroutine(Hashtable hashtable)
  116. {
  117. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanLinkCondition);
  118. bool canSelectSources = card.PermanentOfThisCard().DigivolutionCards.Exists(CanLinkCondition);
  119. if(canSelectSources || canSelectTrash)
  120. {
  121. if(canSelectTrash && canSelectSources)
  122. {
  123. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>
  124. {
  125. new(message: "From sources", value: true, spriteIndex: 0),
  126. new(message: "From trash", value: false, spriteIndex: 1),
  127. };
  128. string selectPlayerMessage = "From which area do you select a card?";
  129. string notSelectPlayerMessage = "The opponent is choosing from which area to select a card.";
  130. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  131. }
  132. else
  133. {
  134. GManager.instance.userSelectionManager.SetBool(canSelectSources);
  135. }
  136. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  137. bool fromSources = GManager.instance.userSelectionManager.SelectedBoolValue;
  138. List<CardSource> selectedCards = new List<CardSource>();
  139. IEnumerator SelectCardCoroutine(CardSource cardSource)
  140. {
  141. selectedCards.Add(cardSource);
  142. yield return null;
  143. }
  144. if (fromSources)
  145. {
  146. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  147. selectCardEffect.SetUp(
  148. canTargetCondition: CanLinkCondition,
  149. canTargetCondition_ByPreSelecetedList: null,
  150. canEndSelectCondition: null,
  151. canNoSelect: () => true,
  152. selectCardCoroutine: SelectCardCoroutine,
  153. afterSelectCardCoroutine: null,
  154. message: "Select 1 digivolution card to link.",
  155. maxCount: 1,
  156. canEndNotMax: false,
  157. isShowOpponent: true,
  158. mode: SelectCardEffect.Mode.Custom,
  159. root: SelectCardEffect.Root.Custom,
  160. customRootCardList: card.PermanentOfThisCard().DigivolutionCards,
  161. canLookReverseCard: true,
  162. selectPlayer: card.Owner,
  163. cardEffect: activateClass);
  164. selectCardEffect.SetUpCustomMessage("Select 1 digivolution card to link.", "The opponent is selecting 1 digivolution card to link.");
  165. selectCardEffect.SetUpCustomMessage_ShowCard("Linked Card");
  166. yield return StartCoroutine(selectCardEffect.Activate());
  167. }
  168. else
  169. {
  170. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  171. selectCardEffect.SetUp(
  172. canTargetCondition: CanLinkCondition,
  173. canTargetCondition_ByPreSelecetedList: null,
  174. canEndSelectCondition: null,
  175. canNoSelect: () => true,
  176. selectCardCoroutine: SelectCardCoroutine,
  177. afterSelectCardCoroutine: null,
  178. message: "Select 1 card to link.",
  179. maxCount: 1,
  180. canEndNotMax: false,
  181. isShowOpponent: true,
  182. mode: SelectCardEffect.Mode.Custom,
  183. root: SelectCardEffect.Root.Trash,
  184. customRootCardList: null,
  185. canLookReverseCard: true,
  186. selectPlayer: card.Owner,
  187. cardEffect: activateClass);
  188. selectCardEffect.SetUpCustomMessage("Select 1 digivolution card to link.", "The opponent is selecting 1 digivolution card to link.");
  189. selectCardEffect.SetUpCustomMessage_ShowCard("Linked Card");
  190. yield return StartCoroutine(selectCardEffect.Activate());
  191. }
  192. if (selectedCards.Count >= 1)
  193. {
  194. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddLinkCard(selectedCards[0], activateClass));
  195. }
  196. }
  197. }
  198. }
  199. #endregion
  200. #region When Digivolving
  201. if (timing == EffectTiming.OnEnterFieldAnyone)
  202. {
  203. ActivateClass activateClass = new ActivateClass();
  204. activateClass.SetUpICardEffect("Link from trash or sources", CanUseCondition, card);
  205. activateClass.SetUpActivateClass(CanActivateConditionShared, ActivateCoroutine, -1, true, EffectDescription());
  206. cardEffects.Add(activateClass);
  207. string EffectDescription()
  208. {
  209. return "[When Digivolving] You may link 1 level 4 or lower Digimon card from your trash or this Digimon's digivolution cards to this Digimon without paying the cost.";
  210. }
  211. bool CanUseCondition(Hashtable hashtable)
  212. {
  213. return CardEffectCommons.CanTriggerOnPlay(hashtable, card);
  214. }
  215. IEnumerator ActivateCoroutine(Hashtable hashtable)
  216. {
  217. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanLinkCondition);
  218. bool canSelectSources = card.PermanentOfThisCard().DigivolutionCards.Exists(CanLinkCondition);
  219. if (canSelectSources || canSelectTrash)
  220. {
  221. if (canSelectTrash && canSelectSources)
  222. {
  223. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>
  224. {
  225. new(message: "From sources", value: true, spriteIndex: 0),
  226. new(message: "From trash", value: false, spriteIndex: 1),
  227. };
  228. string selectPlayerMessage = "From which area do you select a card?";
  229. string notSelectPlayerMessage = "The opponent is choosing from which area to select a card.";
  230. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  231. }
  232. else
  233. {
  234. GManager.instance.userSelectionManager.SetBool(canSelectSources);
  235. }
  236. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  237. bool fromSources = GManager.instance.userSelectionManager.SelectedBoolValue;
  238. List<CardSource> selectedCards = new List<CardSource>();
  239. IEnumerator SelectCardCoroutine(CardSource cardSource)
  240. {
  241. selectedCards.Add(cardSource);
  242. yield return null;
  243. }
  244. if (fromSources)
  245. {
  246. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  247. selectCardEffect.SetUp(
  248. canTargetCondition: CanLinkCondition,
  249. canTargetCondition_ByPreSelecetedList: null,
  250. canEndSelectCondition: null,
  251. canNoSelect: () => true,
  252. selectCardCoroutine: SelectCardCoroutine,
  253. afterSelectCardCoroutine: null,
  254. message: "Select 1 digivolution card to link.",
  255. maxCount: 1,
  256. canEndNotMax: false,
  257. isShowOpponent: true,
  258. mode: SelectCardEffect.Mode.Custom,
  259. root: SelectCardEffect.Root.Custom,
  260. customRootCardList: card.PermanentOfThisCard().DigivolutionCards,
  261. canLookReverseCard: true,
  262. selectPlayer: card.Owner,
  263. cardEffect: activateClass);
  264. selectCardEffect.SetUpCustomMessage("Select 1 digivolution card to link.", "The opponent is selecting 1 digivolution card to link.");
  265. selectCardEffect.SetUpCustomMessage_ShowCard("Linked Card");
  266. yield return StartCoroutine(selectCardEffect.Activate());
  267. }
  268. else
  269. {
  270. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  271. selectCardEffect.SetUp(
  272. canTargetCondition: CanLinkCondition,
  273. canTargetCondition_ByPreSelecetedList: null,
  274. canEndSelectCondition: null,
  275. canNoSelect: () => true,
  276. selectCardCoroutine: SelectCardCoroutine,
  277. afterSelectCardCoroutine: null,
  278. message: "Select 1 card to link.",
  279. maxCount: 1,
  280. canEndNotMax: false,
  281. isShowOpponent: true,
  282. mode: SelectCardEffect.Mode.Custom,
  283. root: SelectCardEffect.Root.Trash,
  284. customRootCardList: null,
  285. canLookReverseCard: true,
  286. selectPlayer: card.Owner,
  287. cardEffect: activateClass);
  288. selectCardEffect.SetUpCustomMessage("Select 1 digivolution card to link.", "The opponent is selecting 1 digivolution card to link.");
  289. selectCardEffect.SetUpCustomMessage_ShowCard("Linked Card");
  290. yield return StartCoroutine(selectCardEffect.Activate());
  291. }
  292. if (selectedCards.Count >= 1)
  293. {
  294. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddLinkCard(selectedCards[0], activateClass));
  295. }
  296. }
  297. }
  298. }
  299. #endregion
  300. #region Your turn
  301. if(timing == EffectTiming.WhenLinked)
  302. {
  303. ActivateClass activateClass = new ActivateClass();
  304. activateClass.SetUpICardEffect("Taunt when linked", CanUseCondition, card);
  305. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDescription());
  306. activateClass.SetHashString("BT21_073_tauntOnLink");
  307. cardEffects.Add(activateClass);
  308. string EffectDescription()
  309. {
  310. return "[Your Turn][Once Per Turn] When this Digimon gets linked, give 1 of your opponent's Digimon \"[Start of Your Main Phase] This Digimon attacks.\" until their turn ends.";
  311. }
  312. bool targetPermanentCondition( Permanent permanent)
  313. {
  314. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  315. }
  316. bool LinkedPermanentCondition(Permanent permanent)
  317. {
  318. return permanent == card.PermanentOfThisCard();
  319. }
  320. bool CanUseCondition(Hashtable hashtable)
  321. {
  322. return CardEffectCommons.CanTriggerWhenLinked(hashtable, LinkedPermanentCondition, null);
  323. }
  324. bool CanActivateCondition(Hashtable hashtable)
  325. {
  326. return isExistOnField(card) && CardEffectCommons.HasMatchConditionOpponentsPermanent(card, targetPermanentCondition);
  327. }
  328. IEnumerator ActivateCoroutine(Hashtable hashtable)
  329. {
  330. if (CardEffectCommons.HasMatchConditionPermanent(targetPermanentCondition))
  331. {
  332. Permanent selectedPermanent = null;
  333. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  334. selectPermanentEffect.SetUp(
  335. selectPlayer: card.Owner,
  336. canTargetCondition: targetPermanentCondition,
  337. canTargetCondition_ByPreSelecetedList: null,
  338. canEndSelectCondition: null,
  339. maxCount: 1,
  340. canNoSelect: false,
  341. canEndNotMax: false,
  342. selectPermanentCoroutine: SelectPermanentCoroutine,
  343. afterSelectPermanentCoroutine: null,
  344. mode: SelectPermanentEffect.Mode.Custom,
  345. cardEffect: activateClass);
  346. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get effects.",
  347. "The opponent is selecting 1 Digimon that will get effects.");
  348. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  349. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  350. {
  351. selectedPermanent = permanent;
  352. yield return null;
  353. }
  354. if (selectedPermanent != null)
  355. {
  356. ActivateClass activateClassDebuff = new ActivateClass();
  357. activateClassDebuff.SetUpICardEffect("Attack with this Digimon", CanUseConditionDebuff,
  358. selectedPermanent.TopCard);
  359. activateClassDebuff.SetUpActivateClass(CanActivateConditionDebuff, ActivateCoroutineDebuff, -1, false,
  360. EffectDescriptionDebuff());
  361. activateClassDebuff.SetEffectSourcePermanent(selectedPermanent);
  362. selectedPermanent.UntilOwnerTurnEndEffects.Add(GetCardEffect);
  363. if (!selectedPermanent.TopCard.CanNotBeAffected(activateClass))
  364. {
  365. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>()
  366. .CreateDebuffEffect(selectedPermanent));
  367. }
  368. string EffectDescriptionDebuff()
  369. {
  370. return "[Start of Your Main Phase] Attack with this Digimon.";
  371. }
  372. bool CanUseConditionDebuff(Hashtable hashtable1)
  373. {
  374. return CardEffectCommons.IsPermanentExistsOnBattleAreaDigimon(selectedPermanent) &&
  375. selectedPermanent.TopCard.Owner.GetBattleAreaDigimons().Contains(selectedPermanent) &&
  376. GManager.instance.turnStateMachine.gameContext.TurnPlayer == selectedPermanent.TopCard.Owner;
  377. }
  378. bool CanActivateConditionDebuff(Hashtable hashtable1)
  379. {
  380. return CardEffectCommons.IsPermanentExistsOnBattleAreaDigimon(selectedPermanent) &&
  381. !selectedPermanent.TopCard.CanNotBeAffected(activateClass) &&
  382. selectedPermanent.CanAttack(activateClassDebuff);
  383. }
  384. IEnumerator ActivateCoroutineDebuff(Hashtable hashtableDebuff)
  385. {
  386. if (CardEffectCommons.IsPermanentExistsOnBattleArea(selectedPermanent) &&
  387. selectedPermanent.CanAttack(activateClassDebuff))
  388. {
  389. SelectAttackEffect selectAttackEffect =
  390. GManager.instance.GetComponent<SelectAttackEffect>();
  391. selectAttackEffect.SetUp(
  392. attacker: selectedPermanent,
  393. canAttackPlayerCondition: () => true,
  394. defenderCondition: _ => true,
  395. cardEffect: activateClassDebuff);
  396. selectAttackEffect.SetCanNotSelectNotAttack();
  397. yield return ContinuousController.instance.StartCoroutine(selectAttackEffect.Activate());
  398. }
  399. }
  400. ICardEffect GetCardEffect(EffectTiming timingDebuff)
  401. {
  402. return timingDebuff == EffectTiming.OnStartMainPhase ? activateClassDebuff : null;
  403. }
  404. }
  405. }
  406. }
  407. }
  408. #endregion
  409. #region Linking
  410. if (timing == EffectTiming.None)
  411. {
  412. bool PermanentCondition(Permanent permanent)
  413. {
  414. return permanent.TopCard.HasAppmonTraits;
  415. }
  416. cardEffects.Add(CardEffectFactory.AddSelfLinkConditionStaticEffect(permanentCondition: PermanentCondition, linkCost: 3, card: card));
  417. }
  418. if(timing == EffectTiming.OnDeclaration)
  419. {
  420. cardEffects.Add(CardEffectFactory.LinkEffect(card));
  421. }
  422. #endregion
  423. #region Link effect
  424. if (timing == EffectTiming.WhenRemoveField)
  425. {
  426. List<Permanent> removedPermanents = new List<Permanent>();
  427. ActivateClass activateClass = new ActivateClass();
  428. activateClass.SetUpICardEffect("Trash a linked card to prevent this digimon from leaving", CanUseCondition, card);
  429. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDescription());
  430. activateClass.SetIsLinkedEffect(true);
  431. activateClass.SetHashString("AllTurns_BT21_073");
  432. cardEffects.Add(activateClass);
  433. string EffectDescription()
  434. {
  435. return
  436. "[All Turns][Once Per Turn] When this Digimon would leave the battle area, by trashing 1 of this Digimon's link cards, it doesn't leave.";
  437. }
  438. bool CanUseCondition(Hashtable hashtable)
  439. {
  440. return CardEffectCommons.IsExistLinked(card) &&
  441. CardEffectCommons.CanTriggerWhenRemoveField(hashtable, card);
  442. }
  443. bool CanSelectPermanentCondition(Permanent permanent)
  444. {
  445. if (permanent == card.PermanentOfThisCard())
  446. {
  447. if (permanent.LinkedCards.Count(CanSelectCardCondition) >= 1)
  448. {
  449. return true;
  450. }
  451. }
  452. return false;
  453. }
  454. bool CanSelectCardCondition(CardSource cardSource)
  455. {
  456. return true;
  457. }
  458. bool CanActivateCondition(Hashtable hashtable)
  459. {
  460. return CardEffectCommons.IsExistLinked(card) &&
  461. !card.PermanentOfThisCard().HasNoLinkCards;
  462. }
  463. IEnumerator ActivateCoroutine(Hashtable hashtable)
  464. {
  465. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.SelectTrashLinkedCards(CanSelectPermanentCondition, CanSelectCardCondition, 1, true, true, activateClass,afterSelectionCoroutine: AfterSelectCardCoroutine));
  466. bool trashed = false;
  467. IEnumerator AfterSelectCardCoroutine(Permanent permanent, List<CardSource> cardSources)
  468. {
  469. if(cardSources.Count == 1)
  470. {
  471. trashed = true;
  472. }
  473. yield return null;
  474. }
  475. if (trashed)
  476. {
  477. card.PermanentOfThisCard().willBeRemoveField = false;
  478. card.PermanentOfThisCard().HideHandBounceEffect();
  479. card.PermanentOfThisCard().HideDeckBounceEffect();
  480. card.PermanentOfThisCard().HideWillRemoveFieldEffect();
  481. card.PermanentOfThisCard().HideDeleteEffect();
  482. }
  483. }
  484. }
  485. #endregion
  486. return cardEffects;
  487. }
  488. }
  489. }