Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
VladimirKhil committed Jan 16, 2024
2 parents 7f95464 + 4dce1b0 commit aafcbc0
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 42 deletions.
3 changes: 3 additions & 0 deletions src/Common/SI.GameServer.Client/GameServerClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,9 @@ public Task<HostInfo> GetGamesHostInfoAsync(CancellationToken cancellationToken
public Task<string> GetNewsAsync(CancellationToken cancellationToken = default) =>
_connection.InvokeAsync<string>("GetNews", cancellationToken);

public Task<ChatMessage[]> GetLatestChatMessagesAsync(CancellationToken cancellationToken = default) =>
_connection.InvokeAsync<ChatMessage[]>("GetLatestChatMessages", cancellationToken);

public Task<string[]> GetUsersAsync(CancellationToken cancellationToken = default) =>
_connection.InvokeAsync<string[]>("GetUsers", cancellationToken);

Expand Down
3 changes: 3 additions & 0 deletions src/Common/SI.GameServer.Contract/ChatMessage.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
namespace SI.GameServer.Contract;

public sealed record ChatMessage(string UserName, string Text);
2 changes: 1 addition & 1 deletion src/Common/SIEngine.Core/FalseStartHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ private static bool ValidateThatStepIsFalseStartable(
{
var contentItem = content.ContentValue[k];

if (contentItem.Type != AtomTypes.Text)
if (contentItem.Type != ContentTypes.Text)
{
return true;
}
Expand Down
7 changes: 3 additions & 4 deletions src/Common/SIEngine.Core/QuestionEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace SIEngine.Core;

/// <summary>
/// Performs SI question playing (new engine version).
/// Performs SI question playing.
/// </summary>
public sealed class QuestionEngine
{
Expand Down Expand Up @@ -283,10 +283,9 @@ public bool PlayNext()
{
ContentValue = new List<ContentItem>
{
new ContentItem
{
new() {
Placement = ContentPlacements.Screen,
Type = AtomTypes.Text,
Type = ContentTypes.Text,
Value = rightAnswer
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Common/SIEngine.Core/QuestionEngineOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public sealed class QuestionEngineOptions
public FalseStartMode FalseStarts { get; set; } = FalseStartMode.Enabled;

/// <summary>
/// Show simple right answers.
/// Show simple right answers flag. Complex right answers are always shown.
/// </summary>
public bool ShowSimpleRightAnswers { get; set; }

Expand Down
37 changes: 18 additions & 19 deletions src/SICore/SICore/BusinessLogic/Localizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,30 @@
using System.Globalization;
using System.Resources;

namespace SICore.BusinessLogic
namespace SICore.BusinessLogic;

public sealed class Localizer : ILocalizer
{
public sealed class Localizer : ILocalizer
{
private readonly ResourceManager _resourceManager;
private readonly ResourceManager _resourceManager;

private ResourceManager _packagesResourceManager;
private ResourceManager _packagesResourceManager;

public CultureInfo Culture { get; }
public CultureInfo Culture { get; }

public Localizer(string culture)
{
_resourceManager = new ResourceManager("SICore.Properties.Resources", typeof(Resources).Assembly);
Culture = new CultureInfo(culture ?? "en-US");
}
public Localizer(string culture)
{
_resourceManager = new ResourceManager("SICore.Properties.Resources", typeof(Resources).Assembly);
Culture = new CultureInfo(culture ?? "en-US");
}

public string this[string key] => _resourceManager.GetString(key, Culture);
public string this[string key] => _resourceManager.GetString(key, Culture);

public string GetPackagesString(string key)
{
_packagesResourceManager ??= new ResourceManager(
"SIPackages.Properties.Resources",
typeof(SIPackages.Properties.Resources).Assembly);
public string GetPackagesString(string key)
{
_packagesResourceManager ??= new ResourceManager(
"SIPackages.Properties.Resources",
typeof(SIPackages.Properties.Resources).Assembly);

return _packagesResourceManager.GetString(key, Culture);
}
return _packagesResourceManager.GetString(key, Culture);
}
}
8 changes: 7 additions & 1 deletion src/SICore/SICore/Clients/Game/GameLogic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,11 @@ internal void Run()
_data.PackageDoc = Engine.Document;

_data.GameResultInfo.Name = _data.GameName;
_data.GameResultInfo.Language = _data.Settings.AppSettings.Culture;
_data.GameResultInfo.PackageName = Engine.PackageName;
_data.GameResultInfo.PackageHash = ""; // Will not use hash for now
_data.GameResultInfo.PackageAuthors = Engine.Document.Package.Info.Authors.ToArray();
_data.GameResultInfo.PackageAuthorsContacts = Engine.Document.Package.ContactUri;

if (_data.Settings.IsAutomatic)
{
Expand Down Expand Up @@ -902,7 +904,11 @@ protected override async ValueTask DisposeAsync(bool disposing) =>
await ClientData.TaskLock.TryLockAsync(
() =>
{
SendReport();
if (_data.Stage != GameStage.Before)
{
SendReport();
}

Engine.Dispose();

return base.DisposeAsync(disposing);
Expand Down
29 changes: 14 additions & 15 deletions src/SICore/SICore/Clients/Player/PlayerTasks.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
namespace SICore.Clients.Player
namespace SICore.Clients.Player;

internal enum PlayerTasks
{
internal enum PlayerTasks
{
Ready,
Answer,
Choose,
Cat,
CatCost,
Stake,
ChooseFinal,
FinalStake,
AnswerRight,
AnswerWrong,
PressButton
}
Ready,
Answer,
Choose,
Cat,
CatCost,
Stake,
ChooseFinal,
FinalStake,
AnswerRight,
AnswerWrong,
PressButton
}
12 changes: 11 additions & 1 deletion src/SICore/SICore/Results/GameResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,15 @@ public sealed class GameResult
/// </summary>
public string Name { get; set; } = "";

/// <summary>
/// Game language.
/// </summary>
public string? Language { get; set; }

/// <summary>
/// Game start time.
/// </summary>
public DateTimeOffset StartTime { get; set; }
public DateTimeOffset StartTime { get; set; } = DateTimeOffset.UtcNow;

/// <summary>
/// Game duration.
Expand All @@ -35,6 +40,11 @@ public sealed class GameResult
/// </summary>
public string[] PackageAuthors { get; set; } = Array.Empty<string>();

/// <summary>
/// Game package authors contacts.
/// </summary>
public string? PackageAuthorsContacts { get; set; }

/// <summary>
/// Players results.
/// </summary>
Expand Down

0 comments on commit aafcbc0

Please sign in to comment.