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); }
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 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."); }
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); }
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); }
/* * Set the docked status of the ship */ public void SetDocked(bool docked) { if (!this.docked && docked) { this.energyLevel = 100; ComsChatter("Commander Scot reports reports, 'Docking is complete, Captain.'"); } if (this.docked && !docked) { ComsChatter("Lt Sulu reports, 'We're clear for maneuvering, Captain.'"); } DamageControl.Docked(docked); Impulse.Docked(docked); LRS.Docked(docked); Phasers.Docked(docked); Probes.Docked(docked); Shields.Docked(docked); SRS.Docked(docked); Torpedoes.Docked(docked); Warp.Docked(docked); this.docked = docked; }
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 ClearLists() { AAGuns.Clear(); AuxiliaryItems.Clear(); SubmarineTorpedoes.Clear(); Torpedoes.Clear(); TorpedoBomberPlanes.Clear(); MainGuns.Clear(); Planes.Clear(); AswItems.Clear(); }
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); }
/* * Check for end of game conditions * and make sure we only process one * end game condition * */ private void endGameCheck() { Debug("Endgame check"); int endGameAction = 0; if (GameBoard.getKlingonCount() < 1) { Debug("YOU WON!"); endGameAction = (GameEnd.ForTheWin() ? 1 : 2); } else if (GameBoard.TimeLeft() <= 0.0) { Debug("Out of Time"); endGameAction = (GameEnd.OutOfTime() ? 1 : 2); } else if (this.energyLevel < .1) { Debug("Out of Energy"); endGameAction = (GameEnd.OutOfEnergy() ? 1 : 2); } else if (this.alertLevel == REDALERT && (!(Impulse.IsHealthy() || Warp.IsHealthy() || Phasers.IsHealthy() || (Torpedoes.IsHealthy() && Torpedoes.getCurrentCount() > 0)))) { Debug("No longer able to fight"); endGameAction = (GameEnd.Destroyed() ? 1 : 2); } // take end game action if > 0 switch (endGameAction) { case 1: Debug("Starting new game"); // TODO - add 16 grid support. If I decide to add multiplayer // player support (not likely) then I'll also add 24 & 32 grid sizes NewGame(8); break; case 2: Debug("Normal exit to game"); System.Windows.Forms.Application.ExitThread(); this.Close(); break; } }
private void AddItemToList(Equipment item, string newType, DPSData dpsData) { switch (newType) { case "AA Gun": AAGuns.Add(new AAGun(item, dpsData)); break; case "Auxiliary": AuxiliaryItems.Add(new AuxiliaryItem(item)); break; case "Submarine Torpedo": SubmarineTorpedoes.Add(new SubmarineTorpedo(item, dpsData)); break; case "Torpedo": Torpedoes.Add(new Torpedo(item, dpsData)); break; case "Torpedo Bomber": TorpedoBomberPlanes.Add(new TorpedoBomberPlane(item, dpsData)); break; case string s when s.Contains("Gun"): MainGuns.Add(new MainGun(item, dpsData)); break; case string s when s == "Fighter" || s == "Dive Bomber" || s == "Seaplane": Planes.Add(new Plane(item, dpsData)); break; default: AswItems.Add(new ASWItem(item)); break; } }
/* * Routine to set everything up for a new game */ public void NewGame(int gridSize) { WriteToLog.write("---- Game Start ----"); // initialize the other classes GameBoard.NewGame(gridSize); GameMap.NewGame(); SRS.NewGame(); LRS.NewGame(); Warp.NewGame(); Torpedoes.NewGame(); Phasers.NewGame(); Shields.NewGame(); Impulse.NewGame(); DamageControl.NewGame(); StarBases.NewGame(); Probes.NewGame(); ComsClear(); // Register starbases for (int i = 0; i < GameBoard.GetSize() * GameBoard.GetSize(); i++) { if (GameBoard.GetGameBoard(i) > 99) { // Register this starbase StarBases.AddStarbase(i); WriteToLog.write("Added starbase to loc " + i.ToString()); } } // locate the enterprise and play the game GameBoard.RandomEnterpriseLocation(); WriteToLog.write("Enteprise is in sector " + GameBoard.GetLocation()); SRS.Execute(); SetCondition(); }
//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 Setup() { Constants.DEBUG_MODE = false; _photonsToTest = new Torpedoes(_setup.TestMap.Playership, this.Game); }
public override void EndInitialization() { if (_log.IsDebugEnabled) { _log.DebugFormat("Starting {0}", MethodBase.GetCurrentMethod().ToString()); } if (Art != null) { Art.EndInitialization(); } if (FleetAICommonality != null) { FleetAICommonality.EndInitialization(); } if (InternalDefinition != null) { InternalDefinition.EndInitialization(); } if (Carrier != null) { Carrier.EndInitialization(); } Shields.EndInitialization(); if (Performance != null) { Performance.EndInitialization(); } if (DronePorts != null) { DronePorts.EndInitialization(); } if (BeamPorts != null) { BeamPorts.EndInitialization(); } if (TorpedoTubes != null) { TorpedoTubes.EndInitialization(); } if (EnginePorts != null) { EnginePorts.EndInitialization(); } if (ManeuverPoints != null) { ManeuverPoints.EndInitialization(); } if (ImpulsePoints != null) { ImpulsePoints.EndInitialization(); } if (Torpedoes != null) { Torpedoes.EndInitialization(); } if (Description != null) { Description.EndInitialization(); } base.EndInitialization(); if (_log.IsDebugEnabled) { _log.DebugFormat("Ending {0}", MethodBase.GetCurrentMethod().ToString()); } }
/* * Button execution was broken out of the button handler so the * short cut keys can access it in a straight forward way */ private void ButtonCommand(string btn) { bool executed = false; // prevent button hot keys during timer execution if (timerStep == 0) { Debug(btn + " pressed"); switch (btn.ToUpper()) { case "IMPL": executed = Impulse.Execute(); break; case "WARP": executed = Warp.Execute(); if (executed) { SRS.Execute(); } break; case "SHLD": Shields.Execute(); timerStep = 4; timer.Enabled = true; //SetCondition(); break; case "POWER": Shields.divertPower(); timerStep = 4; timer.Enabled = true; //SetCondition(); break; case "TORP": executed = Torpedoes.Execute(); break; case "PHAS": executed = Phasers.Execute(); break; case "DMG": DamageControl.FixAllDamage(); timerStep = 4; timer.Enabled = true; //SetCondition(); break; } if (executed) { // update status before animation starts SetCondition(); if (IsUsingAnimation()) { timerStep = 1; timer.Enabled = true; } else { Debug("No Animation Executing"); GameObjects.MoveWithNoAnimation(); GameObjects.TakingFire(); GameObjects.MoveWithNoAnimation(); } } } }
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 override void AcceptChanges() { if (Art != null) { Art.AcceptChanges(); } if (FleetAICommonality != null) { FleetAICommonality.AcceptChanges(); } if (Carrier != null) { Carrier.AcceptChanges(); } if (InternalDefinition != null) { InternalDefinition.AcceptChanges(); } Shields.AcceptChanges(); if (Performance != null) { Performance.AcceptChanges(); } if (BeamPorts != null) { BeamPorts.AcceptChanges(); } if (DronePorts != null) { DronePorts.AcceptChanges(); } if (Torpedoes != null) { Torpedoes.AcceptChanges(); } if (TorpedoTubes != null) { TorpedoTubes.AcceptChanges(); } if (EnginePorts != null) { EnginePorts.AcceptChanges(); } if (ManeuverPoints != null) { ManeuverPoints.AcceptChanges(); } if (ImpulsePoints != null) { ImpulsePoints.AcceptChanges(); } if (Description != null) { Description.AcceptChanges(); } base.AcceptChanges(); }
private void SetConditionExecute() { WriteToLog.write("SetCondition - starDate=" + GameBoard.CurrentStarDate() + " energy=" + this.energyLevel); // set the alert level if (GameBoard.GetGameBoard() % 100 / 10 > 0) { this.alertLevel = REDALERT; } else { //energy <15% or or shields up is yellow alert if (this.energyLevel < 15 || Shields.AreUp()) { this.alertLevel = YELLOWALERT; } else { this.alertLevel = GREENALERT; } } Debug("Alert Level = " + alertLevel); // update the form this.Dispatcher.BeginInvoke((Action)(() => { Debug("Updating Status"); switch (this.alertLevel) { case REDALERT: lblAlert.Content = "RED"; break; case YELLOWALERT: this.lblAlert.Content = "YELLOW"; break; default: this.lblAlert.Content = "GREEN"; break; } // update labels - the updatecontent method sends // the info to the log file when in debug mode UpdateContent(lblStarDate, String.Format("{0:0.0} ({1:0.0})", this.GameBoard.CurrentStarDate(), GameBoard.TimeLeft())); UpdateContent(lblEnergy, String.Format("{0:0.0}%", this.energyLevel)); UpdateContent(lblKlingons, GameBoard.getKlingonCount().ToString()); lblImpulse.Content = Impulse.HealthPercent() + "%"; lblWarp.Content = Warp.HealthPercent() + "%"; lblPhasers.Content = Phasers.HealthPercent() + "%"; lblTorpedoes.Content = Torpedoes.HealthPercent() + "%"; lblTorpedoCount.Content = "(" + Torpedoes.getCurrentCount() + " Remaining)"; lblShields.Content = Shields.HealthPercent() + "%"; lblLRS.Content = LRS.HealthPercent() + "%"; lblShieldPowerRemaining.Content = Shields.levelPercent() + "%"; string[] loc = GameBoard.GetLocationInfo(); lblQuadrant.Content = loc[0]; lblSector.Content = loc[1]; })); // set button colors Debug("Set buttons"); this.Dispatcher.BeginInvoke((Action)(() => { // update button background btnImpulse.Background = ((Impulse.IsHealthy() ? LTGREEN : REDISH)); btnWarp.Background = ((Warp.IsHealthy() ? LTGREEN : REDISH)); btnTorpedoes.Background = ((Torpedoes.IsHealthy() ? (Torpedoes.getCurrentCount() > 2 ? LTGREEN : LTYELLOW) : REDISH)); btnPhasers.Background = ((Phasers.IsHealthy() ? LTGREEN : REDISH)); btnLRS.Background = ((LRS.IsHealthy() ? GREENISH : REDISH)); btnRepairs.Background = (DamageControl.HealthPercent() > 50 ? GREENISH : (DamageControl.IsHealthy() ? LTYELLOW : REDISH)); btnDivert.Background = (Shields.levelPercent() > 80 ? GREENISH : (Shields.levelPercent() < 40 ? REDISH : LTYELLOW)); btnDivert.IsEnabled = !IsDocked(); btnShields.IsEnabled = !IsDocked(); if (this.alertLevel == REDALERT) { if (Shields.HealthPercent() > 60) { btnShields.Background = (Shields.AreUp() ? GREENISH : REDISH); } else { btnShields.Background = ((Shields.IsHealthy() && Shields.AreUp() ? LTYELLOW : REDISH)); } } else { if (Shields.HealthPercent() > 30) { btnShields.Background = (Shields.AreUp() ? GREENISH : LTGREEN); } else { btnShields.Background = ((Shields.IsHealthy() ? (Shields.AreUp() ? LTGREEN : LTYELLOW) : REDISH)); } } })); // are we docked? Debug("Docked"); SetDocked(SRS.AreWeDocked()); // look for starbase updates Debug("Starbases"); StarBases.Execute(); // execute damage control and LRS updates Debug("DC"); DamageControl.Execute(); // update the Long range sensors Debug("LRS"); LRS.Execute(); Debug("Exiting setcondition"); }
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); }
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(); }