BT25_042.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. // ClavisAngemon
  6. namespace DCGO.CardEffects.BT25
  7. {
  8. public class BT25_042 : 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("Angel") ||
  19. targetPermanent.TopCard.EqualsTraits("Archangel") ||
  20. targetPermanent.TopCard.HasTSTraits;
  21. }
  22. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(PermanentCondition, 3, false, card, null, level: 5));
  23. }
  24. #endregion
  25. #region OP/WD/WA Shared
  26. string SharedHashString = "BT25_042_OP_WD_WA";
  27. string SharedEffectName = "By trashing top or bottom security, this digimon is immune to digimon effect until opponent turn ends";
  28. string SharedEffectDescription(string tag) => $"[{tag}] [Once Per Turn] By trashing your top or bottom security card, your opponent's Digimon effects don't affect this Digimon until their turn ends.";
  29. bool AdditionalCanUseCondition(Hashtable hashtable, ActivateClass activateClass) => card.Owner.SecurityCards.Count >= 1;
  30. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  31. {
  32. bool isUsed = false;
  33. bool requiresSelection = card.Owner.SecurityCards.Count >= 2;
  34. if (card.Owner.SecurityCards.Any())
  35. {
  36. #region Setup Location Selection
  37. List<SelectionElement<int>> selectionElements = new List<SelectionElement<int>>();
  38. if (requiresSelection)
  39. {
  40. selectionElements.Add(new SelectionElement<int>("Top", 1, 0));
  41. selectionElements.Add(new SelectionElement<int>("Bottom", 2, 0));
  42. }
  43. else selectionElements.Add(new SelectionElement<int>("Trash only security card", 1, 0));
  44. selectionElements.Add(new SelectionElement<int>("Don't trash", 3, 1));
  45. string selectPlayerMessage = "Will you trash your security?";
  46. string notSelectPlayerMessage = "The opponent is choosing to trash their security";
  47. GManager.instance.userSelectionManager.SetIntSelection(selectionElements: selectionElements, selectPlayer: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
  48. yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
  49. #endregion
  50. bool doTrash = GManager.instance.userSelectionManager.SelectedIntValue != 3;
  51. bool fromTop = GManager.instance.userSelectionManager.SelectedIntValue == 1;
  52. if (doTrash)
  53. {
  54. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.TrashSecurityAndProcessAccordingToResult(
  55. player: card.Owner,
  56. trashAmount: 1,
  57. activateClass: activateClass,
  58. fromTop: fromTop,
  59. successProcess: SuccessProcess,
  60. failureProcess: null));
  61. IEnumerator SuccessProcess(List<CardSource> cardSources)
  62. {
  63. isUsed = true;
  64. Permanent thisPermanent = card.PermanentOfThisCard();
  65. thisPermanent.UntilOpponentTurnEndEffects.Add((_timing) => PermanentEffectFactory.DigimonEffectImmunity(thisPermanent));
  66. yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateBuffEffect(thisPermanent));
  67. }
  68. }
  69. }
  70. if (!isUsed) activateClass.RemoveUse();
  71. }
  72. CardEffectFactory.ActivateClassesForSharedEffects
  73. (ref cardEffects, timing, card,
  74. SharedEffectName,
  75. SharedActivateCoroutine,
  76. SharedEffectDescription,
  77. optional: false,
  78. maxCountPerTurn: 1,
  79. hashValue: SharedHashString,
  80. onPlay: true,
  81. whenDigivolving: true,
  82. whenAttacking: true,
  83. isSkippable: true,
  84. additionalUseCondition: AdditionalCanUseCondition);
  85. #endregion
  86. #region All Turns
  87. if (timing == EffectTiming.OnLoseSecurity)
  88. {
  89. ActivateClass activateClass = new ActivateClass();
  90. activateClass.SetUpICardEffect("Play 1 level 4 or lower [Angel]/[Iliad] trait card from hand without cost, then 2 digimon gain reboot & blocker until opponent turn end", CanUseCondition, card);
  91. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, false, EffectDescription());
  92. activateClass.SetHashString("BT25_042_AT");
  93. cardEffects.Add(activateClass);
  94. string EffectDescription()
  95. {
  96. return "[All Turns] [Once Per Turn] When your security stack is removed from, you may play 1 level 4 or lower [Angel] or [Iliad] trait card from your hand without paying the cost. Then, 2 of your Digimon gain <Reboot> and <Blocker> until your opponent's turn ends.";
  97. }
  98. bool CanUseCondition(Hashtable hashtable)
  99. {
  100. return CardEffectCommons.IsExistOnBattleAreaTrigger(card, activateClass)
  101. && CardEffectCommons.CanTriggerWhenLoseSecurity(hashtable, owner => owner == card.Owner);
  102. }
  103. bool CanActivateCondition(Hashtable hashtable)
  104. {
  105. return CardEffectCommons.IsExistOnBattleAreaActivate(card, activateClass);
  106. }
  107. bool CanPlayCardCondition(CardSource cardSource)
  108. => cardSource.HasLevel
  109. && cardSource.Level <= 4
  110. && (cardSource.EqualsTraits("Angel") || cardSource.HasIliadTraits)
  111. && CardEffectCommons.CanPlayAsNewPermanent(cardSource, false, activateClass);
  112. bool IsOwnedDigimon(Permanent permanent)
  113. => CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
  114. IEnumerator ActivateCoroutine(Hashtable hashtable)
  115. {
  116. if (CardEffectCommons.HasMatchConditionOwnersHand(card, CanPlayCardCondition))
  117. {
  118. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.PlayByEffect(
  119. canTargetCondition: CanPlayCardCondition,
  120. SelectCardEffect.Root.Hand,
  121. activateClass,
  122. payCost: false
  123. ));
  124. }
  125. List<Permanent> selectedPermaments = new List<Permanent>(); ;
  126. if (CardEffectCommons.HasMatchConditionPermanent(IsOwnedDigimon))
  127. {
  128. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  129. int maxCount = Math.Min(2, CardEffectCommons.MatchConditionPermanentCount(IsOwnedDigimon));
  130. selectPermanentEffect.SetUp(
  131. selectPlayer: card.Owner,
  132. canTargetCondition: IsOwnedDigimon,
  133. canTargetCondition_ByPreSelecetedList: null,
  134. canEndSelectCondition: null,
  135. maxCount: maxCount,
  136. canNoSelect: false,
  137. canEndNotMax: false,
  138. selectPermanentCoroutine: SelectPermanentCoroutine,
  139. afterSelectPermanentCoroutine: null,
  140. mode: SelectPermanentEffect.Mode.Custom,
  141. cardEffect: activateClass);
  142. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  143. {
  144. selectedPermaments.Add(permanent);
  145. yield break;
  146. }
  147. selectPermanentEffect.SetUpCustomMessage("Select 2 digimon to gain reboot and blocker.", "The opponent is selecting 2 digimon to gain reboot and blocker.");
  148. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  149. }
  150. if (selectedPermaments.Any())
  151. {
  152. foreach (Permanent permanent in selectedPermaments)
  153. {
  154. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainReboot(
  155. targetPermanent: permanent,
  156. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  157. activateClass: activateClass));
  158. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainBlocker(
  159. targetPermanent: permanent,
  160. effectDuration: EffectDuration.UntilOpponentTurnEnd,
  161. activateClass: activateClass));
  162. }
  163. }
  164. }
  165. }
  166. #endregion
  167. return cardEffects;
  168. }
  169. }
  170. }