EX12_056.cs 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. // Cho-Hakkaimon
  4. namespace DCGO.CardEffects.EX12
  5. {
  6. public class EX12_056 : CEntity_Effect
  7. {
  8. public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
  9. {
  10. List<ICardEffect> cardEffects = new List<ICardEffect>();
  11. #region Alternative Digivolve Condition
  12. if (timing == EffectTiming.None)
  13. {
  14. static bool PermanentCondition(Permanent targetPermanent)
  15. {
  16. return targetPermanent.TopCard.EqualsTraits("Shambala");
  17. }
  18. cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(PermanentCondition, 3, false, card, null, level: 4));
  19. }
  20. #endregion
  21. #region Guard
  22. if (timing == EffectTiming.WhenRemoveField)
  23. {
  24. cardEffects.Add(CardEffectFactory.GuardSelfEffect(isInheritedEffect: false, card: card, condition: null));
  25. }
  26. #endregion
  27. #region Shared OP / WD
  28. string SharedEffectName = "<De-Digivolve 1> 1 enemy Digimon, then 1 of your other [SW] Digimon may gain <Alliance> and attack.";
  29. CardEffectFactory.ActivateClassesForSharedEffects
  30. (ref cardEffects, timing, card,
  31. SharedEffectName,
  32. SharedActivateCoroutine,
  33. SharedEffectDescription,
  34. optional: false,
  35. onPlay: true,
  36. whenDigivolving: true);
  37. string SharedEffectDescription(string tag) => $"[{tag}] <De-Digivolve 1> 1 of your opponent's Digimon. Then, 1 of your other [SW] trait Digimon may gain <Alliance> for the turn and attack.";
  38. bool CanSelectEnemyPermanentCondition(Permanent permanent)
  39. {
  40. return CardEffectCommons.IsPermanentExistsOnOpponentBattleAreaDigimon(permanent, card);
  41. }
  42. bool CanSelectOwnerPermanentCondition(Permanent permanent)
  43. {
  44. return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
  45. && permanent.TopCard.EqualsTraits("SW")
  46. && permanent != card.PermanentOfThisCard();
  47. }
  48. IEnumerator SharedActivateCoroutine(Hashtable hashtable, ActivateClass activateClass)
  49. {
  50. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectEnemyPermanentCondition))
  51. {
  52. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  53. selectPermanentEffect.SetUp(
  54. selectPlayer: card.Owner,
  55. canTargetCondition: CanSelectEnemyPermanentCondition,
  56. canTargetCondition_ByPreSelecetedList: null,
  57. canEndSelectCondition: null,
  58. maxCount: 1,
  59. canNoSelect: false,
  60. canEndNotMax: false,
  61. selectPermanentCoroutine: null,
  62. afterSelectPermanentCoroutine: null,
  63. mode: SelectPermanentEffect.Mode.Degenerate,
  64. cardEffect: activateClass);
  65. selectPermanentEffect.SetUpCustomMessage("Select 1 opponent's Digimon to De-Digivolve", "The opponent is selecting 1 Digimon to De-Digivolve");
  66. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  67. }
  68. if (CardEffectCommons.HasMatchConditionPermanent(CanSelectOwnerPermanentCondition))
  69. {
  70. SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
  71. selectPermanentEffect.SetUp(
  72. selectPlayer: card.Owner,
  73. canTargetCondition: CanSelectOwnerPermanentCondition,
  74. canTargetCondition_ByPreSelecetedList: null,
  75. canEndSelectCondition: null,
  76. maxCount: 1,
  77. canNoSelect: true,
  78. canEndNotMax: false,
  79. selectPermanentCoroutine: SelectPermanentCoroutine,
  80. afterSelectPermanentCoroutine: null,
  81. mode: SelectPermanentEffect.Mode.Custom,
  82. cardEffect: activateClass);
  83. selectPermanentEffect.SetUpCustomMessage("Select 1 Digimon to gain <Alliance> and attack", "The opponent is selecting 1 Digimon to gain <Alliance> and attack");
  84. yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
  85. IEnumerator SelectPermanentCoroutine(Permanent permanent)
  86. {
  87. if (permanent != null)
  88. {
  89. yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.GainAlliance(targetPermanent: permanent, effectDuration: EffectDuration.UntilEachTurnEnd, activateClass: activateClass));
  90. SelectAttackEffect selectAttackEffect = GManager.instance.GetComponent<SelectAttackEffect>();
  91. selectAttackEffect.SetUp(
  92. attacker: permanent,
  93. canAttackPlayerCondition: () => true,
  94. defenderCondition: _ => true,
  95. cardEffect: activateClass);
  96. yield return ContinuousController.instance.StartCoroutine(selectAttackEffect.Activate());
  97. }
  98. }
  99. }
  100. }
  101. #endregion
  102. #region DigiXros
  103. if (timing == EffectTiming.None)
  104. {
  105. AddDigiXrosConditionClass addDigiXrosConditionClass = new AddDigiXrosConditionClass();
  106. addDigiXrosConditionClass.SetUpICardEffect($"DigiXros -2", CanUseCondition, card);
  107. addDigiXrosConditionClass.SetUpAddDigiXrosConditionClass(getDigiXrosCondition: GetDigiXros);
  108. addDigiXrosConditionClass.SetNotShowUI(true);
  109. cardEffects.Add(addDigiXrosConditionClass);
  110. bool CanUseCondition(Hashtable hashtable)
  111. {
  112. return true;
  113. }
  114. DigiXrosCondition GetDigiXros(CardSource cardSource)
  115. {
  116. if (cardSource == card)
  117. {
  118. DigiXrosConditionElement element = new DigiXrosConditionElement(CanSelectCardCondition,
  119. "1 Lv.5 or lower Digimon card w/[Gokuumon] in text or w/[SW] trait");
  120. bool CanSelectCardCondition(CardSource xrosCardSource)
  121. {
  122. return xrosCardSource != null
  123. && xrosCardSource.Owner == card.Owner
  124. && xrosCardSource.IsDigimon
  125. && xrosCardSource.HasLevel
  126. && xrosCardSource.Level <= 5
  127. && (xrosCardSource.HasText("Gokuumon")
  128. || xrosCardSource.EqualsTraits("SW"));
  129. }
  130. List<DigiXrosConditionElement> elements = new List<DigiXrosConditionElement>() { element };
  131. DigiXrosCondition digiXrosCondition = new DigiXrosCondition(elements, null, 2);
  132. return digiXrosCondition;
  133. }
  134. return null;
  135. }
  136. }
  137. #endregion
  138. #region Inherited
  139. if (timing == EffectTiming.OnAllyAttack)
  140. {
  141. ActivateClass activateClass = new ActivateClass();
  142. activateClass.SetUpICardEffect("Change attack target to this Digimon", CanUseCondition, card);
  143. activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, 1, true, EffectDescription());
  144. activateClass.SetHashString("EX12_056_Inherited");
  145. activateClass.SetIsInheritedEffect(true);
  146. cardEffects.Add(activateClass);
  147. string EffectDescription()
  148. {
  149. return "[Opponent's Turn] [Once Per Turn] When one of your opponent's Digimon attacks, you may change the attack target to this Digimon.";
  150. }
  151. bool CanUseCondition(Hashtable hashtable)
  152. {
  153. return CardEffectCommons.IsExistOnBattleAreaDigimonTrigger(card, activateClass)
  154. && CardEffectCommons.IsOpponentTurn(card)
  155. && CardEffectCommons.CanTriggerOnPermanentAttack(hashtable, PermanentCondition);
  156. }
  157. bool CanActivateCondition(Hashtable hashtable)
  158. {
  159. return CardEffectCommons.IsExistOnBattleAreaDigimonActivate(card, activateClass)
  160. && GManager.instance.attackProcess.IsAttacking
  161. && GManager.instance.attackProcess.AttackingPermanent.CanSwitchAttackTarget;
  162. }
  163. bool PermanentCondition(Permanent permanent)
  164. {
  165. return CardEffectCommons.IsOpponentPermanent(permanent, card);
  166. }
  167. IEnumerator ActivateCoroutine(Hashtable _hashtable)
  168. {
  169. yield return ContinuousController.instance.StartCoroutine(GManager.instance.attackProcess.SwitchDefender(
  170. activateClass,
  171. false,
  172. card.PermanentOfThisCard()));
  173. }
  174. }
  175. #endregion
  176. return cardEffects;
  177. }
  178. }
  179. }