diff --git a/src/Common/SI.GameServer.Client/GameServerClient.cs b/src/Common/SI.GameServer.Client/GameServerClient.cs index 63c3a19e..f86d548e 100644 --- a/src/Common/SI.GameServer.Client/GameServerClient.cs +++ b/src/Common/SI.GameServer.Client/GameServerClient.cs @@ -84,6 +84,9 @@ public GameServerClient(IOptions options, IUIThreadExec }; } + public Task RunGameAsync(RunGameRequest runGameRequest, CancellationToken cancellationToken = default) => + Connection.InvokeAsync("RunGame", runGameRequest, cancellationToken); + public Task CreateGameAsync( GameSettingsCore gameSettings, PackageKey packageKey, diff --git a/src/Common/SI.GameServer.Client/IGameServerClient.cs b/src/Common/SI.GameServer.Client/IGameServerClient.cs index 3b74d15c..46b00066 100644 --- a/src/Common/SI.GameServer.Client/IGameServerClient.cs +++ b/src/Common/SI.GameServer.Client/IGameServerClient.cs @@ -54,6 +54,10 @@ public interface IGameServerClient : IGameClient Task UploadPackageAsync(FileKey packageHash, Stream stream, CancellationToken cancellationToken = default); + Task RunGameAsync( + RunGameRequest runGameRequest, + CancellationToken cancellationToken = default); + Task CreateGameAsync( GameSettingsCore gameSettings, PackageKey packageKey, diff --git a/src/Common/SI.GameServer.Contract/RunGameRequest.cs b/src/Common/SI.GameServer.Contract/RunGameRequest.cs new file mode 100644 index 00000000..6e3129e4 --- /dev/null +++ b/src/Common/SI.GameServer.Contract/RunGameRequest.cs @@ -0,0 +1,14 @@ +using SIData; + +namespace SI.GameServer.Contract; + +/// +/// Defines a game run request. +/// +/// Game options. +/// Game package descriptor. +/// Custom computer accounts information. +public sealed record RunGameRequest( + GameSettingsCore GameSettings, + PackageInfo PackageInfo, + ComputerAccount[] ComputerAccounts); diff --git a/src/Common/SI.GameServer.Contract/RunGameResponse.cs b/src/Common/SI.GameServer.Contract/RunGameResponse.cs new file mode 100644 index 00000000..5cf1dec7 --- /dev/null +++ b/src/Common/SI.GameServer.Contract/RunGameResponse.cs @@ -0,0 +1,32 @@ +namespace SI.GameServer.Contract; + +/// +/// Defines a run game response. +/// +public sealed class RunGameResponse +{ + /// + /// Is run successfull. + /// + public bool IsSuccess { get; set; } + + /// + /// Game host uri. + /// + public Uri? HostUri { get; set; } + + /// + /// Game identifier. + /// + public int GameId { get; set; } + + /// + /// Should the person be a game host. + /// + public bool IsHost { get; set; } + + /// + /// Creation error code. + /// + public GameCreationResultCode ErrorType { get; set; } +} diff --git a/src/Common/SIPackages.Providers/PackageHelper.cs b/src/Common/SIPackages.Providers/PackageHelper.cs index 75f0f540..b44c8c74 100644 --- a/src/Common/SIPackages.Providers/PackageHelper.cs +++ b/src/Common/SIPackages.Providers/PackageHelper.cs @@ -45,7 +45,17 @@ public static Task GenerateRandomPackageAsync( { var doc = SIDocument.Create(name, author, folder); - return GenerateCoreAsync(provider, roundsCount, themesCount, baseCost, doc, roundNameFormat, finalName, culture, maxPackageCount, cancellationToken); + return GenerateCoreAsync( + provider, + roundsCount, + themesCount, + baseCost, + doc, + roundNameFormat, + finalName, + culture, + maxPackageCount, + cancellationToken); } private static async Task GenerateCoreAsync( diff --git a/src/SICore/SICore/Clients/Game/Game.cs b/src/SICore/SICore/Clients/Game/Game.cs index e2a35800..894310b6 100644 --- a/src/SICore/SICore/Clients/Game/Game.cs +++ b/src/SICore/SICore/Clients/Game/Game.cs @@ -2987,7 +2987,7 @@ private void SetPerson(string[] args, Account host) } var oldName = account.Name; - GamePersonAccount newAccount; + GamePersonAccount? newAccount; if (!account.IsHuman) {