Beispiel #1
0
        public void RefreshProperties()
        {
            RefreshAttributes();
            RefreshResources();
            RefreshStats();

            ResolvedReviveDuration = Sanitizer.ReplacePropeties(ReviveDuration, this).Resolve().Value.ToLong();
        }
Beispiel #2
0
        public string ToShortString(Entity parent)
        {
            long   cooldownValue = (CooldownFinishTime - parent.Engine.GetTimer().GetNow()) / 1000;
            long   cooldown      = cooldownValue < 0 ? 0 : cooldownValue;
            long   cost          = Sanitizer.ReplacePropeties(Values().Cost.Amount, parent).Resolve().Value.ToLong();
            string costString    = cost == 0 ? "" : $"[Cost: {Utility.TruncateAndAlign($"{cost} {Values().Cost.Resource.Name}",10),10}]";
            string result        = $"{Utils.Utility.TruncateAndAlign(Skill.Name,25),-27} [{Utils.Utility.TruncateAndAlign($"{Skill.Key}",10),-15}][CD: {Utility.FormatSeconds(cooldown),12}]{costString}";

            return(result);
        }
Beispiel #3
0
        public void SanitizerTestReplacePropetyOperators()
        {
            string expected      = "AGI";
            string expression    = $"1 + {expected}";
            double expectedValue = MockPlayer.GetProperty(expected).Value + 1;

            MeNode result = Sanitizer.ReplacePropeties(TreeConverter.Build(expression, Engine), MockPlayer);

            Assert.AreEqual(LConstants.PROP_OP, result.Leaves[1].Value.GetString());
            Assert.AreEqual(expected, result.Leaves[1].Leaves[1].Value.ToMeString());

            MeNode resolved = result.Resolve();

            Assert.AreEqual(expectedValue, resolved.Value.ToDouble());
        }
Beispiel #4
0
 public double ResolveValue(Entity parent)
 {
     return(Sanitizer.ReplacePropeties(Formula, parent).Resolve().Value.ToDouble());
 }
Beispiel #5
0
        public override bool Cast(Entity target, string skillKey, bool autocast = false)
        {
            string tryAlias = Engine.GetSkillManager().GetKeyFromAlias(skillKey);

            if (tryAlias == null)
            {
                tryAlias = skillKey;
            }

            SkillInstance skill = Skills.ContainsKey(tryAlias) ? Skills[tryAlias] : null;

            if (skill == null)
            {
                Engine.Log().Log($"[{Name}] You don't have that skill({tryAlias}).");
                //log that you don't have that skill
                return(false);
            }
            if (skill.CooldownFinishTime != 0)
            {
                long seconds = (skill.CooldownFinishTime - Engine.GetTimer().GetNow()) / GameConstants.TickTime;
                Engine.Log().Log($"[{Name}] {skill.Skill.Name} is on cooldown for {seconds} s.");
                return(false);
            }

            if (!Free)
            {
                Engine.Log().Log($"[{Name}] You are busy.");
                return(false);
            }

            if (!ResourceMap.ContainsKey(skill.Values().Cost.Resource.Key))
            {
                Engine.Log().Log($"[{Name}] You don't have \"{skill.Values().Cost.Resource.Name}\".");
                return(false);
            }
            ResourceInstance res    = ResourceMap[skill.Values().Cost.Resource.Key];
            double           amount = Sanitizer.ReplacePropeties(skill.Values().Cost.Amount, this).Resolve().Value.ToDouble();

            if (!res.CanCast(amount))
            {
                Engine.Log().Log($"[{Name}] Not enough {skill.Values().Cost.Resource.Name} for {skill.Skill.Name}.");
                return(false);
            }

            res.Cast(amount);

            Free = false;

            CurrentlyCasting = new SkillCastData(skill, target, this, Engine.GetTimer().GetNow());
            long time = CurrentlyCasting.CastFinishTime - Engine.GetTimer().GetNow();

            if (time >= GameConstants.TickTime * 3)
            {
                string type         = skill.Skill.Type == SkillType.Cast ? "casting" : "channeling";
                string castedFinish = Key.Equals(CurrentlyCasting.Target.Key)
                    ? ""
                    : $" on  {CurrentlyCasting.Target.Name}";
                Engine.Log()
                .Log(
                    $"[{Name}] Started {type} {CurrentlyCasting.Skill.Skill.Name}{castedFinish}.");
            }
            return(true);
        }
Beispiel #6
0
        public double ResolveModifier(Entity target)
        {
            MeNode entityNode = Sanitizer.ReplacePropeties(StartMod, target);

            return(entityNode.Resolve().Value.ToDouble());
        }
Beispiel #7
0
        public long ResolveInterval(Entity target)
        {
            MeNode entityNode = Sanitizer.ReplacePropeties(RegenInterval, target);

            return(entityNode.Resolve().Value.ToLong());
        }
Beispiel #8
0
        public double ResolveMaxAmount(Entity target)
        {
            MeNode entityNode = Sanitizer.ReplacePropeties(Formula, target);

            return(entityNode.Resolve().Value.ToDouble());
        }