diff --git a/README.md b/README.md index 451ba36..85d60e1 100644 --- a/README.md +++ b/README.md @@ -13,10 +13,11 @@ Usage: Rotationator [options] Arguments: - The last VSSetting BYAML file. + The last VSSetting BYAML file. The output VSSetting BYAML file. Options: - --version Show version information - -?, -h, --help Show help and usage information + --phaseLength The length of each phase, in hours. [default: 4] + --version Show version information + -?, -h, --help Show help and usage information ``` diff --git a/Rotationator/Program.cs b/Rotationator/Program.cs index 9ddf206..dd09435 100644 --- a/Rotationator/Program.cs +++ b/Rotationator/Program.cs @@ -1,4 +1,4 @@ -using System.CommandLine; +using System.CommandLine; using System.CommandLine.Invocation; using System.Text.Json; using OatmealDome.BinaryData; @@ -11,6 +11,7 @@ using Rotationator; // const int maximumPhases = 192; // TODO correct? +const int defaultPhaseLength = 4; Dictionary> bannedStages = new Dictionary>() { @@ -63,10 +64,14 @@ Argument lastByamlArg = new Argument("lastByaml", "The last VSSe Argument outputByamlArg = new Argument("outputByaml", "The output VSSetting BYAML file."); +Option phaseLengthOption = + new Option("--phaseLength", () => defaultPhaseLength, "The length of each phase in hours."); + Command command = new RootCommand("Generates a new VSSetting BYAMl file.") { lastByamlArg, - outputByamlArg + outputByamlArg, + phaseLengthOption }; command.SetHandler(context => Run(context)); @@ -83,6 +88,7 @@ void Run(InvocationContext context) string lastByamlPath = context.ParseResult.GetValueForArgument(lastByamlArg); string outputByamlPath = context.ParseResult.GetValueForArgument(outputByamlArg); + int phaseLength = context.ParseResult.GetValueForOption(phaseLengthOption); dynamic lastByaml = ByamlFile.Load(lastByamlPath); @@ -127,7 +133,7 @@ void Run(InvocationContext context) } // The last phase is set to 10 years, so correct this to the correct phase length. - currentPhases.Last().Length = 4; + currentPhases.Last().Length = phaseLength; // // Generate new phases to fill out the schedule @@ -161,7 +167,7 @@ void Run(InvocationContext context) currentPhase.GachiInfo.Stages.Add(PickStage(currentPhase, lastPhase, gachiRule, stagePools[gachiRule])); currentPhase.GachiInfo.Stages.Sort(); - currentPhase.Length = 4; + currentPhase.Length = phaseLength; currentPhases.Add(currentPhase); } @@ -274,4 +280,4 @@ int PickStage(GambitVersusPhase phase, GambitVersusPhase lastPhase, VersusRule r } return GetRandomElementFromPool(pool, IsStageValid); -} \ No newline at end of file +}