Ejemplo n.º 1
0
        public void DefaultAttackScryptShouldAttack()
        {
            var test = new TestGameWithActors();

            test.ArmAlice();

            test.playerAlice.SetScrypt(ScryptUtil.defaultAttack);
            test.playerAlice.SetScryptLogger(new Action <string>(s => { Console.WriteLine($"scrypt log: {s}"); }));
            test.game.PlayRound_Scrypt();

            Assert.AreNotEqual(0, test.game.Mobs.Where(a => a.Health < a.baseHealth).Count());
        }
Ejemplo n.º 2
0
        public void AttackTargetShouldClearTargetAfterAttack()
        {
            var test = new TestGameWithActors();

            test.ArmAlice();
            test.AggroAliceAndTargetCarly();

            var jint = new Jint.Engine();

            jint.Execute(ScryptUtil.attackTargets.body);
            jint.Invoke(ScryptUtil.attackTargets.name, test.game, test.playerAlice);

            Assert.IsFalse(test.mobCarly.Targeted);
        }
Ejemplo n.º 3
0
        public void AttackTargetShouldDealDamage()
        {
            var test = new TestGameWithActors();

            test.ArmAlice();
            test.mobCarly.Targeted = true;

            var jint = new Jint.Engine();

            jint.Execute(ScryptUtil.attackTargets.body);
            jint.Invoke(ScryptUtil.attackTargets.name, test.game, test.playerAlice);

            Assert.AreEqual(test.mobCarly.Health, test.mobCarly.baseHealth - test.playerAlice.Weapon.damage);
        }
Ejemplo n.º 4
0
        public void ChooseRandomLivingShouldNotChooseDead()
        {
            var test = new TestGameWithActors();

            test.playerBob.TakeDamage(test.mobCarly.baseHealth);
            test.playerAlice.TakeDamage(test.mobDenise.baseHealth);

            var jint = new Jint.Engine();

            jint.Execute(ScryptUtil.chooseRandom.body);

            var rng    = new RNG(0);
            var choice = jint.Invoke(ScryptUtil.chooseRandom.name, test.game.Players, rng);

            Assert.IsTrue(choice.IsNull());
        }
Ejemplo n.º 5
0
        public void ChooseRandomLivingShouldChoosePseudoRandomly()
        {
            var test = new TestGameWithActors();
            var jint = new Jint.Engine();

            jint.Execute(ScryptUtil.chooseRandom.body);

            var rng = new RNG(0);

            void TestChooseRandom(GameActor actor)
            {
                Assert.AreEqual(actor, jint.Invoke(ScryptUtil.chooseRandom.name, test.game.Players, rng).ToObject());
            }

            TestChooseRandom(test.playerBob);
            TestChooseRandom(test.playerAlice);
            TestChooseRandom(test.playerBob);
            TestChooseRandom(test.playerBob);
            TestChooseRandom(test.playerAlice);
        }
Ejemplo n.º 6
0
 public void TestCleanup()
 {
     testData = null;
     GameEvents.ReleaseAllListeners();
 }
Ejemplo n.º 7
0
 public void TestInitialize()
 {
     testData = new TestGameWithActors();
 }