Ejemplo n.º 1
0
    public void Effects_CanCreateAll()
    {
        var types = Enum.GetValues(typeof(EffectType)).Cast <EffectType>().Select(t => new EffectData {
            EffectType = t
        });

        foreach (var effectData in types)
        {
            Assert.IsNotNull(AllEffects.Create(effectData), $"Could not create Effect of Type {effectData.EffectType.ToString()}");
        }
    }
Ejemplo n.º 2
0
    public void OnNextTurnEffect_ApplyEffect_DoesNotApplyInCurrentTurn()
    {
        OnNextTurnEffect timedDamage = new OnNextTurnEffect(
            AllEffects.Create(DamageTarget(1))
            );

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

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

        Assert.AreEqual(
            10,
            target.State[TemporalStatType.HP],
            "Effect applied on current turn."
            );
    }
Ejemplo n.º 3
0
    public void OnNextTurnEffect_ApplyEffect_ApplyOnNextTurn()
    {
        OnNextTurnEffect timedDamage = new OnNextTurnEffect(
            AllEffects.Create(DamageTarget(1))
            );

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

        BattleEvent.Publish(new TurnEnd());
        timedDamage.Apply(attacker, new Single(target));

        Assert.AreEqual(
            9,
            target.State[TemporalStatType.HP],
            "Effect did not applied on next turn."
            );
    }
Ejemplo n.º 4
0
    public void Recurrent_ApplyEffect_ApplyCorrectTimes()
    {
        Effect oneTimer = new Recurrent(
            AllEffects.Create(DamageTarget(1))
            );

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

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

        Assert.AreEqual(
            9,
            target.State[TemporalStatType.HP],
            "Effect applied more than the repetition limit."
            );
    }
Ejemplo n.º 5
0
    public void ForNumberOfTurns_ApplyEffect_DoesNotApplyWhenInactive()
    {
        ForNumberOfTurns timedDamage = new ForNumberOfTurns(AllEffects.Create(DamageTarget(1)));

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

        BattleEvent.Publish(new TurnEnd());
        timedDamage.Apply(attacker, new Single(target));
        BattleEvent.Publish(new TurnEnd());
        timedDamage.Apply(attacker, new Single(target));

        Assert.AreEqual(
            9,
            target.State[TemporalStatType.HP],
            "Effect did applied when inactive."
            );
    }
Ejemplo n.º 6
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."
            );
    }
Ejemplo n.º 7
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."
            );
    }