Skip to content

Commit

Permalink
TODO fix exceptions losing
Browse files Browse the repository at this point in the history
  • Loading branch information
ProMix0 committed May 18, 2022
1 parent 8d5ede4 commit edd93e6
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 9 deletions.
6 changes: 2 additions & 4 deletions CrossesZeroes/Classes/CrossesZeroesGame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public CrossesZeroesGame(IPlayer player1, IPlayer player2, ICrossesZeroesField f
private bool gameCompleted = false;

/// <inheritdoc/>
public async override Task<bool >Turn()
public async override Task<bool> Turn()
{
if (gameCompleted) return false;
field.Set(await cross.Turn(field.AsReadonly()), CellState.Cross);
Expand Down Expand Up @@ -69,9 +69,7 @@ public override void Restart()
gameCompleted = false;

//Смена знака игроков
IPlayer temp = cross;
cross = zero;
zero = temp;
(zero, cross) = (cross, zero);

cross.Init(CellState.Cross);
zero.Init(CellState.Zero);
Expand Down
4 changes: 2 additions & 2 deletions CrossesZeroes/Classes/CustomizableField.cs
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,8 @@ void GetDownDiagonal(int i, int j)

public virtual void Set(Point point, CellState markType)
{
if (markType == CellState.Empty) throw new ArgumentException("", nameof(markType));
if (field[point.x, point.y] != CellState.Empty) throw new ArgumentException("", nameof(point));
if (markType == CellState.Empty) throw new ArgumentException("Unknown type of mark", nameof(markType));
if (field[point.x, point.y] != CellState.Empty) throw new ArgumentException("Cell already filled", nameof(point));

field[point.x, point.y] = markType;
}
Expand Down
14 changes: 12 additions & 2 deletions HostApp/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
using Microsoft.Extensions.Options;
using WpfClient;

await Host.CreateDefaultBuilder()
Console.WriteLine("Building host");

IHost host = Host.CreateDefaultBuilder()
.ConfigureAppConfiguration(config =>
config.AddJsonFile("Settings.json"))

Expand Down Expand Up @@ -43,4 +45,12 @@ await Host.CreateDefaultBuilder()
.ConfigureLogging(logging =>
logging.ClearProviders())

.RunConsoleAsync();
.UseConsoleLifetime()

.Build();

Console.WriteLine("Running host");

await host.RunAsync();

Console.WriteLine("Host shut down");
2 changes: 1 addition & 1 deletion WpfClient/WpfPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public WpfPlayer()

while (client == null) Thread.Sleep(10);

Console.WriteLine("Client isn't null");
//Console.WriteLine("Client isn't null");
}

public void ReportEnd(bool victory, ICrossesZeroesField field)
Expand Down

0 comments on commit edd93e6

Please sign in to comment.