P_237.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System;
  4. //Unique Emblem: Machina's Ascension
  5. namespace DCGO.CardEffects.P
  6. {
  7. public class P_237 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Ignore Color Requirement
  13. if (timing == EffectTiming.None)
  14. {
  15. cardEffects.Add(CardEffectFactory.UseRequirements(card, CardCondition));
  16. bool CardCondition(CardSource cardSource)
  17. {
  18. return cardSource.HasText("Maquinamon");
  19. }
  20. }
  21. #endregion
  22. #region Main
  23. if (timing == EffectTiming.OptionSkill)
  24. {
  25. ActivateClass activateClass = new ActivateClass();
  26. activateClass.SetUpICardEffect("Play 1 [Maquinamon]/[Unchained] from hand or trash, then place in battle area", CanUseCondition, card);
  27. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  28. cardEffects.Add(activateClass);
  29. string EffectDiscription()
  30. {
  31. return "[Main] You may play 1 [Maquinamon] or [Unchained] from your hand or trash without paying the cost. Then, place this card in the battle area.";
  32. }
  33. bool CanUseCondition(Hashtable hashtable)
  34. {
  35. return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  36. }
  37. bool CanSelectCardCondition(CardSource cardSource)
  38. {
  39. return (cardSource.EqualsCardName("Maquinamon") || cardSource.EqualsCardName("Unchained"))
  40. && CardEffectCommons.CanPlayAsNewPermanent(cardSource, false, activateClass);
  41. }
  42. IEnumerator ActivateCoroutine(Hashtable hashtable)
  43. {
  44. if (CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition) || CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  45. {
  46. bool canSelectHand = CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition);
  47. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition);
  48. if (canSelectHand || canSelectTrash)
  49. {
  50. #region Setup Location Selection
  51. if (canSelectHand && canSelectTrash)
  52. {
  53. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  54. {
  55. new SelectionElement<bool>(message: $"From hand", value : true, spriteIndex: 0),
  56. new SelectionElement<bool>(message: $"From trash", value : false, spriteIndex: 1),
  57. };
  58. string selectPlayerMessage = "From which area do you select a card?";
  59. string notSelectPlayerMessage = "The opponent is choosing from which area to select a card.";
  60. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  61. }
  62. else
  63. {
  64. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  65. }
  66. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  67. #endregion
  68. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  69. CardSource selectedCard = null;
  70. IEnumerator SelectCardCoroutine(CardSource cardSource)
  71. {
  72. selectedCard = cardSource;
  73. yield return null;
  74. }
  75. #region Hand/Trash Card Selection & Play
  76. if (fromHand)
  77. {
  78. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  79. selectHandEffect.SetUp(
  80. selectPlayer: card.Owner,
  81. canTargetCondition: CanSelectCardCondition,
  82. canTargetCondition_ByPreSelecetedList: null,
  83. canEndSelectCondition: null,
  84. maxCount: 1,
  85. canNoSelect: true,
  86. canEndNotMax: false,
  87. isShowOpponent: true,
  88. selectCardCoroutine: SelectCardCoroutine,
  89. afterSelectCardCoroutine: null,
  90. mode: SelectHandEffect.Mode.Custom,
  91. cardEffect: activateClass);
  92. selectHandEffect.SetUpCustomMessage("Select 1 [Maquinamon]/[Unchained] to play.", "The opponent is selecting 1 [Maquinamon]/[Unchained] to play.");
  93. yield return StartCoroutine(selectHandEffect.Activate());
  94. if (selectedCard != null) yield return ContinuousController.instance.StartCoroutine(
  95. CardEffectCommons.PlayPermanentCards(new List<CardSource>() { selectedCard }, activateClass, false, false, SelectCardEffect.Root.Hand, true));
  96. }
  97. else
  98. {
  99. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  100. selectCardEffect.SetUp(
  101. canTargetCondition: CanSelectCardCondition,
  102. canTargetCondition_ByPreSelecetedList: null,
  103. canEndSelectCondition: null,
  104. canNoSelect: () => true,
  105. selectCardCoroutine: SelectCardCoroutine,
  106. afterSelectCardCoroutine: null,
  107. message: "Select 1 [Maquinamon]/[Unchained] to play.",
  108. maxCount: 1,
  109. canEndNotMax: false,
  110. isShowOpponent: true,
  111. mode: SelectCardEffect.Mode.Custom,
  112. root: SelectCardEffect.Root.Trash,
  113. customRootCardList: null,
  114. canLookReverseCard: true,
  115. selectPlayer: card.Owner,
  116. cardEffect: activateClass);
  117. selectCardEffect.SetUpCustomMessage("Select 1 [Maquinamon]/[Unchained] to play.", "The opponent is selecting 1 [Maquinamon]/[Unchained] to play.");
  118. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  119. if (selectedCard != null) yield return ContinuousController.instance.StartCoroutine(
  120. CardEffectCommons.PlayPermanentCards(new List<CardSource>() { selectedCard }, activateClass, false, false, SelectCardEffect.Root.Trash, true));
  121. }
  122. #endregion
  123. }
  124. }
  125. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlaceDelayOptionCards(card: card, cardEffect: activateClass));
  126. }
  127. }
  128. #endregion
  129. #region Your turn - Delay
  130. if (timing == EffectTiming.OnEnterFieldAnyone)
  131. {
  132. ActivateClass activateClass = new ActivateClass();
  133. activateClass.SetUpICardEffect("Digivolve into a level 6 or lower Digimon w/[Maquinamon] in text for free.", CanUseCondition, card);
  134. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  135. cardEffects.Add(activateClass);
  136. string EffectDiscription()
  137. {
  138. return "[Your Turn] When any of your [Unchained] are played, <Delay>.\r\n 1 of your Digimon may digivolve into a level 6 or lower Digimon card with [Maquinamon] in its text in the hand without paying the cost.";
  139. }
  140. bool CanUseCondition(Hashtable hashtable)
  141. {
  142. return CardEffectCommons.IsExistOnBattleArea(card)
  143. && CardEffectCommons.CanDeclareOptionDelayEffect(card)
  144. && CardEffectCommons.CanTriggerOnPermanentPlay(hashtable, PlayedPermanentCondition);
  145. }
  146. bool CanActivateCondition(Hashtable hashtable)
  147. {
  148. return CardEffectCommons.IsExistOnBattleArea(card);
  149. }
  150. bool PlayedPermanentCondition(Permanent permanent)
  151. {
  152. return CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card)
  153. && permanent.TopCard.EqualsCardName("Unchained");
  154. }
  155. bool PermanentCondition(Permanent permanent)
  156. {
  157. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  158. }
  159. bool CardCondition(CardSource cardSource)
  160. {
  161. return cardSource.IsDigimon
  162. && cardSource.HasLevel
  163. && cardSource.Level <= 6
  164. && cardSource.HasText("Maquinamon");
  165. }
  166. IEnumerator ActivateCoroutine(Hashtable hashtable)
  167. {
  168. bool delaySuccessful = false;
  169. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(targetPermanents: new List<Permanent>() { card.PermanentOfThisCard() }, activateClass: activateClass, successProcess: permanents => SuccessProcess(), failureProcess: null));
  170. IEnumerator SuccessProcess()
  171. {
  172. delaySuccessful = true;
  173. yield return null;
  174. }
  175. if (delaySuccessful)
  176. {
  177. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, PermanentCondition))
  178. {
  179. Permanent selectedDigimon = null;
  180. #region Select Permament
  181. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOwnersPermanentCount(card, PermanentCondition));
  182. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  183. selectPermanentEffect.SetUp(
  184. selectPlayer: card.Owner,
  185. canTargetCondition: PermanentCondition,
  186. canTargetCondition_ByPreSelecetedList: null,
  187. canEndSelectCondition: null,
  188. maxCount: maxCount,
  189. canNoSelect: true,
  190. canEndNotMax: false,
  191. selectPermanentCoroutine: SelectPermanentCoroutine,
  192. afterSelectPermanentCoroutine: null,
  193. mode: SelectPermanentEffect.Mode.Custom,
  194. cardEffect: activateClass);
  195. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  196. {
  197. selectedDigimon = permanent;
  198. yield return null;
  199. }
  200. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to digivolve", "The opponent is selecting 1 Digimon to digivolve");
  201. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  202. #endregion
  203. if (selectedDigimon != null) yield return ContinuousController.instance.StartCoroutine(
  204. CardEffectCommons.DigivolveIntoHandOrTrashCard(
  205. targetPermanent: selectedDigimon,
  206. cardCondition: CardCondition,
  207. payCost: false,
  208. reduceCostTuple: null,
  209. fixedCostTuple: null,
  210. ignoreDigivolutionRequirementFixedCost: -1,
  211. isHand: true,
  212. activateClass: activateClass,
  213. successProcess: null
  214. )
  215. );
  216. }
  217. }
  218. }
  219. }
  220. #endregion
  221. #region Security Effect
  222. if (timing == EffectTiming.SecuritySkill)
  223. {
  224. CardEffectCommons.AddActivateMainOptionSecurityEffect(
  225. card: card,
  226. cardEffects: ref cardEffects,
  227. effectName: "Play 1 [Maquinamon]/[Unchained] from hand or trash, then place in battle area");
  228. }
  229. #endregion
  230. return cardEffects;
  231. }
  232. }
  233. }