Adding player sensing
Deploy Promiscuity Auth API / deploy (push) Successful in 47s
Deploy Promiscuity Character API / deploy (push) Successful in 59s
Deploy Promiscuity Inventory API / deploy (push) Successful in 47s
Deploy Promiscuity Locations API / deploy (push) Successful in 47s
k8s smoke test / test (push) Successful in 9s
Deploy Promiscuity Auth API / deploy (push) Successful in 47s
Deploy Promiscuity Character API / deploy (push) Successful in 59s
Deploy Promiscuity Inventory API / deploy (push) Successful in 47s
Deploy Promiscuity Locations API / deploy (push) Successful in 47s
k8s smoke test / test (push) Successful in 9s
This commit is contained in:
@@ -17,6 +17,8 @@ public class CharacterStore
|
||||
|
||||
var ownerIndex = Builders<Character>.IndexKeys.Ascending(c => c.OwnerUserId);
|
||||
_col.Indexes.CreateOne(new CreateIndexModel<Character>(ownerIndex));
|
||||
var coordIndex = Builders<Character>.IndexKeys.Ascending("Coord.X").Ascending("Coord.Y");
|
||||
_col.Indexes.CreateOne(new CreateIndexModel<Character>(coordIndex));
|
||||
}
|
||||
|
||||
public Task CreateAsync(Character character) => _col.InsertOneAsync(character);
|
||||
@@ -30,11 +32,38 @@ public class CharacterStore
|
||||
public async Task<bool> UpdateCoordAsync(string id, Coord coord)
|
||||
{
|
||||
var filter = Builders<Character>.Filter.Eq(c => c.Id, id);
|
||||
var update = Builders<Character>.Update.Set(c => c.Coord, coord);
|
||||
var update = Builders<Character>.Update
|
||||
.Set(c => c.Coord, coord)
|
||||
.Set(c => c.LastSeenUtc, DateTime.UtcNow);
|
||||
var result = await _col.UpdateOneAsync(filter, update);
|
||||
return result.ModifiedCount > 0 || result.MatchedCount > 0;
|
||||
}
|
||||
|
||||
public async Task<bool> TouchAsync(string id)
|
||||
{
|
||||
var filter = Builders<Character>.Filter.Eq(c => c.Id, id);
|
||||
var update = Builders<Character>.Update.Set(c => c.LastSeenUtc, DateTime.UtcNow);
|
||||
var result = await _col.UpdateOneAsync(filter, update);
|
||||
return result.ModifiedCount > 0 || result.MatchedCount > 0;
|
||||
}
|
||||
|
||||
public Task<List<VisibleCharacter>> GetVisibleOthersAsync(string characterId, int x, int y, int radius, DateTime onlineSinceUtc) =>
|
||||
_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();
|
||||
|
||||
public async Task<bool> DeleteForOwnerAsync(string id, string ownerUserId, bool allowAnyOwner)
|
||||
{
|
||||
var filter = Builders<Character>.Filter.Eq(c => c.Id, id);
|
||||
|
||||
Reference in New Issue
Block a user