Commit 75bef5bd authored by Adrian Sutton's avatar Adrian Sutton

op-challenger: Add rule to prevent defending the root claim.

parent 64a91e60
......@@ -15,6 +15,7 @@ var rules = []actionRule{
onlyMoveBeforeMaxDepth,
onlyCounterClaimsAtDisagreeingLevels,
doNotDuplicateExistingMoves,
doNotDefendRootClaim,
}
func checkRules(game types.Game, action types.Action) error {
......@@ -75,6 +76,13 @@ func doNotDuplicateExistingMoves(game types.Game, action types.Action) error {
return nil
}
func doNotDefendRootClaim(game types.Game, action types.Action) error {
if game.Claims()[action.ParentIdx].IsRootPosition() && !action.IsAttack {
return fmt.Errorf("defending the root claim at idx %v", action.ParentIdx)
}
return nil
}
func resultingPosition(game types.Game, action types.Action) types.Position {
parentPos := game.Claims()[action.ParentIdx].Position
if action.Type == types.ActionTypeStep {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment