Esempio n. 1
0
        public void PhasersWontFireWhenToldTooMuchEnergy()
        {
            _setup.SetupMapWith1FriendlyAtSector(new Coordinate(2, 1));

            var ship = _setup.TestMap.Playership;

            var startingEnergy = (new StarTrekKGSettings()).GetSetting <int>("energy");

            Assert.AreEqual(startingEnergy, ship.Energy);

            const int testBoltEnergy = 4000;
            var       beforeEnergy   = ship.Energy;

            //This action will hit every single hostile in the Region.  In this case, it will hit no one  :D
            Phasers.For(_setup.TestMap.Playership).Fire(testBoltEnergy);

            Assert.AreEqual(ship.Energy, beforeEnergy); //verify that no energy xfer happened.

            Assert.Greater(Shields.For(ship).Energy, -1);

            //Todo: Mock up Output so we can see the text result
            //Without a mock for Output, we can't see the output, but the conclusion we can draw here is that the phasers didn't fire, and no energy was expended

            Assert.AreEqual(startingEnergy, _setup.TestMap.Playership.Energy);
        }
Esempio n. 2
0
        public void HitThatWounds()
        {
            //_testMap.Regions.GetHostile(0).Shields = 20

            //todo: ensure that baddie has less than 50 (from config?)
            Phasers.For(_setup.TestMap.Playership).Fire(50);
        }
Esempio n. 3
0
        public void PhaserFireSubtractsEnergyFromShip()
        {
            _setup.SetupMapWith1FriendlyAtSector(new Coordinate(2, 1));

            var startingEnergy = (new StarTrekKGSettings()).GetSetting <double>("energy");;

            Assert.AreEqual(startingEnergy, _setup.TestMap.Playership.Energy);

            const int testBoltEnergy = 89;

            //This action will hit every single hostile in the Region.  In this case, it will hit no one  :D
            Phasers.For(_setup.TestMap.Playership).Fire(testBoltEnergy);

            this.VerifyFiringShipIntegrity(_setup.TestMap.Playership, startingEnergy, testBoltEnergy, 1911);

            //Verifies energy subtracted from firing ship.
            Assert.AreEqual(startingEnergy - testBoltEnergy, _setup.TestMap.Playership.Energy);
        }
Esempio n. 4
0
        public void PhasersWontFireWhenToldNotEnoughEnergy()
        {
            _setup.SetupMapWith1FriendlyAtSector(new Coordinate(2, 1));

            var startingEnergy = (new StarTrekKGSettings()).GetSetting <int>("energy");;

            Assert.AreEqual(startingEnergy, _setup.TestMap.Playership.Energy);

            const int testBoltEnergy = -1;

            //This action will hit every single hostile in the Region.  In this case, it will hit no one  :D
            Phasers.For(_setup.TestMap.Playership).Fire(testBoltEnergy);

            this.VerifyFiringShipIntegrity(_setup.TestMap.Playership, startingEnergy, testBoltEnergy, startingEnergy);

            //Todo: Mock up Output so we can see the text result
            //Without a mock for Output, we can't see the output, but the conclusion we can draw here is that the phasers didn't fire, and no energy was expended

            Assert.AreEqual(startingEnergy, _setup.TestMap.Playership.Energy);
        }
Esempio n. 5
0
        //This needs to be a command method that the UI passes values into.
        //Readline is done in UI

        public void Prompt(Ship playerShip, string mapText, Game game)
        {
            this.Console.Write(mapText);

            var readLine = this.Console.ReadLine();

            if (readLine == null)
            {
                return;
            }

            var command = readLine.Trim().ToLower();

            switch (command)
            {
            case "wrp":
            case "imp":
            case "nto":
                Navigation.For(playerShip).Controls(command);
                break;

            case "irs":
                ImmediateRangeScan.For(playerShip).Controls();
                break;

            case "srs":
                ShortRangeScan.For(playerShip).Controls();
                break;

            case "lrs":
                LongRangeScan.For(playerShip).Controls();
                break;

            case "crs":
                CombinedRangeScan.For(playerShip).Controls();
                break;

            case "pha":
                Phasers.For(playerShip).Controls(playerShip);
                break;

            case "tor":
                Torpedoes.For(playerShip).Controls();
                break;

            case "she":
                this.ShieldMenu(playerShip);
                break;

            case "com":
                this.ComputerMenu(playerShip);
                break;

            case "toq":
                Computer.For(playerShip).Controls(command);
                break;

            case "dmg":
                this.DamageControlMenu(playerShip);
                break;

            //Utility Commands
            case "dbg":
                this.DebugMenu(playerShip);
                break;

            case "ver":
                this.Console.WriteLine(this.Config.GetText("AppVersion").TrimStart(' '));
                break;

            case "cls":
                this.Console.Clear();
                break;

            default:     //case "?":
                this.CreateCommandPanel();
                this.Panel(this.GetPanelHead(playerShip.Name), ACTIVITY_PANEL);
                break;
            }
        }
Esempio n. 6
0
        public void HitThatDestroys_Nebula()
        {
            //TestClass_Base called before this, doing some initialization a second time
            _setup.SetupMapWith1HostileAtSector(new Coordinate(2, 1), new Coordinate(2, 6), true);
            Game.RandomFactorForTesting = 123;

            //todo: why active? are hostiles in the same sector?
            var activeRegion = _setup.TestMap.Regions.GetActive();

            activeRegion.Type = RegionType.Nebulae; // for testing purposes.

            var beforeHostiles  = activeRegion.GetHostiles();
            var countOfHostiles = beforeHostiles.Count;

            Assert.AreEqual(1, countOfHostiles);

            //Verify ship's location
            Assert.AreEqual(2, beforeHostiles[0].Sector.X);
            Assert.AreEqual(6, beforeHostiles[0].Sector.Y);

            //verify position on map.
            Assert.AreEqual(SectorItem.HostileShip, activeRegion.Sectors[22].Item);

            //set badguy energy
            var badGuyShields = Shields.For(beforeHostiles[0]);

            badGuyShields.Energy = 50;

            //todo: verify firing ship's starting energy.
            var startingEnergy = (new StarTrekKGSettings()).GetSetting <int>("energy");

            var playershipBefore = _setup.TestMap.Playership;

            Assert.AreEqual(startingEnergy, playershipBefore.Energy);

            const int testBoltEnergy = 444;

            //Random numbers that are used in this operation:
            var phasers = Phasers.For(playershipBefore);

            phasers.Game.RandomFactorForTesting = 3;

            playershipBefore.Game = phasers.Game;
            Torpedoes.For(playershipBefore).Game.RandomFactorForTesting = 2;

            badGuyShields.Game.RandomFactorForTesting = 200;

            //This action will hit every single hostile in the Region
            phasers.Fire(testBoltEnergy);  //due to the distance between the 2 ships, this is how much power it takes to knock the hostile's shield level of 50 down to nothing.

            var playershipAfter = _setup.TestMap.Playership;

            this.VerifyFiringShipIntegrity(playershipAfter, startingEnergy, testBoltEnergy, 1489);

            var afterHostiles      = activeRegion.GetHostiles();
            var afterHostilesCount = afterHostiles.Count;

            //in space. no one can hear you scream.
            Assert.AreEqual(0, afterHostilesCount);
            Assert.AreEqual(null, activeRegion.Sectors[22].Object);
            Assert.AreEqual(SectorItem.Empty, activeRegion.Sectors[22].Item);
        }