mirror of
https://github.com/SoDOff-Project/sodoff.git
synced 2025-11-27 10:06:53 -08:00
Merge d15db80188da5d6c337af8bf95eca8e1f5f8ca3c into 83526569c1341353f2f63c2fa8d902dc0ddfd94f
This commit is contained in:
commit
2c94bb12f5
@ -1389,6 +1389,7 @@ public class ContentController : Controller {
|
||||
List<Party> allParties = ctx.Parties.ToList();
|
||||
List<UserParty> userParties = new List<UserParty>();
|
||||
|
||||
uint gameID = ClientVersion.GetGameID(apiKey);
|
||||
foreach(var party in allParties)
|
||||
{
|
||||
if(DateTime.UtcNow >= party.ExpirationDate)
|
||||
@ -1399,42 +1400,26 @@ public class ContentController : Controller {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Only send parties to their respective games.
|
||||
if (gameID != party.GameID) continue;
|
||||
|
||||
Viking viking = ctx.Vikings.FirstOrDefault(e => e.Id == party.VikingId);
|
||||
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,
|
||||
ExpirationDate = party.ExpirationDate,
|
||||
Icon = party.LocationIconAsset,
|
||||
Icon = party.IconAsset,
|
||||
Location = party.Location,
|
||||
LocationIcon = party.LocationIconAsset,
|
||||
PrivateParty = party.PrivateParty!.Value,
|
||||
UserID = viking.Uid
|
||||
};
|
||||
|
||||
if (party.Location == "MyNeighborhood") userParty.DisplayName = $"{userParty.UserName}'s Block Party";
|
||||
if (party.Location == "MyVIPRoomInt") userParty.DisplayName = $"{userParty.UserName}'s VIP Party";
|
||||
if (party.Location == "MyPodInt") {
|
||||
// Only way to do this without adding another column to the table.
|
||||
if (party.AssetBundle == "RS_DATA/PfMyPodBirthdayParty.unity3d/PfMyPodBirthdayParty") {
|
||||
userParty.DisplayName = $"{userParty.UserName}'s Pod Birthday Party";
|
||||
} else {
|
||||
userParty.DisplayName = $"{userParty.UserName}'s Pod Party";
|
||||
}
|
||||
}
|
||||
|
||||
uint gameID = ClientVersion.GetGameID(apiKey);
|
||||
// Send only JumpStart parties to JumpStart
|
||||
if (gameID == ClientVersion.WoJS
|
||||
&& (party.Location == "MyNeighborhood"
|
||||
|| party.Location == "MyVIPRoomInt")) {
|
||||
userParties.Add(userParty);
|
||||
// Send only Math Blaster parties to Math Blaster
|
||||
} else if (gameID == ClientVersion.MB
|
||||
&& party.Location == "MyPodInt") {
|
||||
userParties.Add(userParty);
|
||||
}
|
||||
userParties.Add(userParty);
|
||||
}
|
||||
|
||||
return Ok(new UserPartyData { NonBuddyParties = userParties.ToArray() });
|
||||
@ -1466,11 +1451,12 @@ public class ContentController : Controller {
|
||||
AvatarData avatarData = XmlUtil.DeserializeXml<AvatarData>(viking.AvatarSerialized);
|
||||
UserPartyComplete userPartyComplete = new UserPartyComplete
|
||||
{
|
||||
DisplayName = avatarData.DisplayName,
|
||||
DisplayName = $"{avatarData.DisplayName}'s {party.Descriptor} Party",
|
||||
UserName = avatarData.DisplayName,
|
||||
ExpirationDate = party.ExpirationDate,
|
||||
Icon = party.LocationIconAsset,
|
||||
Icon = party.IconAsset,
|
||||
Location = party.Location,
|
||||
LocationIcon = party.LocationIconAsset,
|
||||
PrivateParty = party.PrivateParty!.Value,
|
||||
UserID = viking.Uid,
|
||||
AssetBundle = party.AssetBundle
|
||||
@ -1492,48 +1478,33 @@ public class ContentController : Controller {
|
||||
{
|
||||
ItemData itemData = itemService.GetItem(itemId);
|
||||
|
||||
// create a party based on bought itemid
|
||||
Party party = new Party
|
||||
{
|
||||
PrivateParty = false
|
||||
};
|
||||
|
||||
string? partyType = itemData.Attribute?.FirstOrDefault(a => a.Key == "PartyType").Value;
|
||||
|
||||
if (partyType is null) {
|
||||
return Ok(null);
|
||||
}
|
||||
|
||||
uint gameVersion = ClientVersion.GetVersion(apiKey);
|
||||
if (partyType == "Default") {
|
||||
if (gameVersion == ClientVersion.MB) {
|
||||
party.Location = "MyPodInt";
|
||||
party.LocationIconAsset = "RS_DATA/PfUiPartiesListMB.unity3d/IcoMbPartyDefault";
|
||||
party.AssetBundle = "RS_DATA/PfMyPodParty.unity3d/PfMyPodParty";
|
||||
} else {
|
||||
party.Location = "MyNeighborhood";
|
||||
party.LocationIconAsset = "RS_DATA/PfUiPartiesList.unity3d/IcoPartyLocationMyNeighborhood";
|
||||
party.AssetBundle = "RS_DATA/PfMyNeighborhoodParty.unity3d/PfMyNeighborhoodParty";
|
||||
}
|
||||
} else if (partyType == "VIPRoom") {
|
||||
party.Location = "MyVIPRoomInt";
|
||||
party.LocationIconAsset = "RS_DATA/PfUiPartiesList.unity3d/IcoPartyDefault";
|
||||
party.AssetBundle = "RS_DATA/PfMyVIPRoomIntPartyGroup.unity3d/PfMyVIPRoomIntPartyGroup";
|
||||
} else if (partyType == "Birthday") {
|
||||
party.Location = "MyPodInt";
|
||||
party.LocationIconAsset = "RS_DATA/PfUiPartiesListMB.unity3d/IcoMbPartyBirthday";
|
||||
party.AssetBundle = "RS_DATA/PfMyPodBirthdayParty.unity3d/PfMyPodBirthdayParty";
|
||||
} else {
|
||||
Console.WriteLine($"Unsupported partyType = {partyType}");
|
||||
return Ok(null);
|
||||
}
|
||||
uint gameID = ClientVersion.GetGameID(apiKey);
|
||||
|
||||
party.ExpirationDate = DateTime.UtcNow.AddMinutes(
|
||||
Int32.Parse(itemData.Attribute.FirstOrDefault(a => a.Key == "Time").Value)
|
||||
);
|
||||
PartyInfo? info = xmlDataService.GetParty(gameID, partyType);
|
||||
if (info == null) return Ok(null);
|
||||
|
||||
// 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 = xmlDataService.GetPartyLocation(info) ?? "",
|
||||
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
|
||||
viking.AchievementPoints.FirstOrDefault(e => e.Type == (int)AchievementPointTypes.GameCurrency)!.Value -= itemData.Cost;
|
||||
|
||||
@ -13,9 +13,12 @@ namespace sodoff.Model
|
||||
public int VikingId { get; set; }
|
||||
public DateTime ExpirationDate { get; set; } = DateTime.UtcNow;
|
||||
public bool? PrivateParty { get; set; }
|
||||
public string IconAsset { get; set; } = null!;
|
||||
public string LocationIconAsset { get; set; } = null!;
|
||||
public string AssetBundle { get; set; } = null!;
|
||||
[JsonIgnore]
|
||||
public virtual Viking? Viking { get; set; }
|
||||
public uint? GameID { get; set; }
|
||||
public string? Descriptor { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@ -30,6 +30,7 @@ builder.Services.AddSingleton<ItemService>();
|
||||
builder.Services.AddSingleton<StoreService>();
|
||||
builder.Services.AddSingleton<XmlDataService>();
|
||||
builder.Services.AddSingleton<MMOConfigService>();
|
||||
builder.Services.AddSingleton<PartyService>();
|
||||
|
||||
builder.Services.AddScoped<KeyValueService>();
|
||||
builder.Services.AddScoped<MissionService>();
|
||||
|
||||
89
src/Resources/parties_info.xml
Normal file
89
src/Resources/parties_info.xml
Normal file
@ -0,0 +1,89 @@
|
||||
<?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>
|
||||
<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;
|
||||
}
|
||||
33
src/Services/PartyService.cs
Normal file
33
src/Services/PartyService.cs
Normal file
@ -0,0 +1,33 @@
|
||||
using sodoff.Schema;
|
||||
using sodoff.Util;
|
||||
|
||||
namespace sodoff.Services;
|
||||
|
||||
public class PartyService {
|
||||
PartiesInfo parties;
|
||||
Dictionary<uint, Dictionary<string, PartyInfo>> partyData = new Dictionary<uint, Dictionary<string, PartyInfo>>();
|
||||
|
||||
public PartyService() {
|
||||
parties = XmlUtil.DeserializeXml<PartiesInfo>(XmlUtil.ReadResourceXmlString("parties_info"));
|
||||
|
||||
foreach (PartyInfo party in parties.Parties) {
|
||||
if (partyData.TryGetValue(party.GameID, out Dictionary<string, PartyInfo>? partyDict)) {
|
||||
partyDict.TryAdd(party.Type, party);
|
||||
} else {
|
||||
partyDict = new Dictionary<string, PartyInfo>();
|
||||
partyData.Add(party.GameID, partyDict);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public PartyInfo? GetParty(uint gameID, string partyType) {
|
||||
if (!partyData.TryGetValue(gameID, out Dictionary<string, PartyInfo>? partyDict)) return null;
|
||||
partyDict.TryGetValue(partyType, out PartyInfo? party);
|
||||
return party;
|
||||
}
|
||||
|
||||
public string? GetLocation(PartyInfo party) {
|
||||
parties.LocationIcons.TryGetValue(party.Location, out string? value);
|
||||
return value;
|
||||
}
|
||||
}
|
||||
@ -8,6 +8,8 @@ namespace sodoff.Services;
|
||||
public class XmlDataService {
|
||||
Dictionary<int, string> displayNames = new();
|
||||
Dictionary<string, int> worlds_id = new();
|
||||
Dictionary<uint, Dictionary<string, PartyInfo>> partyData = new();
|
||||
Dictionary<string, string> partyLocations;
|
||||
|
||||
public XmlDataService(IOptions<ApiServerConfig> config) {
|
||||
if (!config.Value.LoadNonSoDData)
|
||||
@ -23,6 +25,20 @@ public class XmlDataService {
|
||||
foreach (var w in worlds) {
|
||||
worlds_id[w.Scene] = w.ID;
|
||||
}
|
||||
|
||||
var parties = XmlUtil.DeserializeXml<PartiesInfo>(XmlUtil.ReadResourceXmlString("parties_info"));
|
||||
foreach (PartyInfo party in parties.Parties) {
|
||||
if (partyData.TryGetValue(party.GameID, out Dictionary<string, PartyInfo>? partyDict)) {
|
||||
partyDict.TryAdd(party.Type, party);
|
||||
} else {
|
||||
partyDict = new Dictionary<string, PartyInfo> {
|
||||
{party.Type, party}
|
||||
};
|
||||
partyData.Add(party.GameID, partyDict);
|
||||
}
|
||||
}
|
||||
|
||||
partyLocations = parties.LocationIcons;
|
||||
}
|
||||
|
||||
public string GetDisplayName(int firstNameID, int secondNameID, int thirdNameID) {
|
||||
@ -34,4 +50,15 @@ public class XmlDataService {
|
||||
return worlds_id[mapName];
|
||||
return 0;
|
||||
}
|
||||
|
||||
public PartyInfo? GetParty(uint gameID, string partyType) {
|
||||
if (!partyData.TryGetValue(gameID, out Dictionary<string, PartyInfo>? partyDict)) return null;
|
||||
partyDict.TryGetValue(partyType, out PartyInfo? party);
|
||||
return party;
|
||||
}
|
||||
|
||||
public string? GetPartyLocation(PartyInfo party) {
|
||||
partyLocations.TryGetValue(party.Location, out string? value);
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
@ -146,6 +146,9 @@
|
||||
<EmbeddedResource Include="Resources\worlds.xml">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Resources\parties_info.xml">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Resources\missions\step_missions_steps.xml">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</EmbeddedResource>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user