コード例 #1
0
ファイル: FightData.cs プロジェクト: snakeddp/cookiebot
        private void HandleGameActionFightDispellableEffectMessage(IAccount account,
                                                                   GameActionFightDispellableEffectMessage message)
        {
            if (message.Effect is FightTemporaryBoostStateEffect ftbse)
            {
                if (ftbse.TargetId != Fighter.Id)
                {
                    return;
                }
                if (DurationByEffect.ContainsKey(ftbse.StateId))
                {
                    DurationByEffect.Remove(ftbse.StateId);
                }

                DurationByEffect.Add(ftbse.StateId, ftbse.TurnDuration);
            }
            else if (message.Effect is FightTemporaryBoostEffect ftbe)
            {
                switch (message.ActionId)
                {
                case 168:
                    ((Fighter)Fighter).ActionPoints = (short)(Fighter.ActionPoints - ftbe.Delta);
                    break;

                case 169:
                    ((Fighter)Fighter).MovementPoints = (short)(Fighter.MovementPoints - ftbe.Delta);
                    break;
                }
            }
        }
コード例 #2
0
ファイル: FightData.cs プロジェクト: snakeddp/cookiebot
        protected SpellInabilityReason CanLaunchSpell(int spellId)
        {
            short spellLevel;

            try
            {
                spellLevel = Account.Character.Spells.First(s => s.SpellId == spellId).SpellLevel;
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return(SpellInabilityReason.UnknownSpell);
            }

            var spell           = ObjectDataManager.Instance.Get <API.Datacenter.Spell>(spellId);
            var id              = Convert.ToInt32(spell.SpellLevels[spellLevel - 1]);
            var spellLevelsData = ObjectDataManager.Instance.Get <SpellLevel>(id);

            if (spellLevelsData == null)
            {
                return(SpellInabilityReason.Unknown);
            }
            if (spellId != 0 && Fighter.ActionPoints < spellLevelsData.ApCost)
            {
                return(SpellInabilityReason.ActionPoints);
            }
            if (TotalLaunchBySpell.ContainsKey(spellId) &&
                TotalLaunchBySpell[spellId] >= spellLevelsData.MaxCastPerTurn && spellLevelsData.MaxCastPerTurn > 0)
            {
                return(SpellInabilityReason.TooManyLaunch);
            }
            lock (CheckLock)
            {
                if (LastTurnLaunchBySpell.ContainsKey(spellId))
                {
                    return(SpellInabilityReason.Cooldown);
                }
            }
            var listEffects = spellLevelsData.Effects;

            if (listEffects != null && listEffects.Count > 0 && listEffects[0].EffectId == 181)
            {
                var stats = Account.Character.Stats;
                var total = stats.SummonableCreaturesBoost.Base + stats.SummonableCreaturesBoost.ObjectsAndMountBonus +
                            stats.SummonableCreaturesBoost.AlignGiftBonus + stats.SummonableCreaturesBoost.ContextModif;
                if (GetInvokationNumber() >= total)
                {
                    return(SpellInabilityReason.TooManyInvocations);
                }
            }
            lock (CheckLock)
            {
                var listOfStates = spellLevelsData.StatesRequired;
                if (listOfStates.Any(state => !DurationByEffect.ContainsKey(state)))
                {
                    return(SpellInabilityReason.RequiredState);
                }
                listOfStates = spellLevelsData.StatesForbidden;
                if (listOfStates.Any(state => DurationByEffect.ContainsKey(state)))
                {
                    return(SpellInabilityReason.ForbiddenState);
                }
            }
            return(SpellInabilityReason.None);
        }