Adding a property to spawnable that denotes that the spawnable is consumed when an action is successfully performed
This commit is contained in:
@@ -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.");
|
||||
|
||||
Reference in New Issue
Block a user