mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2025-12-27 13:14:15 -08:00
Standardise accessibility keywords and remove dead code.
This commit is contained in:
@@ -4,7 +4,6 @@ using SuperStarTrek.Resources;
|
||||
using SuperStarTrek.Space;
|
||||
using SuperStarTrek.Systems;
|
||||
using SuperStarTrek.Systems.ComputerFunctions;
|
||||
using static System.StringComparison;
|
||||
|
||||
namespace SuperStarTrek
|
||||
{
|
||||
@@ -22,17 +21,17 @@ namespace SuperStarTrek
|
||||
private int _initialKlingonCount;
|
||||
private Enterprise _enterprise;
|
||||
|
||||
public Game()
|
||||
internal Game(Output output, Input input, Random random)
|
||||
{
|
||||
_output = new Output();
|
||||
_input = new Input(_output);
|
||||
_random = new Random();
|
||||
_output = output;
|
||||
_input = input;
|
||||
_random = random;
|
||||
}
|
||||
|
||||
public float Stardate => _currentStardate;
|
||||
public float StardatesRemaining => _finalStarDate - _currentStardate;
|
||||
internal float Stardate => _currentStardate;
|
||||
internal float StardatesRemaining => _finalStarDate - _currentStardate;
|
||||
|
||||
public void DoIntroduction()
|
||||
internal void DoIntroduction()
|
||||
{
|
||||
_output.Write(Strings.Title);
|
||||
|
||||
@@ -44,11 +43,10 @@ namespace SuperStarTrek
|
||||
}
|
||||
}
|
||||
|
||||
public void Play()
|
||||
internal void Play()
|
||||
{
|
||||
Initialise();
|
||||
var gameOver = false;
|
||||
var newQuadrantText = Strings.StartText;
|
||||
|
||||
while (!gameOver)
|
||||
{
|
||||
@@ -120,7 +118,7 @@ namespace SuperStarTrek
|
||||
private Quadrant BuildCurrentQuadrant() =>
|
||||
new Quadrant(_galaxy[_currentQuadrant], _enterprise, _random, _galaxy, _input, _output);
|
||||
|
||||
public bool Replay() => _galaxy.StarbaseCount > 0 && _input.GetString(Strings.ReplayPrompt, "Aye");
|
||||
internal bool Replay() => _galaxy.StarbaseCount > 0 && _input.GetString(Strings.ReplayPrompt, "Aye");
|
||||
|
||||
private bool CheckIfStranded()
|
||||
{
|
||||
|
||||
@@ -10,24 +10,24 @@ namespace SuperStarTrek
|
||||
{
|
||||
private readonly Output _output;
|
||||
|
||||
public Input(Output output)
|
||||
internal Input(Output output)
|
||||
{
|
||||
_output = output;
|
||||
}
|
||||
|
||||
public void WaitForAnyKeyButEnter(string prompt)
|
||||
internal void WaitForAnyKeyButEnter(string prompt)
|
||||
{
|
||||
_output.Write($"Hit any key but Enter {prompt} ");
|
||||
while (Console.ReadKey(intercept: true).Key == ConsoleKey.Enter);
|
||||
}
|
||||
|
||||
public string GetString(string prompt)
|
||||
internal string GetString(string prompt)
|
||||
{
|
||||
_output.Prompt(prompt);
|
||||
return Console.ReadLine();
|
||||
}
|
||||
|
||||
public float GetNumber(string prompt)
|
||||
internal float GetNumber(string prompt)
|
||||
{
|
||||
_output.Prompt(prompt);
|
||||
|
||||
@@ -44,24 +44,24 @@ namespace SuperStarTrek
|
||||
}
|
||||
}
|
||||
|
||||
public (float X, float Y) GetCoordinates(string prompt)
|
||||
internal (float X, float Y) GetCoordinates(string prompt)
|
||||
{
|
||||
_output.Prompt($"{prompt} (X,Y)");
|
||||
var responses = ReadNumbers(2);
|
||||
return (responses[0], responses[1]);
|
||||
}
|
||||
|
||||
public bool TryGetNumber(string prompt, float minValue, float maxValue, out float value)
|
||||
internal bool TryGetNumber(string prompt, float minValue, float maxValue, out float value)
|
||||
{
|
||||
value = GetNumber($"{prompt} ({minValue}-{maxValue})");
|
||||
|
||||
return value >= minValue && value <= maxValue;
|
||||
}
|
||||
|
||||
internal bool GetString(string replayPrompt, string trueValue)
|
||||
=> GetString(replayPrompt).Equals(trueValue, InvariantCultureIgnoreCase);
|
||||
internal bool GetString(string replayPrompt, string trueValue) =>
|
||||
GetString(replayPrompt).Equals(trueValue, InvariantCultureIgnoreCase);
|
||||
|
||||
public Command GetCommand()
|
||||
internal Command GetCommand()
|
||||
{
|
||||
while(true)
|
||||
{
|
||||
@@ -82,7 +82,7 @@ namespace SuperStarTrek
|
||||
}
|
||||
}
|
||||
|
||||
public bool TryGetCourse(string prompt, string officer, out Course course)
|
||||
internal bool TryGetCourse(string prompt, string officer, out Course course)
|
||||
{
|
||||
if (!TryGetNumber(prompt, 1, 9, out var direction))
|
||||
{
|
||||
@@ -95,7 +95,7 @@ namespace SuperStarTrek
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool GetYesNo(string prompt, YesNoMode mode)
|
||||
internal bool GetYesNo(string prompt, YesNoMode mode)
|
||||
{
|
||||
_output.Prompt($"{prompt} (Y/N)");
|
||||
var response = Console.ReadLine().ToUpperInvariant();
|
||||
@@ -150,7 +150,7 @@ namespace SuperStarTrek
|
||||
return numbers;
|
||||
}
|
||||
|
||||
public enum YesNoMode
|
||||
internal enum YesNoMode
|
||||
{
|
||||
TrueOnY,
|
||||
FalseOnN
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using SuperStarTrek.Commands;
|
||||
using SuperStarTrek.Resources;
|
||||
using SuperStarTrek.Space;
|
||||
@@ -31,22 +30,33 @@ namespace SuperStarTrek.Objects
|
||||
_input = input;
|
||||
}
|
||||
|
||||
public Quadrant Quadrant => _quadrant;
|
||||
public Coordinates QuadrantCoordinates => _quadrant.Coordinates;
|
||||
public Coordinates SectorCoordinates { get; private set; }
|
||||
internal Quadrant Quadrant => _quadrant;
|
||||
|
||||
public string Condition => GetCondition();
|
||||
public LibraryComputer Computer => (LibraryComputer)_commandExecutors[Command.COM];
|
||||
public ShieldControl ShieldControl => (ShieldControl)_commandExecutors[Command.SHE];
|
||||
public float Energy => TotalEnergy - ShieldControl.ShieldEnergy;
|
||||
public float TotalEnergy { get; private set; }
|
||||
public int DamagedSystemCount => _systems.Count(s => s.IsDamaged);
|
||||
public IEnumerable<Subsystem> Systems => _systems;
|
||||
public PhotonTubes PhotonTubes => (PhotonTubes)_commandExecutors[Command.TOR];
|
||||
public bool IsDocked => _quadrant.EnterpriseIsNextToStarbase;
|
||||
public bool IsStranded => TotalEnergy < 10 || Energy < 10 && ShieldControl.IsDamaged;
|
||||
internal Coordinates QuadrantCoordinates => _quadrant.Coordinates;
|
||||
|
||||
public Enterprise Add(Subsystem system)
|
||||
internal Coordinates SectorCoordinates { get; private set; }
|
||||
|
||||
internal string Condition => GetCondition();
|
||||
|
||||
internal LibraryComputer Computer => (LibraryComputer)_commandExecutors[Command.COM];
|
||||
|
||||
internal ShieldControl ShieldControl => (ShieldControl)_commandExecutors[Command.SHE];
|
||||
|
||||
internal float Energy => TotalEnergy - ShieldControl.ShieldEnergy;
|
||||
|
||||
internal float TotalEnergy { get; private set; }
|
||||
|
||||
internal int DamagedSystemCount => _systems.Count(s => s.IsDamaged);
|
||||
|
||||
internal IEnumerable<Subsystem> Systems => _systems;
|
||||
|
||||
internal PhotonTubes PhotonTubes => (PhotonTubes)_commandExecutors[Command.TOR];
|
||||
|
||||
internal bool IsDocked => _quadrant.EnterpriseIsNextToStarbase;
|
||||
|
||||
internal bool IsStranded => TotalEnergy < 10 || Energy < 10 && ShieldControl.IsDamaged;
|
||||
|
||||
internal Enterprise Add(Subsystem system)
|
||||
{
|
||||
_systems.Add(system);
|
||||
_commandExecutors[system.Command] = system;
|
||||
@@ -54,7 +64,7 @@ namespace SuperStarTrek.Objects
|
||||
return this;
|
||||
}
|
||||
|
||||
public void StartIn(Quadrant quadrant)
|
||||
internal void StartIn(Quadrant quadrant)
|
||||
{
|
||||
_quadrant = quadrant;
|
||||
quadrant.Display(Strings.StartText);
|
||||
@@ -68,24 +78,14 @@ namespace SuperStarTrek.Objects
|
||||
_ => "Green"
|
||||
};
|
||||
|
||||
public CommandResult Execute(Command command)
|
||||
internal CommandResult Execute(Command command)
|
||||
{
|
||||
if (command == Command.XXX) { return CommandResult.GameOver; }
|
||||
|
||||
return _commandExecutors[command].ExecuteCommand(_quadrant);
|
||||
}
|
||||
|
||||
public void Refuel() => TotalEnergy = _maxEnergy;
|
||||
|
||||
internal bool Recognises(string command)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
internal string GetCommandList()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
internal void Refuel() => TotalEnergy = _maxEnergy;
|
||||
|
||||
public override string ToString() => "<*>";
|
||||
|
||||
|
||||
@@ -7,19 +7,19 @@ namespace SuperStarTrek.Objects
|
||||
{
|
||||
private readonly Random _random;
|
||||
|
||||
public Klingon(Coordinates sector, Random random)
|
||||
internal Klingon(Coordinates sector, Random random)
|
||||
{
|
||||
Sector = sector;
|
||||
_random = random;
|
||||
Energy = _random.GetFloat(100, 300);
|
||||
}
|
||||
|
||||
public float Energy { get; private set; }
|
||||
public Coordinates Sector { get; private set; }
|
||||
internal float Energy { get; private set; }
|
||||
internal Coordinates Sector { get; private set; }
|
||||
|
||||
public override string ToString() => "+K+";
|
||||
|
||||
public CommandResult FireOn(Enterprise enterprise)
|
||||
internal CommandResult FireOn(Enterprise enterprise)
|
||||
{
|
||||
var attackStrength = _random.GetFloat();
|
||||
var distanceToEnterprise = Sector.GetDistanceTo(enterprise.SectorCoordinates);
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace SuperStarTrek.Objects
|
||||
private readonly Output _output;
|
||||
private readonly float _repairDelay;
|
||||
|
||||
public Starbase(Coordinates sector, Random random, Input input, Output output)
|
||||
internal Starbase(Coordinates sector, Random random, Input input, Output output)
|
||||
{
|
||||
Sector = sector;
|
||||
_repairDelay = random.GetFloat() * 0.5f;
|
||||
|
||||
@@ -4,33 +4,33 @@ namespace SuperStarTrek
|
||||
{
|
||||
internal class Output
|
||||
{
|
||||
public Output Write(string text)
|
||||
internal Output Write(string text)
|
||||
{
|
||||
Console.Write(text);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Output Write(string format, params object[] args)
|
||||
internal Output Write(string format, params object[] args)
|
||||
{
|
||||
Console.Write(format, args);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Output WriteLine(string text = "")
|
||||
internal Output WriteLine(string text = "")
|
||||
{
|
||||
Console.WriteLine(text);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public Output NextLine()
|
||||
internal Output NextLine()
|
||||
{
|
||||
Console.WriteLine();
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public Output Prompt(string text = "")
|
||||
internal Output Prompt(string text = "")
|
||||
{
|
||||
Console.Write($"{text}? ");
|
||||
return this;
|
||||
|
||||
@@ -29,8 +29,11 @@ namespace SuperStarTrek
|
||||
{
|
||||
static void Main()
|
||||
{
|
||||
var foo = Utils.DirectionAndDistance.From(1,1).To(4,5);
|
||||
var game = new Game();
|
||||
var output = new Output();
|
||||
var input = new Input(output);
|
||||
var random = new Random();
|
||||
|
||||
var game = new Game(output, input, random);
|
||||
|
||||
game.DoIntroduction();
|
||||
|
||||
|
||||
@@ -6,20 +6,20 @@ namespace SuperStarTrek
|
||||
{
|
||||
private static readonly System.Random _random = new();
|
||||
|
||||
public Coordinates GetCoordinate() => new Coordinates(Get1To8Inclusive() - 1, Get1To8Inclusive() - 1);
|
||||
internal Coordinates GetCoordinate() => new Coordinates(Get1To8Inclusive() - 1, Get1To8Inclusive() - 1);
|
||||
|
||||
// Duplicates the algorithm used in the original code to get an integer value from 1 to 8, inclusive:
|
||||
// 475 DEF FNR(R)=INT(RND(R)*7.98+1.01)
|
||||
// Returns a value from 1 to 8, inclusive.
|
||||
// Note there's a slight bias away from the extreme values, 1 and 8.
|
||||
public int Get1To8Inclusive() => (int)(GetFloat() * 7.98 + 1.01);
|
||||
internal int Get1To8Inclusive() => (int)(GetFloat() * 7.98 + 1.01);
|
||||
|
||||
public int GetInt(int inclusiveMinValue, int exclusiveMaxValue) =>
|
||||
internal int GetInt(int inclusiveMinValue, int exclusiveMaxValue) =>
|
||||
_random.Next(inclusiveMinValue, exclusiveMaxValue);
|
||||
|
||||
public float GetFloat() => (float)_random.NextDouble();
|
||||
internal float GetFloat() => (float)_random.NextDouble();
|
||||
|
||||
public float GetFloat(float inclusiveMinValue, float exclusiveMaxValue)
|
||||
internal float GetFloat(float inclusiveMinValue, float exclusiveMaxValue)
|
||||
=> GetFloat() * (exclusiveMaxValue - inclusiveMinValue) + inclusiveMinValue;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,31 +6,31 @@ namespace SuperStarTrek.Resources
|
||||
{
|
||||
internal static class Strings
|
||||
{
|
||||
public static string CombatArea => GetResource();
|
||||
public static string ComputerFunctions => GetResource();
|
||||
public static string Congratulations => GetResource();
|
||||
public static string CourtMartial => GetResource();
|
||||
public static string Destroyed => GetResource();
|
||||
public static string EndOfMission => GetResource();
|
||||
public static string Enterprise => GetResource();
|
||||
public static string Instructions => GetResource();
|
||||
public static string LowShields => GetResource();
|
||||
public static string NoEnemyShips => GetResource();
|
||||
public static string NoStarbase => GetResource();
|
||||
public static string NowEntering => GetResource();
|
||||
public static string Orders => GetResource();
|
||||
public static string PermissionDenied => GetResource();
|
||||
public static string Protected => GetResource();
|
||||
public static string RegionNames => GetResource();
|
||||
public static string RelievedOfCommand => GetResource();
|
||||
public static string RepairEstimate => GetResource();
|
||||
public static string RepairPrompt => GetResource();
|
||||
public static string ReplayPrompt => GetResource();
|
||||
public static string ShieldsDropped => GetResource();
|
||||
public static string ShortRangeSensorsOut => GetResource();
|
||||
public static string StartText => GetResource();
|
||||
public static string Stranded => GetResource();
|
||||
public static string Title => GetResource();
|
||||
internal static string CombatArea => GetResource();
|
||||
internal static string ComputerFunctions => GetResource();
|
||||
internal static string Congratulations => GetResource();
|
||||
internal static string CourtMartial => GetResource();
|
||||
internal static string Destroyed => GetResource();
|
||||
internal static string EndOfMission => GetResource();
|
||||
internal static string Enterprise => GetResource();
|
||||
internal static string Instructions => GetResource();
|
||||
internal static string LowShields => GetResource();
|
||||
internal static string NoEnemyShips => GetResource();
|
||||
internal static string NoStarbase => GetResource();
|
||||
internal static string NowEntering => GetResource();
|
||||
internal static string Orders => GetResource();
|
||||
internal static string PermissionDenied => GetResource();
|
||||
internal static string Protected => GetResource();
|
||||
internal static string RegionNames => GetResource();
|
||||
internal static string RelievedOfCommand => GetResource();
|
||||
internal static string RepairEstimate => GetResource();
|
||||
internal static string RepairPrompt => GetResource();
|
||||
internal static string ReplayPrompt => GetResource();
|
||||
internal static string ShieldsDropped => GetResource();
|
||||
internal static string ShortRangeSensorsOut => GetResource();
|
||||
internal static string StartText => GetResource();
|
||||
internal static string Stranded => GetResource();
|
||||
internal static string Title => GetResource();
|
||||
|
||||
private static string GetResource([CallerMemberName] string name = "")
|
||||
{
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace SuperStarTrek.Space
|
||||
// Note that the origin is top-left, x increase downwards, and y increases to the right.
|
||||
internal record Coordinates
|
||||
{
|
||||
public Coordinates(int x, int y)
|
||||
internal Coordinates(int x, int y)
|
||||
{
|
||||
X = Validated(x, nameof(x));
|
||||
Y = Validated(y, nameof(y));
|
||||
@@ -16,10 +16,10 @@ namespace SuperStarTrek.Space
|
||||
SubRegionIndex = Y % 4;
|
||||
}
|
||||
|
||||
public int X { get; }
|
||||
public int Y { get; }
|
||||
public int RegionIndex { get; }
|
||||
public int SubRegionIndex { get; }
|
||||
internal int X { get; }
|
||||
internal int Y { get; }
|
||||
internal int RegionIndex { get; }
|
||||
internal int SubRegionIndex { get; }
|
||||
|
||||
private int Validated(int value, string argumentName)
|
||||
{
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using SuperStarTrek.Objects;
|
||||
using SuperStarTrek.Resources;
|
||||
|
||||
using static System.StringSplitOptions;
|
||||
@@ -21,7 +19,7 @@ namespace SuperStarTrek.Space
|
||||
_subRegionIdentifiers = new[] { "I", "II", "III", "IV" };
|
||||
}
|
||||
|
||||
public Galaxy(Random random)
|
||||
internal Galaxy(Random random)
|
||||
{
|
||||
_random = random;
|
||||
|
||||
@@ -46,16 +44,16 @@ namespace SuperStarTrek.Space
|
||||
}
|
||||
}
|
||||
|
||||
public QuadrantInfo this[Coordinates coordinate] => _quadrants[coordinate.X][coordinate.Y];
|
||||
internal QuadrantInfo this[Coordinates coordinate] => _quadrants[coordinate.X][coordinate.Y];
|
||||
|
||||
public int KlingonCount => _quadrants.SelectMany(q => q).Sum(q => q.KlingonCount);
|
||||
public int StarbaseCount => _quadrants.SelectMany(q => q).Count(q => q.HasStarbase);
|
||||
public IEnumerable<IEnumerable<QuadrantInfo>> Quadrants => _quadrants;
|
||||
internal int KlingonCount => _quadrants.SelectMany(q => q).Sum(q => q.KlingonCount);
|
||||
internal int StarbaseCount => _quadrants.SelectMany(q => q).Count(q => q.HasStarbase);
|
||||
internal IEnumerable<IEnumerable<QuadrantInfo>> Quadrants => _quadrants;
|
||||
|
||||
private static string GetQuadrantName(Coordinates coordinates) =>
|
||||
$"{_regionNames[coordinates.RegionIndex]} {_subRegionIdentifiers[coordinates.SubRegionIndex]}";
|
||||
|
||||
public IEnumerable<IEnumerable<QuadrantInfo>> GetNeighborhood(Quadrant quadrant) =>
|
||||
internal IEnumerable<IEnumerable<QuadrantInfo>> GetNeighborhood(Quadrant quadrant) =>
|
||||
Enumerable.Range(-1, 3)
|
||||
.Select(dx => dx + quadrant.Coordinates.X)
|
||||
.Select(x => GetNeighborhoodRow(quadrant, x));
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace SuperStarTrek.Space
|
||||
private readonly Output _output;
|
||||
private bool _displayed = false;
|
||||
|
||||
public Quadrant(
|
||||
internal Quadrant(
|
||||
QuadrantInfo info,
|
||||
Enterprise enterprise,
|
||||
Random random,
|
||||
@@ -39,13 +39,13 @@ namespace SuperStarTrek.Space
|
||||
PositionObject(_ => new Star(), _info.StarCount);
|
||||
}
|
||||
|
||||
public Coordinates Coordinates => _info.Coordinates;
|
||||
public bool HasKlingons => _info.KlingonCount > 0;
|
||||
public int KlingonCount => _info.KlingonCount;
|
||||
public bool HasStarbase => _info.HasStarbase;
|
||||
public Starbase Starbase { get; }
|
||||
internal Coordinates Coordinates => _info.Coordinates;
|
||||
internal bool HasKlingons => _info.KlingonCount > 0;
|
||||
internal int KlingonCount => _info.KlingonCount;
|
||||
internal bool HasStarbase => _info.HasStarbase;
|
||||
internal Starbase Starbase { get; }
|
||||
internal Galaxy Galaxy { get; }
|
||||
public bool EnterpriseIsNextToStarbase =>
|
||||
internal bool EnterpriseIsNextToStarbase =>
|
||||
_info.HasStarbase &&
|
||||
Math.Abs(_enterprise.SectorCoordinates.X - Starbase.Sector.X) <= 1 &&
|
||||
Math.Abs(_enterprise.SectorCoordinates.Y - Starbase.Sector.Y) <= 1;
|
||||
@@ -166,10 +166,10 @@ namespace SuperStarTrek.Space
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<string> GetDisplayLines() => Enumerable.Range(0, 8).Select(x => GetDisplayLine(x));
|
||||
internal IEnumerable<string> GetDisplayLines() => Enumerable.Range(0, 8).Select(x => GetDisplayLine(x));
|
||||
|
||||
private string GetDisplayLine(int x)
|
||||
=> string.Join(
|
||||
private string GetDisplayLine(int x) =>
|
||||
string.Join(
|
||||
" ",
|
||||
Enumerable
|
||||
.Range(0, 8)
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
using SuperStarTrek.Objects;
|
||||
|
||||
namespace SuperStarTrek.Space
|
||||
{
|
||||
internal class QuadrantInfo
|
||||
@@ -15,13 +13,13 @@ namespace SuperStarTrek.Space
|
||||
HasStarbase = hasStarbase;
|
||||
}
|
||||
|
||||
public Coordinates Coordinates { get; }
|
||||
public string Name { get; }
|
||||
public int KlingonCount { get; private set; }
|
||||
public bool HasStarbase { get; private set; }
|
||||
public int StarCount { get; }
|
||||
internal Coordinates Coordinates { get; }
|
||||
internal string Name { get; }
|
||||
internal int KlingonCount { get; private set; }
|
||||
internal bool HasStarbase { get; private set; }
|
||||
internal int StarCount { get; }
|
||||
|
||||
public static QuadrantInfo Create(Coordinates coordinates, string name)
|
||||
internal static QuadrantInfo Create(Coordinates coordinates, string name)
|
||||
{
|
||||
var random = new Random();
|
||||
var klingonCount = random.GetFloat() switch
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using SuperStarTrek.Objects;
|
||||
using SuperStarTrek.Space;
|
||||
|
||||
@@ -11,7 +8,7 @@ namespace SuperStarTrek.Systems.ComputerFunctions
|
||||
private readonly Enterprise _enterprise;
|
||||
private readonly Input _input;
|
||||
|
||||
public DirectionDistanceCalculator(Enterprise enterprise, Output output, Input input)
|
||||
internal DirectionDistanceCalculator(Enterprise enterprise, Output output, Input input)
|
||||
: base("Starbase nav data", output)
|
||||
{
|
||||
_enterprise = enterprise;
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace SuperStarTrek.Systems.ComputerFunctions
|
||||
{
|
||||
internal abstract class GalacticReport : ComputerFunction
|
||||
{
|
||||
public GalacticReport(string description, Output output, Galaxy galaxy)
|
||||
internal GalacticReport(string description, Output output, Galaxy galaxy)
|
||||
: base(description, output)
|
||||
{
|
||||
Galaxy = galaxy;
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace SuperStarTrek.Systems.ComputerFunctions
|
||||
{
|
||||
private readonly Enterprise _enterprise;
|
||||
|
||||
public StarbaseDataCalculator(Enterprise enterprise, Output output)
|
||||
internal StarbaseDataCalculator(Enterprise enterprise, Output output)
|
||||
: base("Starbase nav data", output)
|
||||
{
|
||||
_enterprise = enterprise;
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace SuperStarTrek.Systems.ComputerFunctions
|
||||
private readonly Galaxy _galaxy;
|
||||
private readonly Enterprise _enterprise;
|
||||
|
||||
public StatusReport(Game game, Galaxy galaxy, Enterprise enterprise, Output output)
|
||||
internal StatusReport(Game game, Galaxy galaxy, Enterprise enterprise, Output output)
|
||||
: base("Status report", output)
|
||||
{
|
||||
_game = game;
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace SuperStarTrek.Systems.ComputerFunctions
|
||||
{
|
||||
private readonly Enterprise _enterprise;
|
||||
|
||||
public TorpedoDataCalculator(Enterprise enterprise, Output output)
|
||||
internal TorpedoDataCalculator(Enterprise enterprise, Output output)
|
||||
: base("Photon torpedo data", output)
|
||||
{
|
||||
_enterprise = enterprise;
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace SuperStarTrek.Systems
|
||||
private readonly Enterprise _enterprise;
|
||||
private readonly Output _output;
|
||||
|
||||
public DamageControl(Enterprise enterprise, Output output)
|
||||
internal DamageControl(Enterprise enterprise, Output output)
|
||||
: base("Damage Control", Command.DAM, output)
|
||||
{
|
||||
_enterprise = enterprise;
|
||||
@@ -40,7 +40,7 @@ namespace SuperStarTrek.Systems
|
||||
return CommandResult.Ok;
|
||||
}
|
||||
|
||||
public void WriteDamageReport()
|
||||
internal void WriteDamageReport()
|
||||
{
|
||||
_output.NextLine().WriteLine("Device State of Repair");
|
||||
foreach (var system in _enterprise.Systems)
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace SuperStarTrek.Systems
|
||||
private readonly Input _input;
|
||||
private readonly ComputerFunction[] _functions;
|
||||
|
||||
public LibraryComputer(Output output, Input input, params ComputerFunction[] functions)
|
||||
internal LibraryComputer(Output output, Input input, params ComputerFunction[] functions)
|
||||
: base("Library-Computer", Command.COM, output)
|
||||
{
|
||||
_output = output;
|
||||
|
||||
@@ -1,10 +1,5 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using SuperStarTrek.Commands;
|
||||
using SuperStarTrek.Objects;
|
||||
using SuperStarTrek.Resources;
|
||||
using SuperStarTrek.Space;
|
||||
|
||||
namespace SuperStarTrek.Systems
|
||||
@@ -14,7 +9,7 @@ namespace SuperStarTrek.Systems
|
||||
private readonly Galaxy _galaxy;
|
||||
private readonly Output _output;
|
||||
|
||||
public LongRangeSensors(Galaxy galaxy, Output output)
|
||||
internal LongRangeSensors(Galaxy galaxy, Output output)
|
||||
: base("Long Range Sensors", Command.LRS, output)
|
||||
{
|
||||
_galaxy = galaxy;
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace SuperStarTrek.Systems
|
||||
private readonly Input _input;
|
||||
private readonly Random _random;
|
||||
|
||||
public PhaserControl(Enterprise enterprise, Output output, Input input, Random random)
|
||||
internal PhaserControl(Enterprise enterprise, Output output, Input input, Random random)
|
||||
: base("Phaser Control", Command.PHA, output)
|
||||
{
|
||||
_enterprise = enterprise;
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace SuperStarTrek.Systems
|
||||
private readonly Output _output;
|
||||
private readonly Input _input;
|
||||
|
||||
public PhotonTubes(int tubeCount, Enterprise enterprise, Output output, Input input)
|
||||
internal PhotonTubes(int tubeCount, Enterprise enterprise, Output output, Input input)
|
||||
: base("Photon Tubes", Command.TOR, output)
|
||||
{
|
||||
TorpedoCount = _tubeCount = tubeCount;
|
||||
@@ -20,7 +20,7 @@ namespace SuperStarTrek.Systems
|
||||
_input = input;
|
||||
}
|
||||
|
||||
public int TorpedoCount { get; private set; }
|
||||
internal int TorpedoCount { get; private set; }
|
||||
|
||||
protected override bool CanExecuteCommand() => HasTorpedoes() && IsOperational("{name} are not operational");
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace SuperStarTrek.Systems
|
||||
private readonly Output _output;
|
||||
private readonly Input _input;
|
||||
|
||||
public ShieldControl(Enterprise enterprise, Output output, Input input)
|
||||
internal ShieldControl(Enterprise enterprise, Output output, Input input)
|
||||
: base("Shield Control", Command.SHE, output)
|
||||
{
|
||||
_enterprise = enterprise;
|
||||
@@ -18,7 +18,7 @@ namespace SuperStarTrek.Systems
|
||||
_input = input;
|
||||
}
|
||||
|
||||
public float ShieldEnergy { get; set; }
|
||||
internal float ShieldEnergy { get; set; }
|
||||
|
||||
protected override bool CanExecuteCommand() => IsOperational("{name} inoperable");
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace SuperStarTrek.Systems
|
||||
private readonly Game _game;
|
||||
private readonly Output _output;
|
||||
|
||||
public ShortRangeSensors(Enterprise enterprise, Galaxy galaxy, Game game, Output output)
|
||||
internal ShortRangeSensors(Enterprise enterprise, Galaxy galaxy, Game game, Output output)
|
||||
: base("Short Range Sensors", Command.SRS, output)
|
||||
{
|
||||
_enterprise = enterprise;
|
||||
@@ -47,7 +47,7 @@ namespace SuperStarTrek.Systems
|
||||
return CommandResult.Ok;
|
||||
}
|
||||
|
||||
public IEnumerable<string> GetStatusLines()
|
||||
internal IEnumerable<string> GetStatusLines()
|
||||
{
|
||||
yield return $"Stardate {_game.Stardate}";
|
||||
yield return $"Condition {_enterprise.Condition}";
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
using System;
|
||||
using SuperStarTrek.Commands;
|
||||
using SuperStarTrek.Space;
|
||||
|
||||
@@ -16,10 +15,10 @@ namespace SuperStarTrek.Systems
|
||||
_output = output;
|
||||
}
|
||||
|
||||
public string Name { get; }
|
||||
public float Condition { get; private set; }
|
||||
public bool IsDamaged => Condition < 0;
|
||||
public Command Command { get; }
|
||||
internal string Name { get; }
|
||||
internal float Condition { get; private set; }
|
||||
internal bool IsDamaged => Condition < 0;
|
||||
internal Command Command { get; }
|
||||
|
||||
protected virtual bool CanExecuteCommand() => true;
|
||||
|
||||
@@ -34,12 +33,12 @@ namespace SuperStarTrek.Systems
|
||||
return true;
|
||||
}
|
||||
|
||||
public CommandResult ExecuteCommand(Quadrant quadrant)
|
||||
internal CommandResult ExecuteCommand(Quadrant quadrant)
|
||||
=> CanExecuteCommand() ? ExecuteCommandCore(quadrant) : CommandResult.Ok;
|
||||
|
||||
protected abstract CommandResult ExecuteCommandCore(Quadrant quadrant);
|
||||
|
||||
public virtual void Repair()
|
||||
internal virtual void Repair()
|
||||
{
|
||||
if (IsDamaged)
|
||||
{
|
||||
@@ -47,7 +46,7 @@ namespace SuperStarTrek.Systems
|
||||
}
|
||||
}
|
||||
|
||||
public virtual bool Repair(float repairWorkDone)
|
||||
internal virtual bool Repair(float repairWorkDone)
|
||||
{
|
||||
if (IsDamaged)
|
||||
{
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace SuperStarTrek.Systems
|
||||
private readonly Output _output;
|
||||
private readonly Input _input;
|
||||
|
||||
public WarpEngines(Enterprise enterprise, Output output, Input input)
|
||||
internal WarpEngines(Enterprise enterprise, Output output, Input input)
|
||||
: base("Warp Engines", Command.NAV, output)
|
||||
{
|
||||
_enterprise = enterprise;
|
||||
|
||||
@@ -14,13 +14,13 @@ namespace SuperStarTrek.Utils
|
||||
_fromY = fromY;
|
||||
}
|
||||
|
||||
public static DirectionAndDistance From(Coordinates coordinates) => From(coordinates.X, coordinates.Y);
|
||||
internal static DirectionAndDistance From(Coordinates coordinates) => From(coordinates.X, coordinates.Y);
|
||||
|
||||
public static DirectionAndDistance From(float x, float y) => new DirectionAndDistance(x, y);
|
||||
internal static DirectionAndDistance From(float x, float y) => new DirectionAndDistance(x, y);
|
||||
|
||||
public (float Direction, float Distance) To(Coordinates coordinates) => To(coordinates.X, coordinates.Y);
|
||||
internal (float Direction, float Distance) To(Coordinates coordinates) => To(coordinates.X, coordinates.Y);
|
||||
|
||||
public (float Direction, float Distance) To(float x, float y)
|
||||
internal (float Direction, float Distance) To(float x, float y)
|
||||
{
|
||||
var deltaX = x - _fromX;
|
||||
var deltaY = y - _fromY;
|
||||
|
||||
Reference in New Issue
Block a user