예제 #1
0
    public void HealPrimaryResourceTests_ApplyEffect()
    {
        EffectData healPrimary = new EffectData {
            EffectType = EffectType.HealPrimaryResource
        };
        Member performer = TestMembers.Create(
            s =>
        {
            StatAddends addend   = new StatAddends();
            addend.ResourceTypes = addend.ResourceTypes.Concat(
                new InMemoryResourceType
            {
                Name           = "Resource",
                StartingAmount = 0,
                MaxAmount      = 2
            }
                ).ToArray();
            addend.With(StatType.MaxHP, 10).With(StatType.Damagability, 1f);
            return(addend);
        }
            );

        performer.State.TakeRawDamage(6);
        performer.State.GainPrimaryResource(2);

        AllEffects.Apply(healPrimary, performer, new Single(performer));
        Assert.AreEqual(
            6,
            performer.State[TemporalStatType.HP],
            "Did not healed primary resource quantity"
            );
    }
예제 #2
0
    public IStats AdditiveStats()
    {
        var stats = new StatAddends();

        modifiers.Where(x => x.ModifierType == StatMathOperator.Additive)
        .ForEach(m => stats.WithRaw(m.StatType, m.Amount));
        return(stats);
    }
예제 #3
0
    public void CostPrimaryResourcesEffect_ApplyEffect_ApplyWhenHaveResource()
    {
        Effect oneTimer = new CostPrimaryResourceEffect(
            AllEffects.Create(DamageTarget(1)),
            1
            );
        Member attacker = TestMembers.Create(
            s => {
            StatAddends addend   = new StatAddends();
            addend.ResourceTypes = addend.ResourceTypes.Concat(
                new InMemoryResourceType
            {
                Name           = "Resource",
                StartingAmount = 0,
                MaxAmount      = 1
            }
                ).ToArray();
            addend.With(StatType.Attack, 1);
            return(addend);
        }
            );

        attacker.State.GainPrimaryResource(1);
        Member target = TestMembers.Create(s => s.With(StatType.MaxHP, 10).With(StatType.Damagability, 1f));

        oneTimer.Apply(attacker, new Single(target));

        Assert.AreEqual(
            9,
            target.State[TemporalStatType.HP],
            "Effect not applied."
            );

        oneTimer.Apply(attacker, new Single(target));
        Assert.AreEqual(
            9,
            target.State[TemporalStatType.HP],
            "Effect applied when not having resources."
            );
    }
예제 #4
0
    public void RepeatUntilPrimaryResourceDepleted_ApplyEffect_ApplyWhileHaveResource()
    {
        Effect twoTimer = new RepeatUntilPrimaryResourceDepleted(
            new CostPrimaryResourceEffect(
                AllEffects.Create(DamageTarget(1)),
                1
                ),
            1
            );
        Member attacker = TestMembers.Create(
            s => {
            StatAddends addend   = new StatAddends();
            addend.ResourceTypes = addend.ResourceTypes.Concat(
                new InMemoryResourceType
            {
                Name           = "Resource",
                StartingAmount = 0,
                MaxAmount      = 2
            }
                ).ToArray();
            addend.With(StatType.Attack, 1);
            return(addend);
        }
            );

        attacker.State.GainPrimaryResource(2);
        Member target = TestMembers.Create(s => s.With(StatType.MaxHP, 10).With(StatType.Damagability, 1f));

        Debug.Log("Let's go");

        twoTimer.Apply(attacker, new Single(target));

        Debug.Log("Done!");

        Assert.AreEqual(
            8,
            target.State[TemporalStatType.HP],
            "Effect not applied correct number of times."
            );
    }