mbunch_kascope 2 роки тому
батько
коміт
9c83e56266

+ 18 - 11
Assets/Scripts/CardController.cs

@@ -3316,6 +3316,20 @@ public class IBattle
         return null;
     }
 
+    public int CompareStats()
+    {
+        int statCheck = 0;
+
+        if(AttackingPermanent.HasIceclad || DefendingPermanent.HasIceclad)
+            statCheck = AttackingPermanent.DigivolutionCards.Count - DefendingPermanent.DigivolutionCards.Count;
+        else
+            statCheck = AttackingPermanent.DP - DefendingPermanent.DP;
+
+        statCheck = Mathf.Clamp(statCheck, -1, 1);
+
+        return statCheck;
+    }
+
     public IEnumerator Battle()
     {
         hashtable = new Hashtable();
@@ -3452,40 +3466,33 @@ public class IBattle
                 #region battle with permanent
                 if (DefendingPermanent != null)
                 {
-                    if (AttackingPermanent.DP > DefendingPermanent.DP)
+                    int battleResults = CompareStats();
+                    if (battleResults == 1)
                     {
                         WinnerPermanents.Add(AttackingPermanent);
 
                         if (DefendingPermanent.CanBeDestroyedByBattle(AttackingPermanent, DefendingPermanent, DefendingCard))
-                        {
                             LoserPermanents.Add(DefendingPermanent);
-                        }
                     }
 
-                    else if (AttackingPermanent.DP == DefendingPermanent.DP)
+                    else if (battleResults == 0)
                     {
                         WinnerPermanents.Add(AttackingPermanent);
                         WinnerPermanents.Add(DefendingPermanent);
 
                         if (AttackingPermanent.CanBeDestroyedByBattle(AttackingPermanent, DefendingPermanent, DefendingCard))
-                        {
                             LoserPermanents.Add(AttackingPermanent);
-                        }
 
                         if (DefendingPermanent.CanBeDestroyedByBattle(AttackingPermanent, DefendingPermanent, DefendingCard))
-                        {
                             LoserPermanents.Add(DefendingPermanent);
-                        }
                     }
 
-                    else if (AttackingPermanent.DP < DefendingPermanent.DP)
+                    else if (battleResults == -1)
                     {
                         WinnerPermanents.Add(DefendingPermanent);
 
                         if (AttackingPermanent.CanBeDestroyedByBattle(AttackingPermanent, DefendingPermanent, DefendingCard))
-                        {
                             LoserPermanents.Add(AttackingPermanent);
-                        }
                     }
                 }
                 #endregion

+ 87 - 0
Assets/Scripts/CardEffectCommons/KeyWordEffects/Iceclad.cs

@@ -0,0 +1,87 @@
+using System.Collections;
+using System.Collections.Generic;
+using System;
+using System.Linq;
+using UnityEngine;
+
+public partial class CardEffectCommons
+{
+    #region Target 1 Digimon gains [Iceclad]
+    public static IEnumerator GainIceclad(Permanent targetPermanent, EffectDuration effectDuration, ICardEffect activateClass)
+    {
+        if (targetPermanent == null) yield break;
+        if (!IsPermanentExistsOnBattleArea(targetPermanent)) yield break;
+        if (activateClass == null) yield break;
+        if (activateClass.EffectSourceCard == null) yield break;
+
+        CardSource card = activateClass.EffectSourceCard;
+
+        bool PermanentCondition(Permanent permanent) => permanent == targetPermanent;
+
+        bool CanUseCondition()
+        {
+            if (IsPermanentExistsOnBattleArea(targetPermanent))
+            {
+                if (!targetPermanent.TopCard.CanNotBeAffected(activateClass))
+                {
+                    return true;
+                }
+            }
+
+            return false;
+        }
+
+        IcecladClass iceclad = CardEffectFactory.IcecladStaticEffect(permanentCondition: PermanentCondition, isInheritedEffect: false, card: card, condition: CanUseCondition);
+
+        AddEffectToPermanent(targetPermanent: targetPermanent, effectDuration: effectDuration, card: card, cardEffect: iceclad, timing: EffectTiming.None);
+
+        if (!targetPermanent.TopCard.CanNotBeAffected(activateClass))
+        {
+            yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateBuffEffect(targetPermanent));
+        }
+    }
+    #endregion
+
+    #region Player gains effect to have Digimon gains [Iceclad]
+    public static IEnumerator GainIcecladPlayerEffect(Func<Permanent, bool> permanentCondition, EffectDuration effectDuration, ICardEffect activateClass)
+    {
+        if (activateClass == null) yield break;
+        if (activateClass.EffectSourceCard == null) yield break;
+
+        CardSource card = activateClass.EffectSourceCard;
+
+        bool PermanentCondition(Permanent permanent)
+        {
+            if (IsPermanentExistsOnBattleArea(permanent))
+            {
+                if (!permanent.TopCard.CanNotBeAffected(activateClass))
+                {
+                    if (permanentCondition == null || permanentCondition(permanent))
+                    {
+                        return true;
+                    }
+                }
+            }
+
+            return false;
+        }
+
+        bool CanUseCondition()
+        {
+            return true;
+        }
+
+        IcecladClass iceclad = CardEffectFactory.IcecladStaticEffect(permanentCondition: PermanentCondition, isInheritedEffect: false, card: card, condition: CanUseCondition);
+
+        AddEffectToPlayer(effectDuration: effectDuration, card: card, cardEffect: iceclad, timing: EffectTiming.None);
+
+        foreach (Permanent permanent in GManager.instance.turnStateMachine.gameContext.PermanentsForTurnPlayer)
+        {
+            if (PermanentCondition(permanent))
+            {
+                yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateBuffEffect(permanent));
+            }
+        }
+    }
+    #endregion
+}

+ 11 - 0
Assets/Scripts/CardEffectCommons/KeyWordEffects/Iceclad.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 64d866940c4b45e428e6eb9600a627d8
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 66 - 0
Assets/Scripts/CardEffectFactory/KeyWordEffects/Iceclad.cs

@@ -0,0 +1,66 @@
+using System.Collections;
+using System.Collections.Generic;
+using System;
+using System.Linq;
+using UnityEngine;
+
+public partial class CardEffectFactory
+{
+    #region Static effect of [Iceclad] on oneself
+    public static IcecladClass IcecladSelfStaticEffect(bool isInheritedEffect, CardSource card, Func<bool> condition)
+    {
+        bool PermanentCondition(Permanent permanent) => permanent == card.PermanentOfThisCard();
+
+        bool CanUseCondition()
+        {
+            if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
+            {
+                if (condition == null || condition())
+                {
+                    return true;
+                }
+            }
+
+            return false;
+        }
+
+        return IcecladStaticEffect(permanentCondition: PermanentCondition, isInheritedEffect: isInheritedEffect, card: card, condition: CanUseCondition);
+    }
+    #endregion
+
+    #region Static effect of [Iceclad]
+    public static IcecladClass IcecladStaticEffect(Func<Permanent, bool> permanentCondition, bool isInheritedEffect, CardSource card, Func<bool> condition)
+    {
+        string effectName = "Iceclad";
+
+        IcecladClass icecladClass = new IcecladClass();
+        icecladClass.SetUpICardEffect(effectName, CanUseCondition, card);
+        icecladClass.SetUpIcecladClass(PermanentCondition: PermanentCondition);
+
+        if (isInheritedEffect)
+        {
+            icecladClass.SetIsInheritedEffect(true);
+        }
+
+        bool CanUseCondition(Hashtable hashtable)
+        {
+            return condition == null || condition();
+        }
+
+        bool PermanentCondition(Permanent permanent)
+        {
+            if (CardEffectCommons.IsPermanentExistsOnBattleArea(permanent))
+            {
+                if (permanentCondition == null || permanentCondition(permanent))
+                {
+                    return true;
+                }
+            }
+
+            return false;
+        }
+
+        return icecladClass;
+    }
+    #endregion
+}

+ 11 - 0
Assets/Scripts/CardEffectFactory/KeyWordEffects/Iceclad.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 4a972d9b9ddc67a48ae1ea2f01470fba
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 8 - 1
Assets/Scripts/CardEffectInterfaces.cs

@@ -30,6 +30,13 @@ public interface IIgnoreColorConditionEffect
 }
 #endregion
 
+#region "Target permanent gains Iceclad" effect
+public interface IIcecladEffect
+{
+    bool HasIceclad(Permanent permanent);
+}
+#endregion
+
 #region "Target permanent gains Rush" effect
 public interface IRushEffect
 {
@@ -37,7 +44,7 @@ public interface IRushEffect
 }
 #endregion
 
-#region "Target permanent gains Rush" effect
+#region "Target permanent gains Reboot" effect
 public interface IRebootEffect
 {
     bool HasReboot(Permanent permanent);

+ 35 - 0
Assets/Scripts/CardEffects/IcecladClass.cs

@@ -0,0 +1,35 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+using System.Linq;
+using Photon;
+using System;
+
+public class IcecladClass : ICardEffect, IIcecladEffect
+{
+    public void SetUpIcecladClass(Func<Permanent, bool> PermanentCondition)
+    {
+        this.PermanentCondition = PermanentCondition;
+    }
+
+    Func<Permanent, bool> PermanentCondition { get; set; }
+
+    public bool HasIceclad(Permanent permanent)
+    {
+        if (PermanentCondition != null)
+        {
+            if (permanent != null)
+            {
+                if (permanent.TopCard != null)
+                {
+                    if (PermanentCondition(permanent))
+                    {
+                        return true;
+                    }
+                }
+            }
+        }
+
+        return false;
+    }
+}

+ 11 - 0
Assets/Scripts/CardEffects/IcecladClass.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: eb8e37651cecf9445a9cb70a265a8bad
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 45 - 0
Assets/Scripts/Permanent.cs

@@ -1847,6 +1847,51 @@ public class Permanent
     }
     #endregion
 
+    #region Has Ice Clad
+    public bool HasIceclad
+    {
+        get
+        {
+            foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
+            {
+                #region Ice clad permanent effects
+                foreach (ICardEffect cardEffect in EffectList(EffectTiming.None))
+                {
+                    if (cardEffect is IIcecladEffect)
+                    {
+                        if (cardEffect.CanTrigger(null))
+                        {
+                            if (((IIcecladEffect)cardEffect).HasIceclad(this))
+                            {
+                                return true;
+                            }
+                        }
+                    }
+                }
+                #endregion
+
+                #region Ice clad Player Effects
+                foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
+                {
+                    if (cardEffect is IIcecladEffect)
+                    {
+                        if (cardEffect.CanTrigger(null))
+                        {
+                            if (((IIcecladEffect)cardEffect).HasIceclad(this))
+                            {
+                                return true;
+                            }
+                        }
+                    }
+                }
+                #endregion
+            }
+
+            return false;
+        }
+    }
+    #endregion
+
     #region Whether this permanent has Pierce
     public bool HasPierce
     {