BT22_091.cs 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. // Arata Sanada
  5. namespace DCGO.CardEffects.BT22
  6. {
  7. public class BT22_091 : CEntity_Effect
  8. {
  9. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  10. {
  11. List<ICardEffect> cardEffects = new List<ICardEffect>();
  12. #region Security
  13. if (timing == EffectTiming.SecuritySkill)
  14. {
  15. cardEffects.Add(CardEffectFactory.PlaySelfTamerSecurityEffect(card));
  16. }
  17. #endregion
  18. #region Start of your turn
  19. if (timing == EffectTiming.OnStartTurn)
  20. {
  21. cardEffects.Add(CardEffectFactory.SetMemoryTo3TamerEffect(card));
  22. }
  23. #endregion
  24. #region Opponents Turn
  25. if (timing == EffectTiming.OnAllyAttack)
  26. {
  27. ActivateClass activateClass = new ActivateClass();
  28. activateClass.SetUpICardEffect("Suspend tamer, change attack target to 1 of your [CS]/[Unidentified] digimon", CanUseCondition, card);
  29. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
  30. cardEffects.Add(activateClass);
  31. string EffectDiscription()
  32. {
  33. return "[Opponent's Turn] When one of your opponent's Digimon attacks, by suspending this Tamer, change the attack target to 1 of your Digimon with the [Unidentified] or [CS] traits.";
  34. }
  35. bool CanUseCondition(Hashtable hashtable)
  36. {
  37. return CardEffectCommons.CanTriggerOnPermanentAttack(hashtable, permanent => CardEffectCommons.IsOpponentPermanent(permanent, card));
  38. }
  39. bool CanActivateCondition(Hashtable hashtable)
  40. {
  41. return CardEffectCommons.IsExistOnBattleArea(card)
  42. && CardEffectCommons.CanActivateSuspendCostEffect(card)
  43. && CardEffectCommons.IsOpponentTurn(card)
  44. && CardEffectCommons.HasMatchConditionOwnersPermanent(card, IsCSOrUniDigimon);
  45. }
  46. bool IsCSOrUniDigimon(Permanent permanent)
  47. {
  48. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  49. && (permanent.TopCard.HasCSTraits || permanent.TopCard.HasUnidentifiedTraits);
  50. }
  51. IEnumerator ActivateCoroutine(Hashtable hashtable)
  52. {
  53. yield return ContinuousController.instance.StartCoroutine(new SuspendPermanentsClass(new List<Permanent> { card.PermanentOfThisCard() }, hashtable).Tap());
  54. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, IsCSOrUniDigimon))
  55. {
  56. Permanent selectedPermanent = null;
  57. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOwnersPermanentCount(card, IsCSOrUniDigimon));
  58. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  59. selectPermanentEffect.SetUp(
  60. selectPlayer: card.Owner,
  61. canTargetCondition: IsCSOrUniDigimon,
  62. canTargetCondition_ByPreSelecetedList: null,
  63. canEndSelectCondition: null,
  64. maxCount: maxCount,
  65. canNoSelect: false,
  66. canEndNotMax: false,
  67. selectPermanentCoroutine: SelectPermanentCoroutine,
  68. afterSelectPermanentCoroutine: null,
  69. mode: SelectPermanentEffect.Mode.Custom,
  70. cardEffect: activateClass);
  71. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  72. {
  73. selectedPermanent = permanent;
  74. yield return null;
  75. }
  76. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to become attack target", "The opponent is selecting 1 Digimon to become attack target");
  77. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  78. if (selectedPermanent != null) yield return ContinuousController.instance.StartCoroutine(GManager.instance.attackProcess.SwitchDefender(activateClass, false, selectedPermanent));
  79. }
  80. }
  81. }
  82. #endregion
  83. #region ESS
  84. if (timing == EffectTiming.OnAllyAttack)
  85. {
  86. ActivateClass activateClass = new ActivateClass();
  87. activateClass.SetUpICardEffect("change attack target to 1 of your [CS]/[Unidentified] digimon", CanUseCondition, card);
  88. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDiscription());
  89. activateClass.SetHashString("BT22_091_Redirect");
  90. activateClass.SetIsInheritedEffect(true);
  91. cardEffects.Add(activateClass);
  92. string EffectDiscription()
  93. {
  94. return "[Opponent's Turn] [Once Per Turn] When one of your opponent's Digimon attacks, if this Digimon is [Eater Adam], you may change the attack target to 1 of your [Unidentified] or [CS] trait Digimon.";
  95. }
  96. bool CanUseCondition(Hashtable hashtable)
  97. {
  98. return CardEffectCommons.CanTriggerOnPermanentAttack(hashtable, permanent => CardEffectCommons.IsOpponentPermanent(permanent, card));
  99. }
  100. bool CanActivateCondition(Hashtable hashtable)
  101. {
  102. return CardEffectCommons.IsExistOnBattleArea(card)
  103. && CardEffectCommons.IsOpponentTurn(card)
  104. && CardEffectCommons.HasMatchConditionOwnersPermanent(card, IsCSOrUniDigimon)
  105. && card.PermanentOfThisCard().TopCard.EqualsCardName("Eater Adam");
  106. }
  107. bool IsCSOrUniDigimon(Permanent permanent)
  108. {
  109. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  110. && (permanent.TopCard.HasCSTraits || permanent.TopCard.HasUnidentifiedTraits);
  111. }
  112. IEnumerator ActivateCoroutine(Hashtable hashtable)
  113. {
  114. if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, IsCSOrUniDigimon))
  115. {
  116. Permanent selectedPermanent = null;
  117. int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOwnersPermanentCount(card, IsCSOrUniDigimon));
  118. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  119. selectPermanentEffect.SetUp(
  120. selectPlayer: card.Owner,
  121. canTargetCondition: IsCSOrUniDigimon,
  122. canTargetCondition_ByPreSelecetedList: null,
  123. canEndSelectCondition: null,
  124. maxCount: maxCount,
  125. canNoSelect: true,
  126. canEndNotMax: false,
  127. selectPermanentCoroutine: SelectPermanentCoroutine,
  128. afterSelectPermanentCoroutine: null,
  129. mode: SelectPermanentEffect.Mode.Custom,
  130. cardEffect: activateClass);
  131. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  132. {
  133. selectedPermanent = permanent;
  134. yield return null;
  135. }
  136. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to become attack target", "The opponent is selecting 1 Digimon to become attack target");
  137. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  138. if (selectedPermanent != null) yield return ContinuousController.instance.StartCoroutine(GManager.instance.attackProcess.SwitchDefender(activateClass, false, selectedPermanent));
  139. }
  140. }
  141. }
  142. #endregion
  143. return cardEffects;
  144. }
  145. }
  146. }