mirror of
https://github.com/SoDOff-Project/sodoff.git
synced 2025-10-11 08:18:49 -07:00
bugfixes: removing item in SetCommonInventory, ...
- fix removing item from inventtory in SetCommonInventory (regresion after switch to InventoryService) - fix null exception in SellItem on invalid UserInventoryCommonIDs - remove unused fields in AchievementService (are in AchievementStoreSingleton)
This commit is contained in:
parent
883fbd2181
commit
ed8cba8159
@ -176,7 +176,7 @@ public class ContentController : Controller {
|
||||
// Now that we know the request is valid, update the inventory
|
||||
foreach (var req in request) {
|
||||
if (req.ItemID == 0) continue; // Do not save a null item
|
||||
|
||||
|
||||
if (inventoryService.ItemNeedUniqueInventorySlot((int)req.ItemID)) {
|
||||
// if req.Quantity < 0 remove unique items
|
||||
for (int i=req.Quantity; i<0; ++i) {
|
||||
@ -190,10 +190,9 @@ public class ContentController : Controller {
|
||||
);
|
||||
}
|
||||
} else {
|
||||
var responseItem = inventoryService.AddItemToInventoryAndGetResponse(viking, (int)req.ItemID!, req.Quantity);
|
||||
if (req.Quantity > 0) {
|
||||
responseItems.Add(
|
||||
inventoryService.AddItemToInventoryAndGetResponse(viking, (int)req.ItemID!, req.Quantity)
|
||||
);
|
||||
responseItems.Add(responseItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1016,6 +1015,10 @@ public class ContentController : Controller {
|
||||
inventoryService.SellInventoryItem(viking, invItemID, ref gold, ref shard);
|
||||
}
|
||||
|
||||
if (gold == 0 && shard == 0) { // NOTE: client sometimes call SellItems with invalid UserInventoryCommonIDs for unknown reasons
|
||||
return Ok(new CommonInventoryResponse { Success = false });
|
||||
}
|
||||
|
||||
// apply shards reward
|
||||
CommonInventoryResponseItem resShardsItem = inventoryService.AddItemToInventoryAndGetResponse(viking, InventoryService.Shards, shard);
|
||||
|
||||
|
@ -10,13 +10,6 @@ namespace sodoff.Services {
|
||||
private AchievementStoreSingleton achievementStore;
|
||||
private InventoryService inventoryService;
|
||||
|
||||
Dictionary<AchievementPointTypes, UserRank[]> ranks = new();
|
||||
Dictionary<int, AchievementReward[]> achivmentsRewardByID = new();
|
||||
Dictionary<int, AchievementReward[]> achivmentsRewardByTask = new();
|
||||
|
||||
int dragonAdultMinXP;
|
||||
int dragonTitanMinXP;
|
||||
|
||||
public AchievementService(AchievementStoreSingleton achievementStore, InventoryService inventoryService) {
|
||||
this.achievementStore = achievementStore;
|
||||
this.inventoryService = inventoryService;
|
||||
|
@ -74,6 +74,8 @@ namespace sodoff.Services {
|
||||
public void SellInventoryItem(Viking viking, int invItemID, ref int gold, ref int shard) {
|
||||
// get item from inventory
|
||||
InventoryItem? item = viking.Inventory.InventoryItems.FirstOrDefault(e => e.Id == invItemID);
|
||||
if (item is null)
|
||||
return;
|
||||
|
||||
// get item data
|
||||
ItemData? itemData = itemService.GetItem(item.ItemId);
|
||||
|
Loading…
x
Reference in New Issue
Block a user