mirror of
https://github.com/SoDOff-Project/sodoff.git
synced 2025-10-11 16:28:50 -07:00
data model improvements
This commit is contained in:
parent
eb3f163fda
commit
fd831058c6
@ -22,15 +22,15 @@ public class VikingSession : Attribute, IAsyncActionFilter {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Session? session = ctx.Sessions.FirstOrDefault(x => x.ApiToken == context.HttpContext.Request.Form[ApiToken].ToString());
|
Session? session = ctx.Sessions.FirstOrDefault(x => x.ApiToken == Guid.Parse(context.HttpContext.Request.Form[ApiToken].ToString()));
|
||||||
|
|
||||||
// get viking / user id from session
|
// get viking / user id from session
|
||||||
|
|
||||||
string? userVikingId = null;
|
string? userVikingId = null;
|
||||||
if (Mode == Modes.VIKING || (Mode == Modes.VIKING_OR_USER && session?.UserId is null) ) {
|
if (Mode == Modes.VIKING || (Mode == Modes.VIKING_OR_USER && session?.UserId is null) ) {
|
||||||
userVikingId = session?.VikingId;
|
userVikingId = session?.VikingId?.ToString();
|
||||||
} else {
|
} else {
|
||||||
userVikingId = session?.UserId;
|
userVikingId = session?.UserId?.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (userVikingId is null) {
|
if (userVikingId is null) {
|
||||||
|
@ -23,7 +23,7 @@ public class AchievementController : Controller {
|
|||||||
public IActionResult GetPetAchievementsByUserID([FromForm] string userId) {
|
public IActionResult GetPetAchievementsByUserID([FromForm] string userId) {
|
||||||
// NOTE: this is public info (for mmo) - no session check
|
// NOTE: this is public info (for mmo) - no session check
|
||||||
List<UserAchievementInfo> dragonsAchievement = new List<UserAchievementInfo>();
|
List<UserAchievementInfo> dragonsAchievement = new List<UserAchievementInfo>();
|
||||||
foreach (Dragon dragon in ctx.Dragons.Where(d => d.VikingId == userId)) {
|
foreach (Dragon dragon in ctx.Dragons.Where(d => d.Viking.Uid == Guid.Parse(userId))) {
|
||||||
dragonsAchievement.Add(
|
dragonsAchievement.Add(
|
||||||
achievementService.CreateUserAchievementInfo(dragon.EntityId, dragon.PetXP, AchievementPointTypes.DragonXP)
|
achievementService.CreateUserAchievementInfo(dragon.EntityId, dragon.PetXP, AchievementPointTypes.DragonXP)
|
||||||
);
|
);
|
||||||
@ -64,7 +64,7 @@ public class AchievementController : Controller {
|
|||||||
[Route("AchievementWebService.asmx/SetDragonXP")] // used by dragonrescue-import
|
[Route("AchievementWebService.asmx/SetDragonXP")] // used by dragonrescue-import
|
||||||
[VikingSession]
|
[VikingSession]
|
||||||
public IActionResult SetDragonXP(Viking viking, [FromForm] string dragonId, [FromForm] int value) {
|
public IActionResult SetDragonXP(Viking viking, [FromForm] string dragonId, [FromForm] int value) {
|
||||||
Dragon? dragon = viking.Dragons.FirstOrDefault(e => e.EntityId == dragonId);
|
Dragon? dragon = viking.Dragons.FirstOrDefault(e => e.EntityId == Guid.Parse(dragonId));
|
||||||
if (dragon is null) {
|
if (dragon is null) {
|
||||||
return Conflict("Dragon not found");
|
return Conflict("Dragon not found");
|
||||||
}
|
}
|
||||||
@ -95,7 +95,7 @@ public class AchievementController : Controller {
|
|||||||
[Route("AchievementWebService.asmx/GetAchievementsByUserID")]
|
[Route("AchievementWebService.asmx/GetAchievementsByUserID")]
|
||||||
public IActionResult GetAchievementsByUserID([FromForm] string userId) {
|
public IActionResult GetAchievementsByUserID([FromForm] string userId) {
|
||||||
// NOTE: this is public info (for mmo) - no session check
|
// NOTE: this is public info (for mmo) - no session check
|
||||||
Viking? viking = ctx.Vikings.FirstOrDefault(e => e.Id == userId);
|
Viking? viking = ctx.Vikings.FirstOrDefault(e => e.Uid == Guid.Parse(userId));
|
||||||
if (viking != null) {
|
if (viking != null) {
|
||||||
return Ok(new ArrayOfUserAchievementInfo {
|
return Ok(new ArrayOfUserAchievementInfo {
|
||||||
UserAchievementInfo = new UserAchievementInfo[]{
|
UserAchievementInfo = new UserAchievementInfo[]{
|
||||||
@ -107,7 +107,7 @@ public class AchievementController : Controller {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Dragon? dragon = ctx.Dragons.FirstOrDefault(e => e.EntityId == userId);
|
Dragon? dragon = ctx.Dragons.FirstOrDefault(e => e.EntityId == Guid.Parse(userId));
|
||||||
if (dragon != null) {
|
if (dragon != null) {
|
||||||
return Ok(new ArrayOfUserAchievementInfo {
|
return Ok(new ArrayOfUserAchievementInfo {
|
||||||
UserAchievementInfo = new UserAchievementInfo[]{
|
UserAchievementInfo = new UserAchievementInfo[]{
|
||||||
@ -127,8 +127,8 @@ public class AchievementController : Controller {
|
|||||||
ArrayOfUserAchievementInfo arrAchievements = new ArrayOfUserAchievementInfo {
|
ArrayOfUserAchievementInfo arrAchievements = new ArrayOfUserAchievementInfo {
|
||||||
UserAchievementInfo = new UserAchievementInfo[]{
|
UserAchievementInfo = new UserAchievementInfo[]{
|
||||||
achievementService.CreateUserAchievementInfo(viking, AchievementPointTypes.PlayerXP),
|
achievementService.CreateUserAchievementInfo(viking, AchievementPointTypes.PlayerXP),
|
||||||
achievementService.CreateUserAchievementInfo(viking.Id, 60000, AchievementPointTypes.PlayerFarmingXP), // TODO: placeholder until there is no leveling for farm XP
|
achievementService.CreateUserAchievementInfo(viking.Uid, 60000, AchievementPointTypes.PlayerFarmingXP), // TODO: placeholder until there is no leveling for farm XP
|
||||||
achievementService.CreateUserAchievementInfo(viking.Id, 20000, AchievementPointTypes.PlayerFishingXP), // TODO: placeholder until there is no leveling for fishing XP
|
achievementService.CreateUserAchievementInfo(viking.Uid, 20000, AchievementPointTypes.PlayerFishingXP), // TODO: placeholder until there is no leveling for fishing XP
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ public class AuthenticationController : Controller {
|
|||||||
// Create session
|
// Create session
|
||||||
Session session = new Session {
|
Session session = new Session {
|
||||||
User = user,
|
User = user,
|
||||||
ApiToken = Guid.NewGuid().ToString(),
|
ApiToken = Guid.NewGuid(),
|
||||||
CreatedAt = DateTime.UtcNow
|
CreatedAt = DateTime.UtcNow
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -55,8 +55,8 @@ public class AuthenticationController : Controller {
|
|||||||
var response = new ParentLoginInfo {
|
var response = new ParentLoginInfo {
|
||||||
UserName = user.Username,
|
UserName = user.Username,
|
||||||
Email = user.Email,
|
Email = user.Email,
|
||||||
ApiToken = session.ApiToken,
|
ApiToken = session.ApiToken.ToString(),
|
||||||
UserID = user.Id,
|
UserID = user.Id.ToString(),
|
||||||
Status = MembershipUserStatus.Success,
|
Status = MembershipUserStatus.Success,
|
||||||
SendActivationReminder = false,
|
SendActivationReminder = false,
|
||||||
UnAuthorized = false
|
UnAuthorized = false
|
||||||
@ -86,12 +86,12 @@ public class AuthenticationController : Controller {
|
|||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Produces("application/xml")]
|
[Produces("application/xml")]
|
||||||
[Route("AuthenticationWebService.asmx/GetUserInfoByApiToken")]
|
[Route("AuthenticationWebService.asmx/GetUserInfoByApiToken")]
|
||||||
public IActionResult GetUserInfoByApiToken([FromForm] string apiToken, [FromForm] string apiKey) {
|
public IActionResult GetUserInfoByApiToken([FromForm] Guid apiToken, [FromForm] string apiKey) {
|
||||||
// First check if this is a user session
|
// First check if this is a user session
|
||||||
User? user = ctx.Sessions.FirstOrDefault(e => e.ApiToken == apiToken)?.User;
|
User? user = ctx.Sessions.FirstOrDefault(e => e.ApiToken == apiToken)?.User;
|
||||||
if (user is not null) {
|
if (user is not null) {
|
||||||
return Ok(new UserInfo {
|
return Ok(new UserInfo {
|
||||||
UserID = user.Id,
|
UserID = user.Id.ToString(),
|
||||||
Username = user.Username,
|
Username = user.Username,
|
||||||
MembershipID = "ef84db9-59c6-4950-b8ea-bbc1521f899b", // placeholder
|
MembershipID = "ef84db9-59c6-4950-b8ea-bbc1521f899b", // placeholder
|
||||||
FacebookUserID = 0,
|
FacebookUserID = 0,
|
||||||
@ -107,7 +107,7 @@ public class AuthenticationController : Controller {
|
|||||||
if (viking is not null)
|
if (viking is not null)
|
||||||
{
|
{
|
||||||
return Ok(new UserInfo {
|
return Ok(new UserInfo {
|
||||||
UserID = viking.Id,
|
UserID = viking.Uid.ToString(),
|
||||||
Username = viking.Name,
|
Username = viking.Name,
|
||||||
FacebookUserID = 0,
|
FacebookUserID = 0,
|
||||||
MultiplayerEnabled = (apiKey != "a1a13a0a-7c6e-4e9b-b0f7-22034d799013" && apiKey != "a2a09a0a-7c6e-4e9b-b0f7-22034d799013" && apiKey != "a3a12a0a-7c6e-4e9b-b0f7-22034d799013"),
|
MultiplayerEnabled = (apiKey != "a1a13a0a-7c6e-4e9b-b0f7-22034d799013" && apiKey != "a2a09a0a-7c6e-4e9b-b0f7-22034d799013" && apiKey != "a3a12a0a-7c6e-4e9b-b0f7-22034d799013"),
|
||||||
@ -124,7 +124,7 @@ 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] string apiToken) {
|
public IActionResult IsValidApiToken([FromForm] Guid apiToken) {
|
||||||
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)
|
||||||
@ -136,7 +136,7 @@ public class AuthenticationController : Controller {
|
|||||||
[Route("AuthenticationWebService.asmx/LoginChild")]
|
[Route("AuthenticationWebService.asmx/LoginChild")]
|
||||||
[DecryptRequest("childUserID")]
|
[DecryptRequest("childUserID")]
|
||||||
[EncryptResponse]
|
[EncryptResponse]
|
||||||
public IActionResult LoginChild([FromForm] string parentApiToken) {
|
public IActionResult LoginChild([FromForm] Guid parentApiToken) {
|
||||||
User? user = ctx.Sessions.FirstOrDefault(e => e.ApiToken == parentApiToken)?.User;
|
User? user = ctx.Sessions.FirstOrDefault(e => e.ApiToken == parentApiToken)?.User;
|
||||||
if (user is null) {
|
if (user is null) {
|
||||||
return Unauthorized();
|
return Unauthorized();
|
||||||
@ -144,7 +144,7 @@ public class AuthenticationController : Controller {
|
|||||||
|
|
||||||
// Find the viking
|
// Find the viking
|
||||||
string? childUserID = Request.Form["childUserID"];
|
string? childUserID = Request.Form["childUserID"];
|
||||||
Viking? viking = ctx.Vikings.FirstOrDefault(e => e.Id == childUserID);
|
Viking? viking = ctx.Vikings.FirstOrDefault(e => e.Uid == Guid.Parse(childUserID));
|
||||||
if (viking is null) {
|
if (viking is null) {
|
||||||
return Unauthorized();
|
return Unauthorized();
|
||||||
}
|
}
|
||||||
@ -157,20 +157,20 @@ public class AuthenticationController : Controller {
|
|||||||
// Create session
|
// Create session
|
||||||
Session session = new Session {
|
Session session = new Session {
|
||||||
Viking = viking,
|
Viking = viking,
|
||||||
ApiToken = Guid.NewGuid().ToString(),
|
ApiToken = Guid.NewGuid(),
|
||||||
CreatedAt = DateTime.UtcNow
|
CreatedAt = DateTime.UtcNow
|
||||||
};
|
};
|
||||||
ctx.Sessions.Add(session);
|
ctx.Sessions.Add(session);
|
||||||
ctx.SaveChanges();
|
ctx.SaveChanges();
|
||||||
|
|
||||||
// Return back the api token
|
// Return back the api token
|
||||||
return Ok(session.ApiToken);
|
return Ok(session.ApiToken.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Produces("application/xml")]
|
[Produces("application/xml")]
|
||||||
[Route("AuthenticationWebService.asmx/DeleteAccountNotification")]
|
[Route("AuthenticationWebService.asmx/DeleteAccountNotification")]
|
||||||
public IActionResult DeleteAccountNotification([FromForm] string apiToken) {
|
public IActionResult DeleteAccountNotification([FromForm] Guid apiToken) {
|
||||||
User? user = ctx.Sessions.FirstOrDefault(e => e.ApiToken == apiToken)?.User;
|
User? user = ctx.Sessions.FirstOrDefault(e => e.ApiToken == apiToken)?.User;
|
||||||
if (user is null)
|
if (user is null)
|
||||||
return Ok(MembershipUserStatus.ValidationError);
|
return Ok(MembershipUserStatus.ValidationError);
|
||||||
|
@ -134,7 +134,7 @@ public class ContentController : Controller {
|
|||||||
} else {
|
} else {
|
||||||
// TODO: placeholder - return 8 viking slot items
|
// TODO: placeholder - return 8 viking slot items
|
||||||
return Ok(new CommonInventoryData {
|
return Ok(new CommonInventoryData {
|
||||||
UserID = Guid.Parse(user.Id),
|
UserID = user.Id,
|
||||||
Item = new UserItemData[] {
|
Item = new UserItemData[] {
|
||||||
new UserItemData {
|
new UserItemData {
|
||||||
UserInventoryID = 0,
|
UserInventoryID = 0,
|
||||||
@ -168,7 +168,7 @@ public class ContentController : Controller {
|
|||||||
// SetCommonInventory can remove any number of items from the inventory, this checks if it's possible
|
// SetCommonInventory can remove any number of items from the inventory, this checks if it's possible
|
||||||
foreach (var req in request) {
|
foreach (var req in request) {
|
||||||
if (req.Quantity >= 0) continue;
|
if (req.Quantity >= 0) continue;
|
||||||
int inventorySum = viking.Inventory.InventoryItems.Sum(e => {if (e.ItemId == req.ItemID) return e.Quantity; return 0;});
|
int inventorySum = viking.InventoryItems.Sum(e => {if (e.ItemId == req.ItemID) return e.Quantity; return 0;});
|
||||||
if (inventorySum < -req.Quantity)
|
if (inventorySum < -req.Quantity)
|
||||||
return Ok(new CommonInventoryResponse { Success = false });
|
return Ok(new CommonInventoryResponse { Success = false });
|
||||||
}
|
}
|
||||||
@ -180,7 +180,7 @@ public class ContentController : Controller {
|
|||||||
if (inventoryService.ItemNeedUniqueInventorySlot((int)req.ItemID)) {
|
if (inventoryService.ItemNeedUniqueInventorySlot((int)req.ItemID)) {
|
||||||
// if req.Quantity < 0 remove unique items
|
// if req.Quantity < 0 remove unique items
|
||||||
for (int i=req.Quantity; i<0; ++i) {
|
for (int i=req.Quantity; i<0; ++i) {
|
||||||
InventoryItem? item = viking.Inventory.InventoryItems.FirstOrDefault(e => e.ItemId == req.ItemID && e.Quantity>0);
|
InventoryItem? item = viking.InventoryItems.FirstOrDefault(e => e.ItemId == req.ItemID && e.Quantity>0);
|
||||||
item.Quantity--;
|
item.Quantity--;
|
||||||
}
|
}
|
||||||
// if req.Quantity > 0 add unique items
|
// if req.Quantity > 0 add unique items
|
||||||
@ -211,7 +211,7 @@ public class ContentController : Controller {
|
|||||||
[Route("ContentWebService.asmx/UseInventory")]
|
[Route("ContentWebService.asmx/UseInventory")]
|
||||||
[VikingSession]
|
[VikingSession]
|
||||||
public IActionResult UseInventory(Viking viking, [FromForm] int userInventoryId, [FromForm] int numberOfUses) {
|
public IActionResult UseInventory(Viking viking, [FromForm] int userInventoryId, [FromForm] int numberOfUses) {
|
||||||
InventoryItem? item = viking.Inventory.InventoryItems.FirstOrDefault(e => e.Id == userInventoryId);
|
InventoryItem? item = viking.InventoryItems.FirstOrDefault(e => e.Id == userInventoryId);
|
||||||
if (item is null)
|
if (item is null)
|
||||||
return Ok(false);
|
return Ok(false);
|
||||||
if (item.Quantity < numberOfUses)
|
if (item.Quantity < numberOfUses)
|
||||||
@ -278,7 +278,7 @@ public class ContentController : Controller {
|
|||||||
// TODO: Investigate SetAsSelectedPet and UnSelectOtherPets - they don't seem to do anything
|
// TODO: Investigate SetAsSelectedPet and UnSelectOtherPets - they don't seem to do anything
|
||||||
|
|
||||||
// Update the RaisedPetData with the info
|
// Update the RaisedPetData with the info
|
||||||
String dragonId = Guid.NewGuid().ToString();
|
string dragonId = Guid.NewGuid().ToString();
|
||||||
raisedPetRequest.RaisedPetData.IsPetCreated = true;
|
raisedPetRequest.RaisedPetData.IsPetCreated = true;
|
||||||
raisedPetRequest.RaisedPetData.RaisedPetID = 0; // Initially make zero, so the db auto-fills
|
raisedPetRequest.RaisedPetData.RaisedPetID = 0; // Initially make zero, so the db auto-fills
|
||||||
raisedPetRequest.RaisedPetData.EntityID = Guid.Parse(dragonId);
|
raisedPetRequest.RaisedPetData.EntityID = Guid.Parse(dragonId);
|
||||||
@ -297,7 +297,7 @@ public class ContentController : Controller {
|
|||||||
};
|
};
|
||||||
// Save the dragon in the db
|
// Save the dragon in the db
|
||||||
Dragon dragon = new Dragon {
|
Dragon dragon = new Dragon {
|
||||||
EntityId = Guid.NewGuid().ToString(),
|
EntityId = Guid.NewGuid(),
|
||||||
Viking = viking,
|
Viking = viking,
|
||||||
RaisedPetData = XmlUtil.SerializeXml(raisedPetRequest.RaisedPetData),
|
RaisedPetData = XmlUtil.SerializeXml(raisedPetRequest.RaisedPetData),
|
||||||
};
|
};
|
||||||
@ -312,7 +312,7 @@ public class ContentController : Controller {
|
|||||||
|
|
||||||
if (raisedPetRequest.CommonInventoryRequests is not null) {
|
if (raisedPetRequest.CommonInventoryRequests is not null) {
|
||||||
foreach (var req in raisedPetRequest.CommonInventoryRequests) {
|
foreach (var req in raisedPetRequest.CommonInventoryRequests) {
|
||||||
InventoryItem? item = viking.Inventory.InventoryItems.FirstOrDefault(e => e.ItemId == req.ItemID);
|
InventoryItem? item = viking.InventoryItems.FirstOrDefault(e => e.ItemId == req.ItemID);
|
||||||
|
|
||||||
//Does the item exist in the user's inventory?
|
//Does the item exist in the user's inventory?
|
||||||
if (item is null) continue; //If not, skip it.
|
if (item is null) continue; //If not, skip it.
|
||||||
@ -404,14 +404,14 @@ public class ContentController : Controller {
|
|||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Produces("application/xml")]
|
[Produces("application/xml")]
|
||||||
[Route("V2/ContentWebService.asmx/GetAllActivePetsByuserId")]
|
[Route("V2/ContentWebService.asmx/GetAllActivePetsByuserId")]
|
||||||
public RaisedPetData[]? GetAllActivePetsByuserId([FromForm] string userId, [FromForm] bool active) {
|
public RaisedPetData[]? GetAllActivePetsByuserId([FromForm] Guid userId, [FromForm] bool active) {
|
||||||
// NOTE: this is public info (for mmo) - no session check
|
// NOTE: this is public info (for mmo) - no session check
|
||||||
Viking? viking = ctx.Vikings.FirstOrDefault(e => e.Id == userId);
|
Viking? viking = ctx.Vikings.FirstOrDefault(e => e.Uid == userId);
|
||||||
if (viking is null)
|
if (viking is null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
RaisedPetData[] dragons = ctx.Dragons
|
RaisedPetData[] dragons = ctx.Dragons
|
||||||
.Where(d => d.VikingId == userId && d.RaisedPetData != null)
|
.Where(d => d.VikingId == viking.Id && d.RaisedPetData != null)
|
||||||
.Select(d => GetRaisedPetDataFromDragon(d, viking.SelectedDragonId))
|
.Select(d => GetRaisedPetDataFromDragon(d, viking.SelectedDragonId))
|
||||||
.ToArray();
|
.ToArray();
|
||||||
|
|
||||||
@ -509,9 +509,9 @@ public class ContentController : Controller {
|
|||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Produces("application/xml")]
|
[Produces("application/xml")]
|
||||||
[Route("ContentWebService.asmx/GetImageByUserId")]
|
[Route("ContentWebService.asmx/GetImageByUserId")]
|
||||||
public ImageData? GetImageByUserId([FromForm] string userId, [FromForm] string ImageType, [FromForm] int ImageSlot) {
|
public ImageData? GetImageByUserId([FromForm] Guid userId, [FromForm] string ImageType, [FromForm] int ImageSlot) {
|
||||||
// NOTE: this is public info (for mmo) - no session check
|
// NOTE: this is public info (for mmo) - no session check
|
||||||
Viking? viking = ctx.Vikings.FirstOrDefault(e => e.Id == userId);
|
Viking? viking = ctx.Vikings.FirstOrDefault(e => e.Uid == userId);
|
||||||
if (viking is null || viking.Images is null) {
|
if (viking is null || viking.Images is null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -522,8 +522,8 @@ public class ContentController : Controller {
|
|||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Produces("application/xml")]
|
[Produces("application/xml")]
|
||||||
[Route("V2/ContentWebService.asmx/GetUserUpcomingMissionState")]
|
[Route("V2/ContentWebService.asmx/GetUserUpcomingMissionState")]
|
||||||
public IActionResult GetUserUpcomingMissionState([FromForm] string apiToken, [FromForm] string userId, [FromForm] string apiKey) {
|
public IActionResult GetUserUpcomingMissionState([FromForm] Guid apiToken, [FromForm] Guid userId, [FromForm] string apiKey) {
|
||||||
Viking? viking = ctx.Vikings.FirstOrDefault(x => x.Id == userId);
|
Viking? viking = ctx.Vikings.FirstOrDefault(x => x.Uid == userId);
|
||||||
if (viking is null)
|
if (viking is null)
|
||||||
return Ok("error");
|
return Ok("error");
|
||||||
|
|
||||||
@ -531,15 +531,15 @@ public class ContentController : Controller {
|
|||||||
foreach (var mission in viking.MissionStates.Where(x => x.MissionStatus == MissionStatus.Upcoming))
|
foreach (var mission in viking.MissionStates.Where(x => x.MissionStatus == MissionStatus.Upcoming))
|
||||||
result.Missions.Add(missionService.GetMissionWithProgress(mission.MissionId, viking.Id, apiKey));
|
result.Missions.Add(missionService.GetMissionWithProgress(mission.MissionId, viking.Id, apiKey));
|
||||||
|
|
||||||
result.UserID = Guid.Parse(viking.Id);
|
result.UserID = viking.Uid;
|
||||||
return Ok(result);
|
return Ok(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Produces("application/xml")]
|
[Produces("application/xml")]
|
||||||
[Route("V2/ContentWebService.asmx/GetUserActiveMissionState")]
|
[Route("V2/ContentWebService.asmx/GetUserActiveMissionState")]
|
||||||
public IActionResult GetUserActiveMissionState([FromForm] string apiToken, [FromForm] string userId, [FromForm] string apiKey) {
|
public IActionResult GetUserActiveMissionState([FromForm] Guid apiToken, [FromForm] Guid userId, [FromForm] string apiKey) {
|
||||||
Viking? viking = ctx.Vikings.FirstOrDefault(x => x.Id == userId);
|
Viking? viking = ctx.Vikings.FirstOrDefault(x => x.Uid == userId);
|
||||||
if (viking is null)
|
if (viking is null)
|
||||||
return Ok("error");
|
return Ok("error");
|
||||||
|
|
||||||
@ -551,15 +551,15 @@ public class ContentController : Controller {
|
|||||||
result.Missions.Add(updatedMission);
|
result.Missions.Add(updatedMission);
|
||||||
}
|
}
|
||||||
|
|
||||||
result.UserID = Guid.Parse(viking.Id);
|
result.UserID = viking.Uid;
|
||||||
return Ok(result);
|
return Ok(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Produces("application/xml")]
|
[Produces("application/xml")]
|
||||||
[Route("V2/ContentWebService.asmx/GetUserCompletedMissionState")]
|
[Route("V2/ContentWebService.asmx/GetUserCompletedMissionState")]
|
||||||
public IActionResult GetUserCompletedMissionState([FromForm] string apiToken, [FromForm] string userId, [FromForm] string apiKey) {
|
public IActionResult GetUserCompletedMissionState([FromForm] Guid apiToken, [FromForm] Guid userId, [FromForm] string apiKey) {
|
||||||
Viking? viking = ctx.Vikings.FirstOrDefault(x => x.Id == userId);
|
Viking? viking = ctx.Vikings.FirstOrDefault(x => x.Uid == userId);
|
||||||
if (viking is null)
|
if (viking is null)
|
||||||
return Ok("error");
|
return Ok("error");
|
||||||
|
|
||||||
@ -567,7 +567,7 @@ public class ContentController : Controller {
|
|||||||
foreach (var mission in viking.MissionStates.Where(x => x.MissionStatus == MissionStatus.Completed))
|
foreach (var mission in viking.MissionStates.Where(x => x.MissionStatus == MissionStatus.Completed))
|
||||||
result.Missions.Add(missionService.GetMissionWithProgress(mission.MissionId, viking.Id, apiKey));
|
result.Missions.Add(missionService.GetMissionWithProgress(mission.MissionId, viking.Id, apiKey));
|
||||||
|
|
||||||
result.UserID = Guid.Parse(viking.Id);
|
result.UserID = viking.Uid;
|
||||||
return Ok(result);
|
return Ok(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -575,8 +575,8 @@ public class ContentController : Controller {
|
|||||||
[Produces("application/xml")]
|
[Produces("application/xml")]
|
||||||
[Route("ContentWebService.asmx/AcceptMission")]
|
[Route("ContentWebService.asmx/AcceptMission")]
|
||||||
[VikingSession]
|
[VikingSession]
|
||||||
public IActionResult AcceptMission(Viking viking, [FromForm] string userId, [FromForm] int missionId) {
|
public IActionResult AcceptMission(Viking viking, [FromForm] Guid userId, [FromForm] int missionId) {
|
||||||
if (viking.Id != userId)
|
if (viking.Uid != userId)
|
||||||
return Unauthorized("Can't accept not owned mission");
|
return Unauthorized("Can't accept not owned mission");
|
||||||
|
|
||||||
MissionState? missionState = viking.MissionStates.FirstOrDefault(x => x.MissionId == missionId);
|
MissionState? missionState = viking.MissionStates.FirstOrDefault(x => x.MissionId == missionId);
|
||||||
@ -592,8 +592,8 @@ public class ContentController : Controller {
|
|||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Produces("application/xml")]
|
[Produces("application/xml")]
|
||||||
[Route("ContentWebService.asmx/GetUserMissionState")] // used by SoD 1.13
|
[Route("ContentWebService.asmx/GetUserMissionState")] // used by SoD 1.13
|
||||||
public IActionResult GetUserMissionStatev1([FromForm] string userId, [FromForm] string filter, [FromForm] string apiKey) {
|
public IActionResult GetUserMissionStatev1([FromForm] Guid userId, [FromForm] string filter, [FromForm] string apiKey) {
|
||||||
Viking? viking = ctx.Vikings.FirstOrDefault(x => x.Id == userId);
|
Viking? viking = ctx.Vikings.FirstOrDefault(x => x.Uid == userId);
|
||||||
if (viking is null)
|
if (viking is null)
|
||||||
return Ok("error");
|
return Ok("error");
|
||||||
|
|
||||||
@ -615,7 +615,7 @@ public class ContentController : Controller {
|
|||||||
result.Missions.Add(updatedMission);
|
result.Missions.Add(updatedMission);
|
||||||
}
|
}
|
||||||
|
|
||||||
result.UserID = Guid.Parse(viking.Id);
|
result.UserID = viking.Uid;
|
||||||
return Ok(result);
|
return Ok(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -623,9 +623,9 @@ public class ContentController : Controller {
|
|||||||
[Produces("application/xml")]
|
[Produces("application/xml")]
|
||||||
[Route("V2/ContentWebService.asmx/GetUserMissionState")]
|
[Route("V2/ContentWebService.asmx/GetUserMissionState")]
|
||||||
//[VikingSession(UseLock=false)]
|
//[VikingSession(UseLock=false)]
|
||||||
public IActionResult GetUserMissionState([FromForm] string userId, [FromForm] string filter, [FromForm] string apiKey) {
|
public IActionResult GetUserMissionState([FromForm] Guid userId, [FromForm] string filter, [FromForm] string apiKey) {
|
||||||
MissionRequestFilterV2 filterV2 = XmlUtil.DeserializeXml<MissionRequestFilterV2>(filter);
|
MissionRequestFilterV2 filterV2 = XmlUtil.DeserializeXml<MissionRequestFilterV2>(filter);
|
||||||
Viking? viking = ctx.Vikings.FirstOrDefault(x => x.Id == userId);
|
Viking? viking = ctx.Vikings.FirstOrDefault(x => x.Uid == userId);
|
||||||
if (viking is null)
|
if (viking is null)
|
||||||
return Ok("error");
|
return Ok("error");
|
||||||
|
|
||||||
@ -634,7 +634,7 @@ public class ContentController : Controller {
|
|||||||
foreach (var m in filterV2.MissionPair)
|
foreach (var m in filterV2.MissionPair)
|
||||||
if (m.MissionID != null)
|
if (m.MissionID != null)
|
||||||
result.Missions.Add(missionService.GetMissionWithProgress((int)m.MissionID, viking.Id, apiKey));
|
result.Missions.Add(missionService.GetMissionWithProgress((int)m.MissionID, viking.Id, apiKey));
|
||||||
// TODO: probably should also check for msiion based on filterV2.ProductGroupID vs mission.GroupID
|
// TODO: probably should also check for mission based on filterV2.ProductGroupID vs mission.GroupID
|
||||||
} else {
|
} else {
|
||||||
if (filterV2.GetCompletedMission ?? false) {
|
if (filterV2.GetCompletedMission ?? false) {
|
||||||
foreach (var mission in viking.MissionStates.Where(x => x.MissionStatus == MissionStatus.Completed))
|
foreach (var mission in viking.MissionStates.Where(x => x.MissionStatus == MissionStatus.Completed))
|
||||||
@ -645,7 +645,7 @@ public class ContentController : Controller {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
result.UserID = Guid.Parse(viking.Id);
|
result.UserID = viking.Uid;
|
||||||
return Ok(result);
|
return Ok(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -653,11 +653,11 @@ public class ContentController : Controller {
|
|||||||
[Produces("application/xml")]
|
[Produces("application/xml")]
|
||||||
[Route("ContentWebService.asmx/SetTaskState")] // used by SoD 1.13
|
[Route("ContentWebService.asmx/SetTaskState")] // used by SoD 1.13
|
||||||
[VikingSession(UseLock=true)]
|
[VikingSession(UseLock=true)]
|
||||||
public IActionResult SetTaskStatev1(Viking viking, [FromForm] string userId, [FromForm] int missionId, [FromForm] int taskId, [FromForm] bool completed, [FromForm] string xmlPayload, [FromForm] string apiKey) {
|
public IActionResult SetTaskStatev1(Viking viking, [FromForm] Guid userId, [FromForm] int missionId, [FromForm] int taskId, [FromForm] bool completed, [FromForm] string xmlPayload, [FromForm] string apiKey) {
|
||||||
if (viking.Id != userId)
|
if (viking.Uid != userId)
|
||||||
return Unauthorized("Can't set not owned task");
|
return Unauthorized("Can't set not owned task");
|
||||||
|
|
||||||
List<MissionCompletedResult> results = missionService.UpdateTaskProgress(missionId, taskId, userId, completed, xmlPayload, apiKey);
|
List<MissionCompletedResult> results = missionService.UpdateTaskProgress(missionId, taskId, viking.Id, completed, xmlPayload, apiKey);
|
||||||
|
|
||||||
SetTaskStateResult taskResult = new SetTaskStateResult {
|
SetTaskStateResult taskResult = new SetTaskStateResult {
|
||||||
Success = true,
|
Success = true,
|
||||||
@ -674,11 +674,11 @@ public class ContentController : Controller {
|
|||||||
[Produces("application/xml")]
|
[Produces("application/xml")]
|
||||||
[Route("V2/ContentWebService.asmx/SetTaskState")]
|
[Route("V2/ContentWebService.asmx/SetTaskState")]
|
||||||
[VikingSession]
|
[VikingSession]
|
||||||
public IActionResult SetTaskState(Viking viking, [FromForm] string userId, [FromForm] int missionId, [FromForm] int taskId, [FromForm] bool completed, [FromForm] string xmlPayload, [FromForm] string apiKey) {
|
public IActionResult SetTaskState(Viking viking, [FromForm] Guid userId, [FromForm] int missionId, [FromForm] int taskId, [FromForm] bool completed, [FromForm] string xmlPayload, [FromForm] string apiKey) {
|
||||||
if (viking.Id != userId)
|
if (viking.Uid != userId)
|
||||||
return Unauthorized("Can't set not owned task");
|
return Unauthorized("Can't set not owned task");
|
||||||
|
|
||||||
List<MissionCompletedResult> results = missionService.UpdateTaskProgress(missionId, taskId, userId, completed, xmlPayload, apiKey);
|
List<MissionCompletedResult> results = missionService.UpdateTaskProgress(missionId, taskId, viking.Id, completed, xmlPayload, apiKey);
|
||||||
|
|
||||||
SetTaskStateResult taskResult = new SetTaskStateResult {
|
SetTaskStateResult taskResult = new SetTaskStateResult {
|
||||||
Success = true,
|
Success = true,
|
||||||
@ -707,7 +707,7 @@ public class ContentController : Controller {
|
|||||||
var req = XmlUtil.DeserializeXml<RedeemRequest>(request);
|
var req = XmlUtil.DeserializeXml<RedeemRequest>(request);
|
||||||
|
|
||||||
// get and reduce quantity of box item
|
// get and reduce quantity of box item
|
||||||
InventoryItem? invItem = viking.Inventory.InventoryItems.FirstOrDefault(e => e.ItemId == req.ItemID);
|
InventoryItem? invItem = viking.InventoryItems.FirstOrDefault(e => e.ItemId == req.ItemID);
|
||||||
if (invItem is null || invItem.Quantity < 1) {
|
if (invItem is null || invItem.Quantity < 1) {
|
||||||
return Ok(new CommonInventoryResponse{ Success = false });
|
return Ok(new CommonInventoryResponse{ Success = false });
|
||||||
}
|
}
|
||||||
@ -804,9 +804,9 @@ public class ContentController : Controller {
|
|||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Produces("application/xml")]
|
[Produces("application/xml")]
|
||||||
[Route("ContentWebService.asmx/GetUserRoomItemPositions")]
|
[Route("ContentWebService.asmx/GetUserRoomItemPositions")]
|
||||||
public IActionResult GetUserRoomItemPositions([FromForm] string userId, [FromForm] string roomID) {
|
public IActionResult GetUserRoomItemPositions([FromForm] Guid userId, [FromForm] string roomID) {
|
||||||
// NOTE: this is public info (for mmo) - no session check
|
// NOTE: this is public info (for mmo) - no session check
|
||||||
Viking? viking = ctx.Vikings.FirstOrDefault(e => e.Id == userId);
|
Viking? viking = ctx.Vikings.FirstOrDefault(e => e.Uid == userId);
|
||||||
|
|
||||||
if (roomID is null)
|
if (roomID is null)
|
||||||
roomID = "";
|
roomID = "";
|
||||||
@ -862,7 +862,7 @@ public class ContentController : Controller {
|
|||||||
// NOTE: this is public info (for mmo) - no session check
|
// NOTE: this is public info (for mmo) - no session check
|
||||||
// TODO: Categories are not supported
|
// TODO: Categories are not supported
|
||||||
UserRoomGetRequest userRoomRequest = XmlUtil.DeserializeXml<UserRoomGetRequest>(request);
|
UserRoomGetRequest userRoomRequest = XmlUtil.DeserializeXml<UserRoomGetRequest>(request);
|
||||||
ICollection<Room>? rooms = ctx.Vikings.FirstOrDefault(x => x.Id == userRoomRequest.UserID.ToString())?.Rooms;
|
ICollection<Room>? rooms = ctx.Vikings.FirstOrDefault(x => x.Uid == userRoomRequest.UserID)?.Rooms;
|
||||||
UserRoomResponse response = new UserRoomResponse { UserRoomList = new List<UserRoom>() };
|
UserRoomResponse response = new UserRoomResponse { UserRoomList = new List<UserRoom>() };
|
||||||
if (rooms is null)
|
if (rooms is null)
|
||||||
return Ok(response);
|
return Ok(response);
|
||||||
@ -873,7 +873,7 @@ public class ContentController : Controller {
|
|||||||
if (room.RoomId != "") {
|
if (room.RoomId != "") {
|
||||||
// farm expansion room: RoomId is Id for expansion item
|
// farm expansion room: RoomId is Id for expansion item
|
||||||
if (Int32.TryParse(room.RoomId, out int inventoryItemId)) {
|
if (Int32.TryParse(room.RoomId, out int inventoryItemId)) {
|
||||||
InventoryItem? item = room.Viking.Inventory.InventoryItems.FirstOrDefault(e => e.Id == inventoryItemId);
|
InventoryItem? item = room.Viking.InventoryItems.FirstOrDefault(e => e.Id == inventoryItemId);
|
||||||
if (item != null) {
|
if (item != null) {
|
||||||
itemID = item.ItemId;
|
itemID = item.ItemId;
|
||||||
}
|
}
|
||||||
@ -966,7 +966,7 @@ public class ContentController : Controller {
|
|||||||
RollUserItemRequest req = XmlUtil.DeserializeXml<RollUserItemRequest>(request);
|
RollUserItemRequest req = XmlUtil.DeserializeXml<RollUserItemRequest>(request);
|
||||||
|
|
||||||
// get item
|
// get item
|
||||||
InventoryItem? invItem = viking.Inventory.InventoryItems.FirstOrDefault(e => e.Id == req.UserInventoryID);
|
InventoryItem? invItem = viking.InventoryItems.FirstOrDefault(e => e.Id == req.UserInventoryID);
|
||||||
if (invItem is null)
|
if (invItem is null)
|
||||||
return Ok(new RollUserItemResponse { Status = Status.ItemNotFound });
|
return Ok(new RollUserItemResponse { Status = Status.ItemNotFound });
|
||||||
|
|
||||||
@ -1061,7 +1061,7 @@ public class ContentController : Controller {
|
|||||||
try {
|
try {
|
||||||
if (req.BluePrintInventoryID != null) {
|
if (req.BluePrintInventoryID != null) {
|
||||||
blueprintItem = itemService.GetItem(
|
blueprintItem = itemService.GetItem(
|
||||||
viking.Inventory.InventoryItems.FirstOrDefault(e => e.Id == req.BluePrintInventoryID).ItemId
|
viking.InventoryItems.FirstOrDefault(e => e.Id == req.BluePrintInventoryID).ItemId
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
blueprintItem = itemService.GetItem(req.BluePrintItemID ?? -1);
|
blueprintItem = itemService.GetItem(req.BluePrintItemID ?? -1);
|
||||||
@ -1074,9 +1074,9 @@ public class ContentController : Controller {
|
|||||||
|
|
||||||
// remove items from DeductibleItemInventoryMaps and BluePrintFuseItemMaps
|
// remove items from DeductibleItemInventoryMaps and BluePrintFuseItemMaps
|
||||||
foreach (var item in req.DeductibleItemInventoryMaps) {
|
foreach (var item in req.DeductibleItemInventoryMaps) {
|
||||||
InventoryItem? invItem = viking.Inventory.InventoryItems.FirstOrDefault(e => e.Id == item.UserInventoryID);
|
InventoryItem? invItem = viking.InventoryItems.FirstOrDefault(e => e.Id == item.UserInventoryID);
|
||||||
if (invItem is null) {
|
if (invItem is null) {
|
||||||
invItem = viking.Inventory.InventoryItems.FirstOrDefault(e => e.ItemId == item.ItemID);
|
invItem = viking.InventoryItems.FirstOrDefault(e => e.ItemId == item.ItemID);
|
||||||
}
|
}
|
||||||
if (invItem is null || invItem.Quantity < item.Quantity) {
|
if (invItem is null || invItem.Quantity < item.Quantity) {
|
||||||
return Ok(new FuseItemsResponse { Status = Status.ItemNotFound });
|
return Ok(new FuseItemsResponse { Status = Status.ItemNotFound });
|
||||||
@ -1087,10 +1087,10 @@ public class ContentController : Controller {
|
|||||||
if (item.UserInventoryID < 0) {
|
if (item.UserInventoryID < 0) {
|
||||||
continue; // TODO: what we should do in this case?
|
continue; // TODO: what we should do in this case?
|
||||||
}
|
}
|
||||||
InventoryItem? invItem = viking.Inventory.InventoryItems.FirstOrDefault(e => e.Id == item.UserInventoryID);
|
InventoryItem? invItem = viking.InventoryItems.FirstOrDefault(e => e.Id == item.UserInventoryID);
|
||||||
if (invItem is null)
|
if (invItem is null)
|
||||||
return Ok(new FuseItemsResponse { Status = Status.ItemNotFound });
|
return Ok(new FuseItemsResponse { Status = Status.ItemNotFound });
|
||||||
viking.Inventory.InventoryItems.Remove(invItem);
|
viking.InventoryItems.Remove(invItem);
|
||||||
}
|
}
|
||||||
// NOTE: we haven't saved any changes so far ... so we can safely interrupt "fusing" by return in loops above
|
// NOTE: we haven't saved any changes so far ... so we can safely interrupt "fusing" by return in loops above
|
||||||
|
|
||||||
@ -1196,7 +1196,7 @@ public class ContentController : Controller {
|
|||||||
case ActionType.MoveToInventory:
|
case ActionType.MoveToInventory:
|
||||||
// item is in inventory in result of ApplyRewards ... only add to itemsAddedToInventory
|
// item is in inventory in result of ApplyRewards ... only add to itemsAddedToInventory
|
||||||
itemsAddedToInventory.Add (new CommonInventoryResponseRewardBinItem {
|
itemsAddedToInventory.Add (new CommonInventoryResponseRewardBinItem {
|
||||||
ItemID = viking.Inventory.InventoryItems.FirstOrDefault(e => e.Id == actionMap.ID).ItemId,
|
ItemID = viking.InventoryItems.FirstOrDefault(e => e.Id == actionMap.ID).ItemId,
|
||||||
CommonInventoryID = actionMap.ID,
|
CommonInventoryID = actionMap.ID,
|
||||||
Quantity = 0,
|
Quantity = 0,
|
||||||
UserItemStatsMapID = actionMap.ID
|
UserItemStatsMapID = actionMap.ID
|
||||||
@ -1333,7 +1333,7 @@ public class ContentController : Controller {
|
|||||||
selectedDragonId = dragon.Viking.SelectedDragonId;
|
selectedDragonId = dragon.Viking.SelectedDragonId;
|
||||||
RaisedPetData data = XmlUtil.DeserializeXml<RaisedPetData>(dragon.RaisedPetData);
|
RaisedPetData data = XmlUtil.DeserializeXml<RaisedPetData>(dragon.RaisedPetData);
|
||||||
data.RaisedPetID = dragon.Id;
|
data.RaisedPetID = dragon.Id;
|
||||||
data.EntityID = Guid.Parse(dragon.EntityId);
|
data.EntityID = dragon.EntityId;
|
||||||
data.IsSelected = (selectedDragonId == dragon.Id);
|
data.IsSelected = (selectedDragonId == dragon.Id);
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
@ -1393,7 +1393,7 @@ public class ContentController : Controller {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
string imageUrl = string.Format("{0}://{1}/RawImage/{2}/{3}/{4}.jpg", HttpContext.Request.Scheme, HttpContext.Request.Host, viking.Id, ImageType, ImageSlot);
|
string imageUrl = string.Format("{0}://{1}/RawImage/{2}/{3}/{4}.jpg", HttpContext.Request.Scheme, HttpContext.Request.Host, viking.Uid, ImageType, ImageSlot);
|
||||||
|
|
||||||
return new ImageData {
|
return new ImageData {
|
||||||
ImageURL = imageUrl,
|
ImageURL = imageUrl,
|
||||||
|
@ -21,8 +21,8 @@ public class ImageController : Controller {
|
|||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[Route("RawImage/{VikingId}/{ImageType}/{ImageSlot}.jpg")]
|
[Route("RawImage/{VikingId}/{ImageType}/{ImageSlot}.jpg")]
|
||||||
public IActionResult RawImage(String VikingId, String ImageType, int ImageSlot) {
|
public IActionResult RawImage(string VikingId, string ImageType, int ImageSlot) {
|
||||||
Image? image = ctx.Images.FirstOrDefault(e => e.VikingId == VikingId && e.ImageType == ImageType && e.ImageSlot == ImageSlot);
|
Image? image = ctx.Images.FirstOrDefault(e => e.Viking.Uid == Guid.Parse(VikingId) && e.ImageType == ImageType && e.ImageSlot == ImageSlot);
|
||||||
if (image is null || image.ImageData is null) {
|
if (image is null || image.ImageData is null) {
|
||||||
return NotFound();
|
return NotFound();
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ public class MembershipController : Controller {
|
|||||||
return Ok();
|
return Ok();
|
||||||
|
|
||||||
ChildList profiles = new ChildList();
|
ChildList profiles = new ChildList();
|
||||||
profiles.strings = user.Vikings.Select(viking => viking.Id + ", " + viking.Name).ToArray();
|
profiles.strings = user.Vikings.Select(viking => viking.Uid + ", " + viking.Name).ToArray();
|
||||||
|
|
||||||
return Ok(profiles);
|
return Ok(profiles);
|
||||||
}
|
}
|
||||||
|
@ -19,10 +19,10 @@ public class ProfileController : Controller {
|
|||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Produces("application/xml")]
|
[Produces("application/xml")]
|
||||||
[Route("ProfileWebService.asmx/GetUserProfileByUserID")]
|
[Route("ProfileWebService.asmx/GetUserProfileByUserID")]
|
||||||
public IActionResult GetUserProfileByUserID([FromForm] string userId, [FromForm] string apiKey) {
|
public IActionResult GetUserProfileByUserID([FromForm] Guid userId, [FromForm] string apiKey) {
|
||||||
// NOTE: this is public info (for mmo) - no session check
|
// NOTE: this is public info (for mmo) - no session check
|
||||||
|
|
||||||
Viking? viking = ctx.Vikings.FirstOrDefault(e => e.Id == userId);
|
Viking? viking = ctx.Vikings.FirstOrDefault(e => e.Uid == userId);
|
||||||
if (viking is null) {
|
if (viking is null) {
|
||||||
return Ok(new UserProfileData());
|
return Ok(new UserProfileData());
|
||||||
// NOTE: do not return `Conflict("Viking not found")` due to client side error handling
|
// NOTE: do not return `Conflict("Viking not found")` due to client side error handling
|
||||||
@ -113,7 +113,7 @@ public class ProfileController : Controller {
|
|||||||
AvatarData avatarData = null;
|
AvatarData avatarData = null;
|
||||||
if (viking.AvatarSerialized is not null) {
|
if (viking.AvatarSerialized is not null) {
|
||||||
avatarData = XmlUtil.DeserializeXml<AvatarData>(viking.AvatarSerialized);
|
avatarData = XmlUtil.DeserializeXml<AvatarData>(viking.AvatarSerialized);
|
||||||
avatarData.Id = viking.Inventory.Id;
|
avatarData.Id = viking.Id;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (avatarData != null && (apiKey == "a3a12a0a-7c6e-4e9b-b0f7-22034d799013")) {
|
if (avatarData != null && (apiKey == "a3a12a0a-7c6e-4e9b-b0f7-22034d799013")) {
|
||||||
@ -135,8 +135,8 @@ public class ProfileController : Controller {
|
|||||||
AvatarData = avatarData,
|
AvatarData = avatarData,
|
||||||
UserInfo = new UserInfo {
|
UserInfo = new UserInfo {
|
||||||
MembershipID = "ef84db9-59c6-4950-b8ea-bbc1521f899b", // placeholder
|
MembershipID = "ef84db9-59c6-4950-b8ea-bbc1521f899b", // placeholder
|
||||||
UserID = viking.Id,
|
UserID = viking.Uid.ToString(),
|
||||||
ParentUserID = viking.UserId,
|
ParentUserID = viking.UserId.ToString(),
|
||||||
Username = viking.Name,
|
Username = viking.Name,
|
||||||
FirstName = viking.Name,
|
FirstName = viking.Name,
|
||||||
MultiplayerEnabled = (apiKey != "a1a13a0a-7c6e-4e9b-b0f7-22034d799013" && apiKey != "a2a09a0a-7c6e-4e9b-b0f7-22034d799013" && apiKey != "a3a12a0a-7c6e-4e9b-b0f7-22034d799013"),
|
MultiplayerEnabled = (apiKey != "a1a13a0a-7c6e-4e9b-b0f7-22034d799013" && apiKey != "a2a09a0a-7c6e-4e9b-b0f7-22034d799013" && apiKey != "a3a12a0a-7c6e-4e9b-b0f7-22034d799013"),
|
||||||
@ -149,7 +149,7 @@ public class ProfileController : Controller {
|
|||||||
FacebookUserID = 0
|
FacebookUserID = 0
|
||||||
},
|
},
|
||||||
UserSubscriptionInfo = new UserSubscriptionInfo {
|
UserSubscriptionInfo = new UserSubscriptionInfo {
|
||||||
UserID = viking.UserId,
|
UserID = viking.UserId.ToString(),
|
||||||
MembershipID = 130687131, // placeholder
|
MembershipID = 130687131, // placeholder
|
||||||
SubscriptionTypeID = 1, // placeholder
|
SubscriptionTypeID = 1, // placeholder
|
||||||
SubscriptionDisplayName = "Member", // placeholder
|
SubscriptionDisplayName = "Member", // placeholder
|
||||||
@ -168,11 +168,11 @@ public class ProfileController : Controller {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return new UserProfileData {
|
return new UserProfileData {
|
||||||
ID = viking.Id,
|
ID = viking.Uid.ToString(),
|
||||||
AvatarInfo = avatar,
|
AvatarInfo = avatar,
|
||||||
AchievementCount = 0,
|
AchievementCount = 0,
|
||||||
MythieCount = 0,
|
MythieCount = 0,
|
||||||
AnswerData = new UserAnswerData { UserID = viking.Id },
|
AnswerData = new UserAnswerData { UserID = viking.Uid.ToString() },
|
||||||
GameCurrency = 65536,
|
GameCurrency = 65536,
|
||||||
CashCurrency = 65536,
|
CashCurrency = 65536,
|
||||||
ActivityCount = 0,
|
ActivityCount = 0,
|
||||||
|
@ -27,13 +27,13 @@ public class RegistrationController : Controller {
|
|||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Produces("application/xml")]
|
[Produces("application/xml")]
|
||||||
[Route("v3/RegistrationWebService.asmx/DeleteProfile")]
|
[Route("v3/RegistrationWebService.asmx/DeleteProfile")]
|
||||||
public IActionResult DeleteProfile([FromForm] string apiToken, [FromForm] string userID) {
|
public IActionResult DeleteProfile([FromForm] Guid apiToken, [FromForm] Guid userID) {
|
||||||
User? user = ctx.Sessions.FirstOrDefault(e => e.ApiToken == apiToken)?.User;
|
User? user = ctx.Sessions.FirstOrDefault(e => e.ApiToken == apiToken)?.User;
|
||||||
if (user is null) {
|
if (user is null) {
|
||||||
return Ok(DeleteProfileStatus.OWNER_ID_NOT_FOUND);
|
return Ok(DeleteProfileStatus.OWNER_ID_NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
Viking? viking = ctx.Vikings.FirstOrDefault(e => e.Id == userID);
|
Viking? viking = ctx.Vikings.FirstOrDefault(e => e.Uid == userID);
|
||||||
if (viking is null) {
|
if (viking is null) {
|
||||||
return Ok(DeleteProfileStatus.PROFILE_NOT_FOUND);
|
return Ok(DeleteProfileStatus.PROFILE_NOT_FOUND);
|
||||||
}
|
}
|
||||||
@ -56,7 +56,7 @@ public class RegistrationController : Controller {
|
|||||||
public IActionResult RegisterParent() {
|
public IActionResult RegisterParent() {
|
||||||
ParentRegistrationData data = XmlUtil.DeserializeXml<ParentRegistrationData>(Request.Form["parentRegistrationData"]);
|
ParentRegistrationData data = XmlUtil.DeserializeXml<ParentRegistrationData>(Request.Form["parentRegistrationData"]);
|
||||||
User u = new User {
|
User u = new User {
|
||||||
Id = Guid.NewGuid().ToString(),
|
Id = Guid.NewGuid(),
|
||||||
Username = data.ChildList[0].ChildName,
|
Username = data.ChildList[0].ChildName,
|
||||||
Password = new PasswordHasher<object>().HashPassword(null, data.Password),
|
Password = new PasswordHasher<object>().HashPassword(null, data.Password),
|
||||||
Email = data.Email
|
Email = data.Email
|
||||||
@ -73,14 +73,14 @@ public class RegistrationController : Controller {
|
|||||||
ParentLoginInfo pli = new ParentLoginInfo {
|
ParentLoginInfo pli = new ParentLoginInfo {
|
||||||
UserName = u.Username,
|
UserName = u.Username,
|
||||||
ApiToken = Guid.NewGuid().ToString(),
|
ApiToken = Guid.NewGuid().ToString(),
|
||||||
UserID = u.Id,
|
UserID = u.Id.ToString(),
|
||||||
Status = MembershipUserStatus.Success,
|
Status = MembershipUserStatus.Success,
|
||||||
UnAuthorized = false
|
UnAuthorized = false
|
||||||
};
|
};
|
||||||
|
|
||||||
var response = new RegistrationResult {
|
var response = new RegistrationResult {
|
||||||
ParentLoginInfo = pli,
|
ParentLoginInfo = pli,
|
||||||
UserID = u.Id,
|
UserID = u.Id.ToString(),
|
||||||
Status = MembershipUserStatus.Success,
|
Status = MembershipUserStatus.Success,
|
||||||
ApiToken = Guid.NewGuid().ToString()
|
ApiToken = Guid.NewGuid().ToString()
|
||||||
};
|
};
|
||||||
@ -94,7 +94,7 @@ public class RegistrationController : Controller {
|
|||||||
[Route("V4/RegistrationWebService.asmx/RegisterChild")]
|
[Route("V4/RegistrationWebService.asmx/RegisterChild")]
|
||||||
[DecryptRequest("childRegistrationData")]
|
[DecryptRequest("childRegistrationData")]
|
||||||
[EncryptResponse]
|
[EncryptResponse]
|
||||||
public IActionResult RegisterChild([FromForm] string parentApiToken, [FromForm] string apiKey) {
|
public IActionResult RegisterChild([FromForm] Guid parentApiToken, [FromForm] string apiKey) {
|
||||||
User? user = ctx.Sessions.FirstOrDefault(e => e.ApiToken == parentApiToken)?.User;
|
User? user = ctx.Sessions.FirstOrDefault(e => e.ApiToken == parentApiToken)?.User;
|
||||||
if (user is null) {
|
if (user is null) {
|
||||||
return Ok(new RegistrationResult{
|
return Ok(new RegistrationResult{
|
||||||
@ -113,14 +113,15 @@ public class RegistrationController : Controller {
|
|||||||
return Ok(new RegistrationResult { Status = MembershipUserStatus.DuplicateUserName });
|
return Ok(new RegistrationResult { Status = MembershipUserStatus.DuplicateUserName });
|
||||||
}
|
}
|
||||||
|
|
||||||
Inventory inv = new Inventory { InventoryItems = new List<InventoryItem>() };
|
List<InventoryItem> items = new() {
|
||||||
inv.InventoryItems.Add(new InventoryItem { ItemId = 8977, Quantity = 1 }); // DragonStableINTDO - Dragons Dragon Stable
|
new InventoryItem { ItemId = 8977, Quantity = 1 } // DragonStableINTDO - Dragons Dragon Stable
|
||||||
|
};
|
||||||
|
|
||||||
Viking v = new Viking {
|
Viking v = new Viking {
|
||||||
Id = Guid.NewGuid().ToString(),
|
Uid = Guid.NewGuid(),
|
||||||
Name = data.ChildName,
|
Name = data.ChildName,
|
||||||
User = user,
|
User = user,
|
||||||
Inventory = inv,
|
InventoryItems = items,
|
||||||
AchievementPoints = new List<AchievementPoints>(),
|
AchievementPoints = new List<AchievementPoints>(),
|
||||||
Rooms = new List<Room>()
|
Rooms = new List<Room>()
|
||||||
};
|
};
|
||||||
@ -145,7 +146,7 @@ public class RegistrationController : Controller {
|
|||||||
roomService.CreateRoom(v, "MyRoomINT");
|
roomService.CreateRoom(v, "MyRoomINT");
|
||||||
|
|
||||||
return Ok(new RegistrationResult {
|
return Ok(new RegistrationResult {
|
||||||
UserID = v.Id,
|
UserID = v.Uid.ToString(),
|
||||||
Status = MembershipUserStatus.Success
|
Status = MembershipUserStatus.Success
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace sodoff.Model;
|
namespace sodoff.Model;
|
||||||
public class AchievementPoints {
|
public class AchievementPoints {
|
||||||
public string VikingId { get; set; }
|
public int VikingId { get; set; }
|
||||||
|
|
||||||
public int Type { get; set; }
|
public int Type { get; set; }
|
||||||
|
|
||||||
|
@ -10,7 +10,6 @@ public class DBContext : DbContext {
|
|||||||
public DbSet<Pair> Pairs { get; set; } = null!;
|
public DbSet<Pair> Pairs { get; set; } = null!;
|
||||||
public DbSet<PairData> PairData { get; set; } = null!;
|
public DbSet<PairData> PairData { get; set; } = null!;
|
||||||
public DbSet<TaskStatus> TaskStatuses { get; set; } = null!;
|
public DbSet<TaskStatus> TaskStatuses { get; set; } = null!;
|
||||||
public DbSet<Inventory> Inventories { get; set; } = null!;
|
|
||||||
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!;
|
||||||
@ -70,10 +69,10 @@ public class DBContext : DbContext {
|
|||||||
builder.Entity<Viking>().HasMany(v => v.PairData)
|
builder.Entity<Viking>().HasMany(v => v.PairData)
|
||||||
.WithOne(e => e.Viking);
|
.WithOne(e => e.Viking);
|
||||||
|
|
||||||
builder.Entity<Viking>().HasOne(v => v.Inventory)
|
builder.Entity<Viking>().HasMany(v => v.Images)
|
||||||
.WithOne(e => e.Viking);
|
.WithOne(e => e.Viking);
|
||||||
|
|
||||||
builder.Entity<Viking>().HasMany(v => v.Images)
|
builder.Entity<Viking>().HasMany(v => v.TaskStatuses)
|
||||||
.WithOne(e => e.Viking);
|
.WithOne(e => e.Viking);
|
||||||
|
|
||||||
builder.Entity<Viking>().HasOne(v => v.SelectedDragon)
|
builder.Entity<Viking>().HasOne(v => v.SelectedDragon)
|
||||||
@ -114,19 +113,14 @@ public class DBContext : DbContext {
|
|||||||
.HasPrincipalKey(e => e.Id);
|
.HasPrincipalKey(e => e.Id);
|
||||||
|
|
||||||
// Inventory & InventoryItem
|
// Inventory & InventoryItem
|
||||||
builder.Entity<Inventory>()
|
builder.Entity<Viking>()
|
||||||
.HasOne(i => i.Viking)
|
.HasMany(v => v.InventoryItems)
|
||||||
.WithOne(e => e.Inventory)
|
.WithOne(i => i.Viking);
|
||||||
.HasForeignKey<Inventory>(e => e.VikingId);
|
|
||||||
|
|
||||||
builder.Entity<Inventory>()
|
|
||||||
.HasMany(i => i.InventoryItems)
|
|
||||||
.WithOne(e => e.Inventory);
|
|
||||||
|
|
||||||
builder.Entity<InventoryItem>()
|
builder.Entity<InventoryItem>()
|
||||||
.HasOne(e => e.Inventory)
|
.HasOne(e => e.Viking)
|
||||||
.WithMany(e => e.InventoryItems)
|
.WithMany(e => e.InventoryItems)
|
||||||
.HasForeignKey(e => e.InventoryId);
|
.HasForeignKey(e => e.VikingId);
|
||||||
|
|
||||||
// Room & RoomItem
|
// Room & RoomItem
|
||||||
builder.Entity<Room>().HasOne(r => r.Viking)
|
builder.Entity<Room>().HasOne(r => r.Viking)
|
||||||
@ -149,7 +143,8 @@ public class DBContext : DbContext {
|
|||||||
|
|
||||||
builder.Entity<TaskStatus>()
|
builder.Entity<TaskStatus>()
|
||||||
.HasOne(t => t.Viking)
|
.HasOne(t => t.Viking)
|
||||||
.WithMany();
|
.WithMany(v => v.TaskStatuses)
|
||||||
|
.HasForeignKey(t => t.VikingId);
|
||||||
|
|
||||||
builder.Entity<MissionState>().HasOne(m => m.Viking)
|
builder.Entity<MissionState>().HasOne(m => m.Viking)
|
||||||
.WithMany(e => e.MissionStates)
|
.WithMany(e => e.MissionStates)
|
||||||
|
@ -9,10 +9,9 @@ public class Dragon {
|
|||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
public string EntityId { get; set; } = null!;
|
public Guid EntityId { get; set; }
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
public string VikingId { get; set; } = null!;
|
public int VikingId { get; set; }
|
||||||
|
|
||||||
public string? RaisedPetData { get; set; }
|
public string? RaisedPetData { get; set; }
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ public class Image {
|
|||||||
public int ImageSlot { get; set; }
|
public int ImageSlot { get; set; }
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
public string VikingId { get; set; } = null!;
|
public int VikingId { get; set; }
|
||||||
|
|
||||||
public string? ImageData { get; set; }
|
public string? ImageData { get; set; }
|
||||||
|
|
||||||
|
@ -1,13 +0,0 @@
|
|||||||
using System.ComponentModel.DataAnnotations;
|
|
||||||
|
|
||||||
namespace sodoff.Model;
|
|
||||||
public class Inventory {
|
|
||||||
[Key]
|
|
||||||
public int Id { get; set; }
|
|
||||||
|
|
||||||
public string VikingId { get; set; }
|
|
||||||
|
|
||||||
public virtual Viking? Viking { get; set; }
|
|
||||||
|
|
||||||
public virtual ICollection<InventoryItem> InventoryItems { get; set; } = null!;
|
|
||||||
}
|
|
@ -7,11 +7,11 @@ namespace sodoff.Model {
|
|||||||
|
|
||||||
public int ItemId { get; set; }
|
public int ItemId { get; set; }
|
||||||
|
|
||||||
public int InventoryId { get; set; }
|
public int VikingId { get; set; }
|
||||||
|
|
||||||
public string? StatsSerialized { get; set; }
|
public string? StatsSerialized { get; set; }
|
||||||
|
|
||||||
public virtual Inventory Inventory { get; set; }
|
public virtual Viking Viking { get; set; } = null!;
|
||||||
|
|
||||||
public int Quantity { get; set; }
|
public int Quantity { get; set; }
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ public class MissionState {
|
|||||||
|
|
||||||
public int MissionId { get; set; }
|
public int MissionId { get; set; }
|
||||||
|
|
||||||
public string VikingId { get; set; } = null!;
|
public int VikingId { get; set; }
|
||||||
|
|
||||||
public virtual Viking? Viking { get; set; }
|
public virtual Viking? Viking { get; set; }
|
||||||
|
|
||||||
|
@ -8,11 +8,11 @@ public class Pair {
|
|||||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
public string Key { get; set; }
|
public string Key { get; set; } = null!;
|
||||||
|
|
||||||
public string Value { get; set; }
|
public string Value { get; set; } = null!;
|
||||||
|
|
||||||
public int MasterId { get; set; }
|
public int MasterId { get; set; }
|
||||||
|
|
||||||
public virtual PairData PairData { get; set; }
|
public virtual PairData PairData { get; set; } = null!;
|
||||||
}
|
}
|
||||||
|
@ -13,9 +13,9 @@ public class PairData {
|
|||||||
|
|
||||||
public int PairId { get; set; }
|
public int PairId { get; set; }
|
||||||
|
|
||||||
public string? UserId { get; set; }
|
public Guid? UserId { get; set; }
|
||||||
|
|
||||||
public string? VikingId { get; set; }
|
public int? VikingId { get; set; }
|
||||||
|
|
||||||
public int? DragonId { get; set; }
|
public int? DragonId { get; set; }
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ public class Room {
|
|||||||
|
|
||||||
public string RoomId { get; set; }
|
public string RoomId { get; set; }
|
||||||
|
|
||||||
public string VikingId { get; set; } = null!;
|
public int VikingId { get; set; }
|
||||||
|
|
||||||
public string? Name { get; set; }
|
public string? Name { get; set; }
|
||||||
|
|
||||||
|
@ -3,11 +3,11 @@
|
|||||||
namespace sodoff.Model;
|
namespace sodoff.Model;
|
||||||
public class Session {
|
public class Session {
|
||||||
[Key]
|
[Key]
|
||||||
public string ApiToken { get; set; } = null!;
|
public Guid ApiToken { get; set; }
|
||||||
|
|
||||||
public string? UserId { get; set; }
|
public Guid? UserId { get; set; }
|
||||||
|
|
||||||
public string? VikingId { get; set; }
|
public int? VikingId { get; set; }
|
||||||
|
|
||||||
public DateTime? CreatedAt { get; set; }
|
public DateTime? CreatedAt { get; set; }
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
public int MissionId { get; set; }
|
public int MissionId { get; set; }
|
||||||
|
|
||||||
public string VikingId { get; set; } = null!;
|
public int VikingId { get; set; }
|
||||||
|
|
||||||
public virtual Viking? Viking { get; set; }
|
public virtual Viking? Viking { get; set; }
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
namespace sodoff.Model;
|
namespace sodoff.Model;
|
||||||
public class User {
|
public class User {
|
||||||
[Key]
|
[Key]
|
||||||
public string Id { get; set; } = null!;
|
public Guid Id { get; set; }
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
public string Email { get; set; } = null!;
|
public string Email { get; set; } = null!;
|
||||||
|
@ -1,15 +1,20 @@
|
|||||||
using System.ComponentModel.DataAnnotations;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
namespace sodoff.Model;
|
namespace sodoff.Model;
|
||||||
|
|
||||||
|
[Index(nameof(Uid))]
|
||||||
public class Viking {
|
public class Viking {
|
||||||
[Key]
|
[Key]
|
||||||
public string Id { get; set; } = null!;
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
public Guid Uid { get; set; }
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
public string Name { get; set; } = null!;
|
public string Name { get; set; } = null!;
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
public string UserId { get; set; } = null!;
|
public Guid UserId { get; set; }
|
||||||
|
|
||||||
public string? AvatarSerialized { get; set; }
|
public string? AvatarSerialized { get; set; }
|
||||||
|
|
||||||
@ -20,9 +25,10 @@ public class Viking {
|
|||||||
public virtual ICollection<Dragon> Dragons { get; set; } = null!;
|
public virtual ICollection<Dragon> Dragons { get; set; } = null!;
|
||||||
public virtual ICollection<Image> Images { get; set; } = null!;
|
public virtual ICollection<Image> Images { get; set; } = null!;
|
||||||
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<Room> Rooms { get; set; } = null!;
|
public virtual ICollection<Room> Rooms { 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 Inventory Inventory { get; set; } = null!;
|
public virtual ICollection<InventoryItem> InventoryItems { get; set; } = null!;
|
||||||
public virtual Dragon? SelectedDragon { get; set; }
|
public virtual Dragon? SelectedDragon { get; set; }
|
||||||
}
|
}
|
||||||
|
@ -15,11 +15,11 @@ namespace sodoff.Services {
|
|||||||
this.inventoryService = inventoryService;
|
this.inventoryService = inventoryService;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UserAchievementInfo CreateUserAchievementInfo(string userId, int? value, AchievementPointTypes type) {
|
public UserAchievementInfo CreateUserAchievementInfo(Guid userId, int? value, AchievementPointTypes type) {
|
||||||
if (value is null)
|
if (value is null)
|
||||||
value = 0;
|
value = 0;
|
||||||
return new UserAchievementInfo {
|
return new UserAchievementInfo {
|
||||||
UserID = Guid.Parse(userId),
|
UserID = userId,
|
||||||
AchievementPointTotal = value,
|
AchievementPointTotal = value,
|
||||||
RankID = achievementStore.GetRankFromXP(value, type),
|
RankID = achievementStore.GetRankFromXP(value, type),
|
||||||
PointTypeID = type
|
PointTypeID = type
|
||||||
@ -27,7 +27,7 @@ namespace sodoff.Services {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public UserAchievementInfo CreateUserAchievementInfo(Viking viking, AchievementPointTypes type) {
|
public UserAchievementInfo CreateUserAchievementInfo(Viking viking, AchievementPointTypes type) {
|
||||||
return CreateUserAchievementInfo(viking.Id, viking.AchievementPoints.FirstOrDefault(a => a.Type == (int)type)?.Value, type);
|
return CreateUserAchievementInfo(viking.Uid, viking.AchievementPoints.FirstOrDefault(a => a.Type == (int)type)?.Value, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DragonLevelUpOnAgeUp(Dragon dragon, RaisedPetGrowthState oldGrowthState, RaisedPetGrowthState newGrowthState) {
|
public void DragonLevelUpOnAgeUp(Dragon dragon, RaisedPetGrowthState oldGrowthState, RaisedPetGrowthState newGrowthState) {
|
||||||
@ -61,7 +61,7 @@ namespace sodoff.Services {
|
|||||||
|
|
||||||
return new AchievementReward{
|
return new AchievementReward{
|
||||||
// NOTE: RewardID and EntityTypeID are not used by client
|
// NOTE: RewardID and EntityTypeID are not used by client
|
||||||
EntityID = Guid.Parse(dragon.EntityId),
|
EntityID = dragon.EntityId,
|
||||||
PointTypeID = AchievementPointTypes.DragonXP,
|
PointTypeID = AchievementPointTypes.DragonXP,
|
||||||
Amount = value ?? 0
|
Amount = value ?? 0
|
||||||
};
|
};
|
||||||
@ -87,7 +87,7 @@ namespace sodoff.Services {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return new AchievementReward{
|
return new AchievementReward{
|
||||||
EntityID = Guid.Parse(viking.Id),
|
EntityID = viking.Uid,
|
||||||
PointTypeID = type,
|
PointTypeID = type,
|
||||||
Amount = value
|
Amount = value
|
||||||
};
|
};
|
||||||
@ -100,7 +100,7 @@ namespace sodoff.Services {
|
|||||||
inventoryService.AddItemToInventory(viking, reward.ItemID, (int)reward.Amount!);
|
inventoryService.AddItemToInventory(viking, reward.ItemID, (int)reward.Amount!);
|
||||||
|
|
||||||
AchievementReward grantedReward = reward.Clone();
|
AchievementReward grantedReward = reward.Clone();
|
||||||
grantedReward.EntityID = Guid.Parse(viking.Id);
|
grantedReward.EntityID = viking.Uid;
|
||||||
return grantedReward;
|
return grantedReward;
|
||||||
} else { // currencies, all types of player XP and dragon XP
|
} else { // currencies, all types of player XP and dragon XP
|
||||||
return AddAchievementPoints(viking, reward.PointTypeID, reward.Amount);
|
return AddAchievementPoints(viking, reward.PointTypeID, reward.Amount);
|
||||||
@ -117,7 +117,7 @@ namespace sodoff.Services {
|
|||||||
double amountDouble = (reward.Amount ?? 0)/dragonsIDs.Length;
|
double amountDouble = (reward.Amount ?? 0)/dragonsIDs.Length;
|
||||||
int amount = (int)Math.Ceiling(amountDouble);
|
int amount = (int)Math.Ceiling(amountDouble);
|
||||||
foreach (Guid dragonID in dragonsIDs) {
|
foreach (Guid dragonID in dragonsIDs) {
|
||||||
Dragon dragon = viking.Dragons.FirstOrDefault(e => e.EntityId == dragonID.ToString());
|
Dragon dragon = viking.Dragons.FirstOrDefault(e => e.EntityId == dragonID);
|
||||||
grantedRewards.Add(
|
grantedRewards.Add(
|
||||||
AddDragonAchievementPoints(dragon, amount)
|
AddDragonAchievementPoints(dragon, amount)
|
||||||
);
|
);
|
||||||
@ -158,7 +158,7 @@ namespace sodoff.Services {
|
|||||||
CashCurrency = 65536,
|
CashCurrency = 65536,
|
||||||
GameCurrency = 65536,
|
GameCurrency = 65536,
|
||||||
UserGameCurrencyID = 1, // TODO: user's wallet ID?
|
UserGameCurrencyID = 1, // TODO: user's wallet ID?
|
||||||
UserID = Guid.Parse(viking.Id)
|
UserID = viking.Uid
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ namespace sodoff.Services {
|
|||||||
public InventoryItem AddItemToInventory(Viking viking, int itemID, int quantity) {
|
public InventoryItem AddItemToInventory(Viking viking, int itemID, int quantity) {
|
||||||
InventoryItem? item = null;
|
InventoryItem? item = null;
|
||||||
if (!ItemNeedUniqueInventorySlot(itemID))
|
if (!ItemNeedUniqueInventorySlot(itemID))
|
||||||
item = viking.Inventory.InventoryItems.FirstOrDefault(e => e.ItemId == itemID);
|
item = viking.InventoryItems.FirstOrDefault(e => e.ItemId == itemID);
|
||||||
if (item is null) {
|
if (item is null) {
|
||||||
ItemData itemData = itemService.GetItem(itemID);
|
ItemData itemData = itemService.GetItem(itemID);
|
||||||
item = new InventoryItem {
|
item = new InventoryItem {
|
||||||
@ -36,7 +36,7 @@ namespace sodoff.Services {
|
|||||||
ItemStats = itemService.CreateItemStats(itemData.PossibleStatsMap, (int)itemData.ItemRarity, itemTier).ToArray()
|
ItemStats = itemService.CreateItemStats(itemData.PossibleStatsMap, (int)itemData.ItemRarity, itemTier).ToArray()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
viking.Inventory.InventoryItems.Add(item);
|
viking.InventoryItems.Add(item);
|
||||||
}
|
}
|
||||||
item.Quantity += quantity;
|
item.Quantity += quantity;
|
||||||
return item;
|
return item;
|
||||||
@ -71,7 +71,7 @@ namespace sodoff.Services {
|
|||||||
item.StatsSerialized = XmlUtil.SerializeXml(itemStatsMap);
|
item.StatsSerialized = XmlUtil.SerializeXml(itemStatsMap);
|
||||||
|
|
||||||
// add to viking
|
// add to viking
|
||||||
viking.Inventory.InventoryItems.Add(item);
|
viking.InventoryItems.Add(item);
|
||||||
ctx.SaveChanges(); // We need to get the ID of the newly created item
|
ctx.SaveChanges(); // We need to get the ID of the newly created item
|
||||||
|
|
||||||
// return item with stats
|
// return item with stats
|
||||||
@ -84,7 +84,7 @@ namespace sodoff.Services {
|
|||||||
|
|
||||||
public void SellInventoryItem(Viking viking, int invItemID, ref int gold, ref int shard) {
|
public void SellInventoryItem(Viking viking, int invItemID, ref int gold, ref int shard) {
|
||||||
// get item from inventory
|
// get item from inventory
|
||||||
InventoryItem? item = viking.Inventory.InventoryItems.FirstOrDefault(e => e.Id == invItemID);
|
InventoryItem? item = viking.InventoryItems.FirstOrDefault(e => e.Id == invItemID);
|
||||||
if (item is null)
|
if (item is null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -110,11 +110,11 @@ namespace sodoff.Services {
|
|||||||
// TODO: calculate cash (gold) rewards
|
// TODO: calculate cash (gold) rewards
|
||||||
|
|
||||||
// remove item
|
// remove item
|
||||||
viking.Inventory.InventoryItems.Remove(item);
|
viking.InventoryItems.Remove(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CommonInventoryData GetCommonInventoryData(Viking viking) {
|
public CommonInventoryData GetCommonInventoryData(Viking viking) {
|
||||||
List<InventoryItem> items = viking.Inventory.InventoryItems.ToList();
|
List<InventoryItem> items = viking.InventoryItems.ToList();
|
||||||
|
|
||||||
List<UserItemData> userItemData = new();
|
List<UserItemData> userItemData = new();
|
||||||
foreach (InventoryItem item in items) {
|
foreach (InventoryItem item in items) {
|
||||||
@ -140,7 +140,7 @@ namespace sodoff.Services {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return new CommonInventoryData {
|
return new CommonInventoryData {
|
||||||
UserID = Guid.Parse(viking.Id),
|
UserID = viking.Uid,
|
||||||
Item = userItemData.ToArray()
|
Item = userItemData.ToArray()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -76,11 +76,12 @@ public class KeyValueService {
|
|||||||
|
|
||||||
private Model.PairData? CheckOwnerAndGetPairData(ref User? user, ref Viking? viking, ref Dragon dragon, string? userId, int pairId) {
|
private Model.PairData? CheckOwnerAndGetPairData(ref User? user, ref Viking? viking, ref Dragon dragon, string? userId, int pairId) {
|
||||||
if (userId != null) {
|
if (userId != null) {
|
||||||
|
Guid userIdGuid = Guid.Parse(userId);
|
||||||
// find dragon
|
// find dragon
|
||||||
dragon = viking?.Dragons.FirstOrDefault(e => e.EntityId == userId);
|
dragon = viking?.Dragons.FirstOrDefault(e => e.EntityId == userIdGuid);
|
||||||
|
|
||||||
// if not dragon then try viking -> check ID
|
// if not dragon then try viking -> check ID
|
||||||
if (dragon != null || viking?.Id != userId) {
|
if (dragon != null || viking?.Uid != userIdGuid) {
|
||||||
// if not viking and user not set, then try set user from viking
|
// if not viking and user not set, then try set user from viking
|
||||||
if (user is null)
|
if (user is null)
|
||||||
user = viking?.User;
|
user = viking?.User;
|
||||||
@ -88,7 +89,7 @@ public class KeyValueService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// if not dragon nor viking then try user -> check ID
|
// if not dragon nor viking then try user -> check ID
|
||||||
if (viking != null || user?.Id != userId) user = null;
|
if (viking != null || user?.Id != userIdGuid) user = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: only one of (dragon, viking, user) can be not null here
|
// NOTE: only one of (dragon, viking, user) can be not null here
|
||||||
|
@ -16,7 +16,7 @@ public class MissionService {
|
|||||||
this.achievementService = achievementService;
|
this.achievementService = achievementService;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Mission GetMissionWithProgress(int missionId, string userId, string apiKey) {
|
public Mission GetMissionWithProgress(int missionId, int userId, string apiKey) {
|
||||||
Mission mission;
|
Mission mission;
|
||||||
if (missionId == 999 && apiKey == "a3a12a0a-7c6e-4e9b-b0f7-22034d799013") { // TODO This is not a pretty solution with hard-coded values.
|
if (missionId == 999 && apiKey == "a3a12a0a-7c6e-4e9b-b0f7-22034d799013") { // TODO This is not a pretty solution with hard-coded values.
|
||||||
mission = missionStore.GetMission(10999);
|
mission = missionStore.GetMission(10999);
|
||||||
@ -34,7 +34,7 @@ public class MissionService {
|
|||||||
return mission;
|
return mission;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<MissionCompletedResult> UpdateTaskProgress(int missionId, int taskId, string userId, bool completed, string xmlPayload, string apiKey) {
|
public List<MissionCompletedResult> UpdateTaskProgress(int missionId, int taskId, int userId, bool completed, string xmlPayload, string apiKey) {
|
||||||
SetTaskProgressDB(missionId, taskId, userId, completed, xmlPayload);
|
SetTaskProgressDB(missionId, taskId, userId, completed, xmlPayload);
|
||||||
|
|
||||||
// NOTE: This won't work if a mission can be completed by completing an inner mission
|
// NOTE: This won't work if a mission can be completed by completing an inner mission
|
||||||
@ -82,7 +82,7 @@ public class MissionService {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateMissionRecursive(Mission mission, string userId) {
|
private void UpdateMissionRecursive(Mission mission, int userId) {
|
||||||
List<Model.TaskStatus> taskStatuses = ctx.TaskStatuses.Where(e => e.VikingId == userId && e.MissionId == mission.MissionID).ToList();
|
List<Model.TaskStatus> taskStatuses = ctx.TaskStatuses.Where(e => e.VikingId == userId && e.MissionId == mission.MissionID).ToList();
|
||||||
|
|
||||||
// Update mission rules and tasks
|
// Update mission rules and tasks
|
||||||
@ -130,7 +130,7 @@ public class MissionService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetTaskProgressDB(int missionId, int taskId, string userId, bool completed, string xmlPayload) {
|
private void SetTaskProgressDB(int missionId, int taskId, int userId, bool completed, string xmlPayload) {
|
||||||
Model.TaskStatus? status = ctx.TaskStatuses.FirstOrDefault(task => task.Id == taskId && task.MissionId == missionId && task.VikingId == userId);
|
Model.TaskStatus? status = ctx.TaskStatuses.FirstOrDefault(task => task.Id == taskId && task.MissionId == missionId && task.VikingId == userId);
|
||||||
|
|
||||||
if (status is null) {
|
if (status is null) {
|
||||||
|
@ -29,7 +29,7 @@ public class RoomService {
|
|||||||
List<UserItemState> states = new();
|
List<UserItemState> states = new();
|
||||||
foreach (var itemRequest in roomItemRequest) {
|
foreach (var itemRequest in roomItemRequest) {
|
||||||
// TODO: Remove item from inventory (using CommonInventoryID)
|
// TODO: Remove item from inventory (using CommonInventoryID)
|
||||||
InventoryItem? i = room.Viking?.Inventory.InventoryItems.FirstOrDefault(x => x.Id == itemRequest.UserInventoryCommonID);
|
InventoryItem? i = room.Viking?.InventoryItems.FirstOrDefault(x => x.Id == itemRequest.UserInventoryCommonID);
|
||||||
if (i != null) {
|
if (i != null) {
|
||||||
i.Quantity--;
|
i.Quantity--;
|
||||||
if (itemRequest.Item is null) {
|
if (itemRequest.Item is null) {
|
||||||
@ -98,7 +98,7 @@ public class RoomService {
|
|||||||
if (ri is null) continue;
|
if (ri is null) continue;
|
||||||
UserItemPosition itemPosition = XmlUtil.DeserializeXml<UserItemPosition>(ri.RoomItemData);
|
UserItemPosition itemPosition = XmlUtil.DeserializeXml<UserItemPosition>(ri.RoomItemData);
|
||||||
room.Items.Remove(ri);
|
room.Items.Remove(ri);
|
||||||
InventoryItem? invItem = room.Viking?.Inventory.InventoryItems.FirstOrDefault(x => x.Id == itemPosition.UserInventoryCommonID);
|
InventoryItem? invItem = room.Viking?.InventoryItems.FirstOrDefault(x => x.Id == itemPosition.UserInventoryCommonID);
|
||||||
if (invItem != null) invItem.Quantity++;
|
if (invItem != null) invItem.Quantity++;
|
||||||
}
|
}
|
||||||
ctx.SaveChanges();
|
ctx.SaveChanges();
|
||||||
@ -128,7 +128,7 @@ public class RoomService {
|
|||||||
|
|
||||||
foreach (var consumable in consumables) {
|
foreach (var consumable in consumables) {
|
||||||
ItemStateCriteriaConsumable c = (ItemStateCriteriaConsumable)consumable;
|
ItemStateCriteriaConsumable c = (ItemStateCriteriaConsumable)consumable;
|
||||||
InventoryItem? invItem = item.Room.Viking?.Inventory.InventoryItems.FirstOrDefault(x => x.ItemId == c.ItemID);
|
InventoryItem? invItem = item.Room.Viking?.InventoryItems.FirstOrDefault(x => x.ItemId == c.ItemID);
|
||||||
if (invItem != null)
|
if (invItem != null)
|
||||||
invItem.Quantity = invItem.Quantity - c.Amount < 0 ? 0 : invItem.Quantity - c.Amount;
|
invItem.Quantity = invItem.Quantity - c.Amount < 0 ? 0 : invItem.Quantity - c.Amount;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user