Procházet zdrojové kódy

Merge pull request #1470 from DCGO2/Guard-and-MAchine-Empire

Guard and Machine Empire
hooperk před 2 měsíci
rodič
revize
e043a44ef1

+ 11 - 0
Assets/Scripts/CardEffect/EX12/Black/EX12_053.cs.meta

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

+ 158 - 0
Assets/Scripts/CardEffect/EX12/Black/EX12_072.cs

@@ -0,0 +1,158 @@
+using System.Collections;
+using System.Collections.Generic;
+
+// Metal Empire
+namespace DCGO.CardEffects.EX12
+{
+    public class EX12_072 : CEntity_Effect
+    {
+        public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
+        {
+            List<ICardEffect> cardEffects = new List<ICardEffect>();
+
+            #region Use Req
+            if (timing == EffectTiming.None)
+            {
+                cardEffects.Add(CardEffectFactory.UseRequirements(card, CardCondition));
+
+                bool CardCondition(CardSource cardSource)
+                {
+                    return cardSource.EqualsTraits("ME");
+                }
+            }
+            #endregion
+
+            #region All Turns Security
+            if (timing == EffectTiming.None)
+            {
+                bool PermanentCondition(Permanent permanent)
+                {
+                    return CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card)
+                        && permanent.TopCard.EqualsTraits("Me");
+                }
+
+                bool CardSourceCondition(CardSource cardSource)
+                {
+                    if (CardEffectCommons.IsExistOnBattleAreaDigimon(cardSource))
+                    {
+                        if (cardSource.Owner == card.Owner)
+                        {
+                            if (cardSource == cardSource.PermanentOfThisCard().TopCard)
+                            {
+                                if (PermanentCondition(cardSource.PermanentOfThisCard()))
+                                {
+                                    return true;
+                                }
+                            }
+                        }
+                    }
+
+                    return false;
+                }
+
+                bool CanUseCondition(Hashtable hashtable)
+                {
+                    return CardEffectCommons.IsExistInSecurity(card, false);
+                }
+
+                List<ICardEffect> GetEffects(CardSource cardSource, List<ICardEffect> cardEffects, EffectTiming _timing)
+                {
+                    if (_timing == EffectTiming.WhenRemoveField)
+                    {
+                        bool Condition()
+                        {
+                            return true;
+                        }
+
+                        cardEffects.Add(CardEffectFactory.GuardSelfEffect(false, cardSource, Condition));
+                    }
+
+                    return cardEffects;
+                }
+
+                AddSkillClass addSkillClass = new AddSkillClass();
+                addSkillClass.SetUpICardEffect("Your Digimon gain Guard", CanUseCondition, card);
+                addSkillClass.SetUpAddSkillClass(cardSourceCondition: CardSourceCondition, getEffects: GetEffects, limitTiming: EffectTiming.WhenRemoveField);
+                cardEffects.Add(addSkillClass);
+
+            }
+            #endregion
+
+            #region Main Effect
+            if (timing == EffectTiming.OptionSkill)
+            {
+                ActivateClass activateClass = new ActivateClass();
+                activateClass.SetUpICardEffect("Replace your bottom sec with this face-up card", CanUseCondition, card);
+                activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDescription());
+                cardEffects.Add(activateClass);
+
+                string EffectDescription()
+                {
+                    return "[Main] Add your bottom security card to the hand and place this card face up as the bottom security card.";
+                }
+
+                bool CanUseCondition(Hashtable hashtable)
+                {
+                    return CardEffectCommons.CanTriggerOptionMainEffect(hashtable, card);
+                }
+
+                IEnumerator ActivateCoroutine(Hashtable hashtable)
+                {
+                    yield return ContinuousController.instance.StartCoroutine(CardEffectFactory.ReplaceBottomSecurityWithFaceUpOptionEffect(card, activateClass));
+                }
+            }
+            #endregion
+
+            #region Security Effect
+            if (timing == EffectTiming.SecuritySkill)
+            {
+                ActivateClass activateClass = new ActivateClass();
+                activateClass.SetUpICardEffect("Play 1 lvl 5 or lower [ME] Digimon card from hand", CanUseCondition, card);
+                activateClass.SetUpActivateClass(null, ActivateCoroutine, -1, false, EffectDescription());
+                activateClass.SetIsSecurityEffect(true);
+                cardEffects.Add(activateClass);
+
+                string EffectDescription()
+                 => "[Security] You may play 1 level 5 or lower [ME] trait Digimon card from your hand without paying the cost.";
+
+                bool CanUseCondition(Hashtable hashtable)
+                {
+                    return CardEffectCommons.CanTriggerSecurityEffect(hashtable, card);
+                }
+
+                bool CanPlayCondition(CardSource cardSource)
+                {
+                    return cardSource.IsDigimon
+                        && cardSource.HasLevel
+                        && cardSource.Level <= 5
+                        && cardSource.EqualsTraits("ME")
+                        && CardEffectCommons.CanPlayAsNewPermanent(cardSource: cardSource, payCost: false, cardEffect: activateClass);
+                }
+
+                IEnumerator ActivateCoroutine(Hashtable hashtable)
+                {
+                    SelectHandEffect selectHandEffect2 = GManager.instance.GetComponent<SelectHandEffect>();
+
+                    selectHandEffect2.SetUp(
+                        selectPlayer: card.Owner,
+                        canTargetCondition: CanPlayCondition,
+                        canTargetCondition_ByPreSelecetedList: null,
+                        canEndSelectCondition: null,
+                        maxCount: 1,
+                        canNoSelect: true,
+                        canEndNotMax: false,
+                        isShowOpponent: true,
+                        selectCardCoroutine: null,
+                        afterSelectCardCoroutine: null,
+                        mode: SelectHandEffect.Mode.PlayForFree,
+                        cardEffect: activateClass);
+
+                    yield return StartCoroutine(selectHandEffect2.Activate());
+                }
+            }
+            #endregion
+
+            return cardEffects;
+        }
+    }
+}

+ 11 - 0
Assets/Scripts/CardEffect/EX12/Black/EX12_072.cs.meta

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

+ 11 - 0
Assets/Scripts/CardEffect/EX12/Blue/EX12_022.cs.meta

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

+ 11 - 0
Assets/Scripts/CardEffect/EX12/Blue/EX12_025.cs.meta

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

+ 11 - 0
Assets/Scripts/CardEffect/EX12/Green/EX12_049.cs.meta

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

+ 1 - 1
Assets/Scripts/CardEffect/EX12/Purple/EX12_065.cs.meta

@@ -1,5 +1,5 @@
 fileFormatVersion: 2
-guid: a6116785332d73b4fb5d8f3992b2c78d
+guid: b50dbde460d6ed54e8b088c86e29a87c
 MonoImporter:
   externalObjects: {}
   serializedVersion: 2

+ 11 - 0
Assets/Scripts/CardEffect/EX12/Red/EX12_008.cs.meta

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

+ 11 - 0
Assets/Scripts/CardEffect/EX12/Red/EX12_066.cs.meta

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

+ 11 - 0
Assets/Scripts/CardEffect/EX12/White/EX12_074.cs.meta

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

+ 11 - 0
Assets/Scripts/CardEffect/EX12/Yellow/EX12_002.cs.meta

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

+ 11 - 0
Assets/Scripts/CardEffect/EX12/Yellow/EX12_038.cs.meta

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

+ 11 - 0
Assets/Scripts/CardEffect/EX12/Yellow/EX12_069.cs.meta

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

+ 11 - 0
Assets/Scripts/CardEffect/P/Purple/P_239.cs.meta

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

+ 154 - 0
Assets/Scripts/Script/CardEffectFactory/KeyWordEffects/Guard.cs

@@ -0,0 +1,154 @@
+using System.Collections;
+using System.Collections.Generic;
+using System;
+
+public partial class CardEffectFactory
+{
+    #region [Guard] self effect
+    public static ActivateClass GuardSelfEffect(bool isInheritedEffect, CardSource card, Func<bool> condition, bool isLinkedEffect = false)
+    {
+        return GuardEffect(
+            targetPermanent: card.PermanentOfThisCard(), 
+            isInheritedEffect,
+            condition,
+            rootCardEffect: null,
+            card,
+            isLinkedEffect);
+    }
+    #endregion
+
+    #region [Guard] Effect
+    public static ActivateClass GuardEffect(Permanent targetPermanent, bool isInheritedEffect, Func<bool> condition, ICardEffect rootCardEffect, CardSource card, bool isLinkedEffect = false)
+    {
+        if (targetPermanent == null) return null;
+        if (targetPermanent.TopCard == null) return null;
+        if (card == null) return null;
+
+        ActivateClass activateClass = new ActivateClass();
+        activateClass.SetUpICardEffect("Guard", CanUseCondition, card);
+        activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, DataBase.GuardEffectDescription());
+        activateClass.SetIsInheritedEffect(isInheritedEffect);
+        activateClass.SetIsLinkedEffect(isLinkedEffect);
+
+        if (rootCardEffect != null)
+        {
+            activateClass.SetIsInheritedEffect(false);
+            activateClass.SetEffectSourcePermanent(targetPermanent);
+            activateClass.SetRootCardEffect(rootCardEffect);
+        }
+
+        bool CanUseCondition(Hashtable hashtable)
+        {
+            return CardEffectCommons.IsPermanentExistsOnBattleAreaDigimon(targetPermanent)
+                && !targetPermanent.TopCard.CanNotBeAffected(activateClass)
+                && CardEffectCommons.CanTriggerWhenPermanentRemoveField(hashtable, PermanentCondition)
+                && CardEffectCommons.IsByEffect(hashtable, effect => CardEffectCommons.IsOpponentEffect(effect, card));
+        }
+
+        bool PermanentCondition(Permanent permanent) => permanent != targetPermanent && CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(permanent, card);
+
+        bool CanActivateCondition(Hashtable hashtable)
+        {
+            return CanActivateGuard(targetPermanent, activateClass);
+        }
+
+        IEnumerator ActivateCoroutine(Hashtable _hashtable)
+        {
+            return CardEffectFactory.GuardProcess(_hashtable, activateClass, targetPermanent);
+        }
+
+        return activateClass;
+    }
+    #endregion
+
+    #region Can activate [Guard]
+    public static bool CanActivateGuard(Permanent permanent, ICardEffect activateClass)
+    {
+        return CardEffectCommons.IsPermanentExistsOnBattleArea(permanent)
+            && permanent.CanBeDestroyedBySkill(activateClass);
+    }
+    #endregion
+
+    #region Effect process of [Guard]
+    public static IEnumerator GuardProcess(Hashtable hashtable, ICardEffect activateClass, Permanent permanent)
+    {
+        if (permanent == null) yield break;
+        if (permanent.TopCard == null) yield break;
+
+        bool PermanentCondition(Permanent otherPermanent) => permanent != otherPermanent && CardEffectCommons.IsPermanentExistsOnOwnerBattleAreaDigimon(otherPermanent, permanent.TopCard);
+
+        Player owner = permanent.TopCard.Owner;
+
+        string selectPlayerMessage = "Will you delete this digimon to prevent the removal?";
+        string notSelectPlayerMessage = "The opponent is choosing if they will use Guard.";
+
+        List<SelectionElement<bool>> command_SelectCommands = new List<SelectionElement<bool>>()
+        {
+            new SelectionElement<bool>(message: $"Yes", value: true, spriteIndex: 0),
+            new SelectionElement<bool>(message: $"No", value: false, spriteIndex: 1),
+        };
+
+        GManager.instance.userSelectionManager.SetBoolSelection(selectionElements: command_SelectCommands, selectPlayer: owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
+
+        yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
+
+        if (GManager.instance.userSelectionManager.SelectedBoolValue)
+        {
+            yield return ContinuousController.instance.StartCoroutine(CardEffectCommons.DeletePeremanentAndProcessAccordingToResult(targetPermanents: new List<Permanent>() { permanent }, activateClass: activateClass, successProcess: permanents => SuccessProcess(), failureProcess: null));
+
+            IEnumerator SuccessProcess()
+            {
+                List<Permanent> GuardedPermanents = CardEffectCommons.GetPermanentsFromHashtable(hashtable).Filter(PermanentCondition);
+
+                foreach (Permanent guardPermanent in GuardedPermanents)
+                {
+                    guardPermanent.willBeRemoveField = false;
+                    guardPermanent.HideDeleteEffect();
+                    guardPermanent.HideHandBounceEffect();
+                    guardPermanent.HideDeckBounceEffect();
+                    guardPermanent.HideWillRemoveFieldEffect();
+                }
+                yield return null;
+            }
+        }
+    }
+    #endregion
+
+    #region Target 1 Digimon gains [Guard]
+    public static IEnumerator GainGuard(Permanent targetPermanent, EffectDuration effectDuration, ICardEffect activateClass)
+    {
+        if (targetPermanent == null) yield break;
+        if (!CardEffectCommons.IsPermanentExistsOnBattleArea(targetPermanent)) yield break;
+        if (activateClass == null) yield break;
+        if (activateClass.EffectSourceCard == null) yield break;
+
+        CardSource card = activateClass.EffectSourceCard;
+
+        bool CanUseCondition()
+        {
+            return CardEffectCommons.IsPermanentExistsOnBattleArea(targetPermanent)
+                && !targetPermanent.TopCard.CanNotBeAffected(activateClass);
+        }
+
+        ActivateClass guard = CardEffectFactory.GuardEffect(
+            targetPermanent: targetPermanent,
+            isInheritedEffect: false,
+            condition: CanUseCondition,
+            rootCardEffect: activateClass,
+            card: targetPermanent.TopCard);
+
+        CardEffectCommons.AddEffectToPermanent(
+            targetPermanent: targetPermanent,
+            effectDuration: effectDuration,
+            card: card,
+            cardEffect: guard,
+            timing: EffectTiming.WhenRemoveField);
+
+        if (!targetPermanent.TopCard.CanNotBeAffected(activateClass))
+        {
+            yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateBuffEffect(targetPermanent));
+        }
+    }
+    #endregion
+
+}

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

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

+ 5 - 0
Assets/Scripts/Script/DataBase.cs

@@ -564,6 +564,11 @@ public class DataBase : MonoBehaviour
         return "[Link] (Plug this card from the hand or battle area sideways into the specified Digimon in the battle area.)";
     }
 
+    public static string GuardEffectDescription()
+    {
+        return "<Guard> (When any of your other Digimon would leave the battle area by your opponent's effects, by deleting this Digimon, they don't leave.)";
+    }
+    
     public static string EngageEffectDescription()
     {
         return "<Engage> (At the end of your turn, this Digimon may attack.)";