static TransitionEffect GetEffect() { var retVal = AllEffects[Rand.Next(AllEffects.Count)](); var randEffect = retVal as RandomizedTransitionEffect; if (randEffect != null) { randEffect.RandomSeed = Rand.NextDouble(); } return(retVal); }
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 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 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()); }
#pragma warning disable IDE0051 // Remove unused private members private void Awake() { hub = ReferenceHub.GetHub(gameObject); AllEffects.Add(typeof(Scp207), new Scp207(hub)); AllEffects.Add(typeof(Scp268), new Scp268(hub)); AllEffects.Add(typeof(Corroding), new Corroding(hub)); AllEffects.Add(typeof(Visuals939), new Visuals939(hub)); AllEffects.Add(typeof(Decontaminating), new Decontaminating(hub)); AllEffects.Add(typeof(SinkHole), new SinkHole(hub)); AllEffects.Add(typeof(Flashed), new Flashed(hub)); AllEffects.Add(typeof(Amnesia), new Amnesia(hub)); AllEffects.Add(typeof(Blinded), new Blinded(hub)); AllEffects.Add(typeof(Hemorrhage), new Hemorrhage(hub)); AllEffects.Add(typeof(Poisoned), new Poisoned(hub)); AllEffects.Add(typeof(Bleeding), new Bleeding(hub)); AllEffects.Add(typeof(Disabled), new Disabled(hub)); AllEffects.Add(typeof(Ensnared), new Ensnared(hub)); AllEffects.Add(typeof(Concussed), new Concussed(hub)); AllEffects.Add(typeof(Burned), new Burned(hub)); AllEffects.Add(typeof(Deafened), new Deafened(hub)); AllEffects.Add(typeof(Asphyxiated), new Asphyxiated(hub)); AllEffects.Add(typeof(Exhausted), new Exhausted(hub)); AllEffects.Add(typeof(Panic), new Panic(hub)); AllEffects.Add(typeof(Invigorated), new Invigorated(hub)); AllEffects.Add(typeof(SCP008), new SCP008(hub)); if (NetworkServer.active) { Resync(); } }
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 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 ResourceFlat_ApplyEffect() { AllEffects.Apply(data, performer, new Single(performer)); Assert.AreEqual( 5, performer.State.ResourceTypes[0].MaxAmount ); }
public bool OnAttacked(float damage, TowerBase tower, List <EffectBase> effects) { AllEffects.UnionWith(effects); var healthDelta = damage * DamageReduction * DamageTypeReduction(tower.DamageType); tower.EnemyAttacked(Math.Min(healthDelta, Health)); return(UpdateHealth(-healthDelta)); }
public void RemoveItem(int index) { Items[index].UpdateTower(null); AllEffects.RemoveWhere(effect => effect.Item == Items[index]); Items.RemoveAt(index); UpdateStats(); OnItemRemoved?.Invoke(this, index); }
public void AddItem(ItemBase item) { Items.Add(item); AllEffects.UnionWith(item.Effects); item.UpdateTower(this); UpdateStats(); OnItemAdded?.Invoke(this, item); }
public void ResourceFlat_ApplyEffect() { var performer = TestMembers.Create(s => s, Ammo); AllEffects.Apply(data, performer, new Single(performer)); Assert.AreEqual(5, performer.State[Ammo]); }
private void Start() { fadeTransition = GetComponent <FadeTransition>(); fsTransition = GetComponent <FourSideTransition>(); gm = this; currAreaName = AreaNames.GRASSLAND; allEffects = GetComponent <AllEffects>(); }
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 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 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 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()}"); } }
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 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 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]); }
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 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)); }
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 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 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 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()); }