Exemplo n.º 1
0
        static TransitionEffect GetEffect()
        {
            var retVal = AllEffects[Rand.Next(AllEffects.Count)]();

            var randEffect = retVal as RandomizedTransitionEffect;

            if (randEffect != null)
            {
                randEffect.RandomSeed = Rand.NextDouble();
            }

            return(retVal);
        }
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 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.º 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());
    }
Exemplo n.º 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());
    }
#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();
            }
        }
Exemplo n.º 7
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.º 8
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.º 9
0
 public void ResourceFlat_ApplyEffect()
 {
     AllEffects.Apply(data, performer, new Single(performer));
     Assert.AreEqual(
         5,
         performer.State.ResourceTypes[0].MaxAmount
         );
 }
Exemplo n.º 10
0
        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));
        }
Exemplo n.º 11
0
 public void RemoveItem(int index)
 {
     Items[index].UpdateTower(null);
     AllEffects.RemoveWhere(effect => effect.Item == Items[index]);
     Items.RemoveAt(index);
     UpdateStats();
     OnItemRemoved?.Invoke(this, index);
 }
Exemplo n.º 12
0
 public void AddItem(ItemBase item)
 {
     Items.Add(item);
     AllEffects.UnionWith(item.Effects);
     item.UpdateTower(this);
     UpdateStats();
     OnItemAdded?.Invoke(this, item);
 }
Exemplo n.º 13
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]);
    }
    private void Start()
    {
        fadeTransition = GetComponent <FadeTransition>();
        fsTransition   = GetComponent <FourSideTransition>();
        gm             = this;
        currAreaName   = AreaNames.GRASSLAND;

        allEffects = GetComponent <AllEffects>();
    }
Exemplo n.º 15
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.º 16
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.º 17
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.º 18
0
    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()}");
        }
    }
Exemplo n.º 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]);
    }
Exemplo n.º 20
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.º 21
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.º 22
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.º 23
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]);
    }
    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.º 25
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.º 26
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));
    }
Exemplo n.º 27
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.º 28
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.º 29
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.º 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());
    }