EX12_045.cs 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. // Sanzomon
  4. namespace DCGO.CardEffects.EX12
  5. {
  6. public class EX12_045 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region Alternative Digivolve Condition
  12. if (timing == EffectTiming.None)
  13. {
  14. static bool PermanentCondition(Permanent targetPermanent)
  15. {
  16. return targetPermanent.TopCard.EqualsTraits("Shambala");
  17. }
  18. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(PermanentCondition, 3, false, card, null, level: 4));
  19. }
  20. #endregion
  21. #region Shared OP / WD
  22. string SharedEffectName = "May add top security to hand, then if 2 or less security, <Recovery +1>";
  23. CardEffectFactory.ActivateClassesForSharedEffects
  24. (ref cardEffects, timing, card,
  25. SharedEffectName,
  26. SharedActivateCoroutine,
  27. SharedEffectDescription,
  28. optional: false,
  29. onPlay: true,
  30. whenDigivolving: true);
  31. string SharedEffectDescription(string tag) => $"[{tag}] You may add your top security card to the hand. Then, if you have 2 or fewer security cards, <Recovery +1>.";
  32. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  33. {
  34. if (card.Owner.SecurityCards.Count >= 1)
  35. {
  36. List<SelectionElement<bool>> selectionElements = new List<SelectionElement<bool>>()
  37. {
  38. new SelectionElement<bool>(message: $"Yes", value : true, spriteIndex: 0),
  39. new SelectionElement<bool>(message: $"No", value : false, spriteIndex: 1),
  40. };
  41. string selectPlayerMessage = "Will you add your top security card to hand?";
  42. string notSelectPlayerMessage = "The opponent is choosing whether or not to add their top security card to hand.";
  43. GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  44. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  45. bool willAdd = GManager.instance.userSelectionManager.SelectedBoolValue;
  46. if (willAdd)
  47. {
  48. CardSource topCard = card.Owner.SecurityCards[0];
  49. yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddHandCards(new List<CardSource>() { topCard }, false, activateClass));
  50. yield return ContinuousController.instance.StartCoroutine(new IReduceSecurity(
  51. player: card.Owner,
  52. refSkillInfos: ref ContinuousController.instance.nullSkillInfos,
  53. activateClass).ReduceSecurity());
  54. }
  55. }
  56. if (card.Owner.SecurityCards.Count <= 2)
  57. {
  58. yield return ContinuousController.instance.StartCoroutine(new IRecovery(card.Owner, 1, activateClass).Recovery());
  59. }
  60. }
  61. #endregion
  62. #region Your Turn
  63. if (timing == EffectTiming.OnLoseSecurity)
  64. {
  65. ActivateClass activateClass = new ActivateClass();
  66. activateClass.SetUpICardEffect("May play 1 [Gokuumon] in text/[SW] trait for 2 less", CanUseCondition, card);
  67. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDescription());
  68. activateClass.SetHashString("EX12_045_YT");
  69. cardEffects.Add(activateClass);
  70. string EffectDescription()
  71. {
  72. return "[Your Turn] [Once Per Turn] When your security stack is removed from, you may play 1 card with [Gokuumon] in its text or the [SW] trait from your hand with the cost reduced by 2.";
  73. }
  74. bool CanUseCondition(Hashtable hashtable)
  75. {
  76. return CardEffectCommons.IsOwnerTurn(card)
  77. && CardEffectCommons.IsExistOnBattleAreaTrigger(card, activateClass)
  78. && CardEffectCommons.CanTriggerWhenLoseSecurity(hashtable, player => player == card.Owner);
  79. }
  80. bool CanActivateCondition(Hashtable hashtable)
  81. {
  82. return CardEffectCommons.IsExistOnBattleAreaActivate(card, activateClass)
  83. && CardEffectCommons.HasMatchConditionOwnersHand(card, CanSelectCardCondition);
  84. }
  85. bool CanSelectCardCondition(CardSource cardSource)
  86. {
  87. return (cardSource.HasText("Gokuumon")
  88. || cardSource.EqualsTraits("SW"))
  89. && CardEffectCommons.CanPlayAsNewPermanent(cardSource, true, activateClass, fixedCost: cardSource.GetCostItself - 2);
  90. }
  91. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  92. {
  93. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayByEffect(
  94. canTargetCondition: CanSelectCardCondition,
  95. SelectCardEffect.Root.Hand,
  96. activateClass,
  97. payCost: true,
  98. reduceCostTuple: (2, null),
  99. afterSelectCardCoroutine: AfterSelectCardCoroutine
  100. ));
  101. IEnumerator AfterSelectCardCoroutine(List<CardSource> cardSources)
  102. {
  103. if (cardSources.Count == 0)
  104. activateClass.RemoveUse();
  105. yield return null;
  106. }
  107. }
  108. }
  109. #endregion
  110. #region Inherited
  111. if (timing == EffectTiming.OnAllyAttack)
  112. {
  113. ActivateClass activateClass = new ActivateClass();
  114. activateClass.SetUpICardEffect("-4000 DP", CanUseCondition, card);
  115. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDescription());
  116. activateClass.SetIsInheritedEffect(true);
  117. activateClass.SetHashString("EX12_045_Inherited");
  118. cardEffects.Add(activateClass);
  119. string EffectDescription()
  120. {
  121. return "[When Attacking] [Once Per Turn] 1 of your opponent's Digimon gets -4000 DP for the turn.";
  122. }
  123. bool CanUseCondition(Hashtable hashtable)
  124. {
  125. return CardEffectCommons.CanTriggerOnAttack(hashtable, card)
  126. && CardEffectCommons.IsExistOnBattleAreaDigimonTrigger(card, activateClass);
  127. }
  128. bool CanActivateCondition(Hashtable hashtable)
  129. {
  130. return CardEffectCommons.IsExistOnBattleAreaDigimonActivate(card, activateClass);
  131. }
  132. bool CanSelectPermanentCondition(Permanent permanent)
  133. {
  134. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  135. }
  136. IEnumerator ActivateCoroutine(Hashtable hashtable)
  137. {
  138. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectPermanentCondition))
  139. {
  140. SelectPermanentEffect selectPermanentEffect =
  141. GManager.instance.GetComponent<SelectPermanentEffect>();
  142. selectPermanentEffect.SetUp(
  143. selectPlayer: card.Owner,
  144. canTargetCondition: CanSelectPermanentCondition,
  145. canTargetCondition_ByPreSelecetedList: null,
  146. canEndSelectCondition: null,
  147. maxCount: 1,
  148. canNoSelect: false,
  149. canEndNotMax: false,
  150. selectPermanentCoroutine: SelectPermanentCoroutine,
  151. afterSelectPermanentCoroutine: null,
  152. mode: SelectPermanentEffect.Mode.Custom,
  153. cardEffect: activateClass);
  154. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that will get DP -4000.",
  155. "The opponent is selecting 1 Digimon that will get DP -4000.");
  156. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  157. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  158. {
  159. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.ChangeDigimonDP(
  160. targetPermanent: permanent,
  161. changeValue: -4000,
  162. effectDuration: EffectDuration.UntilEachTurnEnd,
  163. activateClass: activateClass));
  164. }
  165. }
  166. }
  167. }
  168. #endregion
  169. return cardEffects;
  170. }
  171. }
  172. }