Updating location schema to tracker user territory and lock visibility

This commit is contained in:
hz
2026-05-18 13:59:33 -05:00
parent dd151c5af1
commit afeb9cf625
23 changed files with 590 additions and 38 deletions
+43 -1
View File
@@ -21,10 +21,13 @@ public class LocationResponse
public int Q { get; set; }
public int R { get; set; }
public string Terrain { get; set; } = "Field";
public string Kind { get; set; } = "Open";
public string? OwnerUsername { get; set; }
public string? Label { get; set; }
public int Level { get; set; }
public DateTime? HomeAssignedAtUtc { get; set; }
public DateTime UpdatedAtUtc { get; set; }
public bool IsVisible { get; set; } = true;
public static LocationResponse FromLocation(Location location) => new()
{
@@ -32,9 +35,48 @@ public class LocationResponse
Q = location.Q,
R = location.R,
Terrain = location.Terrain,
Kind = location.Kind,
OwnerUsername = location.OwnerUsername,
Label = location.Label,
Level = location.Level,
UpdatedAtUtc = location.UpdatedAtUtc
HomeAssignedAtUtc = location.HomeAssignedAtUtc,
UpdatedAtUtc = location.UpdatedAtUtc,
IsVisible = true
};
public static LocationResponse FromCoordinate(int q, int r) => new()
{
Q = q,
R = r,
Terrain = LocationTerrain.FromCoordinate(q, r),
Kind = "Open",
Level = 1,
UpdatedAtUtc = DateTime.UtcNow,
IsVisible = true
};
}
public static class LocationTerrain
{
public static string FromCoordinate(int q, int r)
{
var height = Math.Max(Math.Max(Math.Abs(q), Math.Abs(r)), Math.Abs(-q - r));
if (height <= 1)
{
return "Command";
}
if ((q * 19 + r * 7) % 5 == 0)
{
return "Highland";
}
if ((q + r) % 4 == 0)
{
return "Forest";
}
if ((q * 3 - r) % 6 == 0)
{
return "Ore";
}
return "Field";
}
}