Exemplo n.º 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());
    }
Exemplo n.º 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);
    }
Exemplo n.º 3
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());
    }
Exemplo n.º 4
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());
    }
Exemplo n.º 5
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());
    }
Exemplo n.º 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"
            );
    }
Exemplo n.º 7
0
 public void ResourceFlat_ApplyEffect()
 {
     AllEffects.Apply(data, performer, new Single(performer));
     Assert.AreEqual(
         5,
         performer.State.ResourceTypes[0].MaxAmount
         );
 }
Exemplo n.º 8
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]);
    }
Exemplo n.º 9
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());
    }
Exemplo n.º 10
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]);
    }
Exemplo n.º 11
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]);
    }
Exemplo n.º 12
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]);
    }
Exemplo n.º 13
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]);
    }
Exemplo n.º 14
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]);
    }
Exemplo n.º 15
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());
    }
Exemplo n.º 16
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]);
    }
Exemplo n.º 17
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]);
    }
Exemplo n.º 18
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));
    }
    protected override void Execute(ApplyBattleEffect msg)
    {
        var battleSnapshotBefore = state.GetSnapshot();

        AllEffects.Apply(msg.Effect, new EffectContext(msg.Source, msg.Target, state.PlayerState, state.Members));
        var battleSnapshotAfter = state.GetSnapshot();
        var effectResolved      = new EffectResolved(msg.Effect, msg.Source, msg.Target, battleSnapshotBefore, battleSnapshotAfter);

        var reactions = state.Members.Values.SelectMany(v => v.State.GetReactions(effectResolved));

        reactions.ForEach(r => _reactions.Enqueue(r));
        Message.Publish(new Finished <ApplyBattleEffect>());
    }
Exemplo n.º 20
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]
            );
    }
Exemplo n.º 21
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());
    }
Exemplo n.º 22
0
    public void Stun_CleanseDebuffs_IsRemoved()
    {
        var stunForTurns = new EffectData {
            EffectType = EffectType.StunForTurns, NumberOfTurns = new IntReference(5)
        };
        var target = TestMembers.Any();

        AllEffects.Apply(stunForTurns, TestMembers.Any(), target);
        AllEffects.Apply(new EffectData {
            EffectType = EffectType.RemoveDebuffs
        }, TestMembers.Any(), target);

        Assert.AreEqual(0, target.State[TemporalStatType.TurnStun]);
    }
Exemplo n.º 23
0
    public static void ApplyEffectAndReactions(EffectData e, Member source, Member target)
    {
        var battleSnapshotBefore = new BattleStateSnapshot(target.GetSnapshot());

        AllEffects.Apply(e, source, target);
        var battleSnapshotAfter = new BattleStateSnapshot(target.GetSnapshot());

        var effectResolved = new EffectResolved(e, source, new Single(target), battleSnapshotBefore, battleSnapshotAfter);

        var reactions = target.State.GetReactions(effectResolved);

        reactions.ForEach(r => r.Reaction.ActionSequence.CardActions.Actions.Where(a => a.Type == CardBattleActionType.Battle)
                          .ForEach(be => AllEffects.Apply(be.BattleEffect, r.Source, r.Target)));
    }
Exemplo n.º 24
0
    public void StealLifeOnAttack_ApplyEffect_LifeIsStolenCorrectly()
    {
        var caster   = TestMembers.Any();
        var attacker = TestMembers.Create(
            s => s.With(StatType.Attack, 1f).With(StatType.MaxHP, 10).With(StatType.Damagability, 1f)
            );
        var target = TestMembers.Create(s => s.With(StatType.MaxHP, 10).With(StatType.Damagability, 1f));

        attacker.State.TakeRawDamage(6);

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

        Assert.AreEqual(9, attacker.State[TemporalStatType.HP]);
    }
Exemplo n.º 25
0
 public void Apply(Member source, Target target)
 => Effects.ForEach(effect => AllEffects.Apply(effect, source, target));