P_240.cs 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. // Arcturusmon
  4. namespace DCGO.CardEffects.P
  5. {
  6. public class P_240 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region Alternative Digivolution Condition
  12. if (timing == EffectTiming.None)
  13. {
  14. bool PermanentCondition(Permanent targetPermanent)
  15. {
  16. return targetPermanent.TopCard.HasText("Gammamon")
  17. || targetPermanent.TopCard.EqualsTraits("VB");
  18. }
  19. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(
  20. permanentCondition: PermanentCondition,
  21. digivolutionCost: 4,
  22. ignoreDigivolutionRequirement: false,
  23. card: card,
  24. condition: null,
  25. level: 5)
  26. );
  27. }
  28. #endregion
  29. #region Collision
  30. if (timing == EffectTiming.OnCounterTiming)
  31. {
  32. cardEffects.Add(CardEffectFactory.CollisionSelfStaticEffect(false, card, null));
  33. }
  34. #endregion
  35. #region Piercing
  36. if (timing == EffectTiming.OnDetermineDoSecurityCheck)
  37. {
  38. cardEffects.Add(CardEffectFactory.PierceSelfEffect(isInheritedEffect: false, card: card, condition: null));
  39. }
  40. #endregion
  41. #region Reboot
  42. if (timing == EffectTiming.None)
  43. {
  44. cardEffects.Add(CardEffectFactory.RebootSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  45. }
  46. #endregion
  47. #region Blocker
  48. if (timing == EffectTiming.None)
  49. {
  50. cardEffects.Add(CardEffectFactory.BlockerSelfStaticEffect(isInheritedEffect: false, card: card, condition: null));
  51. }
  52. #endregion
  53. #region Shared OP/WD
  54. string SharedEffectName = "<De-Digivolve 3> 1 enemy Digimon, then by placing 2 [Gammamon] text/[VB] from trash under, taunt 1 enemy Digimon";
  55. CardEffectFactory.ActivateClassesForSharedEffects
  56. (ref cardEffects, timing, card,
  57. SharedEffectName,
  58. SharedActivateCoroutine,
  59. SharedEffectDescription,
  60. optional: false,
  61. onPlay: true,
  62. whenDigivolving: true);
  63. string SharedEffectDescription(string tag)
  64. {
  65. return $"[{tag}] <De-Digivolve 3> 1 of your opponent's Digimon. Then, by placing 2 cards with [Gammamon] in their text or the [VB] trait from your trash as this Digimon's bottom digivolution cards, give 1 of your opponent's Digimon \"[Start of Your Main Phase] This Digimon attacks.\" until their turn ends.";
  66. }
  67. bool CanSelectPermanentCondition (Permanent permanent)
  68. {
  69. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  70. }
  71. bool CanSelectCardCondition (CardSource cardSource)
  72. {
  73. return cardSource.HasText("Gammamon")
  74. || cardSource.EqualsTraits("VB");
  75. }
  76. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  77. {
  78. if(CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  79. {
  80. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  81. selectPermanentEffect.SetUp(
  82. selectPlayer: card.Owner,
  83. canTargetCondition: CanSelectPermanentCondition,
  84. canTargetCondition_ByPreSelecetedList: null,
  85. canEndSelectCondition: null,
  86. maxCount: 1,
  87. canNoSelect: false,
  88. canEndNotMax: false,
  89. selectPermanentCoroutine: null,
  90. afterSelectPermanentCoroutine: null,
  91. mode: SelectPermanentEffect.Mode.Degenerate,
  92. cardEffect: activateClass);
  93. selectPermanentEffect.SetDegenerationCount(3);
  94. selectPermanentEffect.SetUpCustomMessage("Select 1 opponent's Digimon to De-Digivolve", "The opponent is selecting 1 Digimon to De-Digivolve");
  95. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  96. }
  97. if (CardEffectCommons.MatchConditionOwnersCardCountInTrash(card, CanSelectCardCondition) >= 2)
  98. {
  99. bool added = false;
  100. if (CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  101. {
  102. List<CardSource> selectedCards = new List<CardSource>();
  103. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  104. selectCardEffect.SetUp(
  105. canTargetCondition: CanSelectCardCondition,
  106. canTargetCondition_ByPreSelecetedList: null,
  107. canEndSelectCondition: null,
  108. canNoSelect: () => true,
  109. selectCardCoroutine: SelectCardCoroutine,
  110. afterSelectCardCoroutine: null,
  111. message: "Select 2 cards to place on bottom of digivolution cards.",
  112. maxCount: 2,
  113. canEndNotMax: false,
  114. isShowOpponent: true,
  115. mode: SelectCardEffect.Mode.Custom,
  116. root: SelectCardEffect.Root.Trash,
  117. customRootCardList: null,
  118. canLookReverseCard: true,
  119. selectPlayer: card.Owner,
  120. cardEffect: activateClass);
  121. selectCardEffect.SetUpCustomMessage_ShowCard("Digivolution Card");
  122. selectCardEffect.SetUpCustomMessage("Select 2 cards to place on bottom of digivolution cards.", "The opponent is selecting 2 cards to place on bottom of digivolution cards.");
  123. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  124. IEnumerator SelectCardCoroutine(CardSource cardSource)
  125. {
  126. selectedCards.Add(cardSource);
  127. yield return null;
  128. }
  129. if (selectedCards.Count == 2)
  130. {
  131. yield return ContinuousController.instance.StartCoroutine(card.PermanentOfThisCard().AddDigivolutionCardsBottom(
  132. selectedCards,
  133. activateClass));
  134. added = true;
  135. }
  136. }
  137. if (added)
  138. {
  139. Permanent selectedPermanent = null;
  140. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  141. selectPermanentEffect.SetUp(
  142. selectPlayer: card.Owner,
  143. canTargetCondition: CanSelectPermanentCondition,
  144. canTargetCondition_ByPreSelecetedList: null,
  145. canEndSelectCondition: null,
  146. maxCount: 1,
  147. canNoSelect: false,
  148. canEndNotMax: false,
  149. selectPermanentCoroutine: SelectPermanentCoroutine,
  150. afterSelectPermanentCoroutine: null,
  151. mode: SelectPermanentEffect.Mode.Custom,
  152. cardEffect: activateClass);
  153. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  154. {
  155. selectedPermanent = permanent;
  156. yield return null;
  157. }
  158. selectPermanentEffect.SetUpCustomMessage("Select 1 digimon to gain '[Start of Your Main Phase] This Digimon attacks'.", "The opponent is selecting 1 digimon to gain '[Start of Your Main Phase] This Digimon attacks'.");
  159. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  160. if (selectedPermanent != null)
  161. {
  162. ActivateClass activateClass1 = new ActivateClass();
  163. activateClass1.SetUpICardEffect("This Digimon attacks", CanUseCondition1, selectedPermanent.TopCard);
  164. activateClass1.SetUpActivateClass(CanActivateCondition1, ActivateCoroutine1, -1, false, EffectDescription1());
  165. activateClass1.SetEffectSourcePermanent(selectedPermanent);
  166. if (!selectedPermanent.TopCard.CanNotBeAffected(activateClass))
  167. {
  168. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateDebuffEffect(selectedPermanent));
  169. }
  170. string EffectDescription1()
  171. {
  172. return "[Start of Your Main Phase] This Digimon attacks.";
  173. }
  174. bool CanUseCondition1(Hashtable hashtable1)
  175. {
  176. return CardEffectCommons.IsPermanentExistsOnBattleArea(selectedPermanent)
  177. && selectedPermanent.TopCard.Owner.GetBattleAreaDigimons().Contains(selectedPermanent)
  178. && GManager.instance.turnStateMachine.gameContext.TurnPlayer == selectedPermanent.TopCard.Owner;
  179. }
  180. bool CanActivateCondition1(Hashtable hashtable1)
  181. {
  182. return CardEffectCommons.IsPermanentExistsOnBattleArea(selectedPermanent)
  183. && !selectedPermanent.TopCard.CanNotBeAffected(activateClass)
  184. && selectedPermanent.CanAttack(activateClass1);
  185. }
  186. IEnumerator ActivateCoroutine1(Hashtable _hashtable1)
  187. {
  188. SelectAttackEffect selectAttackEffect = GManager.instance.GetComponent<SelectAttackEffect>();
  189. selectAttackEffect.SetUp(
  190. attacker: selectedPermanent,
  191. canAttackPlayerCondition: () => true,
  192. defenderCondition: (permanent) => true,
  193. cardEffect: activateClass1);
  194. selectAttackEffect.SetCanNotSelectNotAttack();
  195. yield return ContinuousController.instance.StartCoroutine(selectAttackEffect.Activate());
  196. }
  197. ICardEffect GetCardEffect(EffectTiming _timing)
  198. {
  199. if (_timing == EffectTiming.OnStartMainPhase)
  200. {
  201. return activateClass1;
  202. }
  203. return null;
  204. }
  205. selectedPermanent.UntilOwnerTurnEndEffects.Add(GetCardEffect);
  206. }
  207. }
  208. }
  209. }
  210. #endregion
  211. #region On Deletion
  212. if (timing == EffectTiming.OnDestroyedAnyone)
  213. {
  214. ActivateClass activateClass = new ActivateClass();
  215. activateClass.SetUpICardEffect("You may play 1 [Proximamon] form hand/trash for free", CanUseCondition, card);
  216. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
  217. cardEffects.Add(activateClass);
  218. string EffectDescription()
  219. {
  220. return "[On Deletion] You may play 1 [Proximamon] from your hand or trash without paying the cost.";
  221. }
  222. bool CanUseCondition(Hashtable hashtable)
  223. {
  224. return CardEffectCommons.CanTriggerOnDeletion(hashtable, card, activateClass);
  225. }
  226. bool CanActivateCondition(Hashtable hashtable)
  227. {
  228. return CardEffectCommons.CanActivateOnDeletion(card, activateClass)
  229. && (CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectPlayCardCondition)
  230. || CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectPlayCardCondition));
  231. }
  232. bool CanSelectPlayCardCondition(CardSource cardSource)
  233. {
  234. return cardSource.EqualsCardName("Proximamon")
  235. && CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass);
  236. }
  237. IEnumerator ActivateCoroutine(Hashtable hashtable)
  238. {
  239. bool canSelectHand = CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectPlayCardCondition);
  240. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectPlayCardCondition);
  241. if (canSelectHand || canSelectTrash)
  242. {
  243. #region Setup Location Selection
  244. if (canSelectHand && canSelectTrash)
  245. {
  246. List<SelectionElement<int>> selectionElements = new List<SelectionElement<int>>
  247. {
  248. new(message: $"From hand", value: 1, spriteIndex: 0),
  249. new(message: $"From trash", value: 2, spriteIndex: 0),
  250. new(message: $"Don't play", value: 3, spriteIndex: 1)
  251. };
  252. string selectPlayerMessage = "From which area do you select a card?";
  253. string notSelectPlayerMessage = "The opponent is choosing from which area to select a card.";
  254. GManager.instance.userSelectionManager.SetIntSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  255. }
  256. else
  257. {
  258. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  259. }
  260. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  261. #endregion
  262. SelectCardEffect.Root root = GManager.instance.userSelectionManager.SelectedIntValue == 1 ? SelectCardEffect.Root.Hand : SelectCardEffect.Root.Trash;
  263. bool doSelect = GManager.instance.userSelectionManager.SelectedIntValue != 3;
  264. if (doSelect)
  265. {
  266. #region Hand/Trash Card Selection & Play
  267. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayByEffect(
  268. canTargetCondition: CanSelectPlayCardCondition,
  269. root,
  270. activateClass,
  271. payCost: false
  272. ));
  273. #endregion
  274. }
  275. }
  276. }
  277. }
  278. #endregion
  279. #region Assembly
  280. if (timing == EffectTiming.None)
  281. {
  282. AddAssemblyConditionClass addAssemblyConditionClass = new AddAssemblyConditionClass();
  283. addAssemblyConditionClass.SetUpICardEffect("Assembly", CanUseCondition, card);
  284. addAssemblyConditionClass.SetUpAddAssemblyConditionClass(getAssemblyCondition: GetAssembly);
  285. addAssemblyConditionClass.SetNotShowUI(true);
  286. cardEffects.Add(addAssemblyConditionClass);
  287. bool CanUseCondition(Hashtable hashtable)
  288. {
  289. return true;
  290. }
  291. AssemblyCondition GetAssembly(CardSource cardSource)
  292. {
  293. if (cardSource == card)
  294. {
  295. AssemblyConditionElement element1 = new AssemblyConditionElement(CanSelectCardCondition1, elementCount: 1);
  296. AssemblyConditionElement element2 = new AssemblyConditionElement(CanSelectCardCondition2, elementCount: 1);
  297. AssemblyConditionElement element3 = new AssemblyConditionElement(CanSelectCardCondition3, elementCount: 1);
  298. bool CanSelectCardCondition1(CardSource cardSource)
  299. {
  300. return cardSource != null
  301. && cardSource.Owner == card.Owner
  302. && cardSource.IsLevel5
  303. && (cardSource.HasText("Gammamon")
  304. || cardSource.EqualsTraits("VB"));
  305. }
  306. bool CanSelectCardCondition2(CardSource cardSource)
  307. {
  308. return cardSource != null
  309. && cardSource.Owner == card.Owner
  310. && cardSource.IsLevel4
  311. && (cardSource.HasText("Gammamon")
  312. || cardSource.EqualsTraits("VB"));
  313. }
  314. bool CanSelectCardCondition3(CardSource cardSource)
  315. {
  316. return cardSource != null
  317. && cardSource.Owner == card.Owner
  318. && cardSource.IsLevel3
  319. && (cardSource.HasText("Gammamon")
  320. || cardSource.EqualsTraits("VB"));
  321. }
  322. AssemblyCondition assemblyCondition = new AssemblyCondition(
  323. elements: new List<AssemblyConditionElement>() { element1, element2, element3 },
  324. reduceCost: 6);
  325. return assemblyCondition;
  326. }
  327. return null;
  328. }
  329. }
  330. #endregion
  331. #region Inherited
  332. if (timing == EffectTiming.OnAllyAttack)
  333. {
  334. ActivateClass activateClass = new ActivateClass();
  335. activateClass.SetUpICardEffect("Change attack target to this Digimon", CanUseCondition, card);
  336. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDescription());
  337. activateClass.SetHashString("P_240_Inherited");
  338. activateClass.SetIsInheritedEffect(true);
  339. cardEffects.Add(activateClass);
  340. string EffectDescription()
  341. {
  342. return "[Opponent's Turn] [Once Per Turn] When one of your opponent's Digimon attacks, you may change the attack target to this Digimon.";
  343. }
  344. bool CanUseCondition(Hashtable hashtable)
  345. {
  346. return CardEffectCommons.IsExistOnBattleAreaDigimonTrigger(card, activateClass)
  347. && CardEffectCommons.IsOpponentTurn(card)
  348. && CardEffectCommons.CanTriggerOnPermanentAttack(hashtable, PermanentCondition);
  349. }
  350. bool CanActivateCondition(Hashtable hashtable)
  351. {
  352. return CardEffectCommons.IsExistOnBattleAreaDigimonActivate(card, activateClass)
  353. && GManager.instance.attackProcess.IsAttacking
  354. && GManager.instance.attackProcess.AttackingPermanent.CanSwitchAttackTarget;
  355. }
  356. bool PermanentCondition(Permanent permanent)
  357. {
  358. return CardEffectCommons.IsOpponentPermanent(permanent, card);
  359. }
  360. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  361. {
  362. yield return ContinuousController.instance.StartCoroutine(GManager.instance.attackProcess.SwitchDefender(
  363. activateClass,
  364. false,
  365. card.PermanentOfThisCard()));
  366. }
  367. }
  368. #endregion
  369. return cardEffects;
  370. }
  371. }
  372. }