Untitled

mail@pastecode.io avatar
unknown
csharp
10 days ago
4.8 kB
6
Indexable
Never
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TestMod1
{
    public class Initializer : ModInitializer
    {
        /// <summary>
        /// Called when the mod is loaded.
        /// </summary>
        public override void OnInitializeMod()
        {

        }
        public static class HelperMethods
        {
            public static void InitKrakenBuf(BattleUnitModel battleUnitModel, int addedStacks)
            {
                if (battleUnitModel != null)
                {
                    BattleUnitBuf battleUnitBuf = battleUnitModel.bufListDetail.GetActivatedBufList().Find((BattleUnitBuf x) => x is BattleUnitBuf_kraken_EaF);
                    if (battleUnitBuf == null)
                    {
                        battleUnitBuf = new BattleUnitBuf_kraken_EaF();
                        battleUnitModel.bufListDetail.AddBuf(battleUnitBuf);
                    }
                    battleUnitBuf.OnAddBuf(addedStacks);
                }
            }
        }

        #region Card Scripts
        public class DiceCardSelfAbility_kraken_gain1EaF : DiceCardSelfAbilityBase
        {
            public override string[] Keywords => new string[] { "Kraken_Charge_Keyword" };
            public override void OnUseCard()
            {
                HelperMethods.InitKrakenBuf(base.owner, 1);
            }
        }

        public class DiceCardSelfAbility_kraken_lose1EaF : DiceCardSelfAbilityBase
        {
            public override string[] Keywords => new string[] { "Kraken_Charge_Keyword" };
            public override void OnUseCard()
            {
                HelperMethods.InitKrakenBuf(base.owner, -1);
            }
        }
        #endregion

        #region Status Effects
        public class BattleUnitBuf_kraken_EaF : BattleUnitBuf
        {
            private const int maxStack = 20;
            private const int minStack = -20;
            protected override string keywordId => "Kraken_Charge";
            public override void Init(BattleUnitModel owner)
            {
                base.Init(owner);
                stack = 0;
                if (_owner != null && !_owner.passiveDetail.HasPassive<PassiveAbility_KrakenCharge>())
                {
                    Destroy();
                }
            }
            public override void OnWinParrying(BattleDiceBehavior behavior)
            {
                base.OnWinParrying(behavior);
                OnAddBuf(1);
            }
            public override void OnLoseParrying(BattleDiceBehavior behavior)
            {
                base.OnLoseParrying(behavior);
                OnAddBuf(-1);
            }
            public override void OnKill(BattleUnitModel target)
            {
                base.OnKill(target);
                OnAddBuf(1);
            }
            public override void OnDieOtherUnit(BattleUnitModel unit)
            {
                base.OnDieOtherUnit(unit);
                if (unit.faction == _owner.faction)
                {
                    OnAddBuf(-1);
                } else
                {
                    OnAddBuf(1);
                }
            }
            public override void OnAddBuf(int addedStack)
            {
                if (_owner != null && !_owner.passiveDetail.HasPassive<PassiveAbility_KrakenCharge>())
                {
                    Destroy();
                }
                stack += addedStack;
                if (stack > maxStack)
                {
                    stack = maxStack;
                }
                if (stack < minStack)
                {
                    stack = minStack;
                }
                if (_owner.IsImmune(bufType))
                {
                    stack = 0;
                    Destroy();
                }
            }
            public override void OnRoundEnd()
            {   
                if (_owner.IsImmune(bufType))
                {
                    Destroy();
                }
            }
            public bool UseStack(int cost)
            {
                if (stack + cost > maxStack || stack + cost < minStack)
                {
                    return false;
                }
                stack += cost;
                return true;
            }
        }
        #endregion

        #region Passives
        public class PassiveAbility_KrakenCharge : PassiveAbilityBase
        {
            public override void OnWaveStart()
            {
                base.OnWaveStart();
                HelperMethods.InitKrakenBuf(base.owner, 0);
            }
        }

        #endregion
    }
}
Leave a Comment