mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2026-01-01 15:49:59 -08:00
Add game loop
This commit is contained in:
@@ -24,6 +24,8 @@ internal class Message
|
||||
public static Message LegAdded = new("now have {0} legs");
|
||||
public static Message LegsFull = new("I have 6 feet.", "You have 6 feet already");
|
||||
|
||||
public static Message Complete = new("bug is finished.");
|
||||
|
||||
private Message(string common)
|
||||
: this("I " + common, "You" + common)
|
||||
{
|
||||
@@ -40,5 +42,5 @@ internal class Message
|
||||
|
||||
public static Message DoNotHaveA(Part part) => new($"do no have a {part.Name}");
|
||||
|
||||
public Message ForQuantity(int quantity) => new(string.Format(I, quantity), string.Format(You, quantity));
|
||||
public Message ForValue(int quantity) => new(string.Format(I, quantity), string.Format(You, quantity));
|
||||
}
|
||||
1
16_Bug/csharp/Resources/PlayAgain.txt
Normal file
1
16_Bug/csharp/Resources/PlayAgain.txt
Normal file
@@ -0,0 +1 @@
|
||||
I hope you enjoyed the game, play it again soon!!
|
||||
@@ -9,17 +9,11 @@ internal static class Resource
|
||||
{
|
||||
public static Stream Introduction => GetStream();
|
||||
public static Stream Instructions => GetStream();
|
||||
}
|
||||
|
||||
private static string GetString([CallerMemberName] string? name = null)
|
||||
{
|
||||
using var stream = GetStream(name);
|
||||
using var reader = new StreamReader(stream);
|
||||
return reader.ReadToEnd();
|
||||
public static Stream PlayAgain => GetStream();
|
||||
}
|
||||
|
||||
private static Stream GetStream([CallerMemberName] string? name = null) =>
|
||||
Assembly.GetExecutingAssembly()
|
||||
.GetManifestResourceStream($"{typeof(Resource).Namespace}.{name}.txt")
|
||||
.GetManifestResourceStream($"Bug.Resources.{name}.txt")
|
||||
?? throw new Exception($"Could not find embedded resource stream '{name}'.");
|
||||
}
|
||||
Reference in New Issue
Block a user