mirror of
https://github.com/OatmealDome/Rotationator.git
synced 2026-04-26 00:14:02 -05:00
Program: Allow the user to specify the RNG seed
This commit is contained in:
parent
e684a2c3d0
commit
e6b73be0b2
|
|
@ -20,6 +20,7 @@ Options:
|
||||||
--phaseLength <phaseLength> The length of each phase in hours. [default: 4]
|
--phaseLength <phaseLength> The length of each phase in hours. [default: 4]
|
||||||
--scheduleLength <scheduleLength> How long the schedule should be in days. [default: 30]
|
--scheduleLength <scheduleLength> How long the schedule should be in days. [default: 30]
|
||||||
--overridePhases <overridePhases> The override phases file. []
|
--overridePhases <overridePhases> The override phases file. []
|
||||||
|
--randomSeed <randomSeed> The seed for the random number generator. []
|
||||||
--version Show version information
|
--version Show version information
|
||||||
-?, -h, --help Show help and usage information
|
-?, -h, --help Show help and usage information
|
||||||
```
|
```
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
using System.CommandLine;
|
using System.CommandLine;
|
||||||
using System.CommandLine.Invocation;
|
using System.CommandLine.Invocation;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using OatmealDome.BinaryData;
|
using OatmealDome.BinaryData;
|
||||||
|
|
@ -71,13 +71,16 @@ Option<int> scheduleLengthOption = new Option<int>("--scheduleLength", () => def
|
||||||
Option<string?> overridePhasesOption =
|
Option<string?> overridePhasesOption =
|
||||||
new Option<string?>("--overridePhases", () => null, "The override phases file.");
|
new Option<string?>("--overridePhases", () => null, "The override phases file.");
|
||||||
|
|
||||||
|
Option<uint?> seedOption = new Option<uint?>("--randomSeed", () => null, "The seed for the random number generator.");
|
||||||
|
|
||||||
Command command = new RootCommand("Generates a new VSSetting BYAMl file.")
|
Command command = new RootCommand("Generates a new VSSetting BYAMl file.")
|
||||||
{
|
{
|
||||||
lastByamlArg,
|
lastByamlArg,
|
||||||
outputByamlArg,
|
outputByamlArg,
|
||||||
phaseLengthOption,
|
phaseLengthOption,
|
||||||
scheduleLengthOption,
|
scheduleLengthOption,
|
||||||
overridePhasesOption
|
overridePhasesOption,
|
||||||
|
seedOption
|
||||||
};
|
};
|
||||||
|
|
||||||
command.SetHandler(context => Run(context));
|
command.SetHandler(context => Run(context));
|
||||||
|
|
@ -95,8 +98,9 @@ void Run(InvocationContext context)
|
||||||
int phaseLength = context.ParseResult.GetValueForOption(phaseLengthOption);
|
int phaseLength = context.ParseResult.GetValueForOption(phaseLengthOption);
|
||||||
int scheduleLength = context.ParseResult.GetValueForOption(scheduleLengthOption);
|
int scheduleLength = context.ParseResult.GetValueForOption(scheduleLengthOption);
|
||||||
string? overridePhasesPath = context.ParseResult.GetValueForOption(overridePhasesOption);
|
string? overridePhasesPath = context.ParseResult.GetValueForOption(overridePhasesOption);
|
||||||
|
uint? specifiedSeed = context.ParseResult.GetValueForOption(seedOption);
|
||||||
|
|
||||||
uint seed = (uint)Environment.TickCount;
|
uint seed = specifiedSeed ?? (uint)Environment.TickCount;
|
||||||
SeadRandom random = new SeadRandom(seed);
|
SeadRandom random = new SeadRandom(seed);
|
||||||
|
|
||||||
Console.WriteLine("Random seed: " + seed);
|
Console.WriteLine("Random seed: " + seed);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user