From 36f67c54367bbc2347aaf5d488c94ab9faaafc48 Mon Sep 17 00:00:00 2001 From: Oliveriver Date: Thu, 1 Aug 2024 18:53:52 +0100 Subject: [PATCH] Partially fix convoy location validation --- server/Adjudication/Validation/Validator.cs | 14 ++++++++++++-- server/Repositories/GameRepository.cs | 1 + 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/server/Adjudication/Validation/Validator.cs b/server/Adjudication/Validation/Validator.cs index 57f9e63..423d427 100644 --- a/server/Adjudication/Validation/Validator.cs +++ b/server/Adjudication/Validation/Validator.cs @@ -63,8 +63,18 @@ private void ValidateConvoys() foreach (var convoy in convoys) { // TODO fix for convoying to/from land regions with child coasts - var convoysFromCoast = regions.First(r => r.Id == convoy.Midpoint.RegionId); - var convoysToCoast = regions.First(r => r.Id == convoy.Destination.RegionId); + var locationRegion = regions.First(r => r.Id == convoy.Location.RegionId); + var midpointRegion = regions.First(r => r.Id == convoy.Midpoint.RegionId); + var destinationRegion = regions.First(r => r.Id == convoy.Destination.RegionId); + + if (locationRegion.Type != RegionType.Sea + || midpointRegion.Type != RegionType.Coast + || destinationRegion.Type != RegionType.Coast) + { + convoy.Status = OrderStatus.Invalid; + continue; + } + var hasMatchingMove = world.Orders .OfType() .Any(m => m.Location == convoy.Midpoint && m.Destination == convoy.Destination); diff --git a/server/Repositories/GameRepository.cs b/server/Repositories/GameRepository.cs index 4cd7415..5e46f04 100644 --- a/server/Repositories/GameRepository.cs +++ b/server/Repositories/GameRepository.cs @@ -52,6 +52,7 @@ public async Task CreateSandboxGame() return game; } + // TODO allow re-joining sandbox game public async Task<(Game game, Nation player)> JoinGame(int id, Nation? player) { logger.LogInformation("Joining game {Id} as player {Player}", id, player);