Adding unit tests

This commit is contained in:
hz
2025-06-04 21:33:44 -05:00
parent 638d73561d
commit ec38498957
17 changed files with 468 additions and 33 deletions
+5 -4
View File
@@ -154,6 +154,9 @@ public class PlayerController : ControllerBase
if (currentLocation == null)
return BadRequest("Current location not found.");
if (string.IsNullOrWhiteSpace(req.Direction))
return BadRequest("Direction is required.");
var direction = req.Direction.ToUpper();
var directionMap = new Dictionary<string, (int dx, int dy, string reverse)>
{
@@ -189,16 +192,14 @@ public class PlayerController : ControllerBase
// Generate new location
var newX = currentLocation.X + dx;
var newY = currentLocation.Y + dy;
var random = new Random();
var newZ = currentLocation.Z + random.Next(-1, 2); // -1, 0, or +1
var newZ = currentLocation.Z + Random.Shared.Next(-1, 2); // -1, 0, or +1
string itemId = null;
var spawnables = await _spawnableService.GetAllAsync();
if (spawnables.Any())
{
var rng = new Random();
var roll = rng.Next(0, 100); // 0–99
var roll = Random.Shared.Next(0, 100); // 0–99
foreach (var s in spawnables.OrderBy(s => s.SpawnRate))
{