mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2026-01-08 19:33:31 -08:00
40 lines
1.2 KiB
C#
40 lines
1.2 KiB
C#
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using SuperStarTrek.Commands;
|
|
using SuperStarTrek.Objects;
|
|
using SuperStarTrek.Resources;
|
|
using SuperStarTrek.Space;
|
|
|
|
namespace SuperStarTrek.Systems
|
|
{
|
|
internal class LongRangeSensors : Subsystem
|
|
{
|
|
private readonly Galaxy _galaxy;
|
|
private readonly Output _output;
|
|
|
|
public LongRangeSensors(Galaxy galaxy, Output output)
|
|
: base("Long Range Sensors", Command.LRS, output)
|
|
{
|
|
_galaxy = galaxy;
|
|
_output = output;
|
|
}
|
|
|
|
protected override bool CanExecuteCommand() => IsOperational("{name} are inoperable");
|
|
|
|
protected override CommandResult ExecuteCommandCore(Quadrant quadrant)
|
|
{
|
|
_output.WriteLine($"Long range scan for quadrant {quadrant.Coordinates}");
|
|
_output.WriteLine("-------------------");
|
|
foreach (var quadrants in _galaxy.GetNeighborhood(quadrant))
|
|
{
|
|
_output.WriteLine(": " + string.Join(" : ", quadrants.Select(q => q?.Scan() ?? "***")) + " :");
|
|
_output.WriteLine("-------------------");
|
|
}
|
|
|
|
return CommandResult.Ok;
|
|
}
|
|
}
|
|
}
|