mirror of
https://github.com/SoDOff-Project/sodoff.git
synced 2025-10-11 08:18:49 -07:00
"Rewrote" party creation system, added support for supersecret parties.
This commit is contained in:
parent
bdf7707019
commit
e5fe602ade
@ -1393,6 +1393,9 @@ public class ContentController : Controller {
|
||||
List<Party> allParties = ctx.Parties.ToList();
|
||||
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)
|
||||
{
|
||||
if(DateTime.UtcNow >= party.ExpirationDate)
|
||||
@ -1403,6 +1406,8 @@ public class ContentController : Controller {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Only send parties to their respective games.
|
||||
if (gameVersion != party.GameVersion) continue;
|
||||
|
||||
Viking viking = ctx.Vikings.FirstOrDefault(e => e.Id == party.VikingId);
|
||||
AvatarData avatarData = XmlUtil.DeserializeXml<AvatarData>(viking.AvatarSerialized);
|
||||
@ -1411,34 +1416,29 @@ public class ContentController : Controller {
|
||||
DisplayName = avatarData.DisplayName,
|
||||
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";
|
||||
}
|
||||
}
|
||||
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.
|
||||
|
||||
uint gameVersion = ClientVersion.GetVersion(apiKey);
|
||||
// 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);
|
||||
}
|
||||
userParties.Add(userParty);
|
||||
}
|
||||
|
||||
return Ok(new UserPartyData { NonBuddyParties = userParties.ToArray() });
|
||||
@ -1473,8 +1473,9 @@ public class ContentController : Controller {
|
||||
DisplayName = avatarData.DisplayName,
|
||||
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
|
||||
@ -1496,12 +1497,6 @@ 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) {
|
||||
@ -1509,26 +1504,68 @@ public class ContentController : Controller {
|
||||
}
|
||||
|
||||
uint gameVersion = ClientVersion.GetVersion(apiKey);
|
||||
if (partyType == "Default") {
|
||||
if (gameVersion == ClientVersion.MB) {
|
||||
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
|
||||
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.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}");
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -11,8 +11,11 @@ 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!;
|
||||
public virtual Viking? Viking { get; set; }
|
||||
public uint GameVersion { get; set; } = 0!;
|
||||
public string PartyType { get; set; } = null!;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user