-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
424 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
{ | ||
"PSNBaseURL": "https://s2s.np.playstation.net", | ||
"autoJoin": false, | ||
"clientVersion": "0", | ||
"deployment": "", | ||
"dsSource": "", | ||
"fallbackClaimKeys": [], | ||
"inactiveTimeout": 300, | ||
"inviteTimeout": 60, | ||
"joinability": "INVITE_ONLY", | ||
"maxPlayers": 4, | ||
"minPlayers": 1, | ||
"name": "PartySession", | ||
"nativeSessionSetting": { | ||
"PSNServiceLabel": 0, | ||
"PSNSupportedPlatforms": [], | ||
"SessionTitle": "PAYDAY 3 Party", | ||
"ShouldSync": true, | ||
"XboxServiceConfigID": "00000000-0000-0000-0000-00006056e5d6", | ||
"XboxSessionTemplateName": "Payday3", | ||
"localizedSessionName": { | ||
"defaultLanguage": "en-US", | ||
"localizedText": { | ||
"de-DE": "GRUPPE PAYDAY 3", | ||
"en-US": "PAYDAY 3 Party", | ||
"es-419": "GRUPO PAYDAY 3", | ||
"es-ES": "GRUPO PAYDAY 3", | ||
"fr-FR": "GROUPE PAYDAY 3", | ||
"it-IT": "SQUADRA PAYDAY 3", | ||
"ja-JP": "PAYDAY 3 パーティー", | ||
"ko-KR": "PAYDAY 3 파티", | ||
"pl-PL": "ZESPÓŁ PAYDAY 3", | ||
"pt-BR": "GRUPO PAYDAY 3", | ||
"ru-RU": "КОМАНДА PAYDAY 3", | ||
"tr-TR": "PAYDAY 3 GRUP", | ||
"zh-Hans": "PAYDAY 3 参加者", | ||
"zh-Hant": "PAYDAY 3 隊伍" | ||
} | ||
} | ||
}, | ||
"persistent": false, | ||
"preferredClaimKeys": [], | ||
"requestedRegions": [ | ||
"eu-central-1" | ||
], | ||
"textChat": true, | ||
"tieTeamsSessionLifetime": false, | ||
"type": "NONE" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,161 @@ | ||
using Newtonsoft.Json; | ||
using PayCheckServerLib.Jsons; | ||
using PayCheckServerLib.Jsons.PartyStuff; | ||
using System.Security.Cryptography; | ||
|
||
namespace PayCheckServerLib.Helpers | ||
{ | ||
public class PartyController | ||
{ | ||
|
||
public class SavedStuff | ||
{ | ||
public Dictionary<string, object> Attributes; //WHY I NEED TO SAVE THIS AAAAAAAAAAAAAAA | ||
public string Code; | ||
public string CreatedBy; | ||
public string Id; | ||
public string LeaderId; | ||
public long version; | ||
public List<PartyPost.Member> Members; | ||
public bool IsActive; | ||
public bool IsFull; | ||
public string SessionType; | ||
public string CreatedAt; | ||
public string UpdatedAt; | ||
} | ||
|
||
public static Dictionary<string, SavedStuff> PartySaves = new(); | ||
|
||
public static PartyPost.Response ParsePartyToRSP(SavedStuff stuff) | ||
{ | ||
PartyPost.Response rsp = new(); | ||
rsp.Code = stuff.Code; | ||
rsp.Attributes = stuff.Attributes; | ||
rsp.Configuration = JsonConvert.DeserializeObject<PartyPost.Configuration>(File.ReadAllText($"Files/{stuff.SessionType}Configuration.json")); | ||
rsp.Id = stuff.Id; | ||
rsp.IsActive = stuff.IsActive; | ||
rsp.IsFull = stuff.IsFull; | ||
rsp.LeaderId = stuff.LeaderId; | ||
rsp.CreatedBy = stuff.CreatedBy; | ||
rsp.Namespace = "pd3"; | ||
rsp.Version = stuff.version; | ||
rsp.CreatedAt = stuff.CreatedAt; | ||
rsp.UpdatedAt = stuff.UpdatedAt; | ||
rsp.Members = stuff.Members; | ||
return rsp; | ||
} | ||
|
||
|
||
public static PartyPost.Response CreateParty(PartyPostReq partyPost) | ||
{ | ||
var code = UserIdHelper.CreateCode(); | ||
|
||
PartyPost.Response rsp = new(); | ||
rsp.Code = code; | ||
rsp.Attributes = partyPost.Attributes; | ||
rsp.Configuration = JsonConvert.DeserializeObject<PartyPost.Configuration>(File.ReadAllText($"Files/{partyPost.ConfigurationName}Configuration.json")); | ||
rsp.Id = UserIdHelper.CreateNewID(); | ||
rsp.IsActive = true; | ||
rsp.IsFull = false; | ||
rsp.LeaderId = partyPost.Members[0].ID; | ||
rsp.CreatedBy = partyPost.Members[0].ID; | ||
rsp.Namespace = "pd3"; | ||
rsp.Version = 1; //init version 1 | ||
rsp.CreatedAt = DateTime.UtcNow.ToString("o"); | ||
rsp.UpdatedAt = DateTime.UtcNow.ToString("o"); | ||
rsp.Members = new(); | ||
foreach (var item in partyPost.Members) | ||
{ | ||
rsp.Members.Add(new() | ||
{ | ||
Id = item.ID, | ||
PlatformId = item.PlatformId.ToUpper(), | ||
PlatformUserId = item.PlatformUserId, | ||
Status = "JOINED", | ||
StatusV2 = "JOINED", | ||
UpdatedAt = DateTime.UtcNow.ToString("o") | ||
}); | ||
} | ||
|
||
SavedStuff saved = new() | ||
{ | ||
Code = code, | ||
SessionType = partyPost.ConfigurationName, | ||
CreatedAt = rsp.CreatedAt, | ||
CreatedBy = rsp.CreatedBy, | ||
Id = rsp.Id, | ||
IsActive = rsp.IsActive, | ||
IsFull = rsp.IsFull, | ||
LeaderId = rsp.LeaderId, | ||
Members = rsp.Members, | ||
UpdatedAt = rsp.UpdatedAt, | ||
version = rsp.Version | ||
}; | ||
PartySaves.Add(code, saved); | ||
Debugger.PrintInfo("New Party made!"); | ||
return rsp; | ||
} | ||
|
||
|
||
public static PartyPost.Response JoinParty(string Code, TokenHelper.Token token) | ||
{ | ||
if (!PartySaves.ContainsKey(Code)) | ||
{ | ||
Debugger.PrintError("NO Code???? WHAT THE FUCK"); | ||
throw new Exception("Code is not exist in saved parties????"); | ||
} | ||
var stuff = PartySaves[Code]; | ||
stuff.UpdatedAt = DateTime.UtcNow.ToString("o"); | ||
var user = stuff.Members.Where(x => x.Id == token.UserId).First(); | ||
//shinenigans too edit user in members | ||
stuff.Members.Remove(user); | ||
user.Status = "JOINED"; | ||
user.StatusV2 = "JOINED"; | ||
user.UpdatedAt = DateTime.UtcNow.ToString("o"); | ||
stuff.Members.Add(user); | ||
//stuff.version += 1; //does this needed? | ||
return ParsePartyToRSP(stuff); | ||
} | ||
|
||
|
||
|
||
public static PartyPost.Response UpdateParty(string PartyId, dynamic body) | ||
{ | ||
var party = PartySaves.Where(x=>x.Value.Id == PartyId).FirstOrDefault().Value; | ||
if (party == null) | ||
{ | ||
Debugger.PrintError("NO Code???? WHAT THE FUCK"); | ||
throw new Exception("Code is not exist in saved parties????"); | ||
} | ||
|
||
party.UpdatedAt = DateTime.UtcNow.ToString("o"); | ||
party.Attributes = body.attributes; | ||
party.version = body.version + 1; | ||
|
||
return ParsePartyToRSP(party); | ||
} | ||
|
||
public static void LeftParty(string PartyId, string UserId, PC3Server.PC3Session session) | ||
{ | ||
var party = PartySaves.Where(x => x.Value.Id == PartyId).FirstOrDefault().Value; | ||
if (party == null) | ||
{ | ||
Debugger.PrintError("NO Code???? WHAT THE FUCK"); | ||
throw new Exception("Code is not exist in saved parties????"); | ||
} | ||
|
||
party.UpdatedAt = DateTime.UtcNow.ToString("o"); | ||
party.version += 1; | ||
foreach (var m in party.Members) | ||
{ | ||
if (m.Id == UserId) | ||
{ | ||
m.Status = "LEFT"; | ||
m.StatusV2 = "LEFT"; | ||
} | ||
} | ||
//todo send other users update that we left! | ||
//or if we are the leader send this one dead and sent to leave everybody | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using Newtonsoft.Json; | ||
|
||
namespace PayCheckServerLib.Jsons.PartyStuff | ||
{ | ||
public class OnPartyCreated | ||
{ | ||
[JsonProperty("CreatedBy")] | ||
public string CreatedBy { get; set; } | ||
|
||
[JsonProperty("PartyID")] | ||
public string PartyId { get; set; } | ||
|
||
[JsonProperty("TextChat")] | ||
public bool TextChat { get; set; } | ||
|
||
[JsonProperty("Code")] | ||
public string Code { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
using Newtonsoft.Json; | ||
|
||
namespace PayCheckServerLib.Jsons.PartyStuff | ||
{ | ||
internal class OnPartyUpdated | ||
{ | ||
[JsonProperty("ID")] | ||
public string Id { get; set; } | ||
|
||
[JsonProperty("Namespace")] | ||
public string Namespace { get; set; } | ||
|
||
[JsonProperty("Members")] | ||
public List<PartyPost.Member> Members { get; set; } | ||
|
||
[JsonProperty("Attributes")] | ||
public Dictionary<string, object> Attributes { get; set; } | ||
|
||
[JsonProperty("CreatedAt")] | ||
public string CreatedAt { get; set; } | ||
|
||
[JsonProperty("CreatedBy")] | ||
public string CreatedBy { get; set; } | ||
|
||
[JsonProperty("UpdatedAt")] | ||
public string UpdatedAt { get; set; } | ||
|
||
[JsonProperty("Version")] | ||
public long Version { get; set; } | ||
|
||
[JsonProperty("Configuration")] | ||
public Configuration Configuration { get; set; } | ||
|
||
[JsonProperty("ConfigurationName")] | ||
public string ConfigurationName { get; set; } | ||
|
||
[JsonProperty("IsFull")] | ||
public bool IsFull { get; set; } | ||
|
||
[JsonProperty("LeaderID")] | ||
public string LeaderId { get; set; } | ||
|
||
[JsonProperty("Code")] | ||
public string Code { get; set; } | ||
} | ||
|
||
public partial class Configuration | ||
{ | ||
[JsonProperty("Name")] | ||
public string Name { get; set; } | ||
|
||
[JsonProperty("Joinability")] | ||
public string Joinability { get; set; } | ||
|
||
[JsonProperty("MinPlayers")] | ||
public long MinPlayers { get; set; } | ||
|
||
[JsonProperty("MaxPlayers")] | ||
public long MaxPlayers { get; set; } | ||
|
||
[JsonProperty("ClientVersion")] | ||
public string ClientVersion { get; set; } | ||
|
||
[JsonProperty("RequestedRegions")] | ||
public List<string> RequestedRegions { get; set; } | ||
|
||
[JsonProperty("Type")] | ||
public string Type { get; set; } | ||
|
||
[JsonProperty("InviteTimeout")] | ||
public long InviteTimeout { get; set; } | ||
|
||
[JsonProperty("InactiveTimeout")] | ||
public long InactiveTimeout { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.