mirror of
https://github.com/SoDOff-Project/sodoff.git
synced 2025-10-11 08:18:49 -07:00
unlock all viking slots (placeholder)
This commit is contained in:
parent
5d62a068ac
commit
17303d9256
@ -128,15 +128,46 @@ public class ContentController : Controller {
|
|||||||
[Produces("application/xml")]
|
[Produces("application/xml")]
|
||||||
[Route("ContentWebService.asmx/GetCommonInventory")]
|
[Route("ContentWebService.asmx/GetCommonInventory")]
|
||||||
public IActionResult GetCommonInventory([FromForm] string apiToken) {
|
public IActionResult GetCommonInventory([FromForm] string apiToken) {
|
||||||
// TODO, this is a placeholder
|
// TODO: what is the difference between this and v2? this can be called with user apiToken and v2 not? maybe it should be unified?
|
||||||
User? user = ctx.Sessions.FirstOrDefault(e => e.ApiToken == apiToken)?.User;
|
User? user = ctx.Sessions.FirstOrDefault(e => e.ApiToken == apiToken)?.User;
|
||||||
Viking? viking = ctx.Sessions.FirstOrDefault(e => e.ApiToken == apiToken)?.Viking;
|
Viking? viking = ctx.Sessions.FirstOrDefault(e => e.ApiToken == apiToken)?.Viking;
|
||||||
if (user is null && viking is null) {
|
if (user is null && viking is null) {
|
||||||
return Ok();
|
return Ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
List<UserItemData> userItemData = new();
|
||||||
|
if (viking != null) {
|
||||||
|
List<InventoryItem> items = viking.Inventory.InventoryItems.ToList();
|
||||||
|
foreach (InventoryItem item in items) {
|
||||||
|
if (item.Quantity == 0) continue; // Don't include an item that the viking doesn't have
|
||||||
|
ItemData itemData = itemService.GetItem(item.ItemId);
|
||||||
|
UserItemData uid = new UserItemData {
|
||||||
|
UserInventoryID = item.Id,
|
||||||
|
ItemID = itemData.ItemID,
|
||||||
|
Quantity = item.Quantity,
|
||||||
|
Uses = itemData.Uses,
|
||||||
|
ModifiedDate = new DateTime(DateTime.Now.Ticks),
|
||||||
|
Item = itemData
|
||||||
|
};
|
||||||
|
userItemData.Add(uid);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// TODO: placeholder - return 8 viking slot items
|
||||||
|
UserItemData uid = new UserItemData {
|
||||||
|
UserInventoryID = 0,
|
||||||
|
ItemID = 7971,
|
||||||
|
Quantity = 8,
|
||||||
|
Uses = -1,
|
||||||
|
ModifiedDate = new DateTime(DateTime.Now.Ticks),
|
||||||
|
Item = itemService.GetItem(7971)
|
||||||
|
};
|
||||||
|
userItemData.Add(uid);
|
||||||
|
}
|
||||||
|
|
||||||
return Ok(new CommonInventoryData {
|
return Ok(new CommonInventoryData {
|
||||||
UserID = Guid.Parse(user is not null ? user.Id : viking.Id)
|
UserID = Guid.Parse(user is not null ? user.Id : viking.Id),
|
||||||
|
Item = userItemData.ToArray()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user