Преглед изворни кода

Implement BT25-034 and Ascension

hooperk пре 4 месеци
родитељ
комит
9d2366bbae

+ 100 - 0
Assets/Scripts/CardEffect/BT25/Yellow/BT25_034.cs

@@ -0,0 +1,100 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Linq;
+
+// Angemon
+namespace DCGO.CardEffects.BT25
+{
+    public class BT25_034 : CEntity_Effect
+    {
+        public override List<ICardEffect> CardEffects(EffectTiming timing, CardSource card)
+        {
+            List<ICardEffect> cardEffects = new List<ICardEffect>();
+
+            #region Digivolution Condition
+            if (timing == EffectTiming.None)
+            {
+                bool Condition(Permanent permanent)
+                {
+                    return permanent.TopCard.HasTSTraits;
+                }
+
+                cardEffects.Add(CardEffectFactory.AddSelfDigivolutionRequirementStaticEffect(level: 3, permanentCondition: Condition, digivolutionCost: 2, ignoreDigivolutionRequirement: false, card: card, condition: null));
+            }
+            #endregion
+
+            #region When Trashed
+            if (timing == EffectTiming.OnDiscardSecurity)
+            {
+                ActivateClass activateClass = new ActivateClass();
+                activateClass.SetUpICardEffect("Play 1 level 4 or lower [Angel] or [Iliad] card", CanUseCondition, card);
+                activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, EffectDescription());
+                cardEffects.Add(activateClass);
+
+                string EffectDescription()
+                {
+                    return "When effects trashing this card from the security stack, you may play 1 level 4 or lower [Angel] or [Iliad] trait card from your hand without paying the cost.";
+                }
+
+                bool CanUseCondition(Hashtable hashtable)
+                {
+                    return CardEffectCommons.CanTriggerOnTrashSelfSecurity(hashtable, cardEffect => cardEffect != null, card);
+                }
+
+                bool CanPlayCardCondition(CardSource cardSource)
+                {
+                    return cardSource.HasPlayCost
+                        && cardSource.HasLevel
+                        && cardSource.Level <= 4
+                        && (cardSource.EqualsTraits("Angel") || cardSource.EqualsTraits("Iliad"))
+                        && CardEffectCommons.CanPlayAsNewPermanent(card, false, activateClass);
+                }
+
+                bool CanActivateCondition(Hashtable hashtable)
+                {
+                    return CardEffectCommons.IsExistOnTrash(card)
+                        && CardEffectCommons.HasMatchConditionOwnersHand(card, CanPlayCardCondition);
+                }
+
+                IEnumerator ActivateCoroutine(Hashtable hashtable)
+                {
+                    SelectHandEffect selectHandEffect = GManager.instance.GetComponent<SelectHandEffect>();
+
+                    selectHandEffect.SetUp(
+                        selectPlayer: card.Owner,
+                        canTargetCondition: CanPlayCardCondition,
+                        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(selectHandEffect.Activate());
+                }
+            }
+            #endregion
+
+            #region Ascension
+            if (timing == EffectTiming.OnDestroyedAnyone)
+            {
+                cardEffects.Add(CardEffectFactory.AscensionSelfEffect(isInheritedEffect: false, card: card, condition: null));
+            }
+            #endregion
+
+            #region Barrier
+            if (timing == EffectTiming.WhenPermanentWouldBeDeleted)
+            {
+                cardEffects.Add(CardEffectFactory.BarrierSelfEffect(true, card, null));
+            }
+            #endregion
+
+            return cardEffects;
+        }
+    }
+}

+ 97 - 0
Assets/Scripts/Script/CardEffectCommons/KeyWordEffects/Ascension.cs

@@ -0,0 +1,97 @@
+using System.Collections;
+using System.Collections.Generic;
+using System;
+using System.Linq;
+using UnityEngine;
+
+public partial class CardEffectCommons
+{
+    #region Can Trigger [Ascension]
+    public static bool CanTriggerAscension(Hashtable hashtable, CardSource card)
+    {
+        return CanTriggerOnDeletion(hashtable, card);
+    }
+
+    public static bool CanTriggerPermanentAscension(Hashtable hashtable, Func<Permanent, bool> permanentCondition)
+    {
+        return CanTriggerOnPermanentDeleted(hashtable, permanentCondition);
+    }
+    #endregion
+
+    #region Can activate [Ascension]
+    public static bool CanActivateAscension(Hashtable hashtable, CardSource card)
+    {
+        return CanActivateOnDeletion(card);
+    }
+    #endregion
+
+    #region Effect process of [Ascension]
+    public static IEnumerator AscensionProcess(Hashtable hashtable, ICardEffect activateClass, CardSource card)
+    {
+        if (card.Owner.CanAddSecurity(activateClass))
+        {
+            string selectPlayerMessage = "Will you place this card in security?";
+            string notSelectPlayerMessage = "The opponent is choosing if they will use Ascension.";
+
+            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: card.Owner, selectPlayerMessage: selectPlayerMessage, notSelectPlayerMessage: notSelectPlayerMessage);
+
+            yield return ContinuousController.instance.StartCoroutine(GManager.instance.userSelectionManager.WaitForEndSelect());
+
+            if(GManager.instance.userSelectionManager.SelectedBoolValue)
+            {
+                yield return ContinuousController.instance.StartCoroutine(CardObjectController.AddSecurityCard(card, true));
+            }
+        }
+    }
+    #endregion
+
+    #region Target 1 Digimon gains [Ascension]
+    public static IEnumerator GainAscension(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 CanUseCondition()
+        {
+            if (IsPermanentExistsOnBattleArea(targetPermanent))
+            {
+                if (!targetPermanent.TopCard.CanNotBeAffected(activateClass))
+                {
+                    return true;
+                }
+            }
+
+            return false;
+        }
+
+        ActivateClass ascension = CardEffectFactory.AscensionEffect(
+            targetPermanent: targetPermanent,
+            isInheritedEffect: false,
+            condition: CanUseCondition,
+            rootCardEffect: activateClass,
+            card: activateClass.EffectSourceCard);
+
+        AddEffectToPermanent(
+            targetPermanent: targetPermanent,
+            effectDuration: effectDuration,
+            card: card,
+            cardEffect: ascension,
+            timing: EffectTiming.OnDestroyedAnyone);
+
+        if (!targetPermanent.TopCard.CanNotBeAffected(activateClass))
+        {
+            yield return ContinuousController.instance.StartCoroutine(GManager.instance.GetComponent<Effects>().CreateBuffEffect(targetPermanent));
+        }
+    }
+    #endregion
+}

+ 80 - 0
Assets/Scripts/Script/CardEffectFactory/KeyWordEffects/Ascension.cs

@@ -0,0 +1,80 @@
+using System.Collections;
+using System.Collections.Generic;
+using System;
+using System.Linq;
+using UnityEngine;
+
+public partial class CardEffectFactory
+{
+    #region Trigger effect of [Ascension] on oneself
+    public static ICardEffect AscensionSelfEffect(bool isInheritedEffect, CardSource card, Func<bool> condition)
+    {
+        Permanent targetPermanent = card.PermanentOfThisCard();
+
+        bool CanUseCondition()
+        {
+            if (CardEffectCommons.IsExistOnBattleAreaDigimon(card))
+            {
+                if (condition == null || condition())
+                {
+                    return true;
+                }
+            }
+
+            return false;
+        }
+
+        return AscensionEffect(
+            targetPermanent: targetPermanent,
+            isInheritedEffect: isInheritedEffect,
+            condition: CanUseCondition,
+            rootCardEffect: null, card);
+    }
+    #endregion
+
+    #region Trigger effect of [Ascension]
+    public static ActivateClass AscensionEffect(Permanent targetPermanent, bool isInheritedEffect, Func<bool> condition, ICardEffect rootCardEffect, CardSource card)
+    {
+        if (targetPermanent == null) return null;
+        if (targetPermanent.TopCard == null) return null;
+        if (card == null) return null;
+
+        ActivateClass activateClass = new ActivateClass();
+        activateClass.SetUpICardEffect("Ascension", CanUseCondition, card);
+        activateClass.SetUpActivateClass(CanActivateCondition, ActivateCoroutine, -1, false, DataBase.AscensionEffectDescription());
+        activateClass.SetIsInheritedEffect(isInheritedEffect);
+
+        if (rootCardEffect != null)
+        {
+            activateClass.SetIsInheritedEffect(false);
+            activateClass.SetEffectSourcePermanent(targetPermanent);
+            activateClass.SetRootCardEffect(rootCardEffect);
+        }
+
+        bool CanUseCondition(Hashtable hashtable)
+        {
+            if (CardEffectCommons.CanTriggerPermanentAscension(hashtable, (permanent) => permanent == targetPermanent))
+            {
+                if (condition == null || condition())
+                {
+                    return true;
+                }
+            }
+
+            return false;
+        }
+
+        bool CanActivateCondition(Hashtable hashtable)
+        {
+            return CardEffectCommons.CanActivateAscension(hashtable, targetPermanent.TopCard);
+        }
+
+        IEnumerator ActivateCoroutine(Hashtable _hashtable)
+        {
+            return CardEffectCommons.AscensionProcess(_hashtable, activateClass, targetPermanent.TopCard);
+        }
+
+        return activateClass;
+    }
+    #endregion
+}

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

@@ -513,6 +513,11 @@ public class DataBase : MonoBehaviour
         return "<Alliance> (When this Digimon attacks, by suspending 1 of your other Digimon, this Digimon adds the suspended Digimon's DP and gains <Security Attack +1> for the attack.)";
     }
 
+    public static string AscensionEffectDescription()
+    {
+        return "<Ascension> (When this Digimon is deleted, you may place this card as the top security card.)";
+    }
+
     public static string PartitionEffectDiscription()
     {
         return "<Partition> (When this Digimon with 1 of each specified card in its digivolution cards would leave the battle area other than by one of your effects or in battle, you may play 1 of each card without paying their costs.)";

+ 24 - 0
Assets/Scripts/Script/Permanent.cs

@@ -2765,6 +2765,30 @@ public class Permanent
     }
     #endregion
 
+    #region HasAscension
+    public bool HasAscension
+    {
+        get
+        {
+            foreach (ICardEffect cardEffect in EffectList(EffectTiming.OnDestroyedAnyone))
+            {
+                if (cardEffect is ActivateICardEffect)
+                {
+                    if (cardEffect.EffectName == "Ascension")
+                    {
+                        if (cardEffect.CanTrigger(CardEffectCommons.OnDeletionCheckHashtableOfPermanent(this)))
+                        {
+                            return true;
+                        }
+                    }
+                }
+            }
+
+            return false;
+        }
+    }
+    #endregion
+
     #region Has Fortitude
     public bool HasFortitude
     {

+ 7 - 0
Assets/Scripts/Script/PermanentDetail.cs

@@ -228,6 +228,13 @@ public class PermanentDetail : MonoBehaviour
         }
         #endregion
 
+        #region Ascension
+        if (permanent.HasAscension)
+        {
+            effectString += $"- Ascension\n";
+        }
+        #endregion
+
         #region Security Attack Changes
         if (permanent.HasSecurityAttackChanges)
         {