BT21_073.cs 26 KB

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