fix dragon update

This commit is contained in:
Spirtix 2023-07-02 11:02:06 +02:00
parent 00d0a182c7
commit 09553c9d4f

View File

@ -546,17 +546,19 @@ public class ContentController : Controller {
// Attributes is special - the entire list isn't re-sent, so we need to manually update each
if (dragonData.Attributes is null) dragonData.Attributes = new RaisedPetAttribute[] { };
List<RaisedPetAttribute> attribs = dragonData.Attributes.ToList();
if (newDragonData.Attributes is not null) {
foreach (RaisedPetAttribute newAttribute in newDragonData.Attributes) {
RaisedPetAttribute? attribute = dragonData.Attributes.FirstOrDefault(a => a.Key == newAttribute.Key);
RaisedPetAttribute? attribute = attribs.Find(a => a.Key == newAttribute.Key);
if (attribute is null) {
dragonData.Attributes.Append(newAttribute);
attribs.Add(newAttribute);
}
else {
attribute.Value = newAttribute.Value;
attribute.Type = newAttribute.Type;
}
}
dragonData.Attributes = attribs.ToArray();
}
return dragonData;