Enable fluent definitions of multiple turns

This commit is contained in:
Jaculabilis 2022-03-29 21:01:15 -07:00
parent b347cc88aa
commit 604dda95e8
2 changed files with 17 additions and 9 deletions

View File

@ -167,6 +167,11 @@ public class TestCaseBuilder
/// </summary> /// </summary>
public interface IOrderDefinedContext<OrderType> where OrderType : Order public interface IOrderDefinedContext<OrderType> where OrderType : Order
{ {
/// <summary>
/// Perform validation, adjudication, and update using the defined orders.
/// </summary>
public TestCaseBuilder Execute(IPhaseAdjudicator adjudicator);
/// <summary> /// <summary>
/// Choose a new season to define orders for. /// Choose a new season to define orders for.
/// </summary> /// </summary>
@ -579,6 +584,14 @@ public class TestCaseBuilder
this.Order = order; this.Order = order;
} }
public TestCaseBuilder Execute(IPhaseAdjudicator adjudicator)
{
this.Builder.ValidateOrders(adjudicator);
this.Builder.AdjudicateOrders(adjudicator);
this.Builder.UpdateWorld(adjudicator);
return this.Builder;
}
public ISeasonContext this[(int turn, int timeline) seasonCoord] public ISeasonContext this[(int turn, int timeline) seasonCoord]
=> this.SeasonContext[seasonCoord]; => this.SeasonContext[seasonCoord];

View File

@ -13,18 +13,13 @@ public class TimeTravelTest
{ {
TestCaseBuilder setup = new(World.WithStandardMap()); TestCaseBuilder setup = new(World.WithStandardMap());
// Hold once so the timeline has a past. // Hold to move into the future, then move back into the past.
setup[(0, 0)] setup[(0, 0)]
.GetReference(out Season s0) .GetReference(out Season s0)
["Germany"] ["Germany"]
.Army("Mun").Holds().GetReference(out var mun0); .Army("Mun").Holds().GetReference(out var mun0)
.Execute(MovementPhaseAdjudicator.Instance)
setup.ValidateOrders(MovementPhaseAdjudicator.Instance); [(1, 0)]
setup.AdjudicateOrders(MovementPhaseAdjudicator.Instance);
setup.UpdateWorld(MovementPhaseAdjudicator.Instance);
// Move into the past of the same timeline.
setup[(1, 0)]
.GetReference(out Season s1) .GetReference(out Season s1)
["Germany"] ["Germany"]
.Army("Mun").MovesTo("Tyr", season: s0).GetReference(out var mun1); .Army("Mun").MovesTo("Tyr", season: s0).GetReference(out var mun1);