mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2026-01-14 14:07:38 -08:00
Removed spaces from top-level directory names.
Spaces tend to cause annoyances in a Unix-style shell environment. This change fixes that.
This commit is contained in:
54
84_Super_Star_Trek/csharp/Systems/DamageControl.cs
Normal file
54
84_Super_Star_Trek/csharp/Systems/DamageControl.cs
Normal file
@@ -0,0 +1,54 @@
|
||||
using SuperStarTrek.Commands;
|
||||
using SuperStarTrek.Objects;
|
||||
using SuperStarTrek.Space;
|
||||
|
||||
namespace SuperStarTrek.Systems
|
||||
{
|
||||
internal class DamageControl : Subsystem
|
||||
{
|
||||
private readonly Enterprise _enterprise;
|
||||
private readonly Output _output;
|
||||
|
||||
internal DamageControl(Enterprise enterprise, Output output)
|
||||
: base("Damage Control", Command.DAM, output)
|
||||
{
|
||||
_enterprise = enterprise;
|
||||
_output = output;
|
||||
}
|
||||
|
||||
protected override CommandResult ExecuteCommandCore(Quadrant quadrant)
|
||||
{
|
||||
if (IsDamaged)
|
||||
{
|
||||
_output.WriteLine("Damage Control report not available");
|
||||
}
|
||||
else
|
||||
{
|
||||
_output.NextLine();
|
||||
WriteDamageReport();
|
||||
}
|
||||
|
||||
if (_enterprise.DamagedSystemCount > 0 && _enterprise.IsDocked)
|
||||
{
|
||||
if (quadrant.Starbase.TryRepair(_enterprise, out var repairTime))
|
||||
{
|
||||
WriteDamageReport();
|
||||
return CommandResult.Elapsed(repairTime);
|
||||
}
|
||||
}
|
||||
|
||||
return CommandResult.Ok;
|
||||
}
|
||||
|
||||
internal void WriteDamageReport()
|
||||
{
|
||||
_output.NextLine().WriteLine("Device State of Repair");
|
||||
foreach (var system in _enterprise.Systems)
|
||||
{
|
||||
_output.Write(system.Name.PadRight(25))
|
||||
.WriteLine(((int)(system.Condition * 100) * 0.01).ToString(" 0.##;-0.##"));
|
||||
}
|
||||
_output.NextLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user