mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2025-12-22 15:16:33 -08:00
Fix game loop and finished message
This commit is contained in:
@@ -36,10 +36,15 @@ internal class Game
|
||||
|
||||
while (true)
|
||||
{
|
||||
if (TryBuild(yourBug, m => m.You) || TryBuild(myBug, m => m.I))
|
||||
var partAdded = TryBuild(yourBug, m => m.You);
|
||||
Thread.Sleep(500);
|
||||
_io.WriteLine();
|
||||
partAdded |= TryBuild(myBug, m => m.I);
|
||||
|
||||
if (partAdded)
|
||||
{
|
||||
if (yourBug.IsComplete) { _io.WriteLine(Message.Complete.You); }
|
||||
if (myBug.IsComplete) { _io.WriteLine(Message.Complete.I); }
|
||||
if (yourBug.IsComplete) { _io.WriteLine("Your bug is finished."); }
|
||||
if (myBug.IsComplete) { _io.WriteLine("My bug is finished."); }
|
||||
|
||||
if (!_io.ReadString("Do you want the picture").Equals("no", InvariantCultureIgnoreCase))
|
||||
{
|
||||
|
||||
@@ -36,10 +36,10 @@ internal class PartCollection
|
||||
{
|
||||
if (_count == 0) { return; }
|
||||
|
||||
builder.Append(' ', offset);
|
||||
|
||||
for (var i = 0; i < length; i++)
|
||||
{
|
||||
builder.Append(' ', offset);
|
||||
|
||||
for (var j = 0; j < _count; j++)
|
||||
{
|
||||
builder.Append(character).Append(' ');
|
||||
|
||||
@@ -27,7 +27,7 @@ internal class Message
|
||||
public static Message Complete = new("bug is finished.");
|
||||
|
||||
private Message(string common)
|
||||
: this("I " + common, "You" + common)
|
||||
: this("I " + common, "You " + common)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ internal class Message
|
||||
public string I { get; }
|
||||
public string You { get; }
|
||||
|
||||
public static Message DoNotHaveA(Part part) => new($"do no have a {part.Name}");
|
||||
public static Message DoNotHaveA(Part part) => new($"do not have a {part.Name}");
|
||||
|
||||
public Message ForValue(int quantity) => new(string.Format(I, quantity), string.Format(You, quantity));
|
||||
}
|
||||
Reference in New Issue
Block a user