protected override CommandResult ExecuteCommandCore(Quadrant quadrant) { if (_io.TryReadCourse("Course", " Lt. Sulu", out var course) && TryGetWarpFactor(out var warpFactor) && TryGetDistanceToMove(warpFactor, out var distanceToMove)) { var result = quadrant.KlingonsMoveAndFire(); if (result.IsGameOver) { return(result); } _enterprise.RepairSystems(warpFactor); _enterprise.VaryConditionOfRandomSystem(); var timeElapsed = _enterprise.Move(course, warpFactor, distanceToMove); if (_enterprise.IsDocked) { _enterprise.ShieldControl.DropShields(); _enterprise.Refuel(); _enterprise.PhotonTubes.ReplenishTorpedoes(); } _enterprise.Quadrant.Display(Strings.NowEntering); return(CommandResult.Elapsed(timeElapsed)); } return(CommandResult.Ok); }
protected override CommandResult ExecuteCommandCore(Quadrant quadrant) { if (!_io.TryReadCourse("Photon torpedo course", "Ensign Chekov", out var course)) { return(CommandResult.Ok); } TorpedoCount -= 1; var isHit = false; _io.WriteLine("Torpedo track:"); foreach (var sector in course.GetSectorsFrom(_enterprise.SectorCoordinates)) { _io.WriteLine($" {sector}"); if (quadrant.TorpedoCollisionAt(sector, out var message, out var gameOver)) { _io.WriteLine(message); isHit = true; if (gameOver) { return(CommandResult.GameOver); } break; } } if (!isHit) { _io.WriteLine("Torpedo missed!"); } return(quadrant.KlingonsFireOnEnterprise()); }