Program: Add option to set phase length

This commit is contained in:
OatmealDome 2024-08-09 22:22:00 -04:00
parent 88f893982b
commit 1e248e2f9d
2 changed files with 15 additions and 8 deletions

View File

@ -13,10 +13,11 @@ Usage:
Rotationator <lastByaml> <outputByaml> [options]
Arguments:
<lastByaml> The last VSSetting BYAML file.
<lastByaml> The last VSSetting BYAML file.
<outputByaml> The output VSSetting BYAML file.
Options:
--version Show version information
-?, -h, --help Show help and usage information
--phaseLength <phaseLength> The length of each phase, in hours. [default: 4]
--version Show version information
-?, -h, --help Show help and usage information
```

View File

@ -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<VersusRule, List<int>> bannedStages = new Dictionary<VersusRule, List<int>>()
{
@ -63,10 +64,14 @@ Argument<string> lastByamlArg = new Argument<string>("lastByaml", "The last VSSe
Argument<string> outputByamlArg = new Argument<string>("outputByaml", "The output VSSetting BYAML file.");
Option<int> phaseLengthOption =
new Option<int>("--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);
}
}