mirror of
https://github.com/SoDOff-Project/sodoff.git
synced 2025-10-11 08:18:49 -07:00
Merge 8905d84bc6fe619f21507b1fad472a6f4e843235 into f8b26e468b7d6d3bcd69628c11255a4ca2798417
This commit is contained in:
commit
135992ed1a
@ -1392,6 +1392,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)
|
||||
@ -1402,42 +1403,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() });
|
||||
@ -1472,8 +1457,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
|
||||
@ -1495,55 +1481,46 @@ 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}");
|
||||
uint gameID = ClientVersion.GetGameID(apiKey);
|
||||
|
||||
PartiesInfo data = XmlUtil.DeserializeXml<PartiesInfo>(XmlUtil.ReadResourceXmlString("parties_info"));
|
||||
PartyInfo? info = data.Parties.FirstOrDefault(p => p.GameID == gameID && p.Type == partyType);
|
||||
if (info == null) return Ok(null);
|
||||
|
||||
if (info.Location == null) {
|
||||
Console.WriteLine($"Unsupported partyType \"{partyType}\" for gameid 0x{gameID:X8}");
|
||||
return Ok(null);
|
||||
}
|
||||
|
||||
party.ExpirationDate = DateTime.UtcNow.AddMinutes(
|
||||
Int32.Parse(itemData.Attribute.FirstOrDefault(a => a.Key == "Time").Value)
|
||||
);
|
||||
|
||||
// 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
|
||||
viking.AchievementPoints.FirstOrDefault(e => e.Type == (int)AchievementPointTypes.GameCurrency)!.Value -= itemData.Cost;
|
||||
|
||||
viking.Parties.Add(party);
|
||||
ctx.SaveChanges();
|
||||
|
||||
|
||||
return Ok(true);
|
||||
}
|
||||
|
||||
|
@ -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; }
|
||||
}
|
||||
}
|
||||
|
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;
|
||||
}
|
@ -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