Compare commits
No commits in common. "864a933ba0ae811fb104a36adba256d8b93bf265" and "5b32786904b17c3073a6ae70121c068162c4af39" have entirely different histories.
864a933ba0
...
5b32786904
|
@ -121,41 +121,7 @@ public class AdjudicationQueryScriptHandler(
|
|||
|
||||
case "holds":
|
||||
case "dislodged":
|
||||
re = new(World);
|
||||
prov = new($"^{re.FullLocation}$", RegexOptions.IgnoreCase);
|
||||
match = prov.Match(args[1]);
|
||||
if (!match.Success) return ScriptResult.Fail($"Could not parse province from \"{args[1]}\"", this);
|
||||
|
||||
timeline = match.Groups[1].Length > 0
|
||||
? match.Groups[1].Value
|
||||
: Season.First.Timeline;
|
||||
seasonsInTimeline = World.Timelines.Seasons.Where(season => season.Timeline == timeline);
|
||||
if (!seasonsInTimeline.Any()) return ScriptResult.Fail($"No seasons in timeline {timeline}", this);
|
||||
|
||||
turn = match.Groups[4].Length > 0
|
||||
? int.Parse(match.Groups[4].Value)
|
||||
// If turn is unspecified, use the second-latest turn in the timeline,
|
||||
// since we want to assert against the subjects of the orders just adjudicated,
|
||||
// and adjudication created a new set of seasons.
|
||||
: seasonsInTimeline.Max(season => season.Turn) - 1;
|
||||
season = new(timeline, turn);
|
||||
|
||||
province = World.Map.Provinces.Single(province => province.Is(match.Groups[2].Value));
|
||||
|
||||
var matchingDislodges = Adjudications.Where(adj
|
||||
=> adj is IsDislodged dislodge
|
||||
&& dislodge.Order.Unit.Season == season
|
||||
&& World.Map.GetLocation(dislodge.Order.Unit.Location).ProvinceName == province.Name);
|
||||
if (!matchingDislodges.Any()) return ScriptResult.Fail("No matching dislodge decisions");
|
||||
var isDislodged = matchingDislodges.Cast<IsDislodged>().First();
|
||||
|
||||
if (args[0] == "holds" && isDislodged.Outcome != false) {
|
||||
return ScriptResult.Fail($"Adjudication {isDislodged} is true");
|
||||
}
|
||||
if (args[0] == "dislodged" && isDislodged.Outcome != true) {
|
||||
return ScriptResult.Fail($"Adjudication {isDislodged} is false");
|
||||
}
|
||||
return ScriptResult.Succeed(this);
|
||||
return ScriptResult.Fail($"Unknown assertion \"{args[0]}\"", this);
|
||||
|
||||
case "moves":
|
||||
case "no-move":
|
||||
|
@ -197,41 +163,7 @@ public class AdjudicationQueryScriptHandler(
|
|||
|
||||
case "support-given":
|
||||
case "support-cut":
|
||||
re = new(World);
|
||||
prov = new($"^{re.FullLocation}$", RegexOptions.IgnoreCase);
|
||||
match = prov.Match(args[1]);
|
||||
if (!match.Success) return ScriptResult.Fail($"Could not parse province from \"{args[1]}\"", this);
|
||||
|
||||
timeline = match.Groups[1].Length > 0
|
||||
? match.Groups[1].Value
|
||||
: Season.First.Timeline;
|
||||
seasonsInTimeline = World.Timelines.Seasons.Where(season => season.Timeline == timeline);
|
||||
if (!seasonsInTimeline.Any()) return ScriptResult.Fail($"No seasons in timeline {timeline}", this);
|
||||
|
||||
turn = match.Groups[4].Length > 0
|
||||
? int.Parse(match.Groups[4].Value)
|
||||
// If turn is unspecified, use the second-latest turn in the timeline,
|
||||
// since we want to assert against the subjects of the orders just adjudicated,
|
||||
// and adjudication created a new set of seasons.
|
||||
: seasonsInTimeline.Max(season => season.Turn) - 1;
|
||||
season = new(timeline, turn);
|
||||
|
||||
province = World.Map.Provinces.Single(province => province.Is(match.Groups[2].Value));
|
||||
|
||||
var matchingSupports = Adjudications.Where(adj
|
||||
=> adj is GivesSupport sup
|
||||
&& sup.Order.Unit.Season == season
|
||||
&& World.Map.GetLocation(sup.Order.Unit.Location).ProvinceName == province.Name);
|
||||
if (!matchingSupports.Any()) return ScriptResult.Fail("No matching support decisions");
|
||||
var supports = matchingSupports.Cast<GivesSupport>().First();
|
||||
|
||||
if (args[0] == "support-given" && supports.Outcome != true) {
|
||||
return ScriptResult.Fail($"Adjudication {supports} is false");
|
||||
}
|
||||
if (args[0] == "support-cut" && supports.Outcome != false) {
|
||||
return ScriptResult.Fail($"Adjudication {supports} is true");
|
||||
}
|
||||
return ScriptResult.Succeed(this);
|
||||
return ScriptResult.Fail($"Unknown assertion \"{args[0]}\"", this);
|
||||
|
||||
default:
|
||||
return ScriptResult.Fail($"Unknown assertion \"{args[0]}\"", this);
|
||||
|
|
Loading…
Reference in New Issue