Adding a property to spawnable that denotes that the spawnable is consumed when an action is successfully performed

This commit is contained in:
hz
2025-06-09 18:57:59 -05:00
parent 8ac2b5865f
commit aa8c969906
3 changed files with 60 additions and 1 deletions
+20
View File
@@ -328,7 +328,27 @@ public class PlayerController : ControllerBase
{
cumulative += outcome.SuccessRate;
if (roll < cumulative)
{
if (!string.IsNullOrEmpty(player.InventoryLocationId))
{
var newItem = new Item
{
Name = outcome.Result,
LocationId = player.InventoryLocationId
};
await _itemService.CreateAsync(newItem);
await _locationService.AddItemToLocationAsync(player.InventoryLocationId, newItem.Id);
}
if (spawnable.ConsumeOnSuccess)
{
await _locationService.RemoveItemFromLocationAsync(location.Id, itemId);
await _itemService.DeleteAsync(itemId);
}
return Ok(outcome.Result);
}
}
return Ok("Nothing happens.");