Skip to content

Commit

Permalink
Fix several errors; remove deprecated VALIDATION message
Browse files Browse the repository at this point in the history
  • Loading branch information
VladimirKhil committed Nov 26, 2023
1 parent e5a5a56 commit d2140b2
Show file tree
Hide file tree
Showing 10 changed files with 57 additions and 103 deletions.
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
SIGame projects set

.NET 6 SDK is required to compile the solutions. Visual Studio 2022 is required to publish SImulator ClickOnce application.
.NET 6 SDK is required to compile solutions. Visual Studio 2022 is required to publish SImulator ClickOnce application.

WiX Toolset is required to build app installers.

Expand Down Expand Up @@ -37,14 +37,14 @@ WiX Toolset is required to build app installers.

# Scripts

* *sigame-build.ps1* - builds a SIGame project in Release configuration and sets provided version number;
* *sigame-build-msi.ps1* - builds a SIGame msi for provided platform;
* *sigame-build-setup.ps1* - builds a SIGame installer;
* *sigame-publish.ps1* - publishes a SIGame and sets provided version number;
* *tools/sigame-build.ps1* - builds a SIGame project in Release configuration and sets provided version number;
* *tools/sigame-build-msi.ps1* - builds a SIGame msi for provided platform;
* *tools/sigame-build-setup.ps1* - builds a SIGame installer;
* *tools/sigame-publish.ps1* - publishes a SIGame and sets provided version number;

* *siquester-build.ps1* - builds a SIQuester project in Release configuration;
* *siquester-build-msi.ps1* - builds a SIQuester msi for win-x86 and win-x64;
* *siquester-publish.ps1* - publishes a SIQuester;
* *tools/siquester-build.ps1* - builds a SIQuester project in Release configuration;
* *tools/siquester-build-msi.ps1* - builds a SIQuester msi for win-x86 and win-x64;
* *tools/siquester-publish.ps1* - publishes a SIQuester;

* *simulator-build.ps1* - builds a SImulator project in Release configuration;
* *simulator-publish.ps1* - publishes a SImulator project in Release configuration for win-x86 architecture as a compressed single file;
* *tools/simulator-build.ps1* - builds a SImulator project in Release configuration;
* *tools/simulator-publish.ps1* - publishes a SImulator project in Release configuration for win-x86 architecture as a compressed single file;
5 changes: 4 additions & 1 deletion src/SICore/SICore/Clients/Game/Game.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1657,9 +1657,12 @@ private void OnChanged(Message message, string[] args)
}

var player = ClientData.Players[playerIndex - 1];
var oldSum = player.Sum;
player.Sum = sum;

_gameActions.SpecialReplic($"{ClientData.ShowMan.Name} {LO[nameof(R.Change1)]} {player.Name}{LO[nameof(R.Change3)]} {Notion.FormatNumber(player.Sum)}");
var verbEnding = ClientData.ShowMan.IsMale ? "" : LO[nameof(R.FemaleEnding)];

_gameActions.SpecialReplic(string.Format(LO[nameof(R.ScoreChanged)], ClientData.ShowMan.Name, player.Name, oldSum, sum, verbEnding));
_gameActions.InformSums();

_logic.AddHistory($"Sum change: {playerIndex - 1} = {sum}");
Expand Down
24 changes: 6 additions & 18 deletions src/SICore/SICore/Clients/Game/GameLogic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3227,25 +3227,10 @@ private void AskRight()
}
}

private void SendAnswersInfoToShowman(string answer)
{
_gameActions.SendMessage(BuildValidationMessage(_data.Answerer.Name, answer), _data.ShowMan.Name);

private void SendAnswersInfoToShowman(string answer) =>
_gameActions.SendMessage(
BuildValidation2Message(_data.Answerer.Name, answer, _data.AnswerMode == StepParameterValues.AskAnswerMode_Button),
_data.ShowMan.Name);
}

private string BuildValidationMessage(string name, string answer, bool isCheckingForTheRight = true)
{
var rightAnswers = _data.Question.Right;
var wrongAnswers = _data.Question.Wrong;

return new MessageBuilder(Messages.Validation, name, answer, isCheckingForTheRight ? '+' : '-', rightAnswers.Count)
.AddRange(rightAnswers)
.AddRange(wrongAnswers)
.Build();
}

private string BuildValidation2Message(string name, string answer, bool allowPriceModifications, bool isCheckingForTheRight = true)
{
Expand Down Expand Up @@ -3812,7 +3797,6 @@ private void PrintAppellation()

_gameActions.ShowmanReplic($"{_data.AppellationSource} {origin}. {apellationReplic}");

var validationMessage = BuildValidationMessage(appelaer.Name, appelaer.Answer, _data.IsAppelationForRightAnswer);
var validation2Message = BuildValidation2Message(appelaer.Name, appelaer.Answer, false, _data.IsAppelationForRightAnswer);

_data.AppellationAwaitedVoteCount = 0;
Expand Down Expand Up @@ -3847,7 +3831,6 @@ private void PrintAppellation()
{
_data.AppellationAwaitedVoteCount++;
_data.Players[i].Flag = true;
_gameActions.SendMessage(validationMessage, _data.Players[i].Name);
_gameActions.SendMessage(validation2Message, _data.Players[i].Name);
}
}
Expand Down Expand Up @@ -4428,6 +4411,11 @@ internal void OnButtonPressStart()

internal void OnSetTheme(string themeName)
{
if (string.IsNullOrWhiteSpace(themeName))
{
themeName = _data.Theme?.Name ?? "";
}

_gameActions.SendMessageWithArgs(Messages.QuestionCaption, themeName);

var s = new StringBuilder(LO[nameof(R.Theme)]).Append(": ").Append(themeName);
Expand Down
8 changes: 7 additions & 1 deletion src/SICore/SICore/Clients/Game/QuestionPlayHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,13 @@ public void OnAskAnswerStop()

public void OnButtonPressStart()
{
GameLogic?.OnButtonPressStart();
if (GameLogic == null || GameData == null)
{
return;
}

GameData.AnswerMode = StepParameterValues.AskAnswerMode_Button;
GameLogic.OnButtonPressStart(); // TODO: merge somehow with GameLogic.AskToPress()
}

public void OnContentStart(IEnumerable<ContentItem> contentItems)
Expand Down
34 changes: 0 additions & 34 deletions src/SICore/SICore/Clients/Player/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -403,10 +403,6 @@ protected override async ValueTask OnSystemMessageReceivedAsync(string[] mparams
_logic.PlayerLogic.FinalStake();
break;

case Messages.Validation:
OnValidation(mparams);
break;

case Messages.Validation2:
OnValidation2(mparams);
break;
Expand Down Expand Up @@ -456,36 +452,6 @@ protected override async ValueTask OnSystemMessageReceivedAsync(string[] mparams
}
}

private void OnValidation(string[] mparams)
{
ClientData.PersonDataExtensions.ValidatorName = mparams[1];
ClientData.PersonDataExtensions.Answer = mparams[2];
_logic.PlayerLogic.IsRight(mparams[3] == "+");
_ = int.TryParse(mparams[4], out var rightAnswersCount);
rightAnswersCount = Math.Min(rightAnswersCount, mparams.Length - 5);

var right = new List<string>();

for (int i = 0; i < rightAnswersCount; i++)
{
right.Add(mparams[5 + i]);
}

var wrong = new List<string>();

for (int i = 5 + rightAnswersCount; i < mparams.Length; i++)
{
wrong.Add(mparams[i]);
}

ClientData.PersonDataExtensions.Right = right.ToArray();
ClientData.PersonDataExtensions.Wrong = wrong.ToArray();

ClientData.Hint = LO[nameof(R.HintCheckAnswer)];
ClientData.DialogMode = DialogModes.AnswerValidation;
((PersonAccount)ClientData.Me).IsDeciding = false;
}

private void OnValidation2(string[] mparams)
{
ClientData.PersonDataExtensions.ValidatorName = mparams[1];
Expand Down
34 changes: 0 additions & 34 deletions src/SICore/SICore/Clients/Showman/Showman.cs
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,6 @@ protected override async ValueTask OnSystemMessageReceivedAsync(string[] mparams
#endregion
}

case Messages.Validation:
OnValidation(mparams);
break;

case Messages.Validation2:
OnValidation2(mparams);
break;
Expand Down Expand Up @@ -404,36 +400,6 @@ private void OnPause(string[] mparams)
}
}

private void OnValidation(string[] mparams)
{
ClientData.PersonDataExtensions.ValidatorName = mparams[1];
ClientData.PersonDataExtensions.Answer = mparams[2];
_ = int.TryParse(mparams[4], out var rightAnswersCount);
rightAnswersCount = Math.Min(rightAnswersCount, mparams.Length - 5);

var right = new List<string>();

for (int i = 0; i < rightAnswersCount; i++)
{
right.Add(mparams[5 + i]);
}

var wrong = new List<string>();

for (int i = 5 + rightAnswersCount; i < mparams.Length; i++)
{
wrong.Add(mparams[i]);
}

ClientData.PersonDataExtensions.Right = right.ToArray();
ClientData.PersonDataExtensions.Wrong = wrong.ToArray();

ClientData.Hint = LO[nameof(R.HintCheckAnswer)];
ClientData.DialogMode = DialogModes.AnswerValidation;
((PersonAccount)ClientData.Me).IsDeciding = false;
_logic.ShowmanLogic.IsRight();
}

private void OnValidation2(string[] mparams)
{
ClientData.PersonDataExtensions.ValidatorName = mparams[1];
Expand Down
5 changes: 0 additions & 5 deletions src/SICore/SICore/Messages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -515,11 +515,6 @@ public static class Messages
/// </summary>
public const string Unbanned = "UNBANNED";

/// <summary>
/// Необходимо провалидировать ответ игрока
/// </summary>
public const string Validation = "VALIDATION";

/// <summary>
/// Answer validation.
/// </summary>
Expand Down
18 changes: 18 additions & 0 deletions src/SICore/SICore/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions src/SICore/SICore/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -837,4 +837,10 @@
<data name="SelectAnswerOption" xml:space="preserve">
<value>Select answer option on table</value>
</data>
<data name="FemaleEnding" xml:space="preserve">
<value />
</data>
<data name="ScoreChanged" xml:space="preserve">
<value>{0} changed {1} score from {2} to {3}</value>
</data>
</root>
6 changes: 6 additions & 0 deletions src/SICore/SICore/Properties/Resources.ru-RU.resx
Original file line number Diff line number Diff line change
Expand Up @@ -842,4 +842,10 @@
<data name="SelectAnswerOption" xml:space="preserve">
<value>Выберите вариант ответа на табло</value>
</data>
<data name="FemaleEnding" xml:space="preserve">
<value>а</value>
</data>
<data name="ScoreChanged" xml:space="preserve">
<value>{0} изменил{4} сумму на счёте {1} с {2} на {3}</value>
</data>
</root>

0 comments on commit d2140b2

Please sign in to comment.