Add command-line switch

This commit is contained in:
Andrew Cooper
2022-07-24 16:36:48 +10:00
parent d1cf340e9f
commit 06386a6d5f
3 changed files with 14 additions and 2 deletions

View File

@@ -5,4 +5,6 @@ global using static Cube.Resources.Resource;
using Cube;
new Game(new ConsoleIO(), new RandomNumberGenerator()).Play();
IRandom random = args.Contains("--non-random") ? new ZerosGenerator() : new RandomNumberGenerator();
new Game(new ConsoleIO(), random).Play();

View File

@@ -9,4 +9,4 @@ allows the game to be run in a deterministic (non-random) mode.
Running the C# port without command-line parameters will play the game with random mine locations.
Running the port with a `-d` command-line switch will run the game with non-random mine locations.
Running the port with a `--non-random` command-line switch will run the game with non-random mine locations.

View File

@@ -0,0 +1,10 @@
namespace Cube;
internal class ZerosGenerator : IRandom
{
public float NextFloat() => 0;
public float PreviousFloat() => 0;
public void Reseed(int seed) { }
}