BT23_080.cs 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. // Yu Nogi
  6. namespace DCGO.CardEffects.BT23
  7. {
  8. public class BT23_080 : CEntity_Effect
  9. {
  10. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  11. {
  12. List<ICardEffect> cardEffects = new List<ICardEffect>();
  13. #region Start of Main Phase
  14. if (timing == EffectTiming.OnStartMainPhase)
  15. {
  16. cardEffects.Add(CardEffectFactory.Gain1MemoryTamerEffect(card));
  17. }
  18. #endregion
  19. #region All Turns
  20. if (timing == EffectTiming.WhenPermanentWouldBeDeleted)
  21. {
  22. ActivateClass activateClass = new ActivateClass();
  23. activateClass.SetUpICardEffect("By bouncing this to bottom deck, place 1 digimon about to be deleted to top security", CanUseCondition, card);
  24. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  25. cardEffects.Add(activateClass);
  26. string EffectDiscription()
  27. {
  28. return "[All Turns] When any of your Digimon with the [CS] trait would be deleted, by returning this Tamer to the bottom of the deck, place 1 of those Digimon as the top security card.";
  29. }
  30. bool CanUseCondition(Hashtable hashtable)
  31. {
  32. return CardEffectCommons.IsExistOnBattleArea(card)
  33. && CardEffectCommons.CanTriggerWhenPermanentRemoveField(hashtable, PermanentCondition);
  34. }
  35. bool CanActivateCondition(Hashtable hashtable)
  36. {
  37. return CardEffectCommons.IsExistOnBattleArea(card);
  38. }
  39. bool PermanentCondition(Permanent permanent)
  40. {
  41. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  42. && permanent.TopCard.HasCSTraits
  43. && permanent.willBeRemoveField;
  44. }
  45. IEnumerator ActivateCoroutine(Hashtable hashtable)
  46. {
  47. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeckBouncePeremanentAndProcessAccordingToResult(
  48. targetPermanents: new List<Permanent>() { card.PermanentOfThisCard() },
  49. activateClass: activateClass,
  50. successProcess: SuccessProcess(),
  51. failureProcess: null));
  52. IEnumerator SuccessProcess()
  53. {
  54. List<Permanent> permanents = CardEffectCommons.GetPermanentsFromHashtable(hashtable).Filter(PermanentCondition);
  55. if (permanents.Any())
  56. {
  57. Permanent selectedPermanent = null;
  58. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  59. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionPermanentCount(PermanentCondition));
  60. selectPermanentEffect.SetUp(
  61. selectPlayer: card.Owner,
  62. canTargetCondition: PermanentCondition,
  63. canTargetCondition_ByPreSelecetedList: null,
  64. canEndSelectCondition: null,
  65. maxCount: maxCount,
  66. canNoSelect: false,
  67. canEndNotMax: false,
  68. selectPermanentCoroutine: SelectPermanentCoroutine,
  69. afterSelectPermanentCoroutine: null,
  70. mode: SelectPermanentEffect.Mode.Custom,
  71. cardEffect: activateClass);
  72. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  73. {
  74. selectedPermanent = permanent;
  75. yield return null;
  76. }
  77. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon that prevents its deletion.", "The opponent is selecting 1 Digimon that prevents its deletion.");
  78. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  79. if (selectedPermanent != null)
  80. {
  81. yield return ContinuousController.instance.StartCoroutine(new IPutSecurityPermanent(
  82. permanent: selectedPermanent,
  83. hashtable: hashtable,
  84. toTop: true).PutSecurity()
  85. );
  86. }
  87. }
  88. }
  89. }
  90. }
  91. #endregion
  92. #region Security
  93. if (timing == EffectTiming.SecuritySkill)
  94. {
  95. cardEffects.Add(CardEffectFactory.PlaySelfTamerSecurityEffect(card));
  96. }
  97. #endregion
  98. return cardEffects;
  99. }
  100. }
  101. }