diff --git a/microservices/CharacterApi/Services/CharacterStore.cs b/microservices/CharacterApi/Services/CharacterStore.cs index 07a00a9..14392ad 100644 --- a/microservices/CharacterApi/Services/CharacterStore.cs +++ b/microservices/CharacterApi/Services/CharacterStore.cs @@ -47,23 +47,26 @@ public class CharacterStore return result.ModifiedCount > 0 || result.MatchedCount > 0; } - public Task> GetVisibleOthersAsync(string characterId, int x, int y, int radius, DateTime onlineSinceUtc) => - _col.Find(c => + public async Task> GetVisibleOthersAsync(string characterId, int x, int y, int radius, DateTime onlineSinceUtc) + { + var characters = await _col.Find(c => c.Id != characterId && c.Coord.X >= x - radius && c.Coord.X <= x + radius && c.Coord.Y >= y - radius && c.Coord.Y <= y + radius && c.LastSeenUtc >= onlineSinceUtc) - .Project(c => new VisibleCharacter - { - Id = c.Id ?? string.Empty, - Name = c.Name, - Coord = c.Coord, - LastSeenUtc = c.LastSeenUtc - }) .ToListAsync(); + return characters.Select(c => new VisibleCharacter + { + Id = c.Id ?? string.Empty, + Name = c.Name, + Coord = c.Coord, + LastSeenUtc = c.LastSeenUtc + }).ToList(); + } + public async Task DeleteForOwnerAsync(string id, string ownerUserId, bool allowAnyOwner) { var filter = Builders.Filter.Eq(c => c.Id, id);