Ejemplo n.º 1
0
    public void PhysicalDamage_DamageUnarmoredTarget_ApplyEffect()
    {
        var attacker = TestMembers.With(StatType.Attack, 2);
        var target   = TestMembers.Create(s => s.With(StatType.MaxHP, 10).With(StatType.Damagability, 1f));

        new Damage(new PhysicalDamage(1)).Apply(attacker, new MemberAsTarget(target));

        Assert.AreEqual(8, target.State[TemporalStatType.HP]);
    }
Ejemplo n.º 2
0
    public void ArmorFlat_ApplyEffect_ArmorIsChangedCorrectly()
    {
        var addArmorEffect = ChangeArmorBy(1);
        var target         = TestMembers.With(StatType.Armor, 5);

        AllEffects.Apply(addArmorEffect, TestMembers.Any(), new Single(target));

        Assert.AreEqual(6, target.State.Armor());
    }
Ejemplo n.º 3
0
    public void ShieldOnAttacked_ApplyEffect_TargetIsNotShieldedIfNoAttacked()
    {
        Member paladin  = TestMembers.With(StatType.Toughness, 5);
        Member ally     = TestMembers.With(StatType.Toughness, 10);
        Member attacker = TestMembers.Any();

        AllEffects.Apply(ChangeShieldOnAttackBy(1), paladin, new Single(ally));
        new Attack(0).Apply(attacker, paladin);

        Assert.AreEqual(0, ally.State[TemporalStatType.Shield]);
    }
Ejemplo n.º 4
0
    public void ShieldToughness_ApplyEffect()
    {
        var shieldTarget = new EffectData {
            EffectType = EffectType.ShieldToughness, FloatAmount = new FloatReference(1)
        };
        var performer = TestMembers.With(StatType.Toughness, 5);
        var target    = TestMembers.With(StatType.Toughness, 10);

        AllEffects.Apply(shieldTarget, performer, new Single(target));
        Assert.AreEqual(5, target.State[TemporalStatType.Shield]);
    }
Ejemplo n.º 5
0
    public void Evade_ApplyEffect_AttackIsEvaded()
    {
        Member evader   = TestMembers.Create(s => s.With(StatType.MaxHP, 10).With(StatType.Damagability, 1f));
        Member attacker = TestMembers.With(StatType.Attack, 1);

        new Evade().Apply(evader, new MemberAsTarget(evader));

        new Attack(5).Apply(attacker, evader);

        Assert.AreEqual(
            10,
            evader.State[TemporalStatType.HP],
            "Target did not evaded attack"
            );
    }
Ejemplo n.º 6
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.º 7
0
    public void Regeneration_ApplyEffect_RegenerateFlatForTurns()
    {
        Member attacker = TestMembers.With(StatType.Attack, 1);
        Member caster   = TestMembers.Any();
        Member target   = TestMembers.Create(s => s.With(StatType.MaxHP, 10).With(StatType.Damagability, 1f));

        //creating damage
        new Attack(5).Apply(attacker, new Single(target));

        Debug.Log("Target has " + target.State[TemporalStatType.HP] + "HP");

        new HealFlatForTurnsOnTurnStart(1, 3).Apply(caster, new Single(target));

        BattleEvent.Publish(new TurnEnd());
        BattleEvent.Publish(new TurnStart());
        Assert.AreEqual(
            6,
            target.State[TemporalStatType.HP],
            "Effect did not applied on turn 1."
            );

        BattleEvent.Publish(new TurnEnd());
        BattleEvent.Publish(new TurnStart());
        Assert.AreEqual(
            7,
            target.State[TemporalStatType.HP],
            "Effect did not applied on turn 2."
            );

        BattleEvent.Publish(new TurnEnd());
        BattleEvent.Publish(new TurnStart());
        Assert.AreEqual(
            8,
            target.State[TemporalStatType.HP],
            "Effect did not applied on turn 3."
            );

        BattleEvent.Publish(new TurnEnd());
        BattleEvent.Publish(new TurnStart());
        Assert.AreEqual(
            8,
            target.State[TemporalStatType.HP],
            "Effect applied on turn 4."
            );
    }
Ejemplo n.º 8
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.º 9
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.º 10
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."
            );
    }
    public void Regeneration_ApplyEffect_RegenerateFlatForTurns()
    {
        var attacker = TestMembers.With(StatType.Attack, 1);
        var caster   = TestMembers.Any();
        var target   = TestMembers.Create(s => s.With(StatType.MaxHP, 10).With(StatType.Damagability, 1f));

        new Attack(5).Apply(attacker, new Single(target));

        new HealOverTime(1, 3).Apply(caster, new Single(target));

        target.State.OnTurnStart();
        target.State.OnTurnEnd();
        Assert.AreEqual(
            6,
            target.State[TemporalStatType.HP],
            "Effect did not applied on turn 1."
            );

        target.State.OnTurnStart();
        target.State.OnTurnEnd();
        Assert.AreEqual(
            7,
            target.State[TemporalStatType.HP],
            "Effect did not applied on turn 2."
            );

        target.State.OnTurnStart();
        target.State.OnTurnEnd();
        Assert.AreEqual(
            8,
            target.State[TemporalStatType.HP],
            "Effect did not applied on turn 3."
            );

        target.State.OnTurnStart();
        target.State.OnTurnEnd();
        Assert.AreEqual(
            8,
            target.State[TemporalStatType.HP],
            "Effect applied on turn 4."
            );
    }
    public void InterceptAttack_ApplyEffect_AttackIsIntercepted()
    {
        Member paladin  = TestMembers.Create(s => s.With(StatType.MaxHP, 10).With(StatType.Damagability, 1f));
        Member ally     = TestMembers.With(StatType.MaxHP, 10);
        Member attacker = TestMembers.With(StatType.Attack, 1);

        new InterceptAttack(1).Apply(paladin, new Single(ally));
        new Attack(5).Apply(attacker, new Single(ally));

        Assert.AreEqual(
            5,
            paladin.State[TemporalStatType.HP],
            "Interceptor didn't received the interception damage"
            );

        Assert.AreEqual(
            10,
            ally.State[TemporalStatType.HP],
            "Attack damaged ally"
            );
    }