diff --git a/Shogi.UI/Pages/Play/GameBoard/GameBoardPresentation.razor b/Shogi.UI/Pages/Play/GameBoard/GameBoardPresentation.razor index d86fbaa..d069266 100644 --- a/Shogi.UI/Pages/Play/GameBoard/GameBoardPresentation.razor +++ b/Shogi.UI/Pages/Play/GameBoard/GameBoardPresentation.razor @@ -70,13 +70,13 @@ } } -

Opponent Hand

+

Opponent's Hand

- +
- +
@@ -88,7 +88,7 @@ } else { -

Hand

+

Your Hand

@if (userHand.Any()) { @@ -124,7 +124,6 @@ [Parameter] public EventCallback OnClickTile { get; set; } [Parameter] public EventCallback OnClickHand { get; set; } [Parameter] public EventCallback OnClickJoinGame { get; set; } - [Parameter] public bool IsMyTurn { get; set; } [Parameter] public bool UseSideboard { get; set; } = true; private IReadOnlyCollection opponentHand; @@ -167,9 +166,29 @@ } } - private Func OnClickTileInternal(string position) => () => OnClickTile.InvokeAsync(position); + private bool IsMyTurn => Session?.BoardState.WhoseTurn == Perspective; - private Func OnClickHandInternal(Piece piece) => () => OnClickHand.InvokeAsync(piece); + private bool IsPlayerInCheck => Session?.BoardState.PlayerInCheck == Perspective; + + private bool IsOpponentInCheck => Session?.BoardState.PlayerInCheck != null && Session.BoardState.PlayerInCheck != Perspective; + + private Func OnClickTileInternal(string position) => () => + { + if (IsMyTurn) + { + return OnClickTile.InvokeAsync(position); + } + return Task.CompletedTask; + }; + + private Func OnClickHandInternal(Piece piece) => () => + { + if (IsMyTurn) + { + return OnClickHand.InvokeAsync(piece); + } + return Task.CompletedTask; + }; private Task OnClickJoinGameInternal() => OnClickJoinGame.InvokeAsync(); } diff --git a/Shogi.UI/Pages/Play/GameBoard/PlayerName.razor b/Shogi.UI/Pages/Play/GameBoard/PlayerName.razor index f4c7eb5..d0a9c2c 100644 --- a/Shogi.UI/Pages/Play/GameBoard/PlayerName.razor +++ b/Shogi.UI/Pages/Play/GameBoard/PlayerName.razor @@ -1,7 +1,14 @@ 

@if (IsTurn) { - + Turn +   + } + + @if (InCheck) + { + Check +   } @if (string.IsNullOrEmpty(Name)) @@ -17,5 +24,6 @@ @code { [Parameter][EditorRequired] public bool IsTurn { get; set; } + [Parameter][EditorRequired] public bool InCheck { get; set; } [Parameter][EditorRequired] public string Name { get; set; } = string.Empty; } diff --git a/Shogi.UI/Pages/Play/GameBoard/PlayerName.razor.css b/Shogi.UI/Pages/Play/GameBoard/PlayerName.razor.css new file mode 100644 index 0000000..9be37f4 --- /dev/null +++ b/Shogi.UI/Pages/Play/GameBoard/PlayerName.razor.css @@ -0,0 +1,17 @@ +.turn-marker { + display: inline-block; + padding: 3px 8px; + background-color: #444; + color: beige; + font-weight: bold; + font-size: 80%; +} + +.check-marker { + display: inline-block; + padding: 3px 8px; + background-color: darkred; + color: beige; + font-weight: bold; + font-size: 80%; +} diff --git a/Shogi.UI/Pages/Play/GameBoard/SeatedGameBoard.razor b/Shogi.UI/Pages/Play/GameBoard/SeatedGameBoard.razor index 1a2c285..97fd6dc 100644 --- a/Shogi.UI/Pages/Play/GameBoard/SeatedGameBoard.razor +++ b/Shogi.UI/Pages/Play/GameBoard/SeatedGameBoard.razor @@ -10,8 +10,7 @@ OnClickHand="OnClickHand" OnClickTile="OnClickTile" SelectedPosition="@selectedBoardPosition" - SelectedPieceFromHand="@selectedPieceFromHand" - IsMyTurn="IsMyTurn" /> + SelectedPieceFromHand="@selectedPieceFromHand" /> @if (showPromotePrompt) { @@ -33,7 +32,6 @@ public WhichPlayer Perspective { get; set; } [Parameter, EditorRequired] public Session Session { get; set; } = default!; - private bool IsMyTurn => Session?.BoardState.WhoseTurn == Perspective; private string? selectedBoardPosition; private WhichPiece? selectedPieceFromHand; private bool showPromotePrompt; @@ -65,7 +63,7 @@ async Task OnClickTile(string position) { - if (!IsMyTurn || showPromotePrompt) return; + if (showPromotePrompt) return; var pieceAtPosition = Session.BoardState.Board[position]; if (selectedBoardPosition == position) @@ -133,7 +131,7 @@ void OnClickHand(Piece piece) { - if (!IsMyTurn || showPromotePrompt) return; + if (showPromotePrompt) return; // Prevent selecting from both the hand and the board. selectedBoardPosition = null; diff --git a/Shogi.UI/Shogi.UI.csproj b/Shogi.UI/Shogi.UI.csproj index a44d5de..86c2856 100644 --- a/Shogi.UI/Shogi.UI.csproj +++ b/Shogi.UI/Shogi.UI.csproj @@ -15,12 +15,14 @@ + +