Skip to content

Commit 57bb972

Browse files
committed
Provide several fixes for SIGame and SImulator
1 parent cd543ad commit 57bb972

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+803
-661
lines changed

deploy/SIGame.Setup/SIGame.Setup.wixproj

+6-5
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@
44
<ProductVersion>3.9</ProductVersion>
55
<OutputName>SIGame.$(Platform)</OutputName>
66
<DefineConstants>ProductVersion=$(MsiProductVersion)</DefineConstants>
7-
<SuppressIces>ICE38;ICE57;ICE91</SuppressIces>
7+
<SuppressIces>ICE38;ICE57;ICE91</SuppressIces>
88
</PropertyGroup>
99
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
10-
<DefineConstants>Debug</DefineConstants>
10+
<DefineConstants>Debug</DefineConstants>
1111
</PropertyGroup>
1212
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
1313
</PropertyGroup>
1414
<ItemGroup>
15-
<PackageReference Include="WixToolset.Util.wixext" Version="5.0.1" />
15+
<PackageReference Include="WixToolset.Util.wixext" Version="5.0.2" />
1616
<PackageReference Include="WixToolset.UI.wixext" Version="5.0.1" />
17-
<PackageReference Include="WixToolset.NetFx.wixext" Version="5.0.1" />
17+
<PackageReference Include="WixToolset.NetFx.wixext" Version="5.0.2" />
1818
</ItemGroup>
1919
<ItemGroup>
2020
<ProjectReference Include="..\..\src\SIGame\SIGame\SIGame.csproj">
@@ -27,5 +27,6 @@
2727
</ProjectReference>
2828
</ItemGroup>
2929
<Import Project="Sdk.targets" Sdk="WixToolset.Sdk" Version="5.0.1" />
30-
<Target Name="AfterBuild"></Target>
30+
<Target Name="AfterBuild">
31+
</Target>
3132
</Project>

src/Common/SI.GameServer.Client/SI.GameServer.Client.csproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
</PropertyGroup>
99

1010
<ItemGroup>
11-
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="6.0.3" />
12-
<PackageReference Include="Microsoft.AspNetCore.SignalR.Protocols.MessagePack" Version="6.0.3" />
11+
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="6.0.36" />
12+
<PackageReference Include="Microsoft.AspNetCore.SignalR.Protocols.MessagePack" Version="6.0.36" />
1313
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="6.0.0" />
1414
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="6.0.7" />
1515
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="6.0.0" />

src/Common/SIPackages/Core/AtomTypes.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
/// Defines well-known atom types.
55
/// </summary>
66
[Obsolete("Use ContentTypes class")]
7-
public static class AtomTypes
7+
internal static class AtomTypes
88
{
99
/// <summary>
1010
/// Plain text.

src/Common/SIUI.ViewModel/SIUI.ViewModel.csproj

-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
</ItemGroup>
1818
<ItemGroup>
1919
<PackageReference Include="System.Runtime.Serialization.Primitives" Version="4.3.0" />
20-
<PackageReference Include="System.Xml.XmlSerializer" Version="4.3.0" />
2120
</ItemGroup>
2221
<ItemGroup>
2322
<ProjectReference Include="..\SIUI.Model\SIUI.Model.csproj" />

src/SICore/SICore/Clients/Game/GameLogic.cs

+42-2
Original file line numberDiff line numberDiff line change
@@ -4725,8 +4725,48 @@ internal void OnRightAnswerOption(string rightOptionLabel)
47254725
if (HaveMultipleAnswerers() && _data.AnnouncedAnswerersEnumerator != null)
47264726
{
47274727
_data.AnnouncedAnswerersEnumerator.Reset();
4728-
ScheduleExecution(Tasks.AnnouncePostStake, (answerTime == 0 ? 2 : answerTime) * 10);
4729-
return;
4728+
4729+
if (_data.QuestionPlayState.HiddenStakes)
4730+
{
4731+
ScheduleExecution(Tasks.AnnouncePostStake, (answerTime == 0 ? 2 : answerTime) * 10);
4732+
return;
4733+
}
4734+
else
4735+
{
4736+
while (_data.AnnouncedAnswerersEnumerator.MoveNext())
4737+
{
4738+
var answererIndex = _data.AnnouncedAnswerersEnumerator.Current;
4739+
4740+
if (answererIndex < 0 || answererIndex >= _data.Players.Count)
4741+
{
4742+
continue;
4743+
}
4744+
4745+
var answerer = _data.Players[answererIndex];
4746+
var isRight = answerer.Answer == _data.RightOptionLabel;
4747+
4748+
var message = new MessageBuilder(Messages.Person);
4749+
int outcome;
4750+
4751+
if (isRight)
4752+
{
4753+
message.Add('+');
4754+
answerer.AddRightSum(_data.CurPriceRight);
4755+
outcome = _data.CurPriceRight;
4756+
}
4757+
else
4758+
{
4759+
message.Add('-');
4760+
answerer.SubtractWrongSum(_data.CurPriceWrong);
4761+
outcome = _data.CurPriceWrong;
4762+
}
4763+
4764+
message.Add(answererIndex).Add(outcome);
4765+
_gameActions.SendMessage(message.ToString());
4766+
}
4767+
4768+
_gameActions.InformSums();
4769+
}
47304770
}
47314771

47324772
ScheduleExecution(Tasks.MoveNext, (answerTime == 0 ? 2 : answerTime) * 10);

src/SICore/SICore/Clients/PersonData.cs

-17
Original file line numberDiff line numberDiff line change
@@ -98,25 +98,8 @@ public bool ShowExtraRightButtons
9898
}
9999
}
100100

101-
102-
private ICommand? _isRight = null;
103-
104-
public ICommand? IsRight
105-
{
106-
get => _isRight;
107-
set { _isRight = value; OnPropertyChanged(); }
108-
}
109-
110-
private ICommand _isWrong = null;
111-
112101
public event PropertyChangedEventHandler? PropertyChanged;
113102

114-
public ICommand IsWrong
115-
{
116-
get => _isWrong;
117-
set { _isWrong = value; OnPropertyChanged(); }
118-
}
119-
120103
private void OnPropertyChanged([CallerMemberName] string? propertyName = null) =>
121104
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
122105
}

src/SICore/SICore/Clients/Player/Player.cs

+2-52
Original file line numberDiff line numberDiff line change
@@ -42,37 +42,6 @@ public Player(Client client, Account personData, bool isHost, IViewerLogic logic
4242
Clear();
4343
});
4444

45-
ClientData.PlayerDataExtensions.Apellate = new CustomCommand(arg =>
46-
{
47-
ClientData.PlayerDataExtensions.ApellationCount--;
48-
_viewerActions.SendMessage(Messages.Apellate, arg.ToString());
49-
}) { CanBeExecuted = false };
50-
51-
ClientData.PlayerDataExtensions.Pass = new CustomCommand(arg =>
52-
{
53-
_viewerActions.SendMessage(Messages.Pass);
54-
})
55-
{ CanBeExecuted = false };
56-
57-
ClientData.PersonDataExtensions.IsRight = new CustomCommand(arg => { _viewerActions.SendMessage(Messages.IsRight, "+"); Clear(); });
58-
ClientData.PersonDataExtensions.IsWrong = new CustomCommand(arg => { _viewerActions.SendMessage(Messages.IsRight, "-"); Clear(); });
59-
60-
ClientData.PlayerDataExtensions.Report.Title = LO[nameof(R.ReportTitle)];
61-
ClientData.PlayerDataExtensions.Report.Subtitle = LO[nameof(R.ReportTip)];
62-
63-
ClientData.PlayerDataExtensions.Report.SendReport = new CustomCommand(arg =>
64-
{
65-
if (ClientData.SystemLog.Length > 0)
66-
{
67-
_viewerActions.SendMessage(Messages.Report, MessageParams.Report_Log, ClientData.SystemLog.ToString());
68-
}
69-
70-
_viewerActions.SendMessage(Messages.Report, "ACCEPT", ClientData.PlayerDataExtensions.Report.Comment);
71-
Clear();
72-
});
73-
74-
ClientData.PlayerDataExtensions.Report.SendNoReport = new CustomCommand(arg => { _viewerActions.SendMessage(Messages.Report, "DECLINE"); Clear(); });
75-
7645
ClientData.AutoReadyChanged += ClientData_AutoReadyChanged;
7746
}
7847

@@ -163,8 +132,6 @@ protected override async ValueTask OnSystemMessageReceivedAsync(string[] mparams
163132
ClientData.PlayerDataExtensions.IsQuestionInProgress = true;
164133
}
165134

166-
ClientData.PlayerDataExtensions.Apellate.CanBeExecuted = false;
167-
168135
#endregion
169136
break;
170137

@@ -189,7 +156,6 @@ protected override async ValueTask OnSystemMessageReceivedAsync(string[] mparams
189156

190157
case Messages.Choice:
191158
ClientData.PlayerDataExtensions.IsQuestionInProgress = true;
192-
ClientData.PlayerDataExtensions.Apellate.CanBeExecuted = false;
193159
_logic.OnQuestionSelected();
194160
break;
195161

@@ -209,34 +175,25 @@ protected override async ValueTask OnSystemMessageReceivedAsync(string[] mparams
209175
if (ClientData.QuestionType == QuestionTypes.Simple)
210176
{
211177
_logic.OnEnableButton();
212-
213-
if (!ClientData.FalseStart)
214-
ClientData.PlayerDataExtensions.MyTry = true;
215178
}
216179
break;
217180

218181
case Messages.Try:
219-
ClientData.PlayerDataExtensions.Pass.CanBeExecuted = true;
220-
ClientData.PlayerDataExtensions.Apellate.CanBeExecuted = false;
221182
ClientData.PlayerDataExtensions.TryStartTime = DateTimeOffset.UtcNow;
183+
_logic.OnCanPressButton();
222184
break;
223185

224186
case Messages.YouTry:
225-
ClientData.PlayerDataExtensions.MyTry = true;
226187
_logic.OnEnableButton();
227188
_logic.StartThink();
228189
break;
229190

230191
case Messages.EndTry:
231-
ClientData.PlayerDataExtensions.MyTry = false;
232192
_logic.OnDisableButton();
233193

234194
if (mparams[1] == MessageParams.EndTry_All)
235195
{
236196
_logic.EndThink();
237-
238-
ClientData.PlayerDataExtensions.Apellate.CanBeExecuted = ClientData.PlayerDataExtensions.ApellationCount > 0;
239-
ClientData.PlayerDataExtensions.Pass.CanBeExecuted = false;
240197
}
241198
break;
242199

@@ -361,22 +318,15 @@ protected override async ValueTask OnSystemMessageReceivedAsync(string[] mparams
361318
break;
362319

363320
case Messages.Report:
364-
if (!ClientData.Host.SendReport)
365-
{
366-
ClientData.PlayerDataExtensions.Report.SendNoReport.Execute(null);
367-
break;
368-
}
369-
370321
var report = new StringBuilder();
371322

372323
for (var r = 1; r < mparams.Length; r++)
373324
{
374325
report.AppendLine(mparams[r]);
375326
}
376327

377-
ClientData.PlayerDataExtensions.Report.Report = report.ToString();
378328
((PlayerAccount)ClientData.Me).IsDeciding = false;
379-
_logic.Report();
329+
_logic.Report(report.ToString());
380330
break;
381331
}
382332
}

src/SICore/SICore/Clients/Player/PlayerComputerLogic.cs

+6-4
Original file line numberDiff line numberDiff line change
@@ -1930,11 +1930,13 @@ public void IsRight(bool voteForRight) =>
19301930

19311931
public void Report()
19321932
{
1933-
var cmd = _data.SystemLog.Length > 0 ? _data.PlayerDataExtensions.Report.SendReport : _data.PlayerDataExtensions.Report.SendNoReport;
1934-
1935-
if (cmd != null && cmd.CanExecute(null))
1933+
if (_data.SystemLog.Length > 0)
1934+
{
1935+
_viewerActions.SendMessage(Messages.Report, MessageParams.Report_Log, _data.SystemLog.ToString());
1936+
}
1937+
else
19361938
{
1937-
cmd.Execute(null);
1939+
_viewerActions.SendMessage(Messages.Report, "DECLINE");
19381940
}
19391941
}
19401942

src/SICore/SICore/Clients/Player/PlayerData.cs

-54
Original file line numberDiff line numberDiff line change
@@ -8,36 +8,6 @@ namespace SICore;
88
/// </summary>
99
public sealed class PlayerData : INotifyPropertyChanged
1010
{
11-
private CustomCommand _apellate;
12-
13-
public CustomCommand Apellate
14-
{
15-
get => _apellate;
16-
set
17-
{
18-
if (_apellate != value)
19-
{
20-
_apellate = value;
21-
OnPropertyChanged();
22-
}
23-
}
24-
}
25-
26-
private CustomCommand _pass;
27-
28-
public CustomCommand Pass
29-
{
30-
get => _pass;
31-
set
32-
{
33-
if (_pass != value)
34-
{
35-
_pass = value;
36-
OnPropertyChanged();
37-
}
38-
}
39-
}
40-
4111
/// <summary>
4212
/// Знает ли ответ
4313
/// </summary>
@@ -75,30 +45,6 @@ public CustomCommand Pass
7545
/// </summary>
7646
internal bool IsQuestionInProgress { get; set; }
7747

78-
/// <summary>
79-
/// Отчёт об игре
80-
/// </summary>
81-
public SIReport Report { get; set; } = new SIReport();
82-
83-
private int _apellationCount = int.MaxValue;
84-
85-
public int ApellationCount
86-
{
87-
get => _apellationCount;
88-
set { _apellationCount = value; OnPropertyChanged(); }
89-
}
90-
91-
private bool _myTry;
92-
93-
/// <summary>
94-
/// Можно жать на кнопку (чтобы при игре без фальстартов компьютерные игроки соображали помедленнее)
95-
/// </summary>
96-
public bool MyTry
97-
{
98-
get => _myTry;
99-
set { _myTry = value; OnPropertyChanged(); }
100-
}
101-
10248
/// <summary>
10349
/// Defines time stamp when game buttons have been activated.
10450
/// </summary>

src/SICore/SICore/Clients/Showman/Showman.cs

+1-13
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,6 @@ public sealed class Showman : Viewer
1717
public Showman(Client client, Account personData, bool isHost, IViewerLogic logic, ViewerActions viewerActions, ILocalizer localizer, ViewerData data)
1818
: base(client, personData, isHost, logic, viewerActions, localizer, data)
1919
{
20-
ClientData.PersonDataExtensions.IsRight = new CustomCommand(arg =>
21-
{
22-
_viewerActions.SendMessage(Messages.IsRight, "+", arg?.ToString() ?? "1");
23-
ClearSelections();
24-
});
25-
26-
ClientData.PersonDataExtensions.IsWrong = new CustomCommand(arg =>
27-
{
28-
_viewerActions.SendMessage(Messages.IsRight, "-", arg?.ToString() ?? "1");
29-
ClearSelections();
30-
});
31-
3220
ClientData.AutoReadyChanged += ClientData_AutoReadyChanged;
3321

3422
ClientData.PersonDataExtensions.AreAnswersShown = data.Host.AreAnswersShown;
@@ -49,7 +37,7 @@ private void ClientData_PropertyChanged(object? sender, System.ComponentModel.Pr
4937
}
5038
}
5139

52-
void ClientData_AutoReadyChanged()
40+
private void ClientData_AutoReadyChanged()
5341
{
5442
lock (_readyLock)
5543
{

src/SICore/SICore/Clients/Viewer/IViewerLogic.cs

+4-1
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,8 @@ void OnQuestionContent() { }
258258
/// <summary>
259259
/// Handles game report request.
260260
/// </summary>
261-
void Report();
261+
/// <param name="report">Report text.</param>
262+
void Report(string report);
262263

263264
void OnTheme(string[] mparams) { }
264265

@@ -276,4 +277,6 @@ void OnQuestionSelected() { }
276277
/// Handles game closing.
277278
/// </summary>
278279
void OnGameClosed() { }
280+
281+
void OnCanPressButton() { }
279282
}

0 commit comments

Comments
 (0)