mirror of
https://github.com/SoDOff-Project/sodoff.git
synced 2025-10-11 08:18:49 -07:00
fix intenal error on fuse and reroll
This commit is contained in:
parent
2fa842c822
commit
2e9c8f22da
@ -979,6 +979,9 @@ public class ContentController : Controller {
|
|||||||
foreach (string name in req.ItemStatNames) {
|
foreach (string name in req.ItemStatNames) {
|
||||||
ItemStat itemStat = itemStatsMap.ItemStats.FirstOrDefault(e => e.Name == name);
|
ItemStat itemStat = itemStatsMap.ItemStats.FirstOrDefault(e => e.Name == name);
|
||||||
|
|
||||||
|
if (itemStat is null)
|
||||||
|
return Ok(new RollUserItemResponse { Status = Status.InvalidStatsMap });
|
||||||
|
|
||||||
// draw new stats
|
// draw new stats
|
||||||
StatRangeMap rangeMap = itemData.PossibleStatsMap.Stats.FirstOrDefault(e => e.ItemStatsID == itemStat.ItemStatID).ItemStatsRangeMaps.FirstOrDefault(e => e.ItemTierID == (int)(itemStatsMap.ItemTier));
|
StatRangeMap rangeMap = itemData.PossibleStatsMap.Stats.FirstOrDefault(e => e.ItemStatsID == itemStat.ItemStatID).ItemStatsRangeMaps.FirstOrDefault(e => e.ItemTierID == (int)(itemStatsMap.ItemTier));
|
||||||
int newVal = random.Next(rangeMap.StartRange, rangeMap.EndRange+1);
|
int newVal = random.Next(rangeMap.StartRange, rangeMap.EndRange+1);
|
||||||
@ -1062,12 +1065,21 @@ public class ContentController : Controller {
|
|||||||
// remove items from DeductibleItemInventoryMaps and BluePrintFuseItemMaps
|
// remove items from DeductibleItemInventoryMaps and BluePrintFuseItemMaps
|
||||||
foreach (var item in req.DeductibleItemInventoryMaps) {
|
foreach (var item in req.DeductibleItemInventoryMaps) {
|
||||||
InventoryItem? invItem = viking.Inventory.InventoryItems.FirstOrDefault(e => e.Id == item.UserInventoryID);
|
InventoryItem? invItem = viking.Inventory.InventoryItems.FirstOrDefault(e => e.Id == item.UserInventoryID);
|
||||||
|
if (invItem is null) {
|
||||||
|
invItem = viking.Inventory.InventoryItems.FirstOrDefault(e => e.ItemId == item.ItemID);
|
||||||
|
}
|
||||||
|
if (invItem is null || invItem.Quantity < item.Quantity) {
|
||||||
|
return Ok(new FuseItemsResponse { Status = Status.ItemNotFound });
|
||||||
|
}
|
||||||
invItem.Quantity -= item.Quantity;
|
invItem.Quantity -= item.Quantity;
|
||||||
}
|
}
|
||||||
foreach (var item in req.BluePrintFuseItemMaps) {
|
foreach (var item in req.BluePrintFuseItemMaps) {
|
||||||
InventoryItem? invItem = viking.Inventory.InventoryItems.FirstOrDefault(e => e.Id == item.UserInventoryID);
|
InventoryItem? invItem = viking.Inventory.InventoryItems.FirstOrDefault(e => e.Id == item.UserInventoryID);
|
||||||
|
if (invItem is null)
|
||||||
|
return Ok(new FuseItemsResponse { Status = Status.ItemNotFound });
|
||||||
viking.Inventory.InventoryItems.Remove(invItem);
|
viking.Inventory.InventoryItems.Remove(invItem);
|
||||||
}
|
}
|
||||||
|
// NOTE: we haven't saved any changes so far ... so we can safely interrupt "fusing" by return in loops above
|
||||||
|
|
||||||
var resItemList = new List<InventoryItemStatsMap>();
|
var resItemList = new List<InventoryItemStatsMap>();
|
||||||
foreach (BluePrintSpecification output in blueprintItem.BluePrint.Outputs) {
|
foreach (BluePrintSpecification output in blueprintItem.BluePrint.Outputs) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user