mirror of
https://github.com/SoDOff-Project/sodoff.git
synced 2025-10-11 08:18:49 -07:00
Implement Get/SetScene and Houses
- Attempt Implementation Of ``GetScene`` and ``SetScene`` - Typo In Route - Implement Houses
This commit is contained in:
parent
8d236ef8d3
commit
d796f5c4ce
@ -1,6 +1,7 @@
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Org.BouncyCastle.Security.Certificates;
|
||||||
using sodoff.Attributes;
|
using sodoff.Attributes;
|
||||||
using sodoff.Model;
|
using sodoff.Model;
|
||||||
using sodoff.Schema;
|
using sodoff.Schema;
|
||||||
@ -1621,9 +1622,92 @@ public class ContentController : Controller {
|
|||||||
[HttpPost]
|
[HttpPost]
|
||||||
//[Produces("application/xml")]
|
//[Produces("application/xml")]
|
||||||
[Route("ContentWebService.asmx/GetScene")] // used by World Of Jumpstart
|
[Route("ContentWebService.asmx/GetScene")] // used by World Of Jumpstart
|
||||||
public IActionResult GetScene() {
|
[VikingSession]
|
||||||
// TODO: This is a placeholder
|
public IActionResult GetScene(Viking viking, [FromForm] string sceneName) {
|
||||||
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\" />");
|
SceneData? scene = viking.SceneData.FirstOrDefault(e => e.SceneName == sceneName);
|
||||||
|
|
||||||
|
if (scene is not null) return Ok(scene.XmlData);
|
||||||
|
else return Ok("");
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
[Route("ContentWebSerivce.asmx/GetHouse")] // used by World Of Jumpstart
|
||||||
|
[VikingSession]
|
||||||
|
public IActionResult GetHouse(Viking viking) {
|
||||||
|
if (viking.House is not null) return Ok(viking.House.XmlData);
|
||||||
|
else return Ok("");
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
[Route("ContentWebService.asmx/GetHouseByUserId")] // used by World Of Jumpstart
|
||||||
|
public IActionResult GetHouseByUserId([FromForm] Guid userId)
|
||||||
|
{
|
||||||
|
Viking? viking = ctx.Vikings.FirstOrDefault(e => e.Uid == userId);
|
||||||
|
|
||||||
|
if (viking is not null)
|
||||||
|
{
|
||||||
|
if (viking.House is not null) return Ok(viking.House.XmlData);
|
||||||
|
else return Ok("");
|
||||||
|
}
|
||||||
|
|
||||||
|
return Ok("");
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
//[Produces("application/xml")]
|
||||||
|
[Route("ContentWebService.asmx/GetSceneByUserId")] // used by World Of Jumpstart
|
||||||
|
public IActionResult GetSceneByUserId([FromForm] Guid userId, [FromForm] string sceneName) {
|
||||||
|
SceneData? scene = ctx.Vikings.FirstOrDefault(e => e.Uid == userId)?.SceneData.FirstOrDefault(x => x.SceneName == sceneName);
|
||||||
|
|
||||||
|
if (scene is not null) return Ok(scene.XmlData);
|
||||||
|
else return Ok(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
[Produces("application/xml")]
|
||||||
|
[Route("ContentWebService.asmx/SetScene")] // used by World of Jumpstart
|
||||||
|
[VikingSession]
|
||||||
|
public IActionResult SetScene(Viking viking, [FromForm] string sceneName, [FromForm] string contentXml) {
|
||||||
|
SceneData? existingScene = viking.SceneData.FirstOrDefault(e => e.SceneName == sceneName);
|
||||||
|
|
||||||
|
if(existingScene is not null)
|
||||||
|
{
|
||||||
|
existingScene.XmlData = contentXml;
|
||||||
|
ctx.SaveChanges();
|
||||||
|
return Ok(true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SceneData sceneData = new SceneData
|
||||||
|
{
|
||||||
|
SceneName = sceneName,
|
||||||
|
XmlData = contentXml
|
||||||
|
};
|
||||||
|
viking.SceneData.Add(sceneData);
|
||||||
|
ctx.SaveChanges();
|
||||||
|
return Ok(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
[Produces("application/xml")]
|
||||||
|
[Route("ContentWebService.asmx/SetHouse")] // used by World Of Jumpstart
|
||||||
|
[VikingSession]
|
||||||
|
public IActionResult SetHouse(Viking viking, [FromForm] string contentXml) {
|
||||||
|
HouseData? house = viking.House;
|
||||||
|
|
||||||
|
if(house is null)
|
||||||
|
{
|
||||||
|
HouseData newHouse = new HouseData{ XmlData = contentXml };
|
||||||
|
viking.House = newHouse;
|
||||||
|
ctx.SaveChanges();
|
||||||
|
return Ok(true);
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
house.XmlData = contentXml;
|
||||||
|
ctx.SaveChanges();
|
||||||
|
return Ok(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
@ -1634,7 +1718,7 @@ public class ContentController : Controller {
|
|||||||
GetGameDataRequest request = XmlUtil.DeserializeXml<GetGameDataRequest>(gameDataRequest);
|
GetGameDataRequest request = XmlUtil.DeserializeXml<GetGameDataRequest>(gameDataRequest);
|
||||||
return Ok(gameDataService.GetGameDataForPlayer(viking, request));
|
return Ok(gameDataService.GetGameDataForPlayer(viking, request));
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Produces("application/xml")]
|
[Produces("application/xml")]
|
||||||
[Route("ContentWebService.asmx/GetUserGameCurrency")]
|
[Route("ContentWebService.asmx/GetUserGameCurrency")]
|
||||||
|
@ -15,6 +15,8 @@ public class DBContext : DbContext {
|
|||||||
public DbSet<InventoryItem> InventoryItems { get; set; } = null!;
|
public DbSet<InventoryItem> InventoryItems { get; set; } = null!;
|
||||||
public DbSet<MissionState> MissionStates { get; set; } = null!;
|
public DbSet<MissionState> MissionStates { get; set; } = null!;
|
||||||
public DbSet<Room> Rooms { get; set; } = null!;
|
public DbSet<Room> Rooms { get; set; } = null!;
|
||||||
|
public DbSet<SceneData> SceneData { get; set; } = null!;
|
||||||
|
public DbSet<HouseData> Houses { get; set; } = null!;
|
||||||
public DbSet<RoomItem> RoomItems { get; set; } = null!;
|
public DbSet<RoomItem> RoomItems { get; set; } = null!;
|
||||||
public DbSet<GameData> GameData { get; set; } = null!;
|
public DbSet<GameData> GameData { get; set; } = null!;
|
||||||
public DbSet<GameDataPair> GameDataPairs { get; set; } = null!;
|
public DbSet<GameDataPair> GameDataPairs { get; set; } = null!;
|
||||||
@ -94,6 +96,12 @@ public class DBContext : DbContext {
|
|||||||
builder.Entity<Viking>().HasMany(v => v.Rooms)
|
builder.Entity<Viking>().HasMany(v => v.Rooms)
|
||||||
.WithOne(e => e.Viking);
|
.WithOne(e => e.Viking);
|
||||||
|
|
||||||
|
builder.Entity<Viking>().HasMany(v => v.SceneData)
|
||||||
|
.WithOne(e => e.Viking);
|
||||||
|
|
||||||
|
builder.Entity<Viking>().HasOne(v => v.House)
|
||||||
|
.WithOne(e => e.Viking);
|
||||||
|
|
||||||
builder.Entity<Viking>().HasMany(v => v.AchievementPoints)
|
builder.Entity<Viking>().HasMany(v => v.AchievementPoints)
|
||||||
.WithOne(e => e.Viking);
|
.WithOne(e => e.Viking);
|
||||||
|
|
||||||
@ -224,5 +232,12 @@ public class DBContext : DbContext {
|
|||||||
builder.Entity<ProfileAnswer>().HasOne(i => i.Viking)
|
builder.Entity<ProfileAnswer>().HasOne(i => i.Viking)
|
||||||
.WithMany(i => i.ProfileAnswers)
|
.WithMany(i => i.ProfileAnswers)
|
||||||
.HasForeignKey(e => e.VikingId);
|
.HasForeignKey(e => e.VikingId);
|
||||||
|
|
||||||
|
builder.Entity<SceneData>().HasOne(i => i.Viking)
|
||||||
|
.WithMany(i => i.SceneData)
|
||||||
|
.HasForeignKey(e => e.VikingId);
|
||||||
|
|
||||||
|
builder.Entity<HouseData>().HasOne(i => i.Viking)
|
||||||
|
.WithOne(e => e.House);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
13
src/Model/HouseData.cs
Normal file
13
src/Model/HouseData.cs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
|
namespace sodoff.Model
|
||||||
|
{
|
||||||
|
public class HouseData
|
||||||
|
{
|
||||||
|
[Key]
|
||||||
|
public int Id { get; set; }
|
||||||
|
public int VikingId { get; set; }
|
||||||
|
public virtual Viking Viking { get; set; } = null!;
|
||||||
|
public string XmlData { get; set; } = null!;
|
||||||
|
}
|
||||||
|
}
|
14
src/Model/SceneData.cs
Normal file
14
src/Model/SceneData.cs
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
|
namespace sodoff.Model
|
||||||
|
{
|
||||||
|
public class SceneData
|
||||||
|
{
|
||||||
|
[Key]
|
||||||
|
public int Id { get; set; }
|
||||||
|
public int VikingId { get; set; }
|
||||||
|
public string SceneName { get; set; } = null!;
|
||||||
|
public string XmlData { get; set; } = null!;
|
||||||
|
public virtual Viking Viking { get; set; } = null!;
|
||||||
|
}
|
||||||
|
}
|
@ -27,6 +27,8 @@ public class Viking {
|
|||||||
public virtual ICollection<MissionState> MissionStates { get; set; } = null!;
|
public virtual ICollection<MissionState> MissionStates { get; set; } = null!;
|
||||||
public virtual ICollection<TaskStatus> TaskStatuses { get; set; } = null!;
|
public virtual ICollection<TaskStatus> TaskStatuses { get; set; } = null!;
|
||||||
public virtual ICollection<Room> Rooms { get; set; } = null!;
|
public virtual ICollection<Room> Rooms { get; set; } = null!;
|
||||||
|
public virtual ICollection<SceneData> SceneData { get; set; } = null!;
|
||||||
|
public virtual HouseData House { get; set; } = null!;
|
||||||
public virtual ICollection<AchievementPoints> AchievementPoints { get; set; } = null!;
|
public virtual ICollection<AchievementPoints> AchievementPoints { get; set; } = null!;
|
||||||
public virtual ICollection<PairData> PairData { get; set; } = null!;
|
public virtual ICollection<PairData> PairData { get; set; } = null!;
|
||||||
public virtual ICollection<InventoryItem> InventoryItems { get; set; } = null!;
|
public virtual ICollection<InventoryItem> InventoryItems { get; set; } = null!;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user