Adding inventory stacking and overflow to gather mechanic
Deploy Promiscuity Auth API / deploy (push) Successful in 47s
Deploy Promiscuity Character API / deploy (push) Successful in 44s
Deploy Promiscuity Inventory API / deploy (push) Successful in 58s
Deploy Promiscuity Locations API / deploy (push) Successful in 58s
k8s smoke test / test (push) Successful in 9s

This commit is contained in:
2026-03-19 17:24:10 -05:00
parent 69ff204c5d
commit b8ce13f1d2
6 changed files with 344 additions and 98 deletions
@@ -180,6 +180,64 @@ public class LocationsController : ControllerBase
return StatusCode((int)response.StatusCode, responseBody);
}
var characterGrantedQuantity = interact.QuantityGranted;
var floorGrantedQuantity = 0;
var overflowQuantity = 0;
if (!string.IsNullOrWhiteSpace(responseBody))
{
using var grantJson = JsonDocument.Parse(responseBody);
if (grantJson.RootElement.TryGetProperty("grantedQuantity", out var grantedElement) && grantedElement.ValueKind == JsonValueKind.Number)
characterGrantedQuantity = grantedElement.GetInt32();
if (grantJson.RootElement.TryGetProperty("overflowQuantity", out var overflowElement) && overflowElement.ValueKind == JsonValueKind.Number)
overflowQuantity = overflowElement.GetInt32();
}
if (overflowQuantity > 0)
{
var floorGrantBody = JsonSerializer.Serialize(new
{
itemKey = interact.ItemKey,
quantity = overflowQuantity
});
using var floorRequest = new HttpRequestMessage(
HttpMethod.Post,
$"{inventoryBaseUrl}/api/inventory/by-owner/location/{id}/grant");
floorRequest.Content = new StringContent(floorGrantBody, Encoding.UTF8, "application/json");
if (!string.IsNullOrWhiteSpace(token))
floorRequest.Headers.Authorization = AuthenticationHeaderValue.Parse(token);
using var floorResponse = await client.SendAsync(floorRequest);
var floorResponseBody = await floorResponse.Content.ReadAsStringAsync();
if (!floorResponse.IsSuccessStatusCode)
{
_logger.LogError(
"Character inventory overflow could not be redirected to location inventory. Location {LocationId}, character {CharacterId}, item {ItemKey}, quantity {Quantity}, response {StatusCode}: {Body}",
id,
req.CharacterId,
interact.ItemKey,
overflowQuantity,
(int)floorResponse.StatusCode,
floorResponseBody
);
return StatusCode((int)floorResponse.StatusCode, floorResponseBody);
}
if (!string.IsNullOrWhiteSpace(floorResponseBody))
{
using var floorJson = JsonDocument.Parse(floorResponseBody);
if (floorJson.RootElement.TryGetProperty("grantedQuantity", out var floorGrantedElement) && floorGrantedElement.ValueKind == JsonValueKind.Number)
floorGrantedQuantity = floorGrantedElement.GetInt32();
else
floorGrantedQuantity = overflowQuantity;
}
else
{
floorGrantedQuantity = overflowQuantity;
}
}
return Ok(new InteractLocationObjectResponse
{
LocationId = id,
@@ -188,6 +246,8 @@ public class LocationsController : ControllerBase
ObjectType = interact.ObjectType,
ItemKey = interact.ItemKey,
QuantityGranted = interact.QuantityGranted,
CharacterGrantedQuantity = characterGrantedQuantity,
FloorGrantedQuantity = floorGrantedQuantity,
RemainingQuantity = interact.RemainingQuantity,
Consumed = interact.Consumed,
InventoryResponseJson = responseBody
@@ -14,6 +14,10 @@ public class InteractLocationObjectResponse
public int QuantityGranted { get; set; }
public int CharacterGrantedQuantity { get; set; }
public int FloorGrantedQuantity { get; set; }
public int RemainingQuantity { get; set; }
public bool Consumed { get; set; }