Implement support-hold parsing
This commit is contained in:
parent
26f7cee070
commit
ae5eb22010
@ -214,7 +214,8 @@ public class OrderParser(World world)
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool TryParseOrder(World world, string power, string command, [NotNullWhen(true)] out Order? order) {
|
||||
public static bool TryParseOrder(World world, string power, string command, [NotNullWhen(true)] out Order? order)
|
||||
{
|
||||
order = null;
|
||||
OrderParser re = new(world);
|
||||
|
||||
@ -346,7 +347,19 @@ public class OrderParser(World world)
|
||||
{
|
||||
order = null;
|
||||
var support = ParseSupportHold(match);
|
||||
throw new NotImplementedException();
|
||||
|
||||
if (!TryParseOrderSubject(world, support.timeline, support.turn, support.province, out Unit? subject)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!TryParseOrderSubject(
|
||||
world, support.targetTimeline, support.targetTurn, support.targetProvince, out Unit? target))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
order = new SupportHoldOrder(power, subject, target);
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool TryParseSupportMoveOrder(
|
||||
|
@ -161,6 +161,36 @@ public class ReplTest
|
||||
repl.AssertFails("assert no-move Mun");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AssertSupportHold()
|
||||
{
|
||||
var repl = StandardRepl();
|
||||
|
||||
repl.ExecuteAll("""
|
||||
unit Germany A Mun
|
||||
unit Germany A Boh
|
||||
unit Austria A Tyr
|
||||
---
|
||||
Germany Mun s Boh
|
||||
---
|
||||
""");
|
||||
|
||||
// Support is given
|
||||
repl.Execute("assert support-given Mun");
|
||||
repl.AssertFails("assert support-cut Mun");
|
||||
|
||||
repl.ExecuteAll("""
|
||||
---
|
||||
Germany Mun s Boh
|
||||
Austria Tyr - Mun
|
||||
---
|
||||
""");
|
||||
|
||||
// Support is cut
|
||||
repl.Execute("assert support-cut Mun");
|
||||
repl.AssertFails("assert support-given Mun");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AssertDislodged()
|
||||
{
|
||||
@ -183,45 +213,6 @@ public class ReplTest
|
||||
repl.AssertFails("assert holds Tyr");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AssertMoves()
|
||||
{
|
||||
Assert.Ignore();
|
||||
var repl = StandardRepl();
|
||||
|
||||
repl.ExecuteAll("""
|
||||
unit Germany A Mun
|
||||
---
|
||||
Germany Mun - Tyr
|
||||
---
|
||||
""");
|
||||
|
||||
// Assertion should pass for a move
|
||||
repl.Execute("assert moves Mun");
|
||||
// Assertion should fail for a successful move
|
||||
repl.AssertFails("assert no-move Mun");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AssertRepelled()
|
||||
{
|
||||
Assert.Ignore();
|
||||
var repl = StandardRepl();
|
||||
|
||||
repl.ExecuteAll("""
|
||||
unit Germany A Mun
|
||||
unit Austria A Tyr
|
||||
---
|
||||
Germany Mun - Tyr
|
||||
---
|
||||
""");
|
||||
|
||||
// Assertion should pass for a repelled move
|
||||
repl.Execute("assert no-move Mun");
|
||||
// Assertion should fail for no move
|
||||
repl.AssertFails("assert moves Mun");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AssertSupports()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user