Added saving support for Ice Cubed. (#15)

Saving support now exists for Ice Cubed and any other games using the system.
This commit is contained in:
Hipposgrumm 2024-08-12 03:02:08 -06:00 committed by Robert Paciorek
parent 757392d4d5
commit 6a9f2722e1
2 changed files with 48 additions and 0 deletions

View File

@ -2134,6 +2134,34 @@ public class ContentController : Controller {
return Ok(random.Next(1, 15)); return Ok(random.Next(1, 15));
} }
[HttpPost]
//[Produces("application/xml")]
[Route("ContentWebService.asmx/GetGameProgress")] // used by Math Blaster (Ice Cubed)
[VikingSession]
public string GetGameProgress(Viking viking, [FromForm] int gameId) {
string? ret = Util.SavedData.Get(
viking,
(uint)gameId
);
if (ret is null)
return XmlUtil.SerializeXml<GameProgress>(null);
return ret;
}
[HttpPost]
[Produces("application/xml")]
[Route("ContentWebService.asmx/SetGameProgress")] // used by Math Blaster (Ice Cubed)
[VikingSession]
public IActionResult SetGameProgress(Viking viking, [FromForm] int gameId, [FromForm] string xmlDocumentData) {
Util.SavedData.Set(
viking,
(uint)gameId,
xmlDocumentData
);
ctx.SaveChanges();
return Ok();
}
private static RaisedPetData GetRaisedPetDataFromDragon (Dragon dragon, int? selectedDragonId = null) { private static RaisedPetData GetRaisedPetDataFromDragon (Dragon dragon, int? selectedDragonId = null) {
if (selectedDragonId is null) if (selectedDragonId is null)
selectedDragonId = dragon.Viking.SelectedDragonId; selectedDragonId = dragon.Viking.SelectedDragonId;

View File

@ -0,0 +1,20 @@
using System.Xml.Serialization;
namespace sodoff.Schema;
[XmlRoot(ElementName = "progress", Namespace = "")]
[Serializable]
public class GameProgress {
[XmlElement(ElementName = "name")]
public string Name;
[XmlElement(ElementName = "version")]
public string Version;
[XmlElement(ElementName = "chapter")]
public string[] Chapter;
[XmlElement(ElementName = "custom")]
public string? Custom;
}