Exemplo n.º 1
0
        public void AddStatBuildsToCorrectResult(bool effectActive)
        {
            var expectedStat  = "stat";
            var expectedValue = effectActive ? (NodeValue?)2 : null;
            var statBuilder   = StatBuilderUtils.FromIdentity(new StatFactory(), expectedStat, typeof(double));
            var valueBuilder  = new ValueBuilderImpl(2);
            var activeStat    = new Stat("test.Active");
            var context       = Mock.Of <IValueCalculationContext>(c =>
                                                                   c.GetValue(activeStat, NodeType.Total, PathDefinition.MainPath) == (NodeValue?)effectActive);
            var sut = CreateSut();

            var addedStat = sut.AddStat(statBuilder);

            var(stats, _, valueConverter) = addedStat.BuildToSingleResult();
            var actualStat  = stats.Single().Identity;
            var actualValue = valueConverter(valueBuilder).Build().Calculate(context);

            Assert.AreEqual(expectedStat, actualStat);
            Assert.AreEqual(expectedValue, actualValue);
        }
        public void TemporaryBuildsToCorrectResult(bool expectedCondition)
        {
            var expectedValue     = expectedCondition ? (NodeValue?)3 : null;
            var gainedStatBuilder = StatBuilderUtils.FromIdentity(StatFactory, "s", null);
            var modifierSource    = new ModifierSource.Local.Skill("skill node", "");
            var conditionStat     = new Stat($"Is {modifierSource.SourceName} active?");
            var buffEffectStat    = new Stat($"Buff.EffectOn({default(Entity)})");
            var context           = Mock.Of <IValueCalculationContext>(c =>
                                                                       c.GetValue(conditionStat, NodeType.Total, PathDefinition.MainPath) == (NodeValue?)expectedCondition &&
                                                                       c.GetValue(buffEffectStat, NodeType.Total, PathDefinition.MainPath) == new NodeValue(1.5));
            var sut = CreateSut();

            var(stats, _, valueConverter) = sut.Temporary(gainedStatBuilder)
                                            .BuildToSingleResult(modifierSource);
            var actualValue = valueConverter(new ValueBuilderImpl(2)).Build().Calculate(context);

            Assert.That(stats, Has.One.Items);
            Assert.AreEqual("s", stats[0].Identity);
            Assert.AreEqual(expectedValue, actualValue);
        }
        public void AddStatBuildsToCorrectResultIfNotAsBuffActive()
        {
            var expectedStat   = "stat";
            var expectedValue  = (NodeValue?)2;
            var statBuilder    = StatBuilderUtils.FromIdentity(StatFactory, expectedStat, null);
            var valueBuilder   = new ValueBuilderImpl(2);
            var activeStat     = new Stat("test.Active");
            var buffActiveStat = new Stat("test.BuffActive");
            var context        = Mock.Of <IValueCalculationContext>(c =>
                                                                    c.GetValue(activeStat, NodeType.Total, PathDefinition.MainPath) == (NodeValue?)true &&
                                                                    c.GetValue(buffActiveStat, NodeType.Total, PathDefinition.MainPath) == (NodeValue?)false);
            var sut = CreateSut();

            var addStat = sut.AddStat(statBuilder);

            var(stats, _, valueConverter) = addStat.BuildToSingleResult();
            var actualStat  = stats.Single().Identity;
            var actualValue = valueConverter(valueBuilder).Build().Calculate(context);

            Assert.AreEqual(expectedStat, actualStat);
            Assert.AreEqual(expectedValue, actualValue);
        }
        public BuffBuilders(IStatFactory statFactory, SkillDefinitions skills)
        {
            _statFactory = statFactory;
            Fortify      = Create("Fortify");
            Maim         = Create("Maim");
            Hinder       = Create("Hinder");
            Intimidate   = Create("Intimidate");
            Taunt        = Create("Taunt");
            Blind        = Create("Blind");
            Onslaught    = Create("Onslaught");
            UnholyMight  = Create("UnholyMight");
            Phasing      = Create("Phasing");
            ArcaneSurge  = Create("ArcaneSurge");
            Tailwind     = Create("Tailwind");
            CoveredInAsh = Create("CoveredInAsh");
            Innervation  = Create("Innervation");
            Impale       = new ImpaleBuffBuilder(statFactory);
            Infusion     = Create("Infusion");
            Snare        = Create("Snare");
            Rampage      = Create("Rampage");
            Withered     = Create("Withered");
            Elusive      = Create("Elusive");
            Conflux      = new ConfluxBuffBuilders(statFactory);
            GenericMine  = Create("Mine");
            CurseLimit   = StatBuilderUtils.FromIdentity(statFactory, "CurseLimit", typeof(uint));

            var allBuffs = new List <BuffBuilderWithKeywords>
            {
                new BuffBuilderWithKeywords(Fortify),
                new BuffBuilderWithKeywords(Maim),
                new BuffBuilderWithKeywords(Hinder),
                new BuffBuilderWithKeywords(Intimidate),
                new BuffBuilderWithKeywords(Taunt),
                new BuffBuilderWithKeywords(Blind),
                new BuffBuilderWithKeywords(Onslaught),
                new BuffBuilderWithKeywords(UnholyMight),
                new BuffBuilderWithKeywords(Phasing),
                new BuffBuilderWithKeywords(ArcaneSurge),
                new BuffBuilderWithKeywords(Tailwind, Keyword.Aura),
                new BuffBuilderWithKeywords(CoveredInAsh),
                new BuffBuilderWithKeywords(Innervation),
                new BuffBuilderWithKeywords(Impale),
                new BuffBuilderWithKeywords(Infusion),
                new BuffBuilderWithKeywords(Snare),
                new BuffBuilderWithKeywords(Rampage),
                new BuffBuilderWithKeywords(Withered),
                new BuffBuilderWithKeywords(Elusive),
                new BuffBuilderWithKeywords(Conflux.Chilling),
                new BuffBuilderWithKeywords(Conflux.Elemental),
                new BuffBuilderWithKeywords(Conflux.Igniting),
                new BuffBuilderWithKeywords(Conflux.Shocking),
                // Generic buff effect increase (used for Buff())
                new BuffBuilderWithKeywords(Create("Buff")),
                // Aura effect increase (used for Aura())
                new BuffBuilderWithKeywords(Create("Aura"), Keyword.Aura),
                new BuffBuilderWithKeywords(GenericMine, Keyword.Aura, Keyword.Mine),
            };
            var skillBuffBuilders = skills.Skills
                                    .Where(s => !s.IsSupport && s.ActiveSkill.ProvidesBuff)
                                    .Select(s => new BuffBuilderWithKeywords(Create(s.Id), s.ActiveSkill.Keywords));

            allBuffs.AddRange(skillBuffBuilders);
            _allBuffs = allBuffs;
        }
Exemplo n.º 5
0
 private IValue CreateValue(BuildParameters ps, string identity) =>
 StatBuilderUtils.FromIdentity(_statFactory, identity, typeof(bool), ExplicitRegistrationTypes.UserSpecifiedValue(false))
 .Value.Build(ps);