From 93361c5e845cc6fc90b13af4eb2fb85dcfa59f5b Mon Sep 17 00:00:00 2001 From: Alan Moon Date: Sun, 1 Oct 2023 12:57:23 -0700 Subject: [PATCH] add endpoints for WoJS add: - SetGameCurrency - GetDisplayNameByUserId - GetCommonInventoryByUserId and some placeholders - Reimplement Currency System (WoJS) - Implement ``GetDisplayNameByUserId`` - Move ``GetCombinedListMessage`` To Messaging Controller - Add More Placeholders For MMO - ``SetScore`` Placeholder - Add ``GetRevealIndex`` For Learning Games Co-authored-by: Robert Paciorek --- src/Controllers/Common/ContentController.cs | 42 +++++++++++++++++++ src/Controllers/Common/MessagingController.cs | 9 ++++ src/Controllers/Common/RatingController.cs | 9 ++++ 3 files changed, 60 insertions(+) diff --git a/src/Controllers/Common/ContentController.cs b/src/Controllers/Common/ContentController.cs index 5a00fcc..8d44f84 100644 --- a/src/Controllers/Common/ContentController.cs +++ b/src/Controllers/Common/ContentController.cs @@ -273,6 +273,15 @@ public class ContentController : Controller { } } + [HttpPost] + [Produces("application/xml")] + [Route("ContentWebService.asmx/GetCommonInventoryByUserId")] // used by World Of Jumpstart (?) + public IActionResult GetCommonInventoryByUserId([FromForm] Guid userId, [FromForm] int ContainerId) + { + Viking? viking = ctx.Vikings.FirstOrDefault(e => e.Uid == userId); + return GetCommonInventory(null, viking); + } + [HttpPost] [Produces("application/xml")] [Route("V2/ContentWebService.asmx/GetCommonInventory")] @@ -1405,6 +1414,18 @@ public class ContentController : Controller { return Ok(XmlUtil.ReadResourceXmlString("displaynames")); } + [HttpPost] + [Produces("application/xml")] + [Route("ContentWebService.asmx/GetDisplayNameByUserId")] // used by World Of Jumpstart + public IActionResult GetDisplayNameByUserId([FromForm] Guid userId) + { + Viking? idViking = ctx.Vikings.FirstOrDefault(e => e.Uid == userId); + if (idViking is null) return Ok("???"); + + // return display name + return Ok(XmlUtil.DeserializeXml(idViking.AvatarSerialized!).DisplayName); + } + [HttpPost] //[Produces("application/xml")] [Route("ContentWebService.asmx/SetDisplayName")] // used by World Of Jumpstart @@ -1443,6 +1464,18 @@ public class ContentController : Controller { return Ok(achievementService.GetUserCurrency(viking)); } + [HttpPost] + [Produces("application/xml")] + [Route("ContentWebService.asmx/SetGameCurrency")] // used by World Of Jumpstart + [VikingSession] + public IActionResult SetUserGameCurrency(Viking viking, [FromForm] int amount) + { + achievementService.AddAchievementPoints(viking, AchievementPointTypes.GameCurrency, amount); + + ctx.SaveChanges(); + return Ok(achievementService.GetUserCurrency(viking).GameCurrency ?? 0); + } + [HttpPost] [Produces("application/xml")] [Route("V2/ContentWebService.asmx/RerollUserItem")] @@ -1863,6 +1896,15 @@ public class ContentController : Controller { return Ok(0); } + [HttpPost] + [Produces("application/xml")] + [Route("ContentWebService.asmx/GetRevealIndex")] // used by World Of Jumpstart (Learning Games) + public IActionResult GetRevealIndex() + { + // TODO - figure out proper way of doing this, if any + return Ok(random.Next(1, 15)); + } + private static RaisedPetData GetRaisedPetDataFromDragon (Dragon dragon, int? selectedDragonId = null) { if (selectedDragonId is null) selectedDragonId = dragon.Viking.SelectedDragonId; diff --git a/src/Controllers/Common/MessagingController.cs b/src/Controllers/Common/MessagingController.cs index d348811..b4e71de 100644 --- a/src/Controllers/Common/MessagingController.cs +++ b/src/Controllers/Common/MessagingController.cs @@ -27,4 +27,13 @@ public class MessagingController : Controller { // TODO: this is a placeholder return Ok(false); } + + [HttpPost] + [Produces("application/xml")] + [Route("MessageWebService.asmx/GetCombinedListMessage")] + public IActionResult GetCombinedListMessage() + { + // TODO - placeholder + return Ok(new ArrayOfMessageInfo()); + } } diff --git a/src/Controllers/Common/RatingController.cs b/src/Controllers/Common/RatingController.cs index 019c583..7809dd0 100644 --- a/src/Controllers/Common/RatingController.cs +++ b/src/Controllers/Common/RatingController.cs @@ -9,6 +9,15 @@ namespace sodoff.Controllers.Common; public class RatingController : Controller { + [HttpPost] + [Produces("application/xml")] + [Route("ScoreWebService.asmx/SetScore")] // used by World Of Jumpstart + public IActionResult SetScore() + { + // TODO - placeholder + return Ok(true); + } + [HttpPost] [Produces("application/xml")] [Route("V2/Ratingwebservice.asmx/GetAverageRatingForRoom")]