Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Account system #14

Merged
merged 3 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Fuyu.Launcher/Pages/Account.razor
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@

private void StartEft()
{
var accountId = 659885;
var sessionId = "test";

using (var process = ProcessService.StartEft(SettingsService.ClientDirectory, accountId, SettingsService.Address))
using (var process = ProcessService.StartEft(SettingsService.ClientDirectory, sessionId, SettingsService.Address))
{
process.Start();
}
Expand Down
5 changes: 5 additions & 0 deletions Fuyu.Platform.Common/Http/FuyuContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,10 @@ public T GetJson<T>()
var json = GetText();
return Json.Parse<T>(json);
}

public string GetSessionId()
{
return Request.Cookies["PHPSESSID"].Value;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Fuyu.Platform.Common.Models.EFT.Multiplayer
{
[DataContract]
public struct ProfileStatus
public struct ProfileStatusInfo
{
[DataMember]
public string profileid;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System.Runtime.Serialization;

namespace Fuyu.Platform.Common.Models.EFT.Requests
{
[DataContract]
public struct GameProfileCreateRequest
{
[DataMember]
public string side;

[DataMember]
public string nickname;

[DataMember]
public string headId;

[DataMember]
public string voiceId;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using System.Runtime.Serialization;

namespace Fuyu.Platform.Common.Models.EFT.Requests
{
[DataContract]
public struct GameProfileNicknameValidateRequest
{
[DataMember]
public string nickname;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using System.Runtime.Serialization;

namespace Fuyu.Platform.Common.Models.EFT.Responses
{
[DataContract]
public struct GameProfileCreateResponse
{
[DataMember]
public string uid;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using System.Runtime.Serialization;

namespace Fuyu.Platform.Common.Models.EFT.Responses
{
[DataContract]
public struct GameProfileNicknameValidateResponse
{
[DataMember]
public string status;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ public struct ProfileStatusResponse
public bool maxPveCountExceeded;

[DataMember]
public ProfileStatus[] profiles;
public ProfileStatusInfo[] profiles;
}
}
18 changes: 18 additions & 0 deletions Fuyu.Platform.Common/Models/Fuyu/Account.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using System.Runtime.Serialization;
using Fuyu.Platform.Common.Models.Fuyu.Savegame;

namespace Fuyu.Platform.Common.Models.Fuyu
{
[DataContract]
public struct Account
{
[DataMember]
public string Username;

[DataMember]
public string Password;

[DataMember]
public EftSave EftSave;
}
}
21 changes: 21 additions & 0 deletions Fuyu.Platform.Common/Models/Fuyu/Savegame/EftProfile.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using System.Runtime.Serialization;
using Fuyu.Platform.Common.Models.EFT.Profiles;

namespace Fuyu.Platform.Common.Models.Fuyu.Savegame
{
[DataContract]
public struct EftProfile
{
[DataMember]
public Profile Savage;

[DataMember]
public Profile Pmc;

[DataMember]
public string[] Suites;

[DataMember]
public bool ShouldWipe;
}
}
17 changes: 17 additions & 0 deletions Fuyu.Platform.Common/Models/Fuyu/Savegame/EftSave.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System.Runtime.Serialization;

namespace Fuyu.Platform.Common.Models.Fuyu.Savegame
{
[DataContract]
public struct EftSave
{
[DataMember]
public string Edition;

[DataMember]
public EftProfile PvP;

[DataMember]
public EftProfile PvE;
}
}
8 changes: 4 additions & 4 deletions Fuyu.Platform.Launcher/Services/ProcessService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@ namespace Fuyu.Platform.Launcher.Services
{
public class ProcessService
{
private static string GetLaunchArguments(int accountId, string address)
private static string GetLaunchArguments(string sessionId, string address)
{
var token = $"-token={accountId}";
var token = $"-token={sessionId}";
var config = "-config={\"BackendUrl\":\"" + address + "\",\"Version\":\"live\"}";
var arguments = $"{token} {config}";
return arguments;
}

public static Process StartEft(string cwd, int accountId, string address)
public static Process StartEft(string cwd, string sessionId, string address)
{
return new Process()
{
StartInfo = new ProcessStartInfo()
{
Arguments = GetLaunchArguments(accountId, address),
Arguments = GetLaunchArguments(sessionId, address),
FileName = Path.Combine(cwd, "EscapeFromTarkov.exe"),
WorkingDirectory = cwd
}
Expand Down
20 changes: 20 additions & 0 deletions Fuyu.Platform.Server/Behaviours/EFT/AccountCustomization.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using Fuyu.Platform.Common.Http;
using Fuyu.Platform.Common.IO;

namespace Fuyu.Platform.Server.Behaviours.EFT
{
public class AccountCustomization : FuyuBehaviour
{
private readonly string _response;

public AccountCustomization()
{
_response = Resx.GetText("eft", "database.eft.client.account.customization.json");
}

public override void Run(FuyuContext context)
{
SendJson(context, _response);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
using Fuyu.Platform.Common.Http;
using Fuyu.Platform.Common.IO;

namespace Fuyu.Platform.Server.Behaviours
namespace Fuyu.Platform.Server.Behaviours.EFT
{
public class AchievementList : FuyuBehaviour
{
private readonly string _response;

public AchievementList()
{
_response = Resx.GetText("fuyu", "database.client.achievement.list.json");
_response = Resx.GetText("eft", "database.eft.client.achievement.list.json");
}

public override void Run(FuyuContext context)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
using Fuyu.Platform.Common.Models.EFT.Responses;
using Fuyu.Platform.Common.Serialization;

namespace Fuyu.Platform.Server.Behaviours
namespace Fuyu.Platform.Server.Behaviours.EFT
{
public class AchievementStatistic : FuyuBehaviour
{
private readonly ResponseBody<AchievementStatisticResponse> _response;

public AchievementStatistic()
{
var json = Resx.GetText("fuyu", "database.client.achievement.statistic.json");
var json = Resx.GetText("eft", "database.eft.client.achievement.statistic.json");
_response = Json.Parse<ResponseBody<AchievementStatisticResponse>>(json);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
using Fuyu.Platform.Common.Models.EFT.Responses;
using Fuyu.Platform.Common.Serialization;

namespace Fuyu.Platform.Server.Behaviours
namespace Fuyu.Platform.Server.Behaviours.EFT
{
public class BuildsList : FuyuBehaviour
{
private readonly ResponseBody<BuildsListResponse> _response;

public BuildsList()
{
var json = Resx.GetText("fuyu", "database.client.builds.list.json");
var json = Resx.GetText("eft", "database.eft.client.builds.list.json");
_response = Json.Parse<ResponseBody<BuildsListResponse>>(json);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using Fuyu.Platform.Common.Models.EFT.Responses;
using Fuyu.Platform.Common.Serialization;

namespace Fuyu.Platform.Server.Behaviours
namespace Fuyu.Platform.Server.Behaviours.EFT
{
public class CheckVersion : FuyuBehaviour
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
using Fuyu.Platform.Common.Http;
using Fuyu.Platform.Common.IO;

namespace Fuyu.Platform.Server.Behaviours
namespace Fuyu.Platform.Server.Behaviours.EFT
{
public class Customization : FuyuBehaviour
{
private readonly string _response;

public Customization()
{
_response = Resx.GetText("fuyu", "database.client.customization.json");
_response = Resx.GetText("eft", "database.eft.client.customization.json");
}

public override void Run(FuyuContext context)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
using Fuyu.Platform.Common.Http;
using Fuyu.Platform.Common.Models.EFT.Responses;
using Fuyu.Platform.Common.Serialization;
using Fuyu.Platform.Server.Databases;

namespace Fuyu.Platform.Server.Behaviours
namespace Fuyu.Platform.Server.Behaviours.EFT
{
public class CustomizationStorage : FuyuBehaviour
{
public override void Run(FuyuContext context)
{
var sessionId = context.GetSessionId();
var accountId = FuyuDatabase.Accounts.GetSession(sessionId);
var account = FuyuDatabase.Accounts.GetAccount(accountId);

// TODO: PVP-PVE STATE DETECTION
var response = new ResponseBody<CustomizationStorageResponse>()
{
data = new CustomizationStorageResponse()
{
_id = "664113fa049fd2369707c357",
suites = [
"5cde9ec17d6c8b04723cf479",
"5cde9e957d6c8b0474535da7"
]
_id = account.EftSave.PvE.Pmc._id,
suites = account.EftSave.PvE.Suites
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using Fuyu.Platform.Common.Models.EFT.Responses;
using Fuyu.Platform.Common.Serialization;

namespace Fuyu.Platform.Server.Behaviours
namespace Fuyu.Platform.Server.Behaviours.EFT
{
public class FriendList : FuyuBehaviour
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using Fuyu.Platform.Common.Models.EFT.Responses;
using Fuyu.Platform.Common.Serialization;

namespace Fuyu.Platform.Server.Behaviours
namespace Fuyu.Platform.Server.Behaviours.EFT
{
public class FriendRequestListInbox : FuyuBehaviour
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using Fuyu.Platform.Common.Models.EFT.Responses;
using Fuyu.Platform.Common.Serialization;

namespace Fuyu.Platform.Server.Behaviours
namespace Fuyu.Platform.Server.Behaviours.EFT
{
public class FriendRequestListOutbox : FuyuBehaviour
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using Fuyu.Platform.Common.Models.EFT.Responses;
using Fuyu.Platform.Common.Serialization;

namespace Fuyu.Platform.Server.Behaviours
namespace Fuyu.Platform.Server.Behaviours.EFT
{
public class GameBotGenerate : FuyuBehaviour
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,21 @@
using Fuyu.Platform.Common.Serialization;
using Fuyu.Platform.Server.Databases;

namespace Fuyu.Platform.Server.Behaviours
namespace Fuyu.Platform.Server.Behaviours.EFT
{
public class GameConfig : FuyuBehaviour
{
public override void Run(FuyuContext context)
{
var sessionId = context.GetSessionId();
var accountId = FuyuDatabase.Accounts.GetSession(sessionId);

var languages = EftDatabase.Locales.GetLanguages();
var response = new ResponseBody<GameConfigResponse>
{
data = new GameConfigResponse()
{
aid = 659885,
aid = accountId,
lang = "en", // TODO: observe how this works
languages = languages,
ndaFree = false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using Fuyu.Platform.Common.Models.EFT.Responses;
using Fuyu.Platform.Common.Serialization;

namespace Fuyu.Platform.Server.Behaviours
namespace Fuyu.Platform.Server.Behaviours.EFT
{
public class GameLogout : FuyuBehaviour
{
Expand Down
Loading