Пример #1
0
        public void TestStatsAfterFireWeapon()
        {
            var ship      = new TestShip(Alignment.Player);
            var enemyShip = new TestShip(Alignment.Enemy);

            PlayerCommands.TargetWeapon(ship.Weapons[0], enemyShip.Rooms[0], ship, enemyShip);

            PlayerCommands.TryChangeWeaponState(ship.Weapons[0], ship);

            Assert.AreEqual(100, enemyShip.Rooms[0].CurrentDurability);
            Assert.AreEqual(100, enemyShip.SpecialRooms[0].CurrentDurability);
            Assert.AreEqual(200, enemyShip.Stats.CurrentHP);
            Assert.AreEqual(100, enemyShip.Crew[0].CurrentHP);
            Assert.AreEqual(100, enemyShip.Crew[1].CurrentHP);
            Assert.AreEqual(2000, ship.Weapons[0].TimeLeftToCoolDown);

            WeaponsHandler.Tick(ship, enemyShip, 1000);
            Assert.AreEqual(100, enemyShip.Rooms[0].CurrentDurability);
            Assert.AreEqual(100, enemyShip.SpecialRooms[0].CurrentDurability);
            Assert.AreEqual(200, enemyShip.Stats.CurrentHP);
            Assert.AreEqual(100, enemyShip.Crew[0].CurrentHP);
            Assert.AreEqual(100, enemyShip.Crew[1].CurrentHP);
            Assert.AreEqual(1000, ship.Weapons[0].TimeLeftToCoolDown);

            WeaponsHandler.Tick(ship, enemyShip, 1000);
            Assert.AreEqual(90, enemyShip.Rooms[0].CurrentDurability);
            Assert.AreEqual(90, enemyShip.SpecialRooms[0].CurrentDurability);
            Assert.AreEqual(190, enemyShip.Stats.CurrentHP);
            Assert.AreEqual(90, enemyShip.Crew[0].CurrentHP);
            Assert.AreEqual(90, enemyShip.Crew[1].CurrentHP);
            Assert.AreEqual(2000, ship.Weapons[0].TimeLeftToCoolDown);
        }
Пример #2
0
        public void TestCorrectFullConnectWeapon()
        {
            var ship = new TestShip(Alignment.Player);

            Assert.IsTrue(ship.Weapons.All(c => c.IsOnline == false));

            PlayerCommands.TryChangeWeaponState(ship.Weapons[1], ship);
            Assert.AreEqual(true, ship.Weapons[1].IsOnline);
        }
Пример #3
0
        public void TestTooBigWeaponConnect()
        {
            var ship = new TestShip(Alignment.Player);

            Assert.IsTrue(ship.Weapons.All(c => c.IsOnline == false));

            PlayerCommands.TryChangeWeaponState(ship.Weapons[0], ship);
            PlayerCommands.TryChangeWeaponState(ship.Weapons[1], ship);
            PlayerCommands.TryChangeWeaponState(ship.Weapons[2], ship);
            Assert.AreEqual(false, ship.Weapons[2].IsOnline);
        }
Пример #4
0
        public void TestFireWithNoTargetOnlineWeaponOwerflowCooldown()
        {
            var ship      = new TestShip(Alignment.Player);
            var enemyShip = new TestShip(Alignment.Enemy);

            PlayerCommands.TryChangeWeaponState(ship.Weapons[0], ship);

            WeaponsHandler.Tick(ship, enemyShip, 3000);
            Assert.AreEqual(100, enemyShip.Rooms[0].CurrentDurability);
            Assert.AreEqual(100, enemyShip.SpecialRooms[0].CurrentDurability);
            Assert.AreEqual(200, enemyShip.Stats.CurrentHP);
            Assert.AreEqual(-1000, ship.Weapons[0].TimeLeftToCoolDown);
        }
Пример #5
0
        public void TestSaveTargetAfterConnectAndDisconectWeapon()
        {
            var ship      = new TestShip(Alignment.Player);
            var enemyShip = new TestShip(Alignment.Enemy);

            Assert.IsTrue(ship.Weapons.All(c => c.Target == null));
            Assert.IsTrue(ship.Weapons.All(c => c.IsOnline == false));

            PlayerCommands.TargetWeapon(ship.Weapons[0], enemyShip.Rooms[0], ship, enemyShip);
            Assert.AreEqual(enemyShip.Rooms[0], ship.Weapons[0].Target);
            Assert.AreEqual(false, ship.Weapons[0].IsOnline);

            PlayerCommands.TryChangeWeaponState(ship.Weapons[0], ship);
            Assert.AreEqual(enemyShip.Rooms[0], ship.Weapons[0].Target);
            Assert.AreEqual(true, ship.Weapons[0].IsOnline);

            PlayerCommands.TryChangeWeaponState(ship.Weapons[0], ship);
            Assert.AreEqual(enemyShip.Rooms[0], ship.Weapons[0].Target);
            Assert.AreEqual(false, ship.Weapons[0].IsOnline);
        }
Пример #6
0
        public void TestConnectAndUnconnectTwoWeapons()
        {
            var ship = new TestShip(Alignment.Player);

            Assert.IsTrue(ship.Weapons.All(c => c.IsOnline == false));

            PlayerCommands.TryChangeWeaponState(ship.Weapons[0], ship);
            Assert.AreEqual(true, ship.Weapons[0].IsOnline);
            Assert.AreEqual(false, ship.Weapons[3].IsOnline);

            PlayerCommands.TryChangeWeaponState(ship.Weapons[3], ship);
            Assert.AreEqual(true, ship.Weapons[0].IsOnline);
            Assert.AreEqual(true, ship.Weapons[3].IsOnline);

            PlayerCommands.TryChangeWeaponState(ship.Weapons[0], ship);
            Assert.AreEqual(false, ship.Weapons[0].IsOnline);
            Assert.AreEqual(true, ship.Weapons[3].IsOnline);

            PlayerCommands.TryChangeWeaponState(ship.Weapons[3], ship);
            Assert.IsTrue(ship.Weapons.All(c => c.IsOnline == false));
        }
Пример #7
0
        public void TestFireWithAllCoolDownWeapon()
        {
            var ship      = new TestShip(Alignment.Player);
            var enemyShip = new TestShip(Alignment.Enemy);

            PlayerCommands.TargetWeapon(ship.Weapons[0], enemyShip.Rooms[0], ship, enemyShip);
            PlayerCommands.TryChangeWeaponState(ship.Weapons[0], ship);

            Assert.AreEqual(2000, ship.Weapons[0].TimeLeftToCoolDown);

            WeaponsHandler.Tick(ship, enemyShip, 500);
            Assert.AreEqual(1500, ship.Weapons[0].TimeLeftToCoolDown);

            WeaponsHandler.Tick(ship, enemyShip, 500);
            Assert.AreEqual(1000, ship.Weapons[0].TimeLeftToCoolDown);

            WeaponsHandler.Tick(ship, enemyShip, 500);
            Assert.AreEqual(500, ship.Weapons[0].TimeLeftToCoolDown);

            WeaponsHandler.Tick(ship, enemyShip, 500);
            Assert.AreEqual(2000, ship.Weapons[0].TimeLeftToCoolDown);
        }