Fix display of quadrant after move

This commit is contained in:
Andrew Cooper
2021-04-15 22:24:11 +10:00
parent 1c1eead60a
commit f3fce146e5
3 changed files with 9 additions and 8 deletions

View File

@@ -51,8 +51,6 @@ namespace SuperStarTrek
while (!gameOver) while (!gameOver)
{ {
_enterprise.Quadrant.Display(Strings.NowEntering);
var command = _input.GetCommand(); var command = _input.GetCommand();
var result = _enterprise.Execute(command); var result = _enterprise.Execute(command);

View File

@@ -14,7 +14,7 @@ namespace SuperStarTrek.Space
private readonly Dictionary<Coordinates, object> _sectors; private readonly Dictionary<Coordinates, object> _sectors;
private readonly Enterprise _enterprise; private readonly Enterprise _enterprise;
private readonly Output _output; private readonly Output _output;
private bool _displayed = false; private bool _entered = false;
internal Quadrant( internal Quadrant(
QuadrantInfo info, QuadrantInfo info,
@@ -77,9 +77,11 @@ namespace SuperStarTrek.Space
internal void Display(string textFormat) internal void Display(string textFormat)
{ {
if (_displayed) { return; } if (!_entered)
{
_output.Write(textFormat, this); _output.Write(textFormat, this);
_entered = true;
}
if (_info.KlingonCount > 0) if (_info.KlingonCount > 0)
{ {
@@ -88,8 +90,6 @@ namespace SuperStarTrek.Space
} }
_enterprise.Execute(Command.SRS); _enterprise.Execute(Command.SRS);
_displayed = true;
} }
internal bool HasObjectAt(Coordinates coordinates) => _sectors.ContainsKey(coordinates); internal bool HasObjectAt(Coordinates coordinates) => _sectors.ContainsKey(coordinates);

View File

@@ -1,6 +1,7 @@
using System; using System;
using SuperStarTrek.Commands; using SuperStarTrek.Commands;
using SuperStarTrek.Objects; using SuperStarTrek.Objects;
using SuperStarTrek.Resources;
using SuperStarTrek.Space; using SuperStarTrek.Space;
namespace SuperStarTrek.Systems namespace SuperStarTrek.Systems
@@ -39,6 +40,8 @@ namespace SuperStarTrek.Systems
_enterprise.PhotonTubes.ReplenishTorpedoes(); _enterprise.PhotonTubes.ReplenishTorpedoes();
} }
_enterprise.Quadrant.Display(Strings.NowEntering);
return CommandResult.Elapsed(timeElapsed); return CommandResult.Elapsed(timeElapsed);
} }