mirror of
https://github.com/SoDOff-Project/sodoff.git
synced 2025-10-11 16:28:50 -07:00
Made changes requested in SoDOff-Project/sodoff#27
This commit is contained in:
commit
4c3db02f5e
@ -43,10 +43,10 @@ public class AchievementController : Controller {
|
|||||||
//[Produces("application/xml")]
|
//[Produces("application/xml")]
|
||||||
[Route("AchievementWebService.asmx/GetAllRanks")]
|
[Route("AchievementWebService.asmx/GetAllRanks")]
|
||||||
public IActionResult GetAllRanks([FromForm] string apiKey) {
|
public IActionResult GetAllRanks([FromForm] string apiKey) {
|
||||||
uint gameVersion = ClientVersion.GetVersion(apiKey);
|
uint gameID = ClientVersion.GetGameID(apiKey);
|
||||||
if (gameVersion <= ClientVersion.Max_OldJS && (gameVersion & ClientVersion.WoJS) != 0)
|
if (gameID == ClientVersion.WoJS)
|
||||||
return Ok(XmlUtil.ReadResourceXmlString("ranks.allranks_wojs"));
|
return Ok(XmlUtil.ReadResourceXmlString("ranks.allranks_wojs"));
|
||||||
if (gameVersion == ClientVersion.MB)
|
if (gameID == ClientVersion.MB)
|
||||||
return Ok(XmlUtil.ReadResourceXmlString("ranks.allranks_mb"));
|
return Ok(XmlUtil.ReadResourceXmlString("ranks.allranks_mb"));
|
||||||
return Ok(XmlUtil.ReadResourceXmlString("ranks.allranks_sod"));
|
return Ok(XmlUtil.ReadResourceXmlString("ranks.allranks_sod"));
|
||||||
}
|
}
|
||||||
|
@ -529,8 +529,7 @@ public class ContentController : Controller {
|
|||||||
raisedPetData.PetTypeID = petTypeID;
|
raisedPetData.PetTypeID = petTypeID;
|
||||||
raisedPetData.RaisedPetID = 0; // Initially make zero, so the db auto-fills
|
raisedPetData.RaisedPetID = 0; // Initially make zero, so the db auto-fills
|
||||||
raisedPetData.EntityID = Guid.Parse(dragonId);
|
raisedPetData.EntityID = Guid.Parse(dragonId);
|
||||||
uint gameVersion = ClientVersion.GetVersion(apiKey);
|
if (ClientVersion.GetGameID(apiKey) != ClientVersion.WoJS)
|
||||||
if (gameVersion > ClientVersion.Max_OldJS || (gameVersion & ClientVersion.WoJS) == 0)
|
|
||||||
raisedPetData.Name = string.Concat("Dragon-", dragonId.AsSpan(0, 8)); // Start off with a random name (if game isn't WoJS)
|
raisedPetData.Name = string.Concat("Dragon-", dragonId.AsSpan(0, 8)); // Start off with a random name (if game isn't WoJS)
|
||||||
raisedPetData.IsSelected = false; // The api returns false, not sure why
|
raisedPetData.IsSelected = false; // The api returns false, not sure why
|
||||||
raisedPetData.CreateDate = new DateTime(DateTime.Now.Ticks);
|
raisedPetData.CreateDate = new DateTime(DateTime.Now.Ticks);
|
||||||
@ -1393,9 +1392,7 @@ public class ContentController : Controller {
|
|||||||
List<Party> allParties = ctx.Parties.ToList();
|
List<Party> allParties = ctx.Parties.ToList();
|
||||||
List<UserParty> userParties = new List<UserParty>();
|
List<UserParty> userParties = new List<UserParty>();
|
||||||
|
|
||||||
uint gameVersion = ClientVersion.GetVersion(apiKey);
|
uint gameID = ClientVersion.GetGameID(apiKey);
|
||||||
if (gameVersion <= ClientVersion.Max_OldJS && (gameVersion & ClientVersion.WoJS) != 0)
|
|
||||||
gameVersion = ClientVersion.WoJS; // This can be optimized. It's also a shortcut.
|
|
||||||
foreach(var party in allParties)
|
foreach(var party in allParties)
|
||||||
{
|
{
|
||||||
if(DateTime.UtcNow >= party.ExpirationDate)
|
if(DateTime.UtcNow >= party.ExpirationDate)
|
||||||
@ -1407,13 +1404,15 @@ public class ContentController : Controller {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Only send parties to their respective games.
|
// Only send parties to their respective games.
|
||||||
if (gameVersion != party.GameVersion) continue;
|
if (gameID != party.GameID) continue;
|
||||||
|
|
||||||
Viking viking = ctx.Vikings.FirstOrDefault(e => e.Id == party.VikingId);
|
Viking viking = ctx.Vikings.FirstOrDefault(e => e.Id == party.VikingId);
|
||||||
AvatarData avatarData = XmlUtil.DeserializeXml<AvatarData>(viking.AvatarSerialized);
|
AvatarData avatarData = XmlUtil.DeserializeXml<AvatarData>(viking.AvatarSerialized);
|
||||||
UserParty userParty = new UserParty
|
|
||||||
{
|
|
||||||
DisplayName = avatarData.DisplayName,
|
|
||||||
|
UserParty userParty = new UserParty {
|
||||||
|
DisplayName = $"{avatarData.DisplayName}'s {party.Descriptor} Party",
|
||||||
UserName = avatarData.DisplayName,
|
UserName = avatarData.DisplayName,
|
||||||
ExpirationDate = party.ExpirationDate,
|
ExpirationDate = party.ExpirationDate,
|
||||||
Icon = party.IconAsset,
|
Icon = party.IconAsset,
|
||||||
@ -1423,21 +1422,6 @@ public class ContentController : Controller {
|
|||||||
UserID = viking.Uid
|
UserID = viking.Uid
|
||||||
};
|
};
|
||||||
|
|
||||||
string location = party.Location switch {
|
|
||||||
"MyNeighborhood" => "Block ",
|
|
||||||
"MyPodInt" => "Pod ",
|
|
||||||
"MyLoungeSSInt" => "Lounge ",
|
|
||||||
_ => ""
|
|
||||||
};
|
|
||||||
string type = party.PartyType switch {
|
|
||||||
"VIPRoom" => "VIP ",
|
|
||||||
"Birthday" => "Birthday ",
|
|
||||||
"NewYears" => "New Years ",
|
|
||||||
"Holiday" => "Holiday ",
|
|
||||||
_ => ""
|
|
||||||
};
|
|
||||||
userParty.DisplayName = $"{userParty.UserName}'s {location}{type}Party"; // Spaces are included in the location and type when they aren't empty.
|
|
||||||
|
|
||||||
userParties.Add(userParty);
|
userParties.Add(userParty);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1503,78 +1487,33 @@ public class ContentController : Controller {
|
|||||||
return Ok(null);
|
return Ok(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint gameVersion = ClientVersion.GetVersion(apiKey);
|
uint gameID = ClientVersion.GetGameID(apiKey);
|
||||||
if (gameVersion <= ClientVersion.Max_OldJS && (gameVersion & ClientVersion.WoJS) != 0)
|
|
||||||
gameVersion = ClientVersion.WoJS; // This can be optimized. It's also a shortcut.
|
|
||||||
|
|
||||||
// create a party based on bought itemid
|
PartiesInfo data = XmlUtil.DeserializeXml<PartiesInfo>(XmlUtil.ReadResourceXmlString("parties_info"));
|
||||||
Party party = new Party {
|
PartyInfo? info = data.Parties.FirstOrDefault(p => p.GameID == gameID && p.Type == partyType);
|
||||||
PrivateParty = false,
|
if (info == null) return Ok(null);
|
||||||
GameVersion = gameVersion,
|
|
||||||
PartyType = partyType
|
|
||||||
};
|
|
||||||
|
|
||||||
switch (gameVersion) {
|
if (info.Location == null) {
|
||||||
case ClientVersion.WoJS:
|
Console.WriteLine($"Unsupported partyType \"{partyType}\" for gameid 0x{gameID:X8}");
|
||||||
party.Location = "MyVIPRoomInt";
|
|
||||||
party.IconAsset = "RS_DATA/Parties01.unity3d/IcoPartyDefault";
|
|
||||||
party.LocationIconAsset = "RS_DATA/Parties01.unity3d/IcoPartyLocationVIPRoom";
|
|
||||||
if (partyType == "VIPRoom") {
|
|
||||||
party.AssetBundle = "RS_DATA/PfMyVIPRoomIntPartyGroup.unity3d/PfMyVIPRoomIntPartyGroup";
|
|
||||||
} else if (partyType == "Holiday") {
|
|
||||||
party.IconAsset = "RS_DATA/Parties01.unity3d/IcoPartyDefault";
|
|
||||||
party.AssetBundle = "RS_DATA/PfMyVIPRoomIntXmasGroup.unity3d/PfMyVIPRoomIntXmasGroup";
|
|
||||||
} else {
|
|
||||||
party.Location = "MyNeighborhood";
|
|
||||||
party.LocationIconAsset = "RS_DATA/Parties01.unity3d/IcoPartyLocationMyNeighborhood";
|
|
||||||
party.AssetBundle = "RS_DATA/PfMyNeighborhoodParty.unity3d/PfMyNeighborhoodParty";
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case ClientVersion.MB:
|
|
||||||
party.Location = "MyPodInt";
|
|
||||||
if (partyType == "Birthday") {
|
|
||||||
party.IconAsset = "RS_DATA/PfUiPartiesListMB.unity3d/IcoMbPartyBirthday";
|
|
||||||
party.AssetBundle = "RS_DATA/PfMyPodBirthdayParty.unity3d/PfMyPodBirthdayParty";
|
|
||||||
} else {
|
|
||||||
party.IconAsset = "RS_DATA/PfUiPartiesListMB.unity3d/IcoMbPartyDefault";
|
|
||||||
party.AssetBundle = "RS_DATA/PfMyPodParty.unity3d/PfMyPodParty";
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case ClientVersion.SS:
|
|
||||||
party.Location = "MyLoungeSSInt";
|
|
||||||
switch (partyType) {
|
|
||||||
case "Birthday":
|
|
||||||
party.IconAsset = "RS_DATA/PfUiPartiesListMB.unity3d/IcoSSStorePartyBirthdayDefault";
|
|
||||||
party.AssetBundle = "RS_DATA/PfSsRoomInteriorBirthdayGroup.unity3d/PfSsRoomInteriorBirthdayGroup";
|
|
||||||
break;
|
|
||||||
case "NewYears":
|
|
||||||
party.IconAsset = "RS_DATA/PfUiPartiesListMB.unity3d/IcoSSStorePartyNewYearDefault";
|
|
||||||
party.AssetBundle = "RS_DATA/PfSsRoomInteriorNewYearGroup.unity3d/PfSsRoomInteriorNewYearGroup";
|
|
||||||
break;
|
|
||||||
case "Holiday":
|
|
||||||
party.IconAsset = "RS_DATA/PfUiPartiesListMB.unity3d/IcoSSStorePartyHolidayDefault";
|
|
||||||
party.AssetBundle = "RS_DATA/PfSsRoomInteriorHolidayGroup.unity3d/PfSsRoomInteriorHolidayGroup";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
party.IconAsset = "RS_DATA/PfUiPartiesListMB.unity3d/IcoSSStorePartyDefault";
|
|
||||||
party.AssetBundle = "RS_DATA/PfSsRoomInteriorPartyGroup.unity3d/PfSsRoomInteriorPartyGroup";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (party.Location == null) {
|
|
||||||
Console.WriteLine($"Unsupported partyType \"{partyType}\" for gameversion 0x{gameVersion:X8}");
|
|
||||||
return Ok(null);
|
return Ok(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
party.ExpirationDate = DateTime.UtcNow.AddMinutes(
|
|
||||||
Int32.Parse(itemData.Attribute.FirstOrDefault(a => a.Key == "Time").Value)
|
|
||||||
);
|
|
||||||
|
|
||||||
// check if party already exists
|
// check if party already exists
|
||||||
if (viking.Parties.FirstOrDefault(e => e.Location == party.Location) != null) return Ok(null);
|
if (viking.Parties.Any(e => e.Location == info.Location)) return Ok(null);
|
||||||
|
|
||||||
|
// create a party based on bought itemid
|
||||||
|
Party party = new Party {
|
||||||
|
Location = info.Location,
|
||||||
|
IconAsset = info.Icon,
|
||||||
|
LocationIconAsset = data.LocationIcons.GetValueOrDefault(info.Location, ""),
|
||||||
|
AssetBundle = info.Bundle,
|
||||||
|
PrivateParty = false,
|
||||||
|
GameID = gameID,
|
||||||
|
ExpirationDate = DateTime.UtcNow.AddMinutes(
|
||||||
|
Int32.Parse(itemData.Attribute.FirstOrDefault(a => a.Key == "Time").Value)
|
||||||
|
),
|
||||||
|
Descriptor = info.Descriptor
|
||||||
|
};
|
||||||
|
|
||||||
// take away coins
|
// take away coins
|
||||||
viking.AchievementPoints.FirstOrDefault(e => e.Type == (int)AchievementPointTypes.GameCurrency)!.Value -= itemData.Cost;
|
viking.AchievementPoints.FirstOrDefault(e => e.Type == (int)AchievementPointTypes.GameCurrency)!.Value -= itemData.Cost;
|
||||||
@ -2187,7 +2126,7 @@ public class ContentController : Controller {
|
|||||||
[Route("ContentWebService.asmx/GetPeriodicGameDataByGame")] // used by Math Blaster and WoJS (probably from 24 hours ago to now)
|
[Route("ContentWebService.asmx/GetPeriodicGameDataByGame")] // used by Math Blaster and WoJS (probably from 24 hours ago to now)
|
||||||
[VikingSession(UseLock = true)]
|
[VikingSession(UseLock = true)]
|
||||||
public IActionResult GetPeriodicGameDataByGame(Viking viking, [FromForm] int gameId, bool isMultiplayer, int difficulty, int gameLevel, string key, int count, bool AscendingOrder, int score, bool buddyFilter, string apiKey) {
|
public IActionResult GetPeriodicGameDataByGame(Viking viking, [FromForm] int gameId, bool isMultiplayer, int difficulty, int gameLevel, string key, int count, bool AscendingOrder, int score, bool buddyFilter, string apiKey) {
|
||||||
return Ok(gameDataService.GetGameData(viking, gameId, isMultiplayer, difficulty, gameLevel, key, count, AscendingOrder, buddyFilter, apiKey, DateTime.Now.AddHours(-24), DateTime.Now));
|
return Ok(gameDataService.GetDailyGameData(viking, gameId, isMultiplayer, difficulty, gameLevel, key, count, AscendingOrder, buddyFilter, apiKey));
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
|
@ -77,10 +77,10 @@ public class ItemStoreController : Controller {
|
|||||||
public IActionResult GetAnnouncements([FromForm] string apiKey, [FromForm] int worldObjectID) {
|
public IActionResult GetAnnouncements([FromForm] string apiKey, [FromForm] int worldObjectID) {
|
||||||
// TODO: This is a placeholder, although this endpoint seems to be only used to send announcements to the user (such as the server shutdown), so this might be sufficient.
|
// TODO: This is a placeholder, although this endpoint seems to be only used to send announcements to the user (such as the server shutdown), so this might be sufficient.
|
||||||
|
|
||||||
uint gameVersion = ClientVersion.GetVersion(apiKey);
|
uint gameID = ClientVersion.GetGameID(apiKey);
|
||||||
if (gameVersion <= ClientVersion.Max_OldJS && (gameVersion & ClientVersion.WoJS) != 0) {
|
if (gameID == ClientVersion.WoJS) {
|
||||||
return Ok(XmlUtil.DeserializeXml<AnnouncementList>(XmlUtil.ReadResourceXmlString("announcements_wojs")));
|
return Ok(XmlUtil.DeserializeXml<AnnouncementList>(XmlUtil.ReadResourceXmlString("announcements_wojs")));
|
||||||
} else if (gameVersion == ClientVersion.SS && worldObjectID == 6) {
|
} else if (gameID == ClientVersion.SS && worldObjectID == 6) {
|
||||||
return Ok(XmlUtil.DeserializeXml<AnnouncementList>(XmlUtil.ReadResourceXmlString("announcements_ss")));
|
return Ok(XmlUtil.DeserializeXml<AnnouncementList>(XmlUtil.ReadResourceXmlString("announcements_ss")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,5 +7,6 @@ public class GameDataPair {
|
|||||||
public int GameDataId { get; set; }
|
public int GameDataId { get; set; }
|
||||||
public string Name { get; set; } = null!;
|
public string Name { get; set; } = null!;
|
||||||
public int Value { get; set; }
|
public int Value { get; set; }
|
||||||
|
public int DailyValue { get; set; }
|
||||||
public virtual GameData GameData { get; set; } = null!;
|
public virtual GameData GameData { get; set; } = null!;
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ namespace sodoff.Model
|
|||||||
public string LocationIconAsset { get; set; } = null!;
|
public string LocationIconAsset { get; set; } = null!;
|
||||||
public string AssetBundle { get; set; } = null!;
|
public string AssetBundle { get; set; } = null!;
|
||||||
public virtual Viking? Viking { get; set; }
|
public virtual Viking? Viking { get; set; }
|
||||||
public uint GameVersion { get; set; } = 0!;
|
public uint? GameID { get; set; }
|
||||||
public string PartyType { get; set; } = null!;
|
public string? Descriptor { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
90
src/Resources/parties_info.xml
Normal file
90
src/Resources/parties_info.xml
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<PartiesInfo>
|
||||||
|
<Location>
|
||||||
|
<Name>MyNeighborhood</Name>
|
||||||
|
<Icon>RS_DATA/Parties01.unity3d/IcoPartyLocationMyNeighborhood</Icon>
|
||||||
|
</Location>
|
||||||
|
<Location>
|
||||||
|
<Name>MyVIPRoomInt</Name>
|
||||||
|
<Icon>RS_DATA/Parties01.unity3d/IcoPartyLocationVIPRoom</Icon>
|
||||||
|
</Location>
|
||||||
|
|
||||||
|
<!-- World of JumpStart -->
|
||||||
|
<Party>
|
||||||
|
<Version>0x01000000</Version>
|
||||||
|
<Location>MyNeighborhood</Location>
|
||||||
|
<Type>Default</Type>
|
||||||
|
<Icon>RS_DATA/Parties01.unity3d/IcoPartyDefault</Icon>
|
||||||
|
<AssetBundle>RS_DATA/PfMyNeighborhoodParty.unity3d/PfMyNeighborhoodParty</AssetBundle>
|
||||||
|
<Descriptor>Block</Descriptor>
|
||||||
|
</Party>
|
||||||
|
<Party>
|
||||||
|
<ItemID></ItemID>
|
||||||
|
<Version>0x01000000</Version>
|
||||||
|
<Location>MyVIPRoomInt</Location>
|
||||||
|
<Type>VIPRoom</Type>
|
||||||
|
<Icon>RS_DATA/Parties01.unity3d/IcoPartyDefault</Icon>
|
||||||
|
<AssetBundle>RS_DATA/PfMyVIPRoomIntPartyGroup.unity3d/PfMyVIPRoomIntPartyGroup</AssetBundle>
|
||||||
|
<Descriptor>VIP</Descriptor>
|
||||||
|
</Party>
|
||||||
|
<Party>
|
||||||
|
<Version>0x01000000</Version>
|
||||||
|
<Location>MyVIPRoomInt</Location>
|
||||||
|
<Type>Holiday</Type>
|
||||||
|
<Icon>RS_DATA/Parties01.unity3d/IcoStorePartyXmasDefault</Icon>
|
||||||
|
<AssetBundle>RS_DATA/PfMyVIPRoomIntXmasGroup.unity3d/PfMyVIPRoomIntXmasGroup</AssetBundle>
|
||||||
|
<Descriptor>Holiday</Descriptor>
|
||||||
|
</Party>
|
||||||
|
|
||||||
|
<!-- Math Blaster -->
|
||||||
|
<Party>
|
||||||
|
<Version>0x08000000</Version>
|
||||||
|
<Location>MyPodInt</Location>
|
||||||
|
<Type>Default</Type>
|
||||||
|
<Icon>RS_DATA/PfUiPartiesListMB.unity3d/IcoMbPartyDefault</Icon>
|
||||||
|
<AssetBundle>RS_DATA/PfUiPartiesListMB.unity3d/IcoMbPartyDefault</AssetBundle>
|
||||||
|
<Descriptor>Pod</Descriptor>
|
||||||
|
</Party>
|
||||||
|
<Party>
|
||||||
|
<Version>0x08000000</Version>
|
||||||
|
<Location>MyPodInt</Location>
|
||||||
|
<Type>Birthday</Type>
|
||||||
|
<Icon>RS_DATA/PfUiPartiesListMB.unity3d/IcoMbPartyBirthday</Icon>
|
||||||
|
<AssetBundle>RS_DATA/PfMyPodBirthdayParty.unity3d/PfMyPodBirthdayParty</AssetBundle>
|
||||||
|
<Descriptor>Birthday</Descriptor>
|
||||||
|
</Party>
|
||||||
|
|
||||||
|
<!-- SuperSecret -->
|
||||||
|
<Party>
|
||||||
|
<Version>0x02000000</Version>
|
||||||
|
<Location>MyLoungeSSInt</Location>
|
||||||
|
<Type>Default</Type>
|
||||||
|
<Icon>RS_DATA/SSParties.unity3d/IcoSSStorePartyDefault</Icon>
|
||||||
|
<AssetBundle>RS_DATA/PfSsRoomInteriorPartyGroup.unity3d/PfSsRoomInteriorPartyGroup</AssetBundle>
|
||||||
|
<Descriptor>Lounge</Descriptor>
|
||||||
|
</Party>
|
||||||
|
<Party>
|
||||||
|
<Version>0x02000000</Version>
|
||||||
|
<Location>MyLoungeSSInt</Location>
|
||||||
|
<Type>Birthday</Type>
|
||||||
|
<Icon>RS_DATA/SSParties.unity3d/IcoSSStorePartyBirthdayDefault</Icon>
|
||||||
|
<AssetBundle>RS_DATA/PfSsRoomInteriorBirthdayGroup.unity3d/PfSsRoomInteriorBirthdayGroup</AssetBundle>
|
||||||
|
<Descriptor>Birthday</Descriptor>
|
||||||
|
</Party>
|
||||||
|
<Party>
|
||||||
|
<Version>0x02000000</Version>
|
||||||
|
<Location>MyLoungeSSInt</Location>
|
||||||
|
<Type>NewYears</Type>
|
||||||
|
<Icon>RS_DATA/SSParties.unity3d/IcoSSStorePartyNewYearDefault</Icon>
|
||||||
|
<AssetBundle>RS_DATA/PfSsRoomInteriorNewYearGroup.unity3d/PfSsRoomInteriorNewYearGroup</AssetBundle>
|
||||||
|
<Descriptor>New Years</Descriptor>
|
||||||
|
</Party>
|
||||||
|
<Party>
|
||||||
|
<Version>0x02000000</Version>
|
||||||
|
<Location>MyLoungeSSInt</Location>
|
||||||
|
<Type>Holiday</Type>
|
||||||
|
<Icon>RS_DATA/SSParties.unity3d/IcoSSStorePartyHolidayDefault</Icon>
|
||||||
|
<AssetBundle>RS_DATA/PfSsRoomInteriorHolidayGroup.unity3d/PfSsRoomInteriorHolidayGroup</AssetBundle>
|
||||||
|
<Descriptor>Holiday</Descriptor>
|
||||||
|
</Party>
|
||||||
|
</PartiesInfo>
|
54
src/Schema/PartiesInfo.cs
Normal file
54
src/Schema/PartiesInfo.cs
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
using sodoff.Util;
|
||||||
|
using System.Xml.Serialization;
|
||||||
|
|
||||||
|
namespace sodoff.Schema;
|
||||||
|
|
||||||
|
[XmlRoot(ElementName = "PartiesInfo", Namespace = "")]
|
||||||
|
[Serializable]
|
||||||
|
public class PartiesInfo {
|
||||||
|
[XmlElement(ElementName = "Location")]
|
||||||
|
public PartyIconData[] IconData {
|
||||||
|
get { return LocationIcons.Select(i => new PartyIconData {Name = i.Key, Icon = i.Value}).ToArray(); }
|
||||||
|
set { LocationIcons = value.ToDictionary(i => i.Name, i => i.Icon); }
|
||||||
|
}
|
||||||
|
|
||||||
|
[XmlIgnore]
|
||||||
|
public Dictionary<string, string> LocationIcons;
|
||||||
|
|
||||||
|
[XmlElement(ElementName = "Party")]
|
||||||
|
public PartyInfo[] Parties;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class PartyIconData {
|
||||||
|
[XmlElement("Name")]
|
||||||
|
public string Name;
|
||||||
|
|
||||||
|
[XmlElement("Icon")]
|
||||||
|
public string Icon;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class PartyInfo {
|
||||||
|
[XmlElement("Version")]
|
||||||
|
public string Version {
|
||||||
|
get { return GameID.ToString("X"); }
|
||||||
|
set { GameID = XmlUtil.HexToUint(value); }
|
||||||
|
}
|
||||||
|
|
||||||
|
[XmlIgnore]
|
||||||
|
public uint GameID;
|
||||||
|
|
||||||
|
[XmlElement("Location")]
|
||||||
|
public string Location;
|
||||||
|
|
||||||
|
[XmlElement("Type")]
|
||||||
|
public string Type;
|
||||||
|
|
||||||
|
[XmlElement("Icon")]
|
||||||
|
public string Icon;
|
||||||
|
|
||||||
|
[XmlElement("AssetBundle")]
|
||||||
|
public string Bundle;
|
||||||
|
|
||||||
|
[XmlElement("Descriptor")]
|
||||||
|
public string? Descriptor;
|
||||||
|
}
|
@ -73,14 +73,14 @@ namespace sodoff.Services {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ReadOnlyDictionary<int, int> GetAchievementsGroupIdToTaskId(uint gameVersion) {
|
public ReadOnlyDictionary<int, int> GetAchievementsGroupIdToTaskId(uint gameVersion) {
|
||||||
gameVersion = GameVersionForTasks(gameVersion);
|
gameVersion = ClientVersion.GetGameID(gameVersion);
|
||||||
if (achievementsTasks.ContainsKey(gameVersion))
|
if (achievementsTasks.ContainsKey(gameVersion))
|
||||||
return achievementsTasks[gameVersion].achievementsGroupIdToTaskId;
|
return achievementsTasks[gameVersion].achievementsGroupIdToTaskId;
|
||||||
return new ReadOnlyDictionary<int, int>(new Dictionary<int, int>());
|
return new ReadOnlyDictionary<int, int>(new Dictionary<int, int>());
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<AchievementTaskInfo>? GetAllAchievementTaskInfo(int taskID, uint gameVersion) {
|
public List<AchievementTaskInfo>? GetAllAchievementTaskInfo(int taskID, uint gameVersion) {
|
||||||
gameVersion = GameVersionForTasks(gameVersion);
|
gameVersion = ClientVersion.GetGameID(gameVersion);
|
||||||
if (achievementsTasks.ContainsKey(gameVersion) && achievementsTasks[gameVersion].achievementsRewardByTask.ContainsKey(taskID)) {
|
if (achievementsTasks.ContainsKey(gameVersion) && achievementsTasks[gameVersion].achievementsRewardByTask.ContainsKey(taskID)) {
|
||||||
return achievementsTasks[gameVersion].achievementsRewardByTask[taskID];
|
return achievementsTasks[gameVersion].achievementsRewardByTask[taskID];
|
||||||
}
|
}
|
||||||
@ -121,13 +121,5 @@ namespace sodoff.Services {
|
|||||||
}
|
}
|
||||||
return dragonXP;
|
return dragonXP;
|
||||||
}
|
}
|
||||||
|
|
||||||
private uint GameVersionForTasks(uint gameVersion) {
|
|
||||||
// all SoD version of SoD using the same Tasks database
|
|
||||||
if ((gameVersion & ClientVersion.Min_SoD) == 0xa0000000) return ClientVersion.Min_SoD;
|
|
||||||
// all version of WoJS (including lands) using the same Tasks database
|
|
||||||
if (gameVersion <= ClientVersion.Max_OldJS && (gameVersion & ClientVersion.WoJS) != 0) return ClientVersion.WoJS;
|
|
||||||
return gameVersion;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,9 +31,11 @@ public class GameDataService {
|
|||||||
viking.GameData.Add(gameData);
|
viking.GameData.Add(gameData);
|
||||||
|
|
||||||
}
|
}
|
||||||
gameData.DatePlayed = DateTime.UtcNow;
|
|
||||||
SavePairs(gameData, xmlDocumentData);
|
SavePairs(gameData, xmlDocumentData);
|
||||||
|
gameData.DatePlayed = DateTime.UtcNow;
|
||||||
ctx.SaveChanges();
|
ctx.SaveChanges();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,6 +73,33 @@ public class GameDataService {
|
|||||||
return GetSummaryFromResponse(viking, isMultiplayer, difficulty, gameLevel, key, selectedData);
|
return GetSummaryFromResponse(viking, isMultiplayer, difficulty, gameLevel, key, selectedData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public GameDataSummary GetDailyGameData(Viking viking, int gameId, bool isMultiplayer, int difficulty, int gameLevel, string key, int count, bool AscendingOrder, bool buddyFilter, string apiKey) {
|
||||||
|
IQueryable<GameDataPair> query = ctx.GameData
|
||||||
|
.Where(x =>
|
||||||
|
x.GameId == gameId && x.IsMultiplayer == false &&
|
||||||
|
x.Difficulty == difficulty && x.GameLevel == gameLevel &&
|
||||||
|
x.DatePlayed.Date == DateTime.UtcNow.Date
|
||||||
|
).SelectMany(e => e.GameDataPairs).Where(x => x.Name == key);
|
||||||
|
|
||||||
|
// TODO: Buddy filter
|
||||||
|
|
||||||
|
if (AscendingOrder) query = query.OrderBy(e => e.Value);
|
||||||
|
else query = query.OrderByDescending(e => e.Value);
|
||||||
|
|
||||||
|
List<GameDataResponse> selectedData;
|
||||||
|
if (ClientVersion.GetVersion(apiKey) <= ClientVersion.Max_OldJS)
|
||||||
|
// use DisplayName instead of Name
|
||||||
|
selectedData = query.Select(e => new GameDataResponse(
|
||||||
|
XmlUtil.DeserializeXml<AvatarData>(e.GameData.Viking.AvatarSerialized).DisplayName, e.GameData.Viking.Uid, e.GameData.DatePlayed, false, false, e.DailyValue)
|
||||||
|
).Take(count).ToList();
|
||||||
|
else
|
||||||
|
selectedData = query.Select(e => new GameDataResponse(
|
||||||
|
e.GameData.Viking.Name, e.GameData.Viking.Uid, e.GameData.DatePlayed, false, false, e.DailyValue)
|
||||||
|
).Take(count).ToList();
|
||||||
|
|
||||||
|
return GetSummaryFromResponse(viking, isMultiplayer, difficulty, gameLevel, key, selectedData);
|
||||||
|
}
|
||||||
|
|
||||||
// ByUser for JumpStart's My Scores
|
// ByUser for JumpStart's My Scores
|
||||||
public GameDataSummary GetGameDataByUser(Viking viking, int gameId, bool isMultiplayer, int difficulty, int gameLevel, string key, int count, bool AscendingOrder, string apiKey) {
|
public GameDataSummary GetGameDataByUser(Viking viking, int gameId, bool isMultiplayer, int difficulty, int gameLevel, string key, int count, bool AscendingOrder, string apiKey) {
|
||||||
IQueryable<Model.GameData> query = ctx.GameData.Where(x => x.GameId == gameId && x.IsMultiplayer == false && x.Difficulty == difficulty && x.GameLevel == gameLevel && x.VikingId == viking.Id);
|
IQueryable<Model.GameData> query = ctx.GameData.Where(x => x.GameId == gameId && x.IsMultiplayer == false && x.Difficulty == difficulty && x.GameLevel == gameLevel && x.VikingId == viking.Id);
|
||||||
@ -141,12 +170,20 @@ public class GameDataService {
|
|||||||
private void SavePairs(Model.GameData gameData, string xmlDocumentData) {
|
private void SavePairs(Model.GameData gameData, string xmlDocumentData) {
|
||||||
foreach (var pair in GetGameDataPairs(xmlDocumentData)) {
|
foreach (var pair in GetGameDataPairs(xmlDocumentData)) {
|
||||||
GameDataPair? dbPair = gameData.GameDataPairs.FirstOrDefault(x => x.Name == pair.Name);
|
GameDataPair? dbPair = gameData.GameDataPairs.FirstOrDefault(x => x.Name == pair.Name);
|
||||||
if (dbPair == null)
|
|
||||||
|
// If Name == "time" then (existing <= incoming) needs to be false (effectively (existing > incoming), as time should function).
|
||||||
|
// if Name is anything else, then second condition as normal.
|
||||||
|
bool newBest = (dbPair == null) || ((pair.Name == "time") != (dbPair.Value <= pair.Value));
|
||||||
|
|
||||||
|
if (dbPair == null) {
|
||||||
gameData.GameDataPairs.Add(pair);
|
gameData.GameDataPairs.Add(pair);
|
||||||
else if (pair.Name == "time" && dbPair.Value > pair.Value)
|
dbPair = pair;
|
||||||
dbPair.Value = pair.Value;
|
} else if (newBest) dbPair.Value = pair.Value;
|
||||||
else if (pair.Name != "time" && dbPair.Value <= pair.Value)
|
|
||||||
dbPair.Value = pair.Value;
|
if (
|
||||||
|
newBest || // Surpassed Score (or Unset)
|
||||||
|
gameData.DatePlayed.Date != DateTime.UtcNow.Date // Another Day
|
||||||
|
) dbPair.DailyValue = pair.Value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,6 +13,17 @@ public class ClientVersion {
|
|||||||
public const uint WoJS_StoryLand = 0x01000400; // World of JumpStart -- Storyland
|
public const uint WoJS_StoryLand = 0x01000400; // World of JumpStart -- Storyland
|
||||||
public const uint WoJS_NewAvatar = 0x01010000; // World of JumpStart with new avatars (e.g. 1.21)
|
public const uint WoJS_NewAvatar = 0x01010000; // World of JumpStart with new avatars (e.g. 1.21)
|
||||||
|
|
||||||
|
public static uint GetGameID(uint gameVersion) {
|
||||||
|
if (gameVersion > ClientVersion.Max_OldJS)
|
||||||
|
return gameVersion & 0xf0000000;
|
||||||
|
else
|
||||||
|
return gameVersion & 0x0f000000;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static uint GetGameID(string apiKey) {
|
||||||
|
return GetGameID(GetVersion(apiKey));
|
||||||
|
}
|
||||||
|
|
||||||
public static uint GetVersion(string apiKey) {
|
public static uint GetVersion(string apiKey) {
|
||||||
if (
|
if (
|
||||||
apiKey == "b99f695c-7c6e-4e9b-b0f7-22034d799013" || // PC / Windows
|
apiKey == "b99f695c-7c6e-4e9b-b0f7-22034d799013" || // PC / Windows
|
||||||
|
@ -145,6 +145,9 @@
|
|||||||
<EmbeddedResource Include="Resources\worlds.xml">
|
<EmbeddedResource Include="Resources\worlds.xml">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
|
<EmbeddedResource Include="Resources\parties_info.xml">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</EmbeddedResource>
|
||||||
<EmbeddedResource Include="Resources\missions\step_missions_steps.xml">
|
<EmbeddedResource Include="Resources\missions\step_missions_steps.xml">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user