mirror of
https://github.com/dotnet/intro-to-dotnet-web-dev.git
synced 2025-12-06 05:32:03 +01:00
Fixed 'completed' version
This commit is contained in:
parent
9942167da4
commit
6c2e51b69c
|
|
@ -101,16 +101,12 @@
|
||||||
GameState.WinState.Tie => "It's a tie!",
|
GameState.WinState.Tie => "It's a tie!",
|
||||||
_ => ""
|
_ => ""
|
||||||
};
|
};
|
||||||
if (WinnerMessage != string.Empty) {
|
|
||||||
ResetStyle = string.Empty;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ResetGame()
|
void ResetGame()
|
||||||
{
|
{
|
||||||
State.ResetBoard();
|
State.ResetBoard();
|
||||||
ResetStyle = "display: none;";
|
|
||||||
WinnerMessage = string.Empty;
|
WinnerMessage = string.Empty;
|
||||||
ErrorMessage = string.Empty;
|
ErrorMessage = string.Empty;
|
||||||
Pieces = new string[42];
|
Pieces = new string[42];
|
||||||
|
|
|
||||||
|
|
@ -214,7 +214,9 @@ Blazor components contain all of the HTML and markup needed to be rendered in a
|
||||||
|
|
||||||
The game logic for Connect Four is not too difficult to program. We need some code that will manage the state of the game and identify 4 consecutive game pieces played next to each other and announce the winner. To help keep this tutorial on-topic with teaching about Blazor, we are providing a class called `GameState.cs` that contains the logic for managing the game.
|
The game logic for Connect Four is not too difficult to program. We need some code that will manage the state of the game and identify 4 consecutive game pieces played next to each other and announce the winner. To help keep this tutorial on-topic with teaching about Blazor, we are providing a class called `GameState.cs` that contains the logic for managing the game.
|
||||||
|
|
||||||
1. Copy the [GameState.cs file](1-complete/ConnectFour/Shared/GameState.cs) into your project in the `Shared` folder.
|
The [GameState.cs file is in this repository](1-complete/ConnectFour/Shared/GameState.cs) and you will copy it into your version of the game.
|
||||||
|
|
||||||
|
1. Copy the [GameState.cs file](1-complete/ConnectFour/Shared/GameState.cs) from this repository into your project in the `Shared` folder.
|
||||||
|
|
||||||
1. We need to make an instance of the `GameState` available to any component that requests it, and only 1 instance of `GameState` should be available in our application at a time. We will address this need by registering our GameState as a Singleton in the application. Open the `Program.cs` file at the root of the project and let's add this statement after the `builder.AddServices...` statement:
|
1. We need to make an instance of the `GameState` available to any component that requests it, and only 1 instance of `GameState` should be available in our application at a time. We will address this need by registering our GameState as a Singleton in the application. Open the `Program.cs` file at the root of the project and let's add this statement after the `builder.AddServices...` statement:
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue