mirror of
https://github.com/SoDOff-Project/sodoff.git
synced 2025-10-11 08:18:49 -07:00
add support for customizable items
This commit is contained in:
parent
512348336c
commit
e50207ac2e
@ -208,6 +208,42 @@ public class ContentController : Controller {
|
||||
return Ok(response);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Produces("application/xml")]
|
||||
[Route("ContentWebService.asmx/SetCommonInventoryAttribute")]
|
||||
[VikingSession]
|
||||
public IActionResult SetCommonInventoryAttribute(Viking viking, [FromForm] int commonInventoryID, [FromForm] string pairxml) {
|
||||
InventoryItem? item = viking.InventoryItems.FirstOrDefault(e => e.Id == commonInventoryID);
|
||||
|
||||
List<Schema.Pair> itemAttributes;
|
||||
if (item.AttributesSerialized != null) {
|
||||
itemAttributes = XmlUtil.DeserializeXml<Schema.PairData>(item.AttributesSerialized).Pairs.ToList();
|
||||
} else {
|
||||
itemAttributes = new List<Schema.Pair>();
|
||||
}
|
||||
|
||||
Schema.PairData newItemAttributes = XmlUtil.DeserializeXml<Schema.PairData>(pairxml);
|
||||
foreach (var p in newItemAttributes.Pairs) {
|
||||
var pairItem = itemAttributes.FirstOrDefault(e => e.PairKey == p.PairKey);
|
||||
if (pairItem != null){
|
||||
pairItem.PairValue = p.PairValue;
|
||||
} else {
|
||||
itemAttributes.Add(p);
|
||||
}
|
||||
}
|
||||
|
||||
if (itemAttributes.Count > 0) {
|
||||
item.AttributesSerialized = XmlUtil.SerializeXml(
|
||||
new Schema.PairData{
|
||||
Pairs = itemAttributes.ToArray()
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
ctx.SaveChanges();
|
||||
return Ok(true);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Produces("application/xml")]
|
||||
[Route("ContentWebService.asmx/UseInventory")]
|
||||
|
@ -11,6 +11,8 @@ namespace sodoff.Model {
|
||||
|
||||
public string? StatsSerialized { get; set; }
|
||||
|
||||
public string? AttributesSerialized { get; set; }
|
||||
|
||||
public virtual Viking Viking { get; set; } = null!;
|
||||
|
||||
public int Quantity { get; set; }
|
||||
|
@ -136,6 +136,9 @@ namespace sodoff.Services {
|
||||
uid.ItemStats = itemData.ItemStatsMap?.ItemStats;
|
||||
uid.ItemTier = itemData.ItemStatsMap?.ItemTier;
|
||||
}
|
||||
if (item.AttributesSerialized != null) {
|
||||
uid.UserItemAttributes = XmlUtil.DeserializeXml<Schema.PairData>(item.AttributesSerialized);
|
||||
}
|
||||
userItemData.Add(uid);
|
||||
}
|
||||
|
||||
@ -149,7 +152,7 @@ namespace sodoff.Services {
|
||||
ItemData itemData = itemService.GetItem(itemId);
|
||||
if (itemData.PossibleStatsMap != null) // dragons tactics (battle) items
|
||||
return true;
|
||||
if (itemService.ItemHasCategory(itemData, 541)) // farm expansion
|
||||
if (itemService.ItemHasCategory(itemData, new int[] {541, 657})) // farm expansion or customizable items
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user