implemented SetDisplayName

This commit is contained in:
Robert Paciorek 2024-01-09 20:43:38 +00:00
parent 7e5a90ba87
commit 36d009dc3a
4 changed files with 45 additions and 0 deletions

View File

@ -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

View File

@ -86,6 +86,7 @@ methods = [
'GetGameDataByGame', 'GetGameDataByGame',
'GetGameDataByGameForDateRange', 'GetGameDataByGameForDateRange',
'GetTopAchievementPointUsers', 'GetTopAchievementPointUsers',
'SetDisplayName',
] ]
def routable(path): def routable(path):

View File

@ -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")]

View 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; }
}