P_244.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. //Unique Emblem: Ragnarok Attainer
  5. namespace DCGO.CardEffects.P
  6. {
  7. public class P_244 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Main
  13. if (timing == EffectTiming.OptionSkill)
  14. {
  15. ActivateClass activateClass = new ActivateClass();
  16. activateClass.SetUpICardEffect("Play 1 [Vemmon]/[Zenith] from hand or trash for free, then place in battle area", CanUseCondition, card);
  17. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDescription());
  18. cardEffects.Add(activateClass);
  19. string EffectDescription()
  20. {
  21. return "[Main] You may play 1 [Vemmon] or [Zenith] from your hand or trash without paying the cost. Then, place this card in the battle area.";
  22. }
  23. bool CanUseCondition(Hashtable hashtable)
  24. {
  25. return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  26. }
  27. bool CanSelectCardCondition(CardSource cardSource)
  28. {
  29. return (cardSource.EqualsCardName("Vemmon")
  30. || cardSource.EqualsCardName("Zenith"))
  31. && CardEffectCommons.CanPlayAsNewPermanent(cardSource, false, activateClass);
  32. }
  33. IEnumerator ActivateCoroutine(Hashtable hashtable)
  34. {
  35. if (CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition)
  36. || CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition))
  37. {
  38. bool canSelectHand = CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition);
  39. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, CanSelectCardCondition);
  40. if (canSelectHand || canSelectTrash)
  41. {
  42. #region Setup Location Selection
  43. if (canSelectHand && canSelectTrash)
  44. {
  45. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  46. {
  47. new SelectionElement<bool>(message: $"From hand", value : true, spriteIndex: 0),
  48. new SelectionElement<bool>(message: $"From trash", value : false, spriteIndex: 1),
  49. };
  50. string selectPlayerMessage = "From which area do you select a card?";
  51. string notSelectPlayerMessage = "The opponent is choosing from which area to select a card.";
  52. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  53. }
  54. else
  55. {
  56. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  57. }
  58. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  59. #endregion
  60. SelectCardEffect.Root root = GManager.instance.userSelectionManager.SelectedBoolValue ? SelectCardEffect.Root.Hand : SelectCardEffect.Root.Trash;
  61. #region Hand/Trash Card Selection & Play
  62. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayByEffect(
  63. canTargetCondition: CanSelectCardCondition,
  64. root,
  65. activateClass,
  66. payCost: false
  67. ));
  68. #endregion
  69. }
  70. }
  71. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlaceDelayOptionCards(card: card, cardEffect: activateClass));
  72. }
  73. }
  74. #endregion
  75. #region Your turn - Delay
  76. if (timing == EffectTiming.OnAddDigivolutionCards)
  77. {
  78. ActivateClass activateClass = new ActivateClass();
  79. activateClass.SetUpICardEffect("Digivolve into a Digimon w/[Vemmon] in text for 3 less.", CanUseCondition, card);
  80. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDescription());
  81. cardEffects.Add(activateClass);
  82. string EffectDescription()
  83. {
  84. return "[Your Turn] When effects place [Vemmon] as any of your Digimon's digivolution cards, <Delay>.\r\n 1 of your Digimon with [Vemmon] in its text may digivolve into a Digimon card with [Vemmon] in its text in the hand or trash with the cost reduced by 3.";
  85. }
  86. bool CanUseCondition(Hashtable hashtable)
  87. {
  88. return CardEffectCommons.CanDeclareOptionDelayEffect(card)
  89. && CardEffectCommons.IsOwnerTurn(card)
  90. && CardEffectCommons.CanTriggerOnAddDigivolutionCard(
  91. hashtable: hashtable,
  92. permanentCondition: TriggerPermanentCondition,
  93. cardEffectCondition: cardEffect => cardEffect.EffectSourceCard != null,
  94. cardCondition: cardSource => cardSource.EqualsCardName("Vemmon"));
  95. }
  96. bool CanActivateCondition(Hashtable hashtable)
  97. {
  98. return CardEffectCommons.IsExistOnBattleArea(card);
  99. }
  100. bool TriggerPermanentCondition(Permanent permanent)
  101. {
  102. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  103. }
  104. bool CanSelectPermanentCondition(Permanent permanent)
  105. {
  106. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  107. && permanent.TopCard.HasText("Vemmon");
  108. }
  109. bool CanSelectCardCondition(CardSource cardSource)
  110. {
  111. return cardSource.IsDigimon
  112. && cardSource.HasText("Vemmon");
  113. }
  114. bool ValidTarget(CardSource cardSource, SelectCardEffect.Root root, Permanent permanent)
  115. {
  116. return CanSelectCardCondition(cardSource)
  117. && cardSource.CanPlayCardTargetFrame(permanent.PermanentFrame, false, activateClass, root);
  118. }
  119. IEnumerator ActivateCoroutine(Hashtable hashtable)
  120. {
  121. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(targetPermanents: new List<Permanent>() { card.PermanentOfThisCard() }, activateClass: activateClass, successProcess: permanents => SuccessProcess(), failureProcess: null));
  122. IEnumerator SuccessProcess()
  123. {
  124. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, CanSelectPermanentCondition))
  125. {
  126. Permanent selectedPermanent = null;
  127. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  128. selectPermanentEffect.SetUp(
  129. selectPlayer: card.Owner,
  130. canTargetCondition: CanSelectPermanentCondition,
  131. canTargetCondition_ByPreSelecetedList: null,
  132. canEndSelectCondition: null,
  133. maxCount: 1,
  134. canNoSelect: true,
  135. canEndNotMax: false,
  136. selectPermanentCoroutine: SelectPermanentCoroutine,
  137. afterSelectPermanentCoroutine: null,
  138. mode: SelectPermanentEffect.Mode.Custom,
  139. cardEffect: activateClass);
  140. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to digivolve.", "The opponent is selecting 1 Digimon to return to digivolve.");
  141. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  142. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  143. {
  144. selectedPermanent = permanent;
  145. yield return null;
  146. }
  147. if (selectedPermanent != null)
  148. {
  149. bool ValidCardInHand = card.Owner.HandCards.Any(cardSource => ValidTarget(cardSource, SelectCardEffect.Root.Hand, selectedPermanent));
  150. bool ValidCardInTrash = card.Owner.TrashCards.Any(cardSource => ValidTarget(cardSource, SelectCardEffect.Root.Trash, selectedPermanent));
  151. if (ValidCardInHand && ValidCardInTrash)
  152. {
  153. List<SelectionElement<bool>> selectionElements1 = new List<SelectionElement<bool>>()
  154. {
  155. new SelectionElement<bool>(message: $"From hand", value : true, spriteIndex: 0),
  156. new SelectionElement<bool>(message: $"From trash", value : false, spriteIndex: 1),
  157. };
  158. string selectPlayerMessage1 = "From which area do you select a card?";
  159. string notSelectPlayerMessage1 = "The opponent is choosing from which area to select a card.";
  160. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements1, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage1, notSelectPlayerMessage: notSelectPlayerMessage1);
  161. }
  162. else
  163. {
  164. GManager.instance.userSelectionManager.SetBool(ValidCardInHand);
  165. }
  166. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  167. var fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  168. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  169. selectedPermanent,
  170. CanSelectCardCondition,
  171. payCost: true,
  172. reduceCostTuple: (3, null),
  173. fixedCostTuple: null,
  174. ignoreDigivolutionRequirementFixedCost: -1,
  175. isHand: fromHand,
  176. activateClass,
  177. successProcess: null
  178. ));
  179. }
  180. }
  181. }
  182. }
  183. }
  184. #endregion
  185. #region Security Effect
  186. if (timing == EffectTiming.SecuritySkill)
  187. {
  188. CardEffectCommons.AddActivateMainOptionSecurityEffect(
  189. card: card,
  190. cardEffects: ref cardEffects,
  191. effectName: "Play 1 [Vemmon]/[Zenith] from hand or trash for free, then place in battle area");
  192. }
  193. #endregion
  194. return cardEffects;
  195. }
  196. }
  197. }