Пример #1
0
        public void Combat_MockWeaponSetUpEnvironment()
        {
            TestPreparedWorld tpw = TestUtils.CreateWorldWithBotsReadyForCombat();

            Assert.NotNull(tpw.Engine);
            Assert.NotNull(tpw.Engine);
            Assert.NotNull(tpw.Engine);
        }
Пример #2
0
        public void Combat_WeaponCooldownPreventsFire()
        {
            TestPreparedWorld tpw = TestUtils.CreateWorldWithBotsReadyForCombat(4);
            var ae = tpw.Bot1.GetEquipment("Gun_Turret");

            tpw.Engine.Mock_GetEquipmentInstanceById(ae.InstanceId).CooldownTicksRemaining = 1;

            var eur = tpw.Bot1.FireWeapon(4, "Gun_Turret");

            Assert.Equal(UsageEndState.Fail_CooldownActive, eur.State);
        }
Пример #3
0
        public void Combat_CantFireWhenNoCharge()
        {
            MockEquipmentRepository mor = new MockEquipmentRepository();

            mor.Mock_SetWeaponProperties(100, 10, 89);
            TestPreparedWorld tpw = TestUtils.CreateWorldWithBotsReadyForCombat(4, mor);

            tpw.Engine.Mock_DirectSetBotCharge(tpw.Bot1.PublicId, 0);
            var eur = tpw.Bot1.FireWeapon(4, "Gun_Turret");

            Assert.Equal(UsageEndState.Fail_NoCharge, eur.State);
        }
Пример #4
0
        public void Bot_FireWeapon_IncreasesUseCount()
        {
            TestPreparedWorld tpw = TestUtils.CreateWorldWithBotsReadyForCombat(4);

            Guid weaponGuid      = tpw.Bot1.Mock_GetWeaponEquipmentInstanceId("Gun_Turret").InstanceId;
            var  ae              = tpw.Engine.Mock_GetEquipmentInstanceById(weaponGuid);
            int  currentUseCount = ae.UseCount;
            var  res             = tpw.Bot1.FireWeapon(4, "Gun_Turret");

            Assert.Equal(UsageEndState.Success, res.State);
            Assert.Equal(currentUseCount + 1, ae.UseCount);
        }
Пример #5
0
        public void Weapon_HasCorrectInitialAmmoAllocation()
        {
            MockEquipmentRepository mor = new MockEquipmentRepository();

            mor.Mock_SetWeaponProperties(100, 11);
            TestPreparedWorld tpw = TestUtils.CreateWorldWithBotsReadyForCombat(4, mor);

            var ae            = tpw.Bot1.GetEquipment("Gun_Turret");
            int initialRounds = tpw.Engine.Mock_GetEquipmentInstanceById(ae.InstanceId).RoundsRemaining;

            Assert.Equal(11, initialRounds);
        }
Пример #6
0
        public void Combat_FireProjectileWeaponDepletesAmmo()
        {
            TestPreparedWorld tpw = TestUtils.CreateWorldWithBotsReadyForCombat(4);

            var ae                 = tpw.Bot1.GetEquipment("Gun_Turret");
            var aeE                = tpw.Engine.Mock_GetEquipmentInstanceById(ae.InstanceId);
            int remainingRounds    = aeE.RoundsRemaining;
            var eur                = tpw.Bot1.FireWeapon(4, "Gun_Turret");
            int afterShotRemaining = aeE.RoundsRemaining;

            Assert.True(eur.State == UsageEndState.Success, "The weapon did not fire correctly");
            Assert.True(remainingRounds > afterShotRemaining, "the ammo was not depleted when firing the weapon");
        }
Пример #7
0
        public void Combat_FireProjectileWeaponHitsTargetDoesDamage()
        {
            MockEquipmentRepository mor = new MockEquipmentRepository();

            mor.Mock_SetWeaponProperties(100);
            TestPreparedWorld tpw = TestUtils.CreateWorldWithBotsReadyForCombat(4, mor);

            int beforeLife = tpw.Engine.GetMappedBotById(tpw.GetBot2EngineId()).LifeRemaining;

            tpw.Engine.PerformNextTick();
            var eur = tpw.Bot1.FireWeapon(4, "Gun_Turret");

            Assert.True(eur.State == UsageEndState.Success, "The weapon did not fire correctly");
            int afterLife = tpw.Engine.GetMappedBotById(tpw.GetBot2EngineId()).LifeRemaining;

            Assert.True(afterLife < beforeLife);
        }
Пример #8
0
        public void Combat_ZeroProjectileAmmo_CantFire()
        {
            TestPreparedWorld tpw = TestUtils.CreateWorldWithBotsReadyForCombat(4);

            var ae = tpw.Bot1.GetEquipment("Gun_Turret");

            tpw.Engine.Mock_GetEquipmentInstanceById(ae.InstanceId).RoundsRemaining = 1;

            var aeE = tpw.Engine.Mock_GetEquipmentInstanceById(ae.InstanceId);
            var eur = tpw.Bot1.FireWeapon(4, "Gun_Turret");
            int afterShotRemaining = aeE.RoundsRemaining;

            Assert.Equal(0, afterShotRemaining);
            var eur2 = tpw.Bot1.FireWeapon(4, "Gun_Turret");

            Assert.Equal(UsageEndState.Fail_NoAmmo, eur2.State);
        }
Пример #9
0
        public void Combat_UseScanner_ConsumesCharge()
        {
            MockEquipmentRepository mor = new MockEquipmentRepository();

            mor.Mock_SetScannerProperties(0, 23);
            mor.Mock_SetPowerPackProperties(123);
            TestPreparedWorld tpw = TestUtils.CreateWorldWithBotsReadyForCombat(4, mor);

            var mo     = tpw.Engine.Mock_GetBotMapOBjectByPublicId(tpw.Bot1.PublicId);
            int charge = mo.ChargeRemaining;

            tpw.Bot1.UseEquipment("Scanner");
            int charge2 = mo.ChargeRemaining;

            Assert.True(charge > charge2, "No charge was consumed when the weapon was fired");
            Assert.Equal(23, charge - charge2);
        }
Пример #10
0
        public void Combat_VictimRecievesDamageNoteNextTurn()
        {
            MockEquipmentRepository mor = new MockEquipmentRepository();

            mor.Mock_SetWeaponProperties(100);
            TestPreparedWorld tpw = TestUtils.CreateWorldWithBotsReadyForCombat(4, mor);

            tpw.Engine.Mock_SetBotLife(tpw.Bot2.PublicId, 1000);
            tpw.Engine.PerformNextTick();
            var eur = tpw.Bot1.FireWeapon(4, "Gun_Turret");

            Assert.True(eur.State == UsageEndState.Success, "The weapon did not fire correctly");
            tpw.Engine.PerformNextTick();
            var ad = tpw.Bot2.Mock_GetLTR();

            Assert.NotNull(ad);
            Assert.True(ad.Events.Count == 1, "There should have been a fire event");
        }
Пример #11
0
        public void Combat_FireProjectileWeapon_ConsumesCharge()
        {
            MockEquipmentRepository mor = new MockEquipmentRepository();

            mor.Mock_SetWeaponProperties(100, 10, 89);
            mor.Mock_SetPowerPackProperties(123);
            TestPreparedWorld tpw = TestUtils.CreateWorldWithBotsReadyForCombat(4, mor);

            var ae = tpw.Bot1.GetEquipment("Gun_Turret");

            var mo      = tpw.Engine.Mock_GetBotMapOBjectByPublicId(tpw.Bot1.PublicId);
            int charge  = mo.ChargeRemaining;
            var eur     = tpw.Bot1.FireWeapon(4, "Gun_Turret");
            int charge2 = mo.ChargeRemaining;

            Assert.True(eur.State == UsageEndState.Success, "The weapon did not fire correctly - " + eur.State.ToString());
            Assert.True(charge > charge2, "No charge was consumed when the weapon was fired");
            Assert.Equal(charge - charge2, 89);
        }
Пример #12
0
        public void Combat_FireProjectileFiresGeneratesMessage()
        {
            TestPreparedWorld tpw = TestUtils.CreateWorldWithBotsReadyForCombat(4);
            Hub h           = tpw.HubUsed;
            int msgHitCount = 0;

            h.LookFor <Message_Ui>((mui) => {
                if ((mui.MessageKind == MainMessageKind.UIMessage) && (mui.SubKind == KnownSubkinds.WeaponFire))
                {
                    msgHitCount++;
                }
            });
            tpw.MockRepos.Mock_SetWeaponProperties(0);

            tpw.Engine.PerformNextTick();
            var eur = tpw.Bot1.FireWeapon(4, "Gun_Turret");

            Assert.Equal(1, msgHitCount);
        }
Пример #13
0
        public void Combat_FireProjectileWeaponHitsTargetGeneratesMessage()
        {
            MockEquipmentRepository mor = new MockEquipmentRepository();

            mor.Mock_SetWeaponProperties(100);
            TestPreparedWorld tpw = TestUtils.CreateWorldWithBotsReadyForCombat(4, mor);
            int messageRecieved   = 0;

            tpw.HubUsed.LookFor <Message_Ui>(uim => {
                if (uim.SubKind == KnownSubkinds.WeaponFire)
                {
                    messageRecieved++;
                }
            });

            tpw.Engine.PerformNextTick();
            var eur = tpw.Bot1.FireWeapon(4, "Gun_Turret");

            Assert.Equal(1, messageRecieved);
        }
Пример #14
0
        public static TestPreparedWorld CreateWorldWithBotsReadyForCombat(int withThisScanId = -1, MockEquipmentRepository mer = null) {
            Hub testHub = new Hub(true);
            TestPreparedWorld result = new TestPreparedWorld();
            if (mer == null) {
                result.MockRepos = new MockEquipmentRepository();
            } else {
                result.MockRepos = mer;
            }
            result.Bot1 = (BasicMockBot)new MockBotFactory().CreateBasicMockBot().WithMockPack().WithEquipmentCallback(ab => {
                EquipmentInstallationResult ae = ab.InstallEquipment(KnownEquipmentIds.MOCKPROJECTILEWEAPON, "Gun_Turret", MountPoint.Turret);
                ae = ab.InstallEquipment(KnownEquipmentIds.MOCKPROJECTILEWEAPON, "Gun_Front", MountPoint.Forward);
                ae = ab.InstallEquipment(KnownEquipmentIds.MOCKPROJECTILEWEAPON, "Gun_Near", MountPoint.Nearside);
                ae = ab.InstallEquipment(KnownEquipmentIds.MOCKPROJECTILEWEAPON, "Gun_Offs", MountPoint.Offside);
                ae = ab.InstallEquipment(KnownEquipmentIds.MOCKPROJECTILEWEAPON, "Gun_Rear", MountPoint.Backward);
                ae = ab.InstallEquipment(KnownEquipmentIds.MOCKSCANNER, "Scanner", MountPoint.Internal);
            }).ToBot();
            result.Bot2 = (BasicMockBot)new MockBotFactory().CreateBasicMockBot().WithMockPack().WithEquipmentCallback(ab => {
                EquipmentInstallationResult ae = ab.InstallEquipment(KnownEquipmentIds.MOCKPROJECTILEWEAPON, "Gun_Turret", MountPoint.Turret);
                ae = ab.InstallEquipment(KnownEquipmentIds.MOCKPROJECTILEWEAPON, "Gun_Front", MountPoint.Forward);
                ae = ab.InstallEquipment(KnownEquipmentIds.MOCKPROJECTILEWEAPON, "Gun_Near", MountPoint.Nearside);
                ae = ab.InstallEquipment(KnownEquipmentIds.MOCKPROJECTILEWEAPON, "Gun_Offs", MountPoint.Offside);
                ae = ab.InstallEquipment(KnownEquipmentIds.MOCKPROJECTILEWEAPON, "Gun_Rear", MountPoint.Backward);
                ae = ab.InstallEquipment(KnownEquipmentIds.MOCKSCANNER, "Scanner", MountPoint.Internal);
            }).ToBot();
            result.Engine = new TestEngineFactory().WithHub(testHub).WithDuellingWorld().WithEquipmentSupport(result.MockRepos).WithBot(result.Bot1).WithBot(result.Bot2).WithPrepare().ToMockEngine();
            result.Engine.PerformNextTick();
            result.HubUsed = testHub;

            if (withThisScanId >= 0) {
                int i1 = result.GetBot1EngineId();
                int i2 = result.GetBot2EngineId();

                result.Engine.Mock_CreateArtificalScanId(withThisScanId, i1, i2);
            }
            return result;
        }