BT22_096.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. // Unique Emblem: Poseidia Lagoon
  5. namespace DCGO.CardEffects.BT22
  6. {
  7. public class BT22_096 : 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 [Sangomon] or [Yao Qinglan] from hand or trash", CanUseCondition, card);
  17. activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDiscription());
  18. cardEffects.Add(activateClass);
  19. string EffectDiscription()
  20. {
  21. return "[Main] You may play 1 [Sangomon] or [Yao Qinglan] from your hand or trash without paying the cost. Then, place this card in the battle area.";
  22. }
  23. bool IsYaoQinglanOrSangomon(CardSource cardSource)
  24. {
  25. return cardSource.EqualsCardName("Sangomon") || cardSource.EqualsCardName("Yao Qinglan");
  26. }
  27. bool CanUseCondition(Hashtable hashtable)
  28. {
  29. return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
  30. }
  31. IEnumerator ActivateCoroutine(Hashtable hashtable)
  32. {
  33. bool canSelectHand = CardEffectCommons.HasMatchConditionOwnersHand(card, IsYaoQinglanOrSangomon);
  34. bool canSelectTrash = CardEffectCommons.HasMatchConditionOwnersCardInTrash(card, IsYaoQinglanOrSangomon);
  35. if (canSelectHand || canSelectTrash)
  36. {
  37. #region Option Selection
  38. if (canSelectHand && canSelectTrash)
  39. {
  40. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  41. {
  42. new SelectionElement<bool>(message: $"From hand", value : true, spriteIndex: 0),
  43. new SelectionElement<bool>(message: $"From trash", value : false, spriteIndex: 1),
  44. };
  45. string selectPlayerMessage = "From which area do you select a card?";
  46. string notSelectPlayerMessage = "The opponent is choosing from which area to select a card.";
  47. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  48. }
  49. else
  50. {
  51. GManager.instance.userSelectionManager.SetBool(canSelectHand);
  52. }
  53. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  54. #endregion
  55. bool fromHand = GManager.instance.userSelectionManager.SelectedBoolValue;
  56. CardSource selectedCard = null;
  57. IEnumerator SelectCardCoroutine(CardSource cardSource)
  58. {
  59. selectedCard = cardSource;
  60. yield return null;
  61. }
  62. if (fromHand)
  63. {
  64. #region Play from Hand
  65. SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
  66. selectHandEffect.SetUp(
  67. selectPlayer: card.Owner,
  68. canTargetCondition: IsYaoQinglanOrSangomon,
  69. canTargetCondition_ByPreSelecetedList: null,
  70. canEndSelectCondition: null,
  71. maxCount: 1,
  72. canNoSelect: true,
  73. canEndNotMax: false,
  74. isShowOpponent: true,
  75. selectCardCoroutine: SelectCardCoroutine,
  76. afterSelectCardCoroutine: null,
  77. mode: SelectHandEffect.Mode.Custom,
  78. cardEffect: activateClass);
  79. selectHandEffect.SetUpCustomMessage("Select 1 card to add as source.", "The opponent is selecting 1 card to add as source.");
  80. yield return StartCoroutine(selectHandEffect.Activate());
  81. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(new List<CardSource>() { selectedCard }, activateClass, false, false, SelectCardEffect.Root.Hand, true));
  82. #endregion
  83. }
  84. if (!fromHand)
  85. {
  86. #region Play from Trash
  87. SelectCardEffect selectCardEffect = GManager.instance.GetComponent<SelectCardEffect>();
  88. selectCardEffect.SetUp(
  89. canTargetCondition: IsYaoQinglanOrSangomon,
  90. canTargetCondition_ByPreSelecetedList: null,
  91. canEndSelectCondition: null,
  92. canNoSelect: () => true,
  93. selectCardCoroutine: SelectCardCoroutine,
  94. afterSelectCardCoroutine: null,
  95. message: "Select 1 card to add as source.",
  96. maxCount: 1,
  97. canEndNotMax: false,
  98. isShowOpponent: true,
  99. mode: SelectCardEffect.Mode.Custom,
  100. root: SelectCardEffect.Root.Trash,
  101. customRootCardList: null,
  102. canLookReverseCard: true,
  103. selectPlayer: card.Owner,
  104. cardEffect: activateClass);
  105. selectCardEffect.SetUpCustomMessage("Select 1 card to add as source.", "The opponent is selecting 1 card to add as source.");
  106. yield return ContinuousController.instance.StartCoroutine(selectCardEffect.Activate());
  107. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayPermanentCards(new List<CardSource>() { selectedCard }, activateClass, false, false, SelectCardEffect.Root.Trash, true));
  108. #endregion
  109. }
  110. }
  111. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlaceDelayOptionCards(card: card, cardEffect: activateClass));
  112. }
  113. }
  114. #endregion
  115. #region Delay
  116. if (timing == EffectTiming.OnTappedAnyone)
  117. {
  118. ActivateClass activateClass = new ActivateClass();
  119. activateClass.SetUpICardEffect("Digivolve 1 [Aqua]/[Sea Animal] digimon into a [Aquatic]/[Liberator] digimon in your hand for 3 reduced cost", CanUseCondition, card);
  120. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  121. cardEffects.Add(activateClass);
  122. string EffectDiscription()
  123. {
  124. return "[Your Turn] When any of your [Yao Qinglan] suspend, <Delay> (By trashing this card after the placing turn, activate the effect below.). 1 of your Digimon with [Aqua] or [Sea Animal] in any of its traits may digivolve into an [Aquatic] and [LIBERATOR] trait Digimon card in the hand with the digivolution cost reduced by 3.";
  125. }
  126. bool CanUseCondition(Hashtable hashtable)
  127. {
  128. return CardEffectCommons.CanDeclareOptionDelayEffect(card) &&
  129. CardEffectCommons.IsOwnerTurn(card) &&
  130. CardEffectCommons.CanTriggerWhenPermanentSuspends(hashtable, IsYaoQinglan);
  131. }
  132. bool CanActivateCondition(Hashtable hashtable)
  133. {
  134. return CardEffectCommons.IsExistOnBattleArea(card);
  135. }
  136. bool IsYaoQinglan(Permanent permanent)
  137. {
  138. return CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card)
  139. && permanent.TopCard.EqualsCardName("Yao Qinglan");
  140. }
  141. bool IsAquaOrSeaAnimal(Permanent permanent)
  142. {
  143. return CardEffectCommons.IsPermanentExistsOnOwnerBattleArea(permanent, card)
  144. && permanent.TopCard.HasAquaTraits;
  145. }
  146. bool IsAquaticOrLiberator(CardSource cardSource, Permanent permanent)
  147. {
  148. return CardEffectCommons.IsExistOnHand(cardSource)
  149. && cardSource.CanPlayCardTargetFrame(permanent.PermanentFrame, true, activateClass)
  150. && cardSource.HasAquaticTraits && cardSource.HasLiberatorTraits;
  151. }
  152. IEnumerator ActivateCoroutine(Hashtable hashtable)
  153. {
  154. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(targetPermanents: new List<Permanent>() { card.PermanentOfThisCard() }, activateClass: activateClass, successProcess: permanents => SuccessProcess(), failureProcess: null));
  155. IEnumerator SuccessProcess()
  156. {
  157. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, IsAquaOrSeaAnimal))
  158. {
  159. Permanent selectedPermanent = null;
  160. #region Select [Aqua]/[Sea Animal] Permanent
  161. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOwnersPermanentCount(card, IsAquaOrSeaAnimal));
  162. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  163. selectPermanentEffect.SetUp(
  164. selectPlayer: card.Owner,
  165. canTargetCondition: IsAquaOrSeaAnimal,
  166. canTargetCondition_ByPreSelecetedList: null,
  167. canEndSelectCondition: null,
  168. maxCount: maxCount,
  169. canNoSelect: false,
  170. canEndNotMax: false,
  171. selectPermanentCoroutine: SelectPermanentCoroutine,
  172. afterSelectPermanentCoroutine: null,
  173. mode: SelectPermanentEffect.Mode.Custom,
  174. cardEffect: activateClass);
  175. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  176. {
  177. selectedPermanent = permanent;
  178. yield return null;
  179. }
  180. selectPermanentEffect.SetUpCustomMessage("Select 1 [Aqua]/[Sea Animal] to digivolve.", "The opponent is selecting 1 [Aqua]/[Sea Animal] to digivolve.");
  181. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  182. #endregion
  183. if (selectedPermanent != null)
  184. {
  185. #region Digivolve into [Aquatic/LIBERATOR] Digimon
  186. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DigivolveIntoHandOrTrashCard(
  187. selectedPermanent,
  188. digivolvingCard => IsAquaticOrLiberator(digivolvingCard, selectedPermanent),
  189. payCost: true,
  190. reduceCostTuple: (reduceCost: 3, reduceCostCardCondition: null),
  191. fixedCostTuple: null,
  192. ignoreDigivolutionRequirementFixedCost: -1,
  193. isHand: true,
  194. activateClass: activateClass,
  195. successProcess: null
  196. ));
  197. #endregion
  198. }
  199. }
  200. }
  201. }
  202. }
  203. #endregion
  204. #region Security
  205. if (timing == EffectTiming.SecuritySkill)
  206. {
  207. CardEffectCommons.AddActivateMainOptionSecurityEffect(card: card, cardEffects: ref cardEffects, effectName: $"Play 1 [Sangomon] or [Yao Qinglan] from hand or trash");
  208. }
  209. #endregion
  210. return cardEffects;
  211. }
  212. }
  213. }