Implement repl adjudication
This commit is contained in:
parent
f77cc60185
commit
f02e71d4f9
@ -1,5 +1,6 @@
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
using MultiversalDiplomacy.Adjudicate;
|
||||
using MultiversalDiplomacy.Model;
|
||||
using MultiversalDiplomacy.Orders;
|
||||
|
||||
@ -31,19 +32,31 @@ public class GameScriptHandler(World world, bool strict = false) : IScriptHandle
|
||||
// "---" submits the orders and allows queries about the outcome
|
||||
if (input == "---") {
|
||||
Console.WriteLine("Submitting orders for adjudication");
|
||||
// TODO submit, validate, and adjudicate orders
|
||||
// TODO pass validation, adjudication, and prev/next World to next handler
|
||||
return new AdjudicationQueryScriptHandler(World, Strict);
|
||||
var adjudicator = MovementPhaseAdjudicator.Instance;
|
||||
var validation = adjudicator.ValidateOrders(World, Orders);
|
||||
var validOrders = validation
|
||||
.Where(v => v.Valid)
|
||||
.Select(v => v.Order)
|
||||
.ToList();
|
||||
var adjudication = adjudicator.AdjudicateOrders(World, validOrders);
|
||||
var newWorld = adjudicator.UpdateWorld(World, adjudication);
|
||||
return new AdjudicationQueryScriptHandler(newWorld, Strict);
|
||||
}
|
||||
|
||||
// "===" submits the orders and moves immediately to taking the next set of orders
|
||||
// i.e. it's "---" twice
|
||||
if (input == "===") {
|
||||
Console.WriteLine("Submitting orders for adjudication");
|
||||
// TODO submit, validate, and adjudicate orders
|
||||
// TODO replace World with updated world and return a new handler
|
||||
var adjudicator = MovementPhaseAdjudicator.Instance;
|
||||
var validation = adjudicator.ValidateOrders(World, Orders);
|
||||
var validOrders = validation
|
||||
.Where(v => v.Valid)
|
||||
.Select(v => v.Order)
|
||||
.ToList();
|
||||
var adjudication = adjudicator.AdjudicateOrders(World, validOrders);
|
||||
World = adjudicator.UpdateWorld(World, adjudication);
|
||||
Console.WriteLine("Ready for orders");
|
||||
return new GameScriptHandler(World, Strict);
|
||||
return this;
|
||||
}
|
||||
|
||||
// A block of orders for a single power beginning with "{name}:"
|
||||
|
Loading…
Reference in New Issue
Block a user