mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2025-12-22 23:26:40 -08:00
Add game loops and betting
This commit is contained in:
20
30_Cube/csharp/IOExtensions.cs
Normal file
20
30_Cube/csharp/IOExtensions.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
namespace Cube;
|
||||
|
||||
internal static class IOExtensions
|
||||
{
|
||||
internal static float? ReadWager(this IReadWrite io, float balance)
|
||||
{
|
||||
io.Write(Streams.Wager);
|
||||
if (io.ReadNumber("") == 0) { return null; }
|
||||
|
||||
var prompt = Prompts.HowMuch;
|
||||
|
||||
while(true)
|
||||
{
|
||||
var wager = io.ReadNumber(prompt);
|
||||
if (wager <= balance) { return wager; }
|
||||
|
||||
prompt = Prompts.BetAgain;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user