private string GetCRSRightTextLine(int row, IMap map, IList <string> lrsResults, int totalHostiles) { string retVal = " "; switch (row) { case 0: retVal += String.Format("Torpedoes: {0} Hostiles Left: {1}", Torpedoes.For(map.Playership).Count, totalHostiles); break; case 1: retVal += String.Format("Time remaining: {0}", map.timeRemaining); break; case 2: case 3: case 4: case 5: case 6: case 7: retVal = addLine(row, lrsResults, retVal); break; } return(retVal); }
public void VerifyRunsOutOfTorpedoes() { Constants.DEBUG_MODE = false; _setup.SetupMapWith1Friendly(); _photonsToTest = Torpedoes.For(_setup.TestMap.Playership); _testRegion = _setup.TestMap.Playership.GetRegion(); Constants.DEBUG_MODE = true; for (int i = 0; i < 10; i++) { _photonsToTest.Shoot(7); } Assert.AreEqual(0, _photonsToTest.Count); for (int i = 0; i < 10; i++) { _photonsToTest.Shoot(7); //todo: need test to verify output //Cannot fire. Torpedo Room reports no Torpedoes to fire. } Assert.AreEqual(0, _photonsToTest.Count); }
public void ShootHostileAt(Coordinate friendlySector, Coordinate hostileSector, int directionToShoot, bool debugMode) { Constants.DEBUG_MODE = false; _setup.SetupMapWith1HostileAtSector(friendlySector, hostileSector); var srs = ShortRangeScan.For(_setup.TestMap.Playership); srs.Controls(); _photonsToTest = Torpedoes.For(_setup.TestMap.Playership); _testRegion = _setup.TestMap.Playership.GetRegion(); IShip hostile = _testRegion.GetHostiles().Single(); Assert.AreEqual(friendlySector.X, _photonsToTest.ShipConnectedTo.Sector.X, "Playership.X not at 0"); Assert.AreEqual(friendlySector.Y, _photonsToTest.ShipConnectedTo.Sector.Y, "Playership.Y not at 0"); //Verify Hostile ship's location Assert.AreEqual(hostileSector.X, hostile.Sector.X, "Hostile.X not at 0"); Assert.AreEqual(hostileSector.Y, hostile.Sector.Y, "Hostile.Y not at 1"); Assert.AreEqual(SectorItem.HostileShip, hostile.Sector.Item); Assert.IsNotNull(hostile.Sector.Object); Constants.DEBUG_MODE = debugMode; _photonsToTest.Shoot(directionToShoot); var noMoreHostile = _testRegion.GetHostiles(); //Verify ship's location is no more Assert.AreEqual(0, noMoreHostile.Count, "Hostile Not destroyed."); }
private void ShootHostileTest(bool debugMode) { _setup.SetupMapWith1Hostile(); var srs = ShortRangeScan.For(_setup.TestMap.Playership); srs.Controls(); _photonsToTest = Torpedoes.For(_setup.TestMap.Playership); _testRegion = _setup.TestMap.Playership.GetRegion(); IShip hostile = _testRegion.GetHostiles().Single(); Assert.AreEqual(0, _photonsToTest.ShipConnectedTo.Sector.X, "Playership.X not at 0"); Assert.AreEqual(0, _photonsToTest.ShipConnectedTo.Sector.Y, "Playership.Y not at 0"); //Verify Hostile ship's location Assert.AreEqual(0, hostile.Sector.X, "Hostile.X not at 0"); Assert.AreEqual(1, hostile.Sector.Y, "Hostile.Y not at 1"); Assert.AreEqual(SectorItem.HostileShip, hostile.Sector.Item); Assert.IsNotNull(hostile.Sector.Object); Constants.DEBUG_MODE = debugMode; Assert.IsTrue(_setup.TestMap == _photonsToTest.Game.Map); _photonsToTest.Shoot(7); var noMoreHostile = _testRegion.GetHostiles(); //Verify ship's location is no more Assert.AreEqual(0, noMoreHostile.Count, "Hostile Not destroyed."); }
public void ShootHostileWithNoReturnFire() { _setup.SetupMapWith1Hostile(); _photonsToTest = Torpedoes.For(_setup.TestMap.Playership); _testRegion = _setup.TestMap.Playership.GetRegion(); IShip hostile = _testRegion.GetHostiles().Single(); //Verify ship's location Assert.AreEqual(0, hostile.Sector.X); Assert.AreEqual(1, hostile.Sector.Y); Constants.DEBUG_MODE = true; _photonsToTest.Shoot(7); _photonsToTest.Shoot(1); _photonsToTest.Shoot(5); _photonsToTest.Shoot(3); _photonsToTest.Shoot(7); _photonsToTest.Shoot(1); _photonsToTest.Shoot(5); _photonsToTest.Shoot(3); var noMoreHostile = _testRegion.GetHostiles(); //Verify ship's location is no more Assert.AreEqual(0, noMoreHostile.Count); }
public void SetupPlayershipTorpedoes() { var torpedoes = Torpedoes.For(this.Playership); torpedoes.ShipConnectedTo = this.Playership; torpedoes.Count = this.Config.GetSetting <int>("photonTorpedoes"); //torpedoes.Damage = 0; }
public void ShootTorpedoOnly() { _setup.SetupMapWith1Friendly(); _photonsToTest = Torpedoes.For(_setup.TestMap.Playership); _testRegion = _setup.TestMap.Playership.GetRegion(); Assert.AreEqual(10, _photonsToTest.Count); _photonsToTest.Shoot(7); Assert.AreEqual(9, _photonsToTest.Count); }
private string GetSRSRowIndicator(int row, IMap map, Location location) { string retVal = " "; switch (row) { case 0: retVal += String.Format(this.Config.GetText("SRSRegionIndicator"), Convert.ToString(location.Region.X), Convert.ToString(location.Region.Y)); break; case 1: retVal += String.Format(this.Config.GetText("SRSSectorIndicator"), Convert.ToString(location.Sector.X), Convert.ToString(location.Sector.Y)); break; case 2: retVal += String.Format(this.Config.GetText("SRSStardateIndicator"), map.Stardate); break; case 3: retVal += String.Format(this.Config.GetText("SRSTimeRemainingIndicator"), map.timeRemaining); break; case 4: retVal += String.Format(this.Config.GetText("SRSConditionIndicator"), map.Playership.GetConditionAndSetIcon()); break; case 5: retVal += String.Format(this.Config.GetText("SRSEnergyIndicator"), map.Playership.Energy); break; case 6: retVal += String.Format(this.Config.GetText("SRSShieldsIndicator"), Shields.For(map.Playership).Energy); break; case 7: retVal += String.Format(this.Config.GetText("SRSTorpedoesIndicator"), Torpedoes.For(map.Playership).Count); break; } return(retVal); }
//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; } }
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); }
public void Scavenge(ScavengeType scavengeType) { int photonsScavenged = 0; int energyScavenged = 0; string scavengedFrom = ""; //todo: if found a ship with destroyed = true and it is not removed from map, but has subsystems with energy, then pull energy from all those subsystems switch (scavengeType) { case ScavengeType.Starbase: photonsScavenged = Utility.Utility.Random.Next(10); //todo: resource out this number energyScavenged = Utility.Utility.Random.Next(2500); //todo: resource out this number scavengedFrom = "Starbase"; break; case ScavengeType.FederationShip: photonsScavenged = Utility.Utility.Random.Next(5); //todo: resource out this number energyScavenged = Utility.Utility.Random.Next(750); //todo: resource out this number scavengedFrom = "Federation starship"; break; case ScavengeType.OtherShip: //var testingTorpsScavenged = Torpedoes.For(this).Game.RandomFactorForTesting; //var testingEnergyScavenged = this.Game.RandomFactorForTesting; //int randomPhotonsScavenged = testingTorpsScavenged == 0 ? Utility.Utility.Random.Next(2) : testingTorpsScavenged; //int randomEnergyScavenged = testingEnergyScavenged == 0 ? Utility.Utility.Random.Next(100) : testingEnergyScavenged; photonsScavenged = Utility.Utility.TestableRandom(this.Game, 2, 2); //randomPhotonsScavenged; //todo: resource out this number energyScavenged = Utility.Utility.TestableRandom(this.Game, 100, 100); //randomEnergyScavenged; //todo: resource out this number scavengedFrom = "ship"; break; } //seem like a lot? well.. you are taking on the ENTIRE FEDERATION! You will need it! var scavengedText = ""; var foundPhotons = (photonsScavenged > 0); if (foundPhotons) { Torpedoes.For(this).Count += photonsScavenged; scavengedText = photonsScavenged + " Torpedoes found"; } if (energyScavenged > 0) { this.Energy += energyScavenged; if (foundPhotons) { scavengedText += ", & "; } scavengedText += energyScavenged + " Energy found"; } this.Map.Write.Line(scavengedText + " from destroyed " + scavengedFrom + " debris field. "); //todo: credit scavenged energy to ship energy. //note: create ship.autoscavenge, and turn it off for testing. this.UpdateDivinedSectors(); }