Example #1
0
 public TestEngineFactory WithEquipmentSupport(EquipmentRepository equipRepos = null)
 {
     this.shouldIncludeEqipmentSupport = true;
     if (equipRepos == null)
     {
         equipRepos = new MockEquipmentRepository();
     }
     this.equipmentSupportTouse = new EquipmentSupport(equipRepos);
     return(this);
 }
        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);
        }
        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);
        }
Example #4
0
        public MockBotFactory WithItemSupport(EquipmentRepository thisOne = null)
        {
            if (thisOne == null)
            {
                EquipmentRepositoryUsed = new MockEquipmentRepository();

                EquipmentSupportUsed = new EquipmentSupport(EquipmentRepositoryUsed);
            }
            else
            {
                EquipmentSupportUsed = new EquipmentSupport(thisOne);
            }
            return(this);
        }
        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);
        }
        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);
        }
        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");
        }
        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);
        }
        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);
        }
Example #10
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;
        }