"Rewrote" party creation system, added support for supersecret parties.

This commit is contained in:
Hipposgrumm 2025-06-14 15:12:27 -06:00
parent bdf7707019
commit e5fe602ade
2 changed files with 88 additions and 48 deletions

View File

@ -1393,6 +1393,9 @@ 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);
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)
@ -1403,6 +1406,8 @@ public class ContentController : Controller {
continue; continue;
} }
// Only send parties to their respective games.
if (gameVersion != party.GameVersion) 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);
@ -1411,34 +1416,29 @@ public class ContentController : Controller {
DisplayName = avatarData.DisplayName, DisplayName = avatarData.DisplayName,
UserName = avatarData.DisplayName, UserName = avatarData.DisplayName,
ExpirationDate = party.ExpirationDate, ExpirationDate = party.ExpirationDate,
Icon = party.LocationIconAsset, Icon = party.IconAsset,
Location = party.Location, Location = party.Location,
LocationIcon = party.LocationIconAsset,
PrivateParty = party.PrivateParty!.Value, PrivateParty = party.PrivateParty!.Value,
UserID = viking.Uid UserID = viking.Uid
}; };
if (party.Location == "MyNeighborhood") userParty.DisplayName = $"{userParty.UserName}'s Block Party"; string location = party.Location switch {
if (party.Location == "MyVIPRoomInt") userParty.DisplayName = $"{userParty.UserName}'s VIP Party"; "MyNeighborhood" => "Block ",
if (party.Location == "MyPodInt") { "MyPodInt" => "Pod ",
// Only way to do this without adding another column to the table. "MyLoungeSSInt" => "Lounge ",
if (party.AssetBundle == "RS_DATA/PfMyPodBirthdayParty.unity3d/PfMyPodBirthdayParty") { _ => ""
userParty.DisplayName = $"{userParty.UserName}'s Pod Birthday Party"; };
} else { string type = party.PartyType switch {
userParty.DisplayName = $"{userParty.UserName}'s Pod Party"; "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.
uint gameVersion = ClientVersion.GetVersion(apiKey); userParties.Add(userParty);
// Send only JumpStart parties to JumpStart
if (gameVersion <= ClientVersion.Max_OldJS && (gameVersion & ClientVersion.WoJS) != 0
&& (party.Location == "MyNeighborhood"
|| party.Location == "MyVIPRoomInt")) {
userParties.Add(userParty);
// Send only Math Blaster parties to Math Blaster
} else if (gameVersion == ClientVersion.MB
&& party.Location == "MyPodInt") {
userParties.Add(userParty);
}
} }
return Ok(new UserPartyData { NonBuddyParties = userParties.ToArray() }); return Ok(new UserPartyData { NonBuddyParties = userParties.ToArray() });
@ -1473,8 +1473,9 @@ public class ContentController : Controller {
DisplayName = avatarData.DisplayName, DisplayName = avatarData.DisplayName,
UserName = avatarData.DisplayName, UserName = avatarData.DisplayName,
ExpirationDate = party.ExpirationDate, ExpirationDate = party.ExpirationDate,
Icon = party.LocationIconAsset, Icon = party.IconAsset,
Location = party.Location, Location = party.Location,
LocationIcon = party.LocationIconAsset,
PrivateParty = party.PrivateParty!.Value, PrivateParty = party.PrivateParty!.Value,
UserID = viking.Uid, UserID = viking.Uid,
AssetBundle = party.AssetBundle AssetBundle = party.AssetBundle
@ -1496,12 +1497,6 @@ public class ContentController : Controller {
{ {
ItemData itemData = itemService.GetItem(itemId); 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; string? partyType = itemData.Attribute?.FirstOrDefault(a => a.Key == "PartyType").Value;
if (partyType is null) { if (partyType is null) {
@ -1509,26 +1504,68 @@ public class ContentController : Controller {
} }
uint gameVersion = ClientVersion.GetVersion(apiKey); uint gameVersion = ClientVersion.GetVersion(apiKey);
if (partyType == "Default") { if (gameVersion <= ClientVersion.Max_OldJS && (gameVersion & ClientVersion.WoJS) != 0)
if (gameVersion == ClientVersion.MB) { gameVersion = ClientVersion.WoJS; // This can be optimized. It's also a shortcut.
// create a party based on bought itemid
Party party = new Party {
PrivateParty = false,
GameVersion = gameVersion,
PartyType = partyType
};
switch (gameVersion) {
case ClientVersion.WoJS:
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"; party.Location = "MyPodInt";
party.LocationIconAsset = "RS_DATA/PfUiPartiesListMB.unity3d/IcoMbPartyDefault"; if (partyType == "Birthday") {
party.AssetBundle = "RS_DATA/PfMyPodParty.unity3d/PfMyPodParty"; party.IconAsset = "RS_DATA/PfUiPartiesListMB.unity3d/IcoMbPartyBirthday";
} else { party.AssetBundle = "RS_DATA/PfMyPodBirthdayParty.unity3d/PfMyPodBirthdayParty";
party.Location = "MyNeighborhood"; } else {
party.LocationIconAsset = "RS_DATA/PfUiPartiesList.unity3d/IcoPartyLocationMyNeighborhood"; party.IconAsset = "RS_DATA/PfUiPartiesListMB.unity3d/IcoMbPartyDefault";
party.AssetBundle = "RS_DATA/PfMyNeighborhoodParty.unity3d/PfMyNeighborhoodParty"; party.AssetBundle = "RS_DATA/PfMyPodParty.unity3d/PfMyPodParty";
} }
} else if (partyType == "VIPRoom") { break;
party.Location = "MyVIPRoomInt"; case ClientVersion.SS:
party.LocationIconAsset = "RS_DATA/PfUiPartiesList.unity3d/IcoPartyDefault"; party.Location = "MyLoungeSSInt";
party.AssetBundle = "RS_DATA/PfMyVIPRoomIntPartyGroup.unity3d/PfMyVIPRoomIntPartyGroup"; switch (partyType) {
} else if (partyType == "Birthday") { case "Birthday":
party.Location = "MyPodInt"; party.IconAsset = "RS_DATA/PfUiPartiesListMB.unity3d/IcoSSStorePartyBirthdayDefault";
party.LocationIconAsset = "RS_DATA/PfUiPartiesListMB.unity3d/IcoMbPartyBirthday"; party.AssetBundle = "RS_DATA/PfSsRoomInteriorBirthdayGroup.unity3d/PfSsRoomInteriorBirthdayGroup";
party.AssetBundle = "RS_DATA/PfMyPodBirthdayParty.unity3d/PfMyPodBirthdayParty"; break;
} else { case "NewYears":
Console.WriteLine($"Unsupported partyType = {partyType}"); 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);
} }

View File

@ -11,8 +11,11 @@ namespace sodoff.Model
public int VikingId { get; set; } public int VikingId { get; set; }
public DateTime ExpirationDate { get; set; } = DateTime.UtcNow; public DateTime ExpirationDate { get; set; } = DateTime.UtcNow;
public bool? PrivateParty { get; set; } public bool? PrivateParty { get; set; }
public string IconAsset { get; set; } = null!;
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 string PartyType { get; set; } = null!;
} }
} }