ST23_05.cs 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. // Habakirimon
  6. namespace DCGO.CardEffects.ST23
  7. {
  8. public class ST23_05 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Digivolution Condition
  14. if (timing == EffectTiming.None)
  15. {
  16. bool PermanentCondition(Permanent targetPermanent)
  17. {
  18. return targetPermanent.TopCard.EqualsTraits("Glowing Dawn");
  19. }
  20. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(level: 5, permanentCondition: PermanentCondition, digivolutionCost: 3, ignoreDigivolutionRequirement: false, card: card, condition: null));
  21. }
  22. #endregion
  23. #region shared WD / WA
  24. string SharedHashString = "ST23_05_WD_WA";
  25. string SharedEffectName = "Place 1 opponent's lowest DP Digimon on top of security. Then may trash top security from the player with most security to Recover +1";
  26. string SharedEffectDescription(string tag) => $"[{tag}] [Once Per Turn] Place 1 of your opponent's lowest DP Digimon as the top security card. Then, by trashing the top security card of 1 player with the most security cards, <Recovery +1>.";
  27. CardEffectFactory.ActivateClassesForSharedEffects(ref cardEffects, timing, card,
  28. SharedEffectName,
  29. SharedActivateCoroutine,
  30. SharedEffectDescription,
  31. false,
  32. maxCountPerTurn: 1,
  33. hashValue: SharedHashString,
  34. whenDigivolving: true,
  35. whenAttacking: true
  36. );
  37. bool IsWeakestEnemyDigimon(Permanent permanent) => CardEffectCommons.IsMinDP(permanent, card.Owner.Enemy);
  38. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  39. {
  40. if (card.Owner.CanAddSecurity(activateClass))
  41. {
  42. int validTargets = CardEffectCommons.MatchConditionOpponentsPermanentCount(card, IsWeakestEnemyDigimon);
  43. if (validTargets == 1)
  44. {
  45. yield return ContinuousController.instance.StartCoroutine(new IPutSecurityPermanent(
  46. card.Owner.Enemy.GetBattleAreaDigimons().Filter(IsWeakestEnemyDigimon).FirstOrDefault(),
  47. CardEffectCommons.CardEffectHashtable(activateClass), true, false).PutSecurity());
  48. }
  49. else if (validTargets > 1)
  50. {
  51. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  52. selectPermanentEffect.SetUp(
  53. selectPlayer: card.Owner,
  54. canTargetCondition: IsWeakestEnemyDigimon,
  55. canTargetCondition_ByPreSelecetedList: null,
  56. canEndSelectCondition: null,
  57. maxCount: 1,
  58. canNoSelect: false,
  59. canEndNotMax: false,
  60. selectPermanentCoroutine: null,
  61. afterSelectPermanentCoroutine: null,
  62. mode: SelectPermanentEffect.Mode.PutSecurityTop,
  63. cardEffect: activateClass);
  64. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to place in security.", "The opponent is selecting 1 Digimon to place in security.");
  65. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  66. }
  67. }
  68. bool validOwnerSecurity = card.Owner.SecurityCards.Count > 0 && card.Owner.SecurityCards.Count >= card.Owner.Enemy.SecurityCards.Count;
  69. bool validEnemySecurity = card.Owner.Enemy.SecurityCards.Count > 0 && card.Owner.Enemy.SecurityCards.Count >= card.Owner.SecurityCards.Count;
  70. if (validOwnerSecurity || validEnemySecurity)
  71. {
  72. List<SelectionElement<int>> selectionElements = new List<SelectionElement<int>>();
  73. if (validOwnerSecurity)
  74. {
  75. selectionElements.Add(new (message: $"Trash your own top security card", value : 1, spriteIndex: 0));
  76. }
  77. if (validEnemySecurity)
  78. {
  79. selectionElements.Add(new (message: $"Trash your opponent's top security card", value : 2, spriteIndex: 0));
  80. }
  81. selectionElements.Add( new (message: $"Don't trash security", value: 3, spriteIndex: 1));
  82. string selectPlayerMessage = "Will you trash 1 player's security to <Recover +1>?";
  83. string notSelectPlayerMessage = "The opponent is choosing if they will trash a security.";
  84. GManager.instance.userSelectionManager.SetIntSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  85. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  86. bool doTrash = GManager.instance.userSelectionManager.SelectedIntValue != 3;
  87. bool ownSecurity = GManager.instance.userSelectionManager.SelectedIntValue == 1;
  88. if (doTrash)
  89. {
  90. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.TrashSecurityAndProcessAccordingToResult(
  91. player: ownSecurity ? card.Owner : card.Owner.Enemy,
  92. trashAmount: 1,
  93. activateClass: activateClass,
  94. fromTop: true,
  95. successProcess: SuccessProcess,
  96. failureProcess: null
  97. ));
  98. IEnumerator SuccessProcess(List<CardSource> cardSources)
  99. {
  100. yield return ContinuousController.instance.StartCoroutine(new IRecovery(card.Owner, 1, activateClass).Recovery());
  101. }
  102. }
  103. }
  104. }
  105. #endregion
  106. #region All Turns Protect Glowing Dawn
  107. if (timing == EffectTiming.WhenRemoveField)
  108. {
  109. ActivateClass activateClass = new ActivateClass();
  110. activateClass.SetUpICardEffect("By trashing top security, card doesn't leave", CanUseCondition, card);
  111. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  112. activateClass.SetHashString("ST23_15_AT_Protect");
  113. cardEffects.Add(activateClass);
  114. string EffectDiscription()
  115. {
  116. return "[All Turns] [Once Per Turn] When any of your [Glowing Dawn] trait Digimon would leave the battle area, by trashing your top security card, they don't leave.";
  117. }
  118. bool CanUseCondition(Hashtable hashtable)
  119. {
  120. return CardEffectCommons.IsExistOnBattleArea(card)
  121. && CardEffectCommons.CanTriggerWhenPermanentRemoveField(hashtable, PermanentCondition);
  122. }
  123. bool CanActivateCondition(Hashtable hashtable)
  124. {
  125. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  126. && card.Owner.SecurityCards.Count > 0;
  127. }
  128. bool PermanentCondition(Permanent permanent)
  129. {
  130. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  131. && permanent.TopCard.EqualsTraits("Glowing Dawn");
  132. }
  133. IEnumerator ActivateCoroutine(Hashtable hashtable)
  134. {
  135. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.TrashSecurityAndProcessAccordingToResult(
  136. player: card.Owner,
  137. trashAmount: 1,
  138. activateClass: activateClass,
  139. fromTop: true,
  140. successProcess: SuccessProcess,
  141. failureProcess: null
  142. ));
  143. IEnumerator SuccessProcess(List<CardSource> cardSources)
  144. {
  145. List<Permanent> protectedPermanents = CardEffectCommons.GetPermanentsFromHashtable(hashtable)
  146. .Filter(PermanentCondition);
  147. foreach (Permanent permanent in protectedPermanents)
  148. {
  149. permanent.willBeRemoveField = false;
  150. permanent.HideDeleteEffect();
  151. permanent.HideHandBounceEffect();
  152. permanent.HideDeckBounceEffect();
  153. permanent.HideWillRemoveFieldEffect();
  154. }
  155. yield return null;
  156. }
  157. }
  158. }
  159. #endregion
  160. return cardEffects;
  161. }
  162. }
  163. }