mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2025-12-22 23:26:40 -08:00
Fix compiler messages
This commit is contained in:
@@ -4,7 +4,7 @@ namespace SuperStarTrek
|
|||||||
{
|
{
|
||||||
internal class Random
|
internal class Random
|
||||||
{
|
{
|
||||||
private static readonly System.Random _random = new();
|
private readonly System.Random _random = new();
|
||||||
|
|
||||||
internal Coordinates GetCoordinate() => new Coordinates(Get1To8Inclusive() - 1, Get1To8Inclusive() - 1);
|
internal Coordinates GetCoordinate() => new Coordinates(Get1To8Inclusive() - 1, Get1To8Inclusive() - 1);
|
||||||
|
|
||||||
|
|||||||
@@ -35,9 +35,7 @@ namespace SuperStarTrek.Resources
|
|||||||
private static string GetResource([CallerMemberName] string name = "")
|
private static string GetResource([CallerMemberName] string name = "")
|
||||||
{
|
{
|
||||||
var streamName = $"SuperStarTrek.Resources.{name}.txt";
|
var streamName = $"SuperStarTrek.Resources.{name}.txt";
|
||||||
using var stream = Assembly
|
using var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(streamName);
|
||||||
.GetExecutingAssembly()
|
|
||||||
.GetManifestResourceStream(streamName);
|
|
||||||
using var reader = new StreamReader(stream);
|
using var reader = new StreamReader(stream);
|
||||||
|
|
||||||
return reader.ReadToEnd();
|
return reader.ReadToEnd();
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ namespace SuperStarTrek.Space
|
|||||||
internal int RegionIndex { get; }
|
internal int RegionIndex { get; }
|
||||||
internal int SubRegionIndex { get; }
|
internal int SubRegionIndex { get; }
|
||||||
|
|
||||||
private int Validated(int value, string argumentName)
|
private static int Validated(int value, string argumentName)
|
||||||
{
|
{
|
||||||
if (value >= 0 && value <= 7) { return value; }
|
if (value >= 0 && value <= 7) { return value; }
|
||||||
|
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ namespace SuperStarTrek.Space
|
|||||||
return (xComplete && yComplete, new Coordinates(quadrantX, quadrantY), new Coordinates(sectorX, sectorY));
|
return (xComplete && yComplete, new Coordinates(quadrantX, quadrantY), new Coordinates(sectorX, sectorY));
|
||||||
}
|
}
|
||||||
|
|
||||||
private (bool, int, int) GetNewCoordinate(int quadrant, int sector, float sectorsTravelled)
|
private static (bool, int, int) GetNewCoordinate(int quadrant, int sector, float sectorsTravelled)
|
||||||
{
|
{
|
||||||
var galacticCoordinate = quadrant * 8 + sector + sectorsTravelled;
|
var galacticCoordinate = quadrant * 8 + sector + sectorsTravelled;
|
||||||
var newQuadrant = (int)(galacticCoordinate / 8);
|
var newQuadrant = (int)(galacticCoordinate / 8);
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ namespace SuperStarTrek.Space
|
|||||||
private static readonly string[] _regionNames;
|
private static readonly string[] _regionNames;
|
||||||
private static readonly string[] _subRegionIdentifiers;
|
private static readonly string[] _subRegionIdentifiers;
|
||||||
private readonly QuadrantInfo[][] _quadrants;
|
private readonly QuadrantInfo[][] _quadrants;
|
||||||
private readonly Random _random;
|
|
||||||
|
|
||||||
static Galaxy()
|
static Galaxy()
|
||||||
{
|
{
|
||||||
@@ -21,8 +20,6 @@ namespace SuperStarTrek.Space
|
|||||||
|
|
||||||
internal Galaxy(Random random)
|
internal Galaxy(Random random)
|
||||||
{
|
{
|
||||||
_random = random;
|
|
||||||
|
|
||||||
_quadrants = Enumerable
|
_quadrants = Enumerable
|
||||||
.Range(0, 8)
|
.Range(0, 8)
|
||||||
.Select(x => Enumerable
|
.Select(x => Enumerable
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ namespace SuperStarTrek.Utils
|
|||||||
// 8430 PRINT"DIRECTION =";C1+(((ABS(X)-ABS(A))+ABS(X))/ABS(X)):GOTO8460
|
// 8430 PRINT"DIRECTION =";C1+(((ABS(X)-ABS(A))+ABS(X))/ABS(X)):GOTO8460
|
||||||
// 8450 PRINT"DIRECTION =";C1+(ABS(X)/ABS(A))
|
// 8450 PRINT"DIRECTION =";C1+(ABS(X)/ABS(A))
|
||||||
// 8460 PRINT"DISTANCE =";SQR(X^2+A^2):IFH8=1THEN1990
|
// 8460 PRINT"DISTANCE =";SQR(X^2+A^2):IFH8=1THEN1990
|
||||||
private float GetDirection(float deltaX, float deltaY)
|
private static float GetDirection(float deltaX, float deltaY)
|
||||||
{
|
{
|
||||||
var deltaXDominant = Math.Abs(deltaX) > Math.Abs(deltaY);
|
var deltaXDominant = Math.Abs(deltaX) > Math.Abs(deltaY);
|
||||||
var fractionalPart = deltaXDominant ? deltaY / deltaX : -deltaX / deltaY;
|
var fractionalPart = deltaXDominant ? deltaY / deltaX : -deltaX / deltaY;
|
||||||
@@ -59,7 +59,7 @@ namespace SuperStarTrek.Utils
|
|||||||
return direction < 1 ? direction + 8 : direction;
|
return direction < 1 ? direction + 8 : direction;
|
||||||
}
|
}
|
||||||
|
|
||||||
private float GetDistance(float deltaX, float deltaY) =>
|
private static float GetDistance(float deltaX, float deltaY) =>
|
||||||
(float)Math.Sqrt(Math.Pow(deltaX, 2) + Math.Pow(deltaY, 2));
|
(float)Math.Sqrt(Math.Pow(deltaX, 2) + Math.Pow(deltaY, 2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user