Ver Fonte

Highlight the target of optional effect for BT21-083

hooperk há 5 meses atrás
pai
commit
1b8735f5d0

+ 47 - 54
Assets/Scripts/CardEffect/BT21/Red/BT21_083.cs

@@ -113,11 +113,10 @@ namespace DCGO.CardEffects.BT21
 
 
             if (timing == EffectTiming.OnEnterFieldAnyone)
             if (timing == EffectTiming.OnEnterFieldAnyone)
             {
             {
-                List<Permanent> playedPermanents = new List<Permanent>();
-
                 ActivateClass activateClass = new ActivateClass();
                 ActivateClass activateClass = new ActivateClass();
                 activateClass.SetUpICardEffect("Suspend this tamer, Attack with a [Xros Heart]/[Hero] Digimon", CanUseCondition, card);
                 activateClass.SetUpICardEffect("Suspend this tamer, Attack with a [Xros Heart]/[Hero] Digimon", CanUseCondition, card);
                 activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
                 activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, true, EffectDiscription());
+                activateClass.SetEffectTargets(TargetablePermanents);
                 cardEffects.Add(activateClass);
                 cardEffects.Add(activateClass);
 
 
                 string EffectDiscription()
                 string EffectDiscription()
@@ -158,77 +157,71 @@ namespace DCGO.CardEffects.BT21
                            (permanent.TopCard.EqualsTraits("Xros Heart") || permanent.TopCard.EqualsTraits("Hero"));
                            (permanent.TopCard.EqualsTraits("Xros Heart") || permanent.TopCard.EqualsTraits("Hero"));
                 }
                 }
 
 
-                IEnumerator ActivateCoroutine(Hashtable hashtable)
+                List<Permanent> TargetablePermanents(Hashtable hashtable)
                 {
                 {
-                    yield return ContinuousController.instance.StartCoroutine(new SuspendPermanentsClass(new List<Permanent>() { card.PermanentOfThisCard() }, CardEffectCommons.CardEffectHashtable(activateClass)).Tap());
+                    List<Permanent> playedPermanents = new List<Permanent>();
 
 
                     foreach (Hashtable hash in CardEffectCommons.GetHashtablesFromHashtable(hashtable))
                     foreach (Hashtable hash in CardEffectCommons.GetHashtablesFromHashtable(hashtable))
                     {
                     {
                         playedPermanents.Add(CardEffectCommons.GetPermanentFromHashtable(hash));
                         playedPermanents.Add(CardEffectCommons.GetPermanentFromHashtable(hash));
                     }
                     }
 
 
+                    return playedPermanents.Filter(AttackingPermanentCondition);
+
                     bool AttackingPermanentCondition(Permanent permanent)
                     bool AttackingPermanentCondition(Permanent permanent)
                     {
                     {
-                        if (playedPermanents.Contains(permanent))
-                        {
-                            if (CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card))
-                            {
-                                if (permanent.TopCard.EqualsTraits("Xros Heart") || permanent.TopCard.EqualsTraits("Hero"))
-                                {
-                                    if (permanent.CanAttack(activateClass))
-                                    {
-                                        return true;
-                                    }
-                                }
-                            }
-                        }
-
-                        return false;
+                        return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
+                            && permanent.TopCard.EqualsTraits("Xros Heart") || permanent.TopCard.EqualsTraits("Hero")
+                            && permanent.CanAttack(activateClass);
                     }
                     }
+                }
 
 
-                    if (CardEffectCommons.HasMatchConditionOwnersPermanent(card, AttackingPermanentCondition))
-                    {
-                        Permanent selectedPermanent = null;
-                        int maxCount = Math.Min(1, CardEffectCommons.MatchConditionOwnersPermanentCount(card, AttackingPermanentCondition));
-                        SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
+                IEnumerator ActivateCoroutine(Hashtable hashtable)
+                {
+                    yield return ContinuousController.instance.StartCoroutine(new SuspendPermanentsClass(new List<Permanent>() { card.PermanentOfThisCard() }, CardEffectCommons.CardEffectHashtable(activateClass)).Tap());
 
 
-                        selectPermanentEffect.SetUp(
-                            selectPlayer: card.Owner,
-                            canTargetCondition: AttackingPermanentCondition,
-                            canTargetCondition_ByPreSelecetedList: null,
-                            canEndSelectCondition: null,
-                            maxCount: maxCount,
-                            canNoSelect: true,
-                            canEndNotMax: false,
-                            selectPermanentCoroutine: SelectPermanentCoroutine,
-                            afterSelectPermanentCoroutine: null,
-                            mode: SelectPermanentEffect.Mode.Custom,
-                            cardEffect: activateClass);
+                    List<Permanent> targets = TargetablePermanents(hashtable);
 
 
-                        selectPermanentEffect.SetUpCustomMessage("Select 1 digimon to attack", "The opponent is selecting 1 digimon to attack");
+                    Permanent selectedPermanent = null;
+                    int maxCount = Math.Min(1, targets.Count);
+                    SelectPermanentEffect selectPermanentEffect = GManager.instance.GetComponent<SelectPermanentEffect>();
 
 
-                        yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
+                    selectPermanentEffect.SetUp(
+                        selectPlayer: card.Owner,
+                        canTargetCondition: targets.Contains,
+                        canTargetCondition_ByPreSelecetedList: null,
+                        canEndSelectCondition: null,
+                        maxCount: maxCount,
+                        canNoSelect: true,
+                        canEndNotMax: false,
+                        selectPermanentCoroutine: SelectPermanentCoroutine,
+                        afterSelectPermanentCoroutine: null,
+                        mode: SelectPermanentEffect.Mode.Custom,
+                        cardEffect: activateClass);
 
 
-                        IEnumerator SelectPermanentCoroutine(Permanent permanent)
-                        {
-                            selectedPermanent = permanent;
-                            yield return null;
-                        }
+                    selectPermanentEffect.SetUpCustomMessage("Select 1 digimon to attack", "The opponent is selecting 1 digimon to attack");
 
 
-                        if (selectedPermanent != null)
+                    yield return ContinuousController.instance.StartCoroutine(selectPermanentEffect.Activate());
+
+                    IEnumerator SelectPermanentCoroutine(Permanent permanent)
+                    {
+                        selectedPermanent = permanent;
+                        yield return null;
+                    }
+
+                    if (selectedPermanent != null)
+                    {
+                        if (selectedPermanent.CanAttack(activateClass))
                         {
                         {
-                            if (selectedPermanent.CanAttack(activateClass))
-                            {
-                                SelectAttackEffect selectAttackEffect = GManager.instance.GetComponent<SelectAttackEffect>();
+                            SelectAttackEffect selectAttackEffect = GManager.instance.GetComponent<SelectAttackEffect>();
 
 
-                                selectAttackEffect.SetUp(
-                                    attacker: selectedPermanent,
-                                    canAttackPlayerCondition: () => true,
-                                    defenderCondition: _ => true,
-                                    cardEffect: activateClass);
+                            selectAttackEffect.SetUp(
+                                attacker: selectedPermanent,
+                                canAttackPlayerCondition: () => true,
+                                defenderCondition: _ => true,
+                                cardEffect: activateClass);
 
 
-                                yield return ContinuousController.instance.StartCoroutine(selectAttackEffect.Activate());
-                            }
+                            yield return ContinuousController.instance.StartCoroutine(selectAttackEffect.Activate());
                         }
                         }
                     }
                     }
                 }
                 }

+ 24 - 3
Assets/Scripts/Script/ICardEffect.cs

@@ -16,6 +16,7 @@ public abstract class ICardEffect
         SetEffectSourcePermanent(null);
         SetEffectSourcePermanent(null);
         SetMaxCountPerTurn(-1);
         SetMaxCountPerTurn(-1);
         SetEffectName(effectName);
         SetEffectName(effectName);
+        SetEffectTargets(null);
         SetEffectDiscription("");
         SetEffectDiscription("");
         SetHashString("");
         SetHashString("");
         SetOnProcessCallbuck(null);
         SetOnProcessCallbuck(null);
@@ -143,6 +144,26 @@ public abstract class ICardEffect
 
 
     #endregion
     #endregion
 
 
+    #region Effect Target, used to display a detail of what card triggered this / will be targetted by the effect if performed
+
+    Func<Hashtable, List<Permanent>> _effectTargets = null;
+
+    public Func<Hashtable, List<Permanent>> EffectTargets
+    {
+        get { return _effectTargets; }
+        private set
+        {
+            _effectTargets = value;
+        }
+    }
+
+    internal void SetEffectTargets(Func<Hashtable, List<Permanent>> effectTargets)
+    {
+        EffectTargets = effectTargets;
+    }
+
+    #endregion
+
     #region Effect discription
     #region Effect discription
 
 
     string _effectDiscription = "";
     string _effectDiscription = "";
@@ -973,11 +994,11 @@ public static class ActivateICardEffectExtensionClass
 {
 {
     #region Optional
     #region Optional
 
 
-    public static IEnumerator Activate_Optional(this ActivateICardEffect activateICardEffect)
+    public static IEnumerator Activate_Optional(this ActivateICardEffect activateICardEffect, Hashtable hash)
     {
     {
         if (((ICardEffect)activateICardEffect).IsOptional)
         if (((ICardEffect)activateICardEffect).IsOptional)
         {
         {
-            yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<OptionalSkill>().SelectOptional((ICardEffect)activateICardEffect));
+            yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<OptionalSkill>().SelectOptional((ICardEffect)activateICardEffect, hash));
         }
         }
     }
     }
 
 
@@ -1119,7 +1140,7 @@ public static class ActivateICardEffectExtensionClass
             {
             {
                 if (isCheckOptional)
                 if (isCheckOptional)
                 {
                 {
-                    yield return ContinuousController.instance.StartCoroutine(Activate_Optional(activateICardEffect));
+                    yield return ContinuousController.instance.StartCoroutine(Activate_Optional(activateICardEffect, hash));
                 }
                 }
                 else
                 else
                 {
                 {

+ 32 - 3
Assets/Scripts/Script/OptionalSkill.cs

@@ -10,14 +10,25 @@ public class OptionalSkill : MonoBehaviourPunCallbacks
     public string waitingText { get; set; } = "The opponent is considering whether to use the effect.";
     public string waitingText { get; set; } = "The opponent is considering whether to use the effect.";
     bool _endSelect = false;
     bool _endSelect = false;
     bool _useOptional = false;
     bool _useOptional = false;
-    public IEnumerator SelectOptional(ICardEffect cardEffect)
+    public IEnumerator SelectOptional(ICardEffect cardEffect, Hashtable hash)
     {
     {
         List<string> _YesNoTexts = new List<string>() { "Use", "Not use" };
         List<string> _YesNoTexts = new List<string>() { "Use", "Not use" };
 
 
         _endSelect = false;
         _endSelect = false;
         _useOptional = false;
         _useOptional = false;
 
 
-        string _Message = $"Will you use \"{cardEffect.EffectName}\"?";
+        string _Message;
+
+        List<Permanent> effectTargets = cardEffect.EffectTargets != null ? cardEffect.EffectTargets(hash) : null;
+
+        if (effectTargets == null || effectTargets.Count == 0)
+        {
+            _Message = $"Will you use \"{cardEffect.EffectName}\"?";
+        }
+        else
+        {
+            _Message = $"Will you use \"{cardEffect.EffectName}\" targetting {string.Join(", ", effectTargets.Select(permanent => permanent.TopCard.CardNames[0]))}?";
+        }
 
 
         yield return GManager.instance.photonWaitController.StartWait("SelectOptional");
         yield return GManager.instance.photonWaitController.StartWait("SelectOptional");
 
 
@@ -48,15 +59,33 @@ public class OptionalSkill : MonoBehaviourPunCallbacks
         if (cardEffect.EffectSourceCard.Owner.isYou)
         if (cardEffect.EffectSourceCard.Owner.isYou)
         {
         {
             Permanent permanent = cardEffect.EffectSourceCard.PermanentOfThisCard();
             Permanent permanent = cardEffect.EffectSourceCard.PermanentOfThisCard();
+            List<FieldPermanentCard> highlightPermanents = new List<FieldPermanentCard>();
 
 
             if (permanent != null)
             if (permanent != null)
             {
             {
                 if (permanent.ShowingPermanentCard != null)
                 if (permanent.ShowingPermanentCard != null)
                 {
                 {
-                    GManager.instance.hideCannotSelectObject.SetUpHideCannotSelectObject(new List<FieldPermanentCard>() { permanent.ShowingPermanentCard }, false);
+                    highlightPermanents.Add(permanent.ShowingPermanentCard);
+                
                 }
                 }
             }
             }
 
 
+            if (effectTargets != null)
+            {
+                foreach (Permanent targetPermanent in effectTargets)
+                {
+                    if (targetPermanent.ShowingPermanentCard != null)
+                    {
+                        highlightPermanents.Add(targetPermanent.ShowingPermanentCard);
+                    }
+                }
+            }
+
+            if (highlightPermanents.Count > 0)
+            {
+                GManager.instance.hideCannotSelectObject.SetUpHideCannotSelectObject(highlightPermanents, false);
+            }
+
             GManager.instance.commandText.OpenCommandText(_Message);
             GManager.instance.commandText.OpenCommandText(_Message);
 
 
             List<Command_SelectCommand> commands = new List<Command_SelectCommand>()
             List<Command_SelectCommand> commands = new List<Command_SelectCommand>()