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()); }
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); }
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()); }
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()); }
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()); }
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" ); }
public void ResourceFlat_ApplyEffect() { AllEffects.Apply(data, performer, new Single(performer)); Assert.AreEqual( 5, performer.State.ResourceTypes[0].MaxAmount ); }
public void ResourceFlat_ApplyEffect() { var performer = TestMembers.Create(s => s, Ammo); AllEffects.Apply(data, performer, new Single(performer)); Assert.AreEqual(5, performer.State[Ammo]); }
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()); }
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]); }
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]); }
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]); }
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]); }
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]); }
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()); }
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]); }
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]); }
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>()); }
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] ); }
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()); }
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]); }
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))); }
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]); }
public void Apply(Member source, Target target) => Effects.ForEach(effect => AllEffects.Apply(effect, source, target));