initial support for World Of Jumpstart

This commit is contained in:
Robert Paciorek 2023-08-15 08:33:18 +00:00
parent 58a9c2ebd3
commit f5c7bc0fca
5 changed files with 77 additions and 4 deletions

View File

@ -90,6 +90,20 @@ public class AchievementController : Controller {
return Ok("OK"); return Ok("OK");
} }
[HttpPost]
[Produces("application/xml")]
[Route("AchievementWebService.asmx/GetUserAchievementInfo")]
public IActionResult GetUserAchievementInfo([FromForm] string apiToken) {
Viking? viking = ctx.Sessions.FirstOrDefault(x => x.ApiToken == apiToken).Viking;
if (viking != null) {
return Ok(
achievementService.CreateUserAchievementInfo(viking, AchievementPointTypes.PlayerXP)
);
}
return null;
}
[HttpPost] [HttpPost]
[Produces("application/xml")] [Produces("application/xml")]
[Route("AchievementWebService.asmx/GetAchievementsByUserID")] [Route("AchievementWebService.asmx/GetAchievementsByUserID")]

View File

@ -33,11 +33,18 @@ public class AuthenticationController : Controller {
[Route("v3/AuthenticationWebService.asmx/LoginParent")] [Route("v3/AuthenticationWebService.asmx/LoginParent")]
[DecryptRequest("parentLoginData")] [DecryptRequest("parentLoginData")]
[EncryptResponse] [EncryptResponse]
public IActionResult LoginParent() { public IActionResult LoginParent([FromForm] string apiKey) {
ParentLoginData data = XmlUtil.DeserializeXml<ParentLoginData>(Request.Form["parentLoginData"]); ParentLoginData data = XmlUtil.DeserializeXml<ParentLoginData>(Request.Form["parentLoginData"]);
// Authenticate the user // Authenticate the user
User? user = ctx.Users.FirstOrDefault(e => e.Username == data.UserName); User? user = null;
uint gameVersion = ClientVersion.GetVersion(apiKey);
if (gameVersion == ClientVersion.WoJS) {
user = ctx.Users.FirstOrDefault(e => e.Email == data.UserName);
} else {
user = ctx.Users.FirstOrDefault(e => e.Username == data.UserName);
}
if (user is null || new PasswordHasher<object>().VerifyHashedPassword(null, user.Password, data.Password) != PasswordVerificationResult.Success) { if (user is null || new PasswordHasher<object>().VerifyHashedPassword(null, user.Password, data.Password) != PasswordVerificationResult.Success) {
return Ok(new ParentLoginInfo { Status = MembershipUserStatus.InvalidPassword }); return Ok(new ParentLoginInfo { Status = MembershipUserStatus.InvalidPassword });
} }
@ -52,6 +59,11 @@ public class AuthenticationController : Controller {
ctx.Sessions.Add(session); ctx.Sessions.Add(session);
ctx.SaveChanges(); ctx.SaveChanges();
var childList = new List<sodoff.Schema.UserLoginInfo>();
foreach (var viking in user.Vikings) {
childList.Add(new sodoff.Schema.UserLoginInfo{UserName = viking.Name, UserID = viking.Uid.ToString()});
}
var response = new ParentLoginInfo { var response = new ParentLoginInfo {
UserName = user.Username, UserName = user.Username,
//Email = user.Email, /* disabled to avoid put email in client debug logs */ //Email = user.Email, /* disabled to avoid put email in client debug logs */
@ -59,7 +71,8 @@ public class AuthenticationController : Controller {
UserID = user.Id.ToString(), UserID = user.Id.ToString(),
Status = MembershipUserStatus.Success, Status = MembershipUserStatus.Success,
SendActivationReminder = false, SendActivationReminder = false,
UnAuthorized = false UnAuthorized = false,
ChildList = childList.ToArray()
}; };
return Ok(response); return Ok(response);
@ -124,7 +137,9 @@ public class AuthenticationController : Controller {
[HttpPost] [HttpPost]
[Produces("application/xml")] [Produces("application/xml")]
[Route("AuthenticationWebService.asmx/IsValidApiToken_V2")] [Route("AuthenticationWebService.asmx/IsValidApiToken_V2")]
public IActionResult IsValidApiToken([FromForm] Guid apiToken) { public IActionResult IsValidApiToken([FromForm] Guid? apiToken) {
if (apiToken is null)
return Ok(ApiTokenStatus.TokenNotFound);
User? user = ctx.Sessions.FirstOrDefault(e => e.ApiToken == apiToken)?.User; User? user = ctx.Sessions.FirstOrDefault(e => e.ApiToken == apiToken)?.User;
Viking? viking = ctx.Sessions.FirstOrDefault(e => e.ApiToken == apiToken)?.Viking; Viking? viking = ctx.Sessions.FirstOrDefault(e => e.ApiToken == apiToken)?.Viking;
if (user is null && viking is null) if (user is null && viking is null)

View File

@ -315,8 +315,21 @@ public class ContentController : Controller {
return 0; return 0;
} }
[HttpPost]
//[Produces("application/xml")]
[Route("ContentWebService.asmx/GetAvatar")] // used by World Of Jumpstart
public IActionResult GetAvatar([FromForm] string apiToken) {
Viking? viking = ctx.Sessions.FirstOrDefault(e => e.ApiToken == apiToken)?.Viking;
if (viking is null || viking.AvatarSerialized is null) {
// TODO: result for invalid session
return Ok();
}
return Ok(viking.AvatarSerialized);
}
[HttpPost] [HttpPost]
[Produces("application/xml")] [Produces("application/xml")]
[Route("ContentWebService.asmx/SetAvatar")] // used by World Of Jumpstart
[Route("V2/ContentWebService.asmx/SetAvatar")] [Route("V2/ContentWebService.asmx/SetAvatar")]
[VikingSession] [VikingSession]
public IActionResult SetAvatar(Viking viking, [FromForm] string contentXML) { public IActionResult SetAvatar(Viking viking, [FromForm] string contentXML) {
@ -577,6 +590,8 @@ public class ContentController : Controller {
[HttpPost] [HttpPost]
[Produces("application/xml")] [Produces("application/xml")]
[Route("ContentWebService.asmx/GetSelectedRaisedPet")] [Route("ContentWebService.asmx/GetSelectedRaisedPet")]
[Route("ContentWebService.asmx/GetCurrentPetByUserID")] // used by World Of Jumpstart
[Route("ContentWebService.asmx/GetActiveRaisedPet")] // used by World Of Jumpstart
[VikingSession(UseLock=false)] [VikingSession(UseLock=false)]
public RaisedPetData[]? GetSelectedRaisedPet(Viking viking, [FromForm] string userId, [FromForm] bool isActive) { public RaisedPetData[]? GetSelectedRaisedPet(Viking viking, [FromForm] string userId, [FromForm] bool isActive) {
Dragon? dragon = viking.SelectedDragon; Dragon? dragon = viking.SelectedDragon;
@ -1156,6 +1171,22 @@ public class ContentController : Controller {
return Ok(roomService.NextItemState(item, request.OverrideStateCriteria)); return Ok(roomService.NextItemState(item, request.OverrideStateCriteria));
} }
[HttpPost]
//[Produces("application/xml")]
[Route("ContentWebService.asmx/GetDisplayNames")] // used by World Of Jumpstart
public IActionResult GetDisplayNames() {
// TODO: This is a placeholder
return Ok("<?xml version=\"1.0\" encoding=\"utf-8\"?> <DisplayNames xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"> <DisplayName> <ID>1</ID> <Name>Aaliyah</Name> <Ordinal>1</Ordinal> </DisplayName> <DisplayName> <ID>2</ID> <Name>Abby</Name> <Ordinal>1</Ordinal> </DisplayName> <DisplayName> <ID>3</ID> <Name>Adrian</Name> <Ordinal>1</Ordinal> </DisplayName> <DisplayName> <ID>261</ID> <Name>Alan</Name> <Ordinal>1</Ordinal> </DisplayName> </DisplayNames>");
}
[HttpPost]
//[Produces("application/xml")]
[Route("ContentWebService.asmx/GetScene")] // used by World Of Jumpstart
public IActionResult GetScene() {
// TODO: This is a placeholder
return Ok("<?xml version=\"1.0\" encoding=\"utf-8\"?><SceneData xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:nil=\"true\" />");
}
[HttpPost] [HttpPost]
[Produces("application/xml")] [Produces("application/xml")]
[Route("V2/ContentWebService.asmx/GetGameData")] [Route("V2/ContentWebService.asmx/GetGameData")]

View File

@ -46,6 +46,13 @@ public class ItemStoreController : Controller {
return Ok(itemService.GetItem(itemId)); return Ok(itemService.GetItem(itemId));
} }
[HttpPost]
[Produces("application/xml")]
[Route("ItemStoreWebService.asmx/GetItemsInStore")] // used by World Of Jumpstart
public IActionResult GetItemsInStore([FromForm] int storeId) {
return Ok(storeService.GetStore(storeId));
}
[HttpPost] [HttpPost]
//[Produces("application/xml")] //[Produces("application/xml")]
[Route("ItemStoreWebService.asmx/GetRankAttributeData")] [Route("ItemStoreWebService.asmx/GetRankAttributeData")]

View File

@ -63,6 +63,12 @@ public class RegistrationController : Controller {
}; };
// Check if user exists // Check if user exists
uint gameVersion = ClientVersion.GetVersion(apiKey);
if (gameVersion == ClientVersion.WoJS || gameVersion == ClientVersion.MB) {
if (ctx.Users.Count(e => e.Email == u.Email) > 0) {
return Ok(new RegistrationResult { Status = MembershipUserStatus.DuplicateEmail });
}
}
if (ctx.Users.Count(e => e.Username== u.Username) > 0) { if (ctx.Users.Count(e => e.Username== u.Username) > 0) {
return Ok(new RegistrationResult { Status = MembershipUserStatus.DuplicateUserName }); return Ok(new RegistrationResult { Status = MembershipUserStatus.DuplicateUserName });
} }