forked from SoDOff-Project/sodoff
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
@ -190,10 +190,9 @@ public class ContentController : Controller {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
var responseItem = inventoryService.AddItemToInventoryAndGetResponse(viking, (int)req.ItemID!, req.Quantity);
|
||||||
if (req.Quantity > 0) {
|
if (req.Quantity > 0) {
|
||||||
responseItems.Add(
|
responseItems.Add(responseItem);
|
||||||
inventoryService.AddItemToInventoryAndGetResponse(viking, (int)req.ItemID!, req.Quantity)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1016,6 +1015,10 @@ public class ContentController : Controller {
|
|||||||
inventoryService.SellInventoryItem(viking, invItemID, ref gold, ref shard);
|
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
|
// apply shards reward
|
||||||
CommonInventoryResponseItem resShardsItem = inventoryService.AddItemToInventoryAndGetResponse(viking, InventoryService.Shards, shard);
|
CommonInventoryResponseItem resShardsItem = inventoryService.AddItemToInventoryAndGetResponse(viking, InventoryService.Shards, shard);
|
||||||
|
|
||||||
|
@ -10,13 +10,6 @@ namespace sodoff.Services {
|
|||||||
private AchievementStoreSingleton achievementStore;
|
private AchievementStoreSingleton achievementStore;
|
||||||
private InventoryService inventoryService;
|
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) {
|
public AchievementService(AchievementStoreSingleton achievementStore, InventoryService inventoryService) {
|
||||||
this.achievementStore = achievementStore;
|
this.achievementStore = achievementStore;
|
||||||
this.inventoryService = inventoryService;
|
this.inventoryService = inventoryService;
|
||||||
|
@ -74,6 +74,8 @@ namespace sodoff.Services {
|
|||||||
public void SellInventoryItem(Viking viking, int invItemID, ref int gold, ref int shard) {
|
public void SellInventoryItem(Viking viking, int invItemID, ref int gold, ref int shard) {
|
||||||
// get item from inventory
|
// get item from inventory
|
||||||
InventoryItem? item = viking.Inventory.InventoryItems.FirstOrDefault(e => e.Id == invItemID);
|
InventoryItem? item = viking.Inventory.InventoryItems.FirstOrDefault(e => e.Id == invItemID);
|
||||||
|
if (item is null)
|
||||||
|
return;
|
||||||
|
|
||||||
// get item data
|
// get item data
|
||||||
ItemData? itemData = itemService.GetItem(item.ItemId);
|
ItemData? itemData = itemService.GetItem(item.ItemId);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user