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);
|
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]
|
[HttpPost]
|
||||||
[Produces("application/xml")]
|
[Produces("application/xml")]
|
||||||
[Route("ContentWebService.asmx/UseInventory")]
|
[Route("ContentWebService.asmx/UseInventory")]
|
||||||
|
@ -8,9 +8,11 @@ namespace sodoff.Model {
|
|||||||
public int ItemId { get; set; }
|
public int ItemId { get; set; }
|
||||||
|
|
||||||
public int VikingId { get; set; }
|
public int VikingId { get; set; }
|
||||||
|
|
||||||
public string? StatsSerialized { get; set; }
|
public string? StatsSerialized { get; set; }
|
||||||
|
|
||||||
|
public string? AttributesSerialized { get; set; }
|
||||||
|
|
||||||
public virtual Viking Viking { get; set; } = null!;
|
public virtual Viking Viking { get; set; } = null!;
|
||||||
|
|
||||||
public int Quantity { get; set; }
|
public int Quantity { get; set; }
|
||||||
|
@ -136,6 +136,9 @@ namespace sodoff.Services {
|
|||||||
uid.ItemStats = itemData.ItemStatsMap?.ItemStats;
|
uid.ItemStats = itemData.ItemStatsMap?.ItemStats;
|
||||||
uid.ItemTier = itemData.ItemStatsMap?.ItemTier;
|
uid.ItemTier = itemData.ItemStatsMap?.ItemTier;
|
||||||
}
|
}
|
||||||
|
if (item.AttributesSerialized != null) {
|
||||||
|
uid.UserItemAttributes = XmlUtil.DeserializeXml<Schema.PairData>(item.AttributesSerialized);
|
||||||
|
}
|
||||||
userItemData.Add(uid);
|
userItemData.Add(uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -149,7 +152,7 @@ namespace sodoff.Services {
|
|||||||
ItemData itemData = itemService.GetItem(itemId);
|
ItemData itemData = itemService.GetItem(itemId);
|
||||||
if (itemData.PossibleStatsMap != null) // dragons tactics (battle) items
|
if (itemData.PossibleStatsMap != null) // dragons tactics (battle) items
|
||||||
return true;
|
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 true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user