Adding unit tests
This commit is contained in:
@@ -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))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user