forked from SoDOff-Project/sodoff
implemented SetDisplayName
This commit is contained in:
parent
7e5a90ba87
commit
36d009dc3a
@ -90,6 +90,7 @@ Then run School of Dragons.
|
|||||||
- SetAchievementByEntityIDs
|
- SetAchievementByEntityIDs
|
||||||
- SetAvatar
|
- SetAvatar
|
||||||
- SetCommonInventory
|
- SetCommonInventory
|
||||||
|
- SetDisplayName (V2)
|
||||||
- SetDragonXP (used by account import tools)
|
- SetDragonXP (used by account import tools)
|
||||||
- SetImage
|
- SetImage
|
||||||
- SetKeyValuePair
|
- SetKeyValuePair
|
||||||
|
@ -86,6 +86,7 @@ methods = [
|
|||||||
'GetGameDataByGame',
|
'GetGameDataByGame',
|
||||||
'GetGameDataByGameForDateRange',
|
'GetGameDataByGameForDateRange',
|
||||||
'GetTopAchievementPointUsers',
|
'GetTopAchievementPointUsers',
|
||||||
|
'SetDisplayName',
|
||||||
]
|
]
|
||||||
|
|
||||||
def routable(path):
|
def routable(path):
|
||||||
|
@ -102,6 +102,33 @@ public class ContentController : Controller {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
[Produces("application/xml")]
|
||||||
|
[Route("/V2/ContentWebService.asmx/SetDisplayName")]
|
||||||
|
[VikingSession]
|
||||||
|
public IActionResult SetDisplayName(Viking viking, [FromForm] string request) {
|
||||||
|
string newName = XmlUtil.DeserializeXml<SetDisplayNameRequest>(request).DisplayName;
|
||||||
|
|
||||||
|
if (String.IsNullOrWhiteSpace(newName) || ctx.Vikings.Count(e => e.Name == newName) > 0) {
|
||||||
|
return Ok(new SetAvatarResult {
|
||||||
|
Success = false,
|
||||||
|
StatusCode = AvatarValidationResult.AvatarDisplayNameInvalid
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
viking.Name = newName;
|
||||||
|
AvatarData avatarData = XmlUtil.DeserializeXml<AvatarData>(viking.AvatarSerialized);
|
||||||
|
avatarData.DisplayName = newName;
|
||||||
|
viking.AvatarSerialized = XmlUtil.SerializeXml(avatarData);
|
||||||
|
ctx.SaveChanges();
|
||||||
|
|
||||||
|
return Ok(new SetAvatarResult {
|
||||||
|
Success = true,
|
||||||
|
DisplayName = viking.Name,
|
||||||
|
StatusCode = AvatarValidationResult.Valid
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Produces("application/xml")]
|
[Produces("application/xml")]
|
||||||
[Route("ContentWebService.asmx/GetKeyValuePair")]
|
[Route("ContentWebService.asmx/GetKeyValuePair")]
|
||||||
|
16
src/Schema/SetDisplayNameRequest.cs
Normal file
16
src/Schema/SetDisplayNameRequest.cs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
using System.Xml.Serialization;
|
||||||
|
|
||||||
|
namespace sodoff.Schema;
|
||||||
|
|
||||||
|
[XmlRoot(ElementName = "sdnr", Namespace = "")]
|
||||||
|
[Serializable]
|
||||||
|
public class SetDisplayNameRequest {
|
||||||
|
[XmlElement(ElementName = "dn")]
|
||||||
|
public string DisplayName { get; set; }
|
||||||
|
|
||||||
|
[XmlElement(ElementName = "iid")]
|
||||||
|
public int ItemID { get; set; }
|
||||||
|
|
||||||
|
[XmlElement(ElementName = "sid")]
|
||||||
|
public int StoreID { get; set; }
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user