forked from SoDOff-Project/sodoff
SoD 1.6 fixes
- CreateRaisedPet endpoint - support for 1.6 apiKey + util class for management apiKey version recognition
This commit is contained in:
parent
80481713e3
commit
47e1bfb065
@ -95,7 +95,7 @@ public class AuthenticationController : Controller {
|
|||||||
Username = user.Username,
|
Username = user.Username,
|
||||||
MembershipID = "ef84db9-59c6-4950-b8ea-bbc1521f899b", // placeholder
|
MembershipID = "ef84db9-59c6-4950-b8ea-bbc1521f899b", // placeholder
|
||||||
FacebookUserID = 0,
|
FacebookUserID = 0,
|
||||||
MultiplayerEnabled = (apiKey != "a1a13a0a-7c6e-4e9b-b0f7-22034d799013" && apiKey != "a2a09a0a-7c6e-4e9b-b0f7-22034d799013" && apiKey != "a3a12a0a-7c6e-4e9b-b0f7-22034d799013"),
|
MultiplayerEnabled = !ClientVersion.IsOldSoD(apiKey),
|
||||||
IsApproved = true,
|
IsApproved = true,
|
||||||
Age = 24,
|
Age = 24,
|
||||||
OpenChatEnabled = true
|
OpenChatEnabled = true
|
||||||
@ -110,7 +110,7 @@ public class AuthenticationController : Controller {
|
|||||||
UserID = viking.Uid.ToString(),
|
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 = !ClientVersion.IsOldSoD(apiKey),
|
||||||
IsApproved = true,
|
IsApproved = true,
|
||||||
Age = 24,
|
Age = 24,
|
||||||
OpenChatEnabled = true
|
OpenChatEnabled = true
|
||||||
|
@ -271,6 +271,53 @@ public class ContentController : Controller {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
[Produces("application/xml")]
|
||||||
|
[Route("ContentWebService.asmx/CreateRaisedPet")] // used by SoD 1.6
|
||||||
|
[VikingSession]
|
||||||
|
public RaisedPetData? CreateRaisedPet(Viking viking, int petTypeID) {
|
||||||
|
// Update the RaisedPetData with the info
|
||||||
|
String dragonId = Guid.NewGuid().ToString();
|
||||||
|
|
||||||
|
var raisedPetData = new RaisedPetData();
|
||||||
|
raisedPetData.IsPetCreated = true;
|
||||||
|
raisedPetData.PetTypeID = petTypeID;
|
||||||
|
raisedPetData.RaisedPetID = 0; // Initially make zero, so the db auto-fills
|
||||||
|
raisedPetData.EntityID = Guid.Parse(dragonId);
|
||||||
|
raisedPetData.Name = string.Concat("Dragon-", dragonId.AsSpan(0, 8)); // Start off with a random name
|
||||||
|
raisedPetData.IsSelected = false; // The api returns false, not sure why
|
||||||
|
raisedPetData.CreateDate = new DateTime(DateTime.Now.Ticks);
|
||||||
|
raisedPetData.UpdateDate = new DateTime(DateTime.Now.Ticks);
|
||||||
|
raisedPetData.GrowthState = new RaisedPetGrowthState { Name = "BABY" };
|
||||||
|
int imageSlot = (viking.Images.Select(i => i.ImageSlot).DefaultIfEmpty(-1).Max() + 1);
|
||||||
|
raisedPetData.ImagePosition = imageSlot;
|
||||||
|
// NOTE: Placing an egg into a hatchery slot calls CreatePet, but doesn't SetImage.
|
||||||
|
// NOTE: We need to force create an image slot because hatching multiple eggs at once would create dragons with the same slot
|
||||||
|
Image image = new Image {
|
||||||
|
ImageType = "EggColor", // NOTE: The game doesn't seem to use anything other than EggColor.
|
||||||
|
ImageSlot = imageSlot,
|
||||||
|
Viking = viking,
|
||||||
|
};
|
||||||
|
// Save the dragon in the db
|
||||||
|
Dragon dragon = new Dragon {
|
||||||
|
EntityId = Guid.NewGuid(),
|
||||||
|
Viking = viking,
|
||||||
|
RaisedPetData = XmlUtil.SerializeXml(raisedPetData),
|
||||||
|
};
|
||||||
|
|
||||||
|
ctx.Dragons.Add(dragon);
|
||||||
|
ctx.Images.Add(image);
|
||||||
|
|
||||||
|
if (petTypeID != 2) {
|
||||||
|
// Minisaurs should not be set as active pet
|
||||||
|
viking.SelectedDragon = dragon;
|
||||||
|
ctx.Update(viking);
|
||||||
|
}
|
||||||
|
ctx.SaveChanges();
|
||||||
|
|
||||||
|
return GetRaisedPetDataFromDragon(dragon);
|
||||||
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Produces("application/xml")]
|
[Produces("application/xml")]
|
||||||
[Route("V2/ContentWebService.asmx/CreatePet")]
|
[Route("V2/ContentWebService.asmx/CreatePet")]
|
||||||
|
@ -116,7 +116,7 @@ public class ProfileController : Controller {
|
|||||||
avatarData.Id = viking.Id;
|
avatarData.Id = viking.Id;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (avatarData != null && (apiKey == "a3a12a0a-7c6e-4e9b-b0f7-22034d799013")) {
|
if (avatarData != null && ClientVersion.Use2019SoDTutorial(apiKey)) {
|
||||||
if (avatarData.Part.FirstOrDefault(e => e.PartType == "Sword") is null) {
|
if (avatarData.Part.FirstOrDefault(e => e.PartType == "Sword") is null) {
|
||||||
var extraParts = new AvatarDataPart[] {
|
var extraParts = new AvatarDataPart[] {
|
||||||
new AvatarDataPart {
|
new AvatarDataPart {
|
||||||
@ -139,7 +139,7 @@ public class ProfileController : Controller {
|
|||||||
ParentUserID = viking.UserId.ToString(),
|
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 = !ClientVersion.IsOldSoD(apiKey),
|
||||||
Locale = "en-US", // placeholder
|
Locale = "en-US", // placeholder
|
||||||
GenderID = Gender.Male, // placeholder
|
GenderID = Gender.Male, // placeholder
|
||||||
OpenChatEnabled = true,
|
OpenChatEnabled = true,
|
||||||
|
@ -131,7 +131,7 @@ public class RegistrationController : Controller {
|
|||||||
ctx.Vikings.Add(v);
|
ctx.Vikings.Add(v);
|
||||||
ctx.SaveChanges();
|
ctx.SaveChanges();
|
||||||
|
|
||||||
if (apiKey == "a1a13a0a-7c6e-4e9b-b0f7-22034d799013") {
|
if (ClientVersion.Use2013SoDTutorial(apiKey)) {
|
||||||
keyValueService.SetPairData(null, v, null, 2017, new Schema.PairData {
|
keyValueService.SetPairData(null, v, null, 2017, new Schema.PairData {
|
||||||
Pairs = new Schema.Pair[]{
|
Pairs = new Schema.Pair[]{
|
||||||
new Schema.Pair {
|
new Schema.Pair {
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using sodoff.Model;
|
using sodoff.Model;
|
||||||
using sodoff.Schema;
|
using sodoff.Schema;
|
||||||
|
using sodoff.Util;
|
||||||
using System.Runtime.Serialization.Formatters.Binary;
|
using System.Runtime.Serialization.Formatters.Binary;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
@ -17,19 +18,23 @@ public class MissionService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Mission GetMissionWithProgress(int missionId, int userId, string apiKey) {
|
public Mission GetMissionWithProgress(int missionId, int userId, string apiKey) {
|
||||||
Mission mission;
|
Mission mission = null;
|
||||||
if (missionId == 999 && apiKey == "a3a12a0a-7c6e-4e9b-b0f7-22034d799013") { // TODO This is not a pretty solution with hard-coded values.
|
|
||||||
mission = missionStore.GetMission(10999);
|
if (missionId == 999) { // TODO This is not a pretty solution with hard-coded values.
|
||||||
|
if (ClientVersion.Use2013SoDTutorial(apiKey)) {
|
||||||
|
mission = missionStore.GetMission(30999);
|
||||||
|
} else if (ClientVersion.Use2016SoDTutorial(apiKey)) {
|
||||||
|
mission = missionStore.GetMission(20999);
|
||||||
|
} else if (ClientVersion.Use2019SoDTutorial(apiKey)) {
|
||||||
|
mission = missionStore.GetMission(10999);
|
||||||
|
}
|
||||||
mission.MissionID = 999;
|
mission.MissionID = 999;
|
||||||
} else if (missionId == 999 && apiKey == "a2a09a0a-7c6e-4e9b-b0f7-22034d799013") {
|
}
|
||||||
mission = missionStore.GetMission(20999);
|
|
||||||
mission.MissionID = 999;
|
if (mission is null) {
|
||||||
} else if (missionId == 999 && apiKey == "a1a13a0a-7c6e-4e9b-b0f7-22034d799013") {
|
|
||||||
mission = missionStore.GetMission(30999);
|
|
||||||
mission.MissionID = 999;
|
|
||||||
} else {
|
|
||||||
mission = missionStore.GetMission(missionId);
|
mission = missionStore.GetMission(missionId);
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateMissionRecursive(mission, userId);
|
UpdateMissionRecursive(mission, userId);
|
||||||
return mission;
|
return mission;
|
||||||
}
|
}
|
||||||
|
@ -30,14 +30,14 @@ public class MissionStoreSingleton {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int[] GetActiveMissions(string apiKey) {
|
public int[] GetActiveMissions(string apiKey) {
|
||||||
if (apiKey == "a1a13a0a-7c6e-4e9b-b0f7-22034d799013") {
|
if (ClientVersion.Use2013SoDTutorial(apiKey)) {
|
||||||
return activeMissionsV1;
|
return activeMissionsV1;
|
||||||
}
|
}
|
||||||
return activeMissions;
|
return activeMissions;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int[] GetUpcomingMissions(string apiKey) {
|
public int[] GetUpcomingMissions(string apiKey) {
|
||||||
if (apiKey == "a1a13a0a-7c6e-4e9b-b0f7-22034d799013") {
|
if (ClientVersion.Use2013SoDTutorial(apiKey)) {
|
||||||
return upcomingMissionsV1;
|
return upcomingMissionsV1;
|
||||||
}
|
}
|
||||||
return upcomingMissions;
|
return upcomingMissions;
|
||||||
|
30
src/Util/ClientVersion.cs
Normal file
30
src/Util/ClientVersion.cs
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
namespace sodoff.Util;
|
||||||
|
public class ClientVersion {
|
||||||
|
public static bool IsOldSoD(string apiKey) {
|
||||||
|
return (
|
||||||
|
apiKey == "a1a06a0a-7c6e-4e9b-b0f7-22034d799013" ||
|
||||||
|
apiKey == "a1a13a0a-7c6e-4e9b-b0f7-22034d799013" ||
|
||||||
|
apiKey == "a2a09a0a-7c6e-4e9b-b0f7-22034d799013" ||
|
||||||
|
apiKey == "a3a12a0a-7c6e-4e9b-b0f7-22034d799013"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
public static bool Use2013SoDTutorial(string apiKey) {
|
||||||
|
return (
|
||||||
|
apiKey == "a1a06a0a-7c6e-4e9b-b0f7-22034d799013" ||
|
||||||
|
apiKey == "a1a13a0a-7c6e-4e9b-b0f7-22034d799013"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
public static bool Use2016SoDTutorial(string apiKey) {
|
||||||
|
return (
|
||||||
|
apiKey == "a2a09a0a-7c6e-4e9b-b0f7-22034d799013"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
public static bool Use2019SoDTutorial(string apiKey) {
|
||||||
|
return (
|
||||||
|
apiKey == "a3a12a0a-7c6e-4e9b-b0f7-22034d799013"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
public static bool Use2021SoDTutorial(string apiKey) {
|
||||||
|
return !IsOldSoD(apiKey);
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user