コード例 #1
0
    public void OnEvaded_ApplyTwice_OnlyGeneratesOneReaction()
    {
        var target   = TestMembers.Create(s => s.With(StatType.MaxHP, 10));
        var attacker = TestMembers.Create(s => s.With(StatType.Attack, 1));

        target.State.AdjustEvade(1);

        var reactionCardType = TestCards.Reaction(
            ReactiveMember.Possessor,
            ReactiveTargetScope.Self,
            new EffectData {
            EffectType = EffectType.AdjustStatAdditively, FloatAmount = new FloatReference(1), EffectScope = new StringReference("Armor"), NumberOfTurns = new IntReference(-1)
        });

        AllEffects.Apply(new EffectData
        {
            EffectType       = EffectType.OnEvaded,
            NumberOfTurns    = new IntReference(3),
            ReactionSequence = reactionCardType
        }, new EffectContext(target, new Single(target)));

        ReactiveTestUtilities.ApplyEffectAndReactions(new EffectData
        {
            EffectType  = EffectType.Attack,
            FloatAmount = new FloatReference(1),
            EffectScope = new StringReference(ReactiveTargetScope.Self.ToString())
        }, attacker, target);

        Assert.AreEqual(10, target.State[TemporalStatType.HP]);
        Assert.AreEqual(1, target.State.Armor());
    }
コード例 #2
0
    public void OnAttacked_ApplyTwice_OnlyGeneratesOneReaction()
    {
        var target = TestMembers.Any();

        var reactionCardType = TestCards.Reaction(
            ReactiveMember.Originator,
            ReactiveTargetScope.Attacker,
            new EffectData {
            EffectType = EffectType.Attack, FloatAmount = new FloatReference(1)
        });

        AllEffects.Apply(new EffectData
        {
            EffectType       = EffectType.OnAttacked,
            NumberOfTurns    = new IntReference(3),
            ReactionSequence = reactionCardType
        }, target, target);

        AllEffects.Apply(new EffectData
        {
            EffectType       = EffectType.OnAttacked,
            NumberOfTurns    = new IntReference(3),
            ReactionSequence = reactionCardType
        }, target, target);

        Assert.AreEqual(1, target.State.ReactiveStates.Length);
    }
コード例 #3
0
    public void OnShieldBroken_Attacked_TriggersCorrectly(int startingShields, bool triggered)
    {
        var target   = TestMembers.Create(x => x.With(StatType.MaxHP, 10).With(StatType.Toughness, 1));
        var attacker = TestMembers.Create(s => s.With(StatType.Attack, 1));

        target.State.GainShield(startingShields);

        var reactionCardType = TestCards.Reaction(
            ReactiveMember.Possessor,
            ReactiveTargetScope.Self,
            new EffectData {
            EffectType = EffectType.AdjustStatAdditively, FloatAmount = new FloatReference(1), EffectScope = new StringReference("Armor"), NumberOfTurns = new IntReference(-1)
        });

        AllEffects.Apply(new EffectData
        {
            EffectType       = EffectType.OnShieldBroken,
            NumberOfTurns    = new IntReference(3),
            ReactionSequence = reactionCardType
        }, target, target);

        ReactiveTestUtilities.ApplyEffectAndReactions(new EffectData
        {
            EffectType  = EffectType.Attack,
            FloatAmount = new FloatReference(1),
            EffectScope = new StringReference(ReactiveTargetScope.Self.ToString())
        }, attacker, target);

        Assert.AreEqual(triggered ? 1 : 0, target.State.Armor());
    }
コード例 #4
0
    public void ReactiveTrigger_OnAttacked_GainedOneArmor()
    {
        var target   = TestMembers.Create(s => s.With(StatType.MaxHP, 10));
        var attacker = TestMembers.Create(s => s.With(StatType.Attack, 1));

        var reactionCardType = TestCards.Reaction(
            ReactiveMember.Possessor,
            ReactiveTargetScope.Self,
            new EffectData {
            EffectType = EffectType.AdjustStatAdditively, FloatAmount = new FloatReference(1), EffectScope = new StringReference("Armor"), NumberOfTurns = new IntReference(-1)
        });

        AllEffects.Apply(new EffectData
        {
            EffectType       = EffectType.OnAttacked,
            NumberOfTurns    = new IntReference(3),
            ReactionSequence = reactionCardType
        }, target, target);

        ReactiveTestUtilities.ApplyEffectAndReactions(new EffectData
        {
            EffectType  = EffectType.Attack,
            FloatAmount = new FloatReference(1),
            EffectScope = new StringReference(ReactiveTargetScope.Self.ToString())
        }, attacker, target);

        Assert.AreEqual(1, target.State.Armor());
    }
コード例 #5
0
    public void ReactiveTrigger_OnAttacked_AttackerHitForOneDamage()
    {
        var target   = TestMembers.Create(s => s.With(StatType.MaxHP, 10).With(StatType.Attack, 1));
        var attacker = TestMembers.Create(s => s.With(StatType.MaxHP, 10).With(StatType.Attack, 1));

        var reactionCardType = TestCards.Reaction(
            ReactiveMember.Originator,
            ReactiveTargetScope.Attacker,
            new EffectData {
            EffectType = EffectType.Attack, FloatAmount = new FloatReference(1)
        });

        AllEffects.Apply(new EffectData
        {
            EffectType       = EffectType.OnAttacked,
            NumberOfTurns    = new IntReference(3),
            ReactionSequence = reactionCardType
        }, target, target);

        ReactiveTestUtilities.ApplyEffectAndReactions(new EffectData
        {
            EffectType  = EffectType.Attack,
            FloatAmount = new FloatReference(1),
            EffectScope = new StringReference(ReactiveTargetScope.Self.ToString())
        }, attacker, target);

        Assert.AreEqual(9, attacker.CurrentHp());
    }
コード例 #6
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"
            );
    }
コード例 #7
0
    public void SpellFlatDamageEffect_DamageTargetWithResistance_DamageIsAppliedCorrectly()
    {
        var target = TestMembers.Create(s => s.With(StatType.MaxHP, 10).With(StatType.Resistance, 1));

        new SpellFlatDamageEffect(2).Apply(TestMembers.Any(), target);

        Assert.AreEqual(9, target.CurrentHp());
    }
コード例 #8
0
    public void HealFlat_ApplyEffect_DoesNotPassFullHealth()
    {
        Member target = TestMembers.Create(s => s.With(StatType.MaxHP, 10).With(StatType.Damagability, 1f));

        new Heal(5).Apply(TestMembers.Any(), new Single(target));

        Assert.AreEqual(10, target.State[TemporalStatType.HP]);
    }
コード例 #9
0
    public void PhysicalDamage_DamageArmoredTarget_ApplyEffect()
    {
        var target = TestMembers.Create(s => s.With(StatType.MaxHP, 10).With(StatType.Armor, 1));

        new Damage(new PhysicalDamage(1)).Apply(_attacker, new Single(target));

        Assert.AreEqual(9, target.State[TemporalStatType.HP]);
    }
コード例 #10
0
    public void ResourceFlat_ApplyEffect()
    {
        var performer = TestMembers.Create(s => s, Ammo);

        AllEffects.Apply(data, performer, new Single(performer));

        Assert.AreEqual(5, performer.State[Ammo]);
    }
コード例 #11
0
    public void SpellFlatDamageEffect_DamageTargetWithNoResistance_DamageIsAppliedCorrectly()
    {
        Member attacker = TestMembers.Any();
        Member target   = TestMembers.Create(s => s.With(StatType.MaxHP, 10).With(StatType.Damagability, 1f));

        new SpellFlatDamageEffect(1).Apply(attacker, target);

        Assert.AreEqual(9, target.State[TemporalStatType.HP]);
    }
コード例 #12
0
    public void Attack_ApplyEffect_AttackIsAppliedCorrectly()
    {
        var attacker = TestMembers.Create(s => s.With(StatType.Attack, 1f));
        var target   = TestMembers.Create(s => s.With(StatType.MaxHP, 10));

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

        Assert.AreEqual(9, target.State[TemporalStatType.HP]);
    }
コード例 #13
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]);
    }
コード例 #14
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());
    }
コード例 #15
0
    public void HealFlat_OnUnconsciousMember_ShouldDoNothing()
    {
        var target = TestMembers.Any();

        target.State.TakeRawDamage(99);

        new Heal(5).Apply(TestMembers.Any(), target);

        Assert.IsFalse(target.IsConscious());
    }
コード例 #16
0
    public void HealFlat_Take6DamageAndThenHeal5_HpIsCorrect()
    {
        Member target = TestMembers.Create(s => s.With(StatType.MaxHP, 10).With(StatType.Damagability, 1f));

        target.State.TakeRawDamage(6);

        new Heal(5).Apply(TestMembers.Any(), new Single(target));

        Assert.AreEqual(9, target.State[TemporalStatType.HP]);
    }
コード例 #17
0
    public void Attack_ApplyEffect_AttackIsAppliedCorrectly()
    {
        Member attacker = TestMembers.Create(
            s => s.With(StatType.Attack, 1f).With(StatType.MaxHP, 10).With(StatType.Damagability, 1f)
            );
        Member target = TestMembers.Create(s => s.With(StatType.MaxHP, 10).With(StatType.Damagability, 1f));

        new Attack(1).Apply(attacker, target);

        Assert.AreEqual(9, target.State[TemporalStatType.HP]);
    }
コード例 #18
0
    public void TurnStun_StunFor5Turns_IsStunnedFor5Turns()
    {
        var stunForTurns = new EffectData {
            EffectType = EffectType.StunForTurns, NumberOfTurns = new IntReference(5)
        };
        var target = TestMembers.Any();

        AllEffects.Apply(stunForTurns, TestMembers.Any(), target);

        Assert.AreEqual(5, target.State[TemporalStatType.TurnStun]);
    }
コード例 #19
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]);
    }
コード例 #20
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]);
    }
コード例 #21
0
    public void AdjustStatAdditively_ApplyEffect_CharactersStatsAdjusted()
    {
        var adjustment = new EffectData {
            EffectType = EffectType.AdjustStatAdditively, EffectScope = new StringReference("Attack"), FloatAmount = new FloatReference(1), NumberOfTurns = new IntReference(0)
        };
        var target = TestMembers.Create(s => s.With(StatType.Attack, 10));

        AllEffects.Apply(adjustment, TestMembers.Any(), target);

        Assert.AreEqual(11, target.State[StatType.Attack]);
    }
コード例 #22
0
    public void DamageOnAttacker_ApplyEffect_AttackerIsNotDamagedOnAttackingOther()
    {
        Member paladin  = TestMembers.Create(s => s.With(StatType.Attack, 1f));
        Member ally     = TestMembers.Any();
        Member attacker = TestMembers.Create(s => s.With(StatType.MaxHP, 10).With(StatType.Damagability, 1f));

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

        Assert.AreEqual(10, attacker.State[TemporalStatType.HP]);
    }
コード例 #23
0
    public void VulnerableMember_IsAttacked_TakesCorrectDamage()
    {
        var attacker = TestMembers.Create(s => s.With(StatType.Attack, 10));
        var target   = TestMembers.Create(s => s.With(StatType.MaxHP, 30));

        AllEffects.Apply(Vulnerable(), attacker, target);

        new Attack(1).Apply(attacker, target);

        Assert.AreEqual(1.33f, target.State[StatType.Damagability]);
        Assert.AreEqual(16, target.CurrentHp());
    }
コード例 #24
0
    public void Stun_AdvanceTurn_RemovesOneStunCounter()
    {
        var stunForTurns = new EffectData {
            EffectType = EffectType.StunForTurns, NumberOfTurns = new IntReference(5)
        };
        var target = TestMembers.Any();

        AllEffects.Apply(stunForTurns, TestMembers.Any(), target);
        target.State.OnTurnEnd();

        Assert.AreEqual(4, target.State[TemporalStatType.TurnStun]);
    }
コード例 #25
0
    public void PhysicalDamage_DamageMultipleEnemies_ApplyEffect()
    {
        var target = new[]
        {
            TestMembers.Create(s => s.With(StatType.MaxHP, 10)),
            TestMembers.Create(s => s.With(StatType.MaxHP, 10))
        };

        new Damage(new PhysicalDamage(1)).Apply(_attacker, new Multiple(target));

        Assert.AreEqual(8, target[0].State[TemporalStatType.HP]);
        Assert.AreEqual(8, target[1].State[TemporalStatType.HP]);
    }
コード例 #26
0
    public void RemoveDebuffs_ApplyEffect_RemovesAdditiveEffect()
    {
        var removeDebuffs = new EffectData {
            EffectType = EffectType.RemoveDebuffs
        };
        var target = TestMembers.Create(s => s.With(StatType.Attack, 10));

        target.State.ApplyTemporaryAdditive(new AdjustedStats(new StatAddends().With(StatType.Attack, -5), 5, true, false, StatusTag.None));

        AllEffects.Apply(removeDebuffs, TestMembers.Any(), target);

        Assert.AreEqual(10, target.State[StatType.Attack]);
    }
コード例 #27
0
    public void RemoveDebuffs_ApplyEffect_DoesNotRemoveBuff()
    {
        var removeDebuffs = new EffectData {
            EffectType = EffectType.RemoveDebuffs
        };
        var target = TestMembers.Create(s => s);

        target.State.AddReactiveState(new ReactOnAttacked(false, 2, 2, ReactiveTriggerScope.All, new Dictionary <int, Member>(), 1, target, TestCards.AnyReaction()));

        AllEffects.Apply(removeDebuffs, TestMembers.Any(), target);

        Assert.True(target.State.HasStatus(StatusTag.CounterAttack));
    }
コード例 #28
0
    public void Stun_ApplyEffect()
    {
        var stunFor5 = new EffectData {
            EffectType = EffectType.Stun, NumberOfTurns = new IntReference(5)
        };
        var target = TestMembers.Any();

        AllEffects.Apply(stunFor5, target, new Single(target));
        Assert.AreEqual(
            5,
            target.State[TemporalStatType.Stun]
            );
    }
コード例 #29
0
    public void ExcludeSelfFromEffect_ApplyEffect_ExcludeSelfAndApplyAlly()
    {
        var caster = TestMembers.Create(s => s.With(StatType.MaxHP, 10).With(StatType.Damagability, 1f));
        var ally   = TestMembers.Create(s => s.With(StatType.MaxHP, 10).With(StatType.Damagability, 1f));

        caster.State.TakeRawDamage(1);
        ally.State.TakeRawDamage(1);

        new ExcludeSelfFromEffect(new Heal(5)).Apply(caster, new Multiple(new[] { caster, ally }));

        Assert.AreEqual(9, caster.State[TemporalStatType.HP], "Applied effect to self");
        Assert.AreEqual(10, ally.State[TemporalStatType.HP], "Did not applied effect to ally");
    }
コード例 #30
0
    public void With0Armor_ReduceArmor_ArmorIs0()
    {
        var member   = TestMembers.Create(s => s.With(StatType.MaxHP, 10));
        var attacker = TestMembers.Create(s => s.With(StatType.Attack, 5));

        AllEffects.Apply(new EffectData
        {
            EffectType  = EffectType.AdjustStatAdditively,
            EffectScope = new StringReference(StatType.Armor.ToString()),
            FloatAmount = new FloatReference(-1)
        }, attacker, member);

        Assert.AreEqual(0, member.Armor());
    }