ST23_05.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  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. isOptionalFunction: IsOptional,
  33. maxCountPerTurn: 1,
  34. hashValue: SharedHashString,
  35. whenDigivolving: true,
  36. whenAttacking: true
  37. );
  38. bool IsOptional(Hashtable hashtable) => !CardEffectCommons.HasMatchConditionPermanent(IsWeakestEnemyDigimon);
  39. bool IsWeakestEnemyDigimon(Permanent permanent) => CardEffectCommons.IsMinDP(permanent, card.Owner.Enemy);
  40. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  41. {
  42. if (card.Owner.CanAddSecurity(activateClass))
  43. {
  44. int validTargets = CardEffectCommons.MatchConditionOpponentsPermanentCount(card, IsWeakestEnemyDigimon);
  45. if (validTargets == 1)
  46. {
  47. yield return ContinuousController.instance.StartCoroutine(new IPutSecurityPermanent(
  48. card.Owner.Enemy.GetBattleAreaDigimons().Filter(IsWeakestEnemyDigimon).FirstOrDefault(),
  49. CardEffectCommons.CardEffectHashtable(activateClass), true, false).PutSecurity());
  50. }
  51. else if (validTargets > 1)
  52. {
  53. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  54. selectPermanentEffect.SetUp(
  55. selectPlayer: card.Owner,
  56. canTargetCondition: IsWeakestEnemyDigimon,
  57. canTargetCondition_ByPreSelecetedList: null,
  58. canEndSelectCondition: null,
  59. maxCount: 1,
  60. canNoSelect: false,
  61. canEndNotMax: false,
  62. selectPermanentCoroutine: null,
  63. afterSelectPermanentCoroutine: null,
  64. mode: SelectPermanentEffect.Mode.PutSecurityTop,
  65. cardEffect: activateClass);
  66. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to place in security.", "The opponent is selecting 1 Digimon to place in security.");
  67. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  68. }
  69. }
  70. bool validOwnerSecurity = card.Owner.SecurityCards.Count > 0 && card.Owner.SecurityCards.Count >= card.Owner.Enemy.SecurityCards.Count;
  71. bool validEnemySecurity = card.Owner.Enemy.SecurityCards.Count > 0 && card.Owner.Enemy.SecurityCards.Count >= card.Owner.SecurityCards.Count;
  72. if (validOwnerSecurity || validEnemySecurity)
  73. {
  74. List<SelectionElement<int>> selectionElements = new List<SelectionElement<int>>();
  75. if (validOwnerSecurity)
  76. {
  77. selectionElements.Add(new (message: $"Trash your own top security card", value : 1, spriteIndex: 0));
  78. }
  79. if (validEnemySecurity)
  80. {
  81. selectionElements.Add(new (message: $"Trash your opponent's top security card", value : 2, spriteIndex: 0));
  82. }
  83. selectionElements.Add( new (message: $"Don't trash security", value: 3, spriteIndex: 1));
  84. string selectPlayerMessage = "Will you trash 1 player's security to <Recover +1>?";
  85. string notSelectPlayerMessage = "The opponent is choosing if they will trash a security.";
  86. GManager.instance.userSelectionManager.SetIntSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  87. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  88. bool doTrash = GManager.instance.userSelectionManager.SelectedIntValue != 3;
  89. bool ownSecurity = GManager.instance.userSelectionManager.SelectedIntValue == 1;
  90. if (doTrash)
  91. {
  92. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.TrashSecurityAndProcessAccordingToResult(
  93. player: ownSecurity ? card.Owner : card.Owner.Enemy,
  94. trashAmount: 1,
  95. activateClass: activateClass,
  96. fromTop: true,
  97. successProcess: SuccessProcess,
  98. failureProcess: null
  99. ));
  100. IEnumerator SuccessProcess(List<CardSource> cardSources)
  101. {
  102. yield return ContinuousController.instance.StartCoroutine(new IRecovery(card.Owner, 1, activateClass).Recovery());
  103. }
  104. }
  105. }
  106. }
  107. #endregion
  108. #region All Turns Protect Glowing Dawn
  109. if (timing == EffectTiming.WhenRemoveField)
  110. {
  111. ActivateClass activateClass = new ActivateClass();
  112. activateClass.SetUpICardEffect("By trashing top security, card doesn't leave", CanUseCondition, card);
  113. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  114. activateClass.SetHashString("ST23_15_AT_Protect");
  115. cardEffects.Add(activateClass);
  116. string EffectDiscription()
  117. {
  118. 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.";
  119. }
  120. bool CanUseCondition(Hashtable hashtable)
  121. {
  122. return CardEffectCommons.IsExistOnBattleArea(card)
  123. && CardEffectCommons.CanTriggerWhenPermanentRemoveField(hashtable, PermanentCondition);
  124. }
  125. bool CanActivateCondition(Hashtable hashtable)
  126. {
  127. return CardEffectCommons.IsExistOnBattleAreaDigimon(card)
  128. && card.Owner.SecurityCards.Count > 0;
  129. }
  130. bool PermanentCondition(Permanent permanent)
  131. {
  132. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  133. && permanent.TopCard.EqualsTraits("Glowing Dawn");
  134. }
  135. IEnumerator ActivateCoroutine(Hashtable hashtable)
  136. {
  137. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.TrashSecurityAndProcessAccordingToResult(
  138. player: card.Owner,
  139. trashAmount: 1,
  140. activateClass: activateClass,
  141. fromTop: true,
  142. successProcess: SuccessProcess,
  143. failureProcess: null
  144. ));
  145. IEnumerator SuccessProcess(List<CardSource> cardSources)
  146. {
  147. List<Permanent> protectedPermanents = CardEffectCommons.GetPermanentsFromHashtable(hashtable)
  148. .Filter(PermanentCondition);
  149. foreach (Permanent permanent in protectedPermanents)
  150. {
  151. permanent.willBeRemoveField = false;
  152. permanent.HideDeleteEffect();
  153. permanent.HideHandBounceEffect();
  154. permanent.HideDeckBounceEffect();
  155. permanent.HideWillRemoveFieldEffect();
  156. }
  157. yield return null;
  158. }
  159. }
  160. }
  161. #endregion
  162. return cardEffects;
  163. }
  164. }
  165. }