Skip to content

Commit

Permalink
Partially fix convoy location validation
Browse files Browse the repository at this point in the history
  • Loading branch information
Oliveriver committed Aug 1, 2024
1 parent 1ab0294 commit 36f67c5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
14 changes: 12 additions & 2 deletions server/Adjudication/Validation/Validator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Move>()
.Any(m => m.Location == convoy.Midpoint && m.Destination == convoy.Destination);
Expand Down
1 change: 1 addition & 0 deletions server/Repositories/GameRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public async Task<Game> 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);
Expand Down

0 comments on commit 36f67c5

Please sign in to comment.