Turn and Check markers.
This commit is contained in:
@@ -70,13 +70,13 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
<p class="text-center">Opponent Hand</p>
|
<p class="text-center">Opponent's Hand</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="place-self-center">
|
<div class="place-self-center">
|
||||||
<PlayerName Name="@opponentName" IsTurn="!IsMyTurn" />
|
<PlayerName Name="@opponentName" IsTurn="!IsMyTurn" InCheck="IsOpponentInCheck" />
|
||||||
<hr />
|
<hr />
|
||||||
<PlayerName Name="@userName" IsTurn="IsMyTurn" />
|
<PlayerName Name="@userName" IsTurn="IsMyTurn" InCheck="IsPlayerInCheck" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="player-area">
|
<div class="player-area">
|
||||||
@@ -88,7 +88,7 @@
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
<p class="text-center">Hand</p>
|
<p class="text-center">Your Hand</p>
|
||||||
<div class="hand">
|
<div class="hand">
|
||||||
@if (userHand.Any())
|
@if (userHand.Any())
|
||||||
{
|
{
|
||||||
@@ -124,7 +124,6 @@
|
|||||||
[Parameter] public EventCallback<string> OnClickTile { get; set; }
|
[Parameter] public EventCallback<string> OnClickTile { get; set; }
|
||||||
[Parameter] public EventCallback<Piece> OnClickHand { get; set; }
|
[Parameter] public EventCallback<Piece> OnClickHand { get; set; }
|
||||||
[Parameter] public EventCallback OnClickJoinGame { get; set; }
|
[Parameter] public EventCallback OnClickJoinGame { get; set; }
|
||||||
[Parameter] public bool IsMyTurn { get; set; }
|
|
||||||
[Parameter] public bool UseSideboard { get; set; } = true;
|
[Parameter] public bool UseSideboard { get; set; } = true;
|
||||||
|
|
||||||
private IReadOnlyCollection<Piece> opponentHand;
|
private IReadOnlyCollection<Piece> opponentHand;
|
||||||
@@ -167,9 +166,29 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Func<Task> OnClickTileInternal(string position) => () => OnClickTile.InvokeAsync(position);
|
private bool IsMyTurn => Session?.BoardState.WhoseTurn == Perspective;
|
||||||
|
|
||||||
private Func<Task> 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<Task> OnClickTileInternal(string position) => () =>
|
||||||
|
{
|
||||||
|
if (IsMyTurn)
|
||||||
|
{
|
||||||
|
return OnClickTile.InvokeAsync(position);
|
||||||
|
}
|
||||||
|
return Task.CompletedTask;
|
||||||
|
};
|
||||||
|
|
||||||
|
private Func<Task> OnClickHandInternal(Piece piece) => () =>
|
||||||
|
{
|
||||||
|
if (IsMyTurn)
|
||||||
|
{
|
||||||
|
return OnClickHand.InvokeAsync(piece);
|
||||||
|
}
|
||||||
|
return Task.CompletedTask;
|
||||||
|
};
|
||||||
|
|
||||||
private Task OnClickJoinGameInternal() => OnClickJoinGame.InvokeAsync();
|
private Task OnClickJoinGameInternal() => OnClickJoinGame.InvokeAsync();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,14 @@
|
|||||||
<p style="margin: 0">
|
<p style="margin: 0">
|
||||||
@if (IsTurn)
|
@if (IsTurn)
|
||||||
{
|
{
|
||||||
<span>* </span>
|
<span class="turn-marker" title="Shows which player is next to move a piece.">Turn</span>
|
||||||
|
<span> </span>
|
||||||
|
}
|
||||||
|
|
||||||
|
@if (InCheck)
|
||||||
|
{
|
||||||
|
<span class="check-marker" title="King is in danger!">Check</span>
|
||||||
|
<span> </span>
|
||||||
}
|
}
|
||||||
|
|
||||||
@if (string.IsNullOrEmpty(Name))
|
@if (string.IsNullOrEmpty(Name))
|
||||||
@@ -17,5 +24,6 @@
|
|||||||
|
|
||||||
@code {
|
@code {
|
||||||
[Parameter][EditorRequired] public bool IsTurn { get; set; }
|
[Parameter][EditorRequired] public bool IsTurn { get; set; }
|
||||||
|
[Parameter][EditorRequired] public bool InCheck { get; set; }
|
||||||
[Parameter][EditorRequired] public string Name { get; set; } = string.Empty;
|
[Parameter][EditorRequired] public string Name { get; set; } = string.Empty;
|
||||||
}
|
}
|
||||||
|
|||||||
17
Shogi.UI/Pages/Play/GameBoard/PlayerName.razor.css
Normal file
17
Shogi.UI/Pages/Play/GameBoard/PlayerName.razor.css
Normal file
@@ -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%;
|
||||||
|
}
|
||||||
@@ -10,8 +10,7 @@
|
|||||||
OnClickHand="OnClickHand"
|
OnClickHand="OnClickHand"
|
||||||
OnClickTile="OnClickTile"
|
OnClickTile="OnClickTile"
|
||||||
SelectedPosition="@selectedBoardPosition"
|
SelectedPosition="@selectedBoardPosition"
|
||||||
SelectedPieceFromHand="@selectedPieceFromHand"
|
SelectedPieceFromHand="@selectedPieceFromHand" />
|
||||||
IsMyTurn="IsMyTurn" />
|
|
||||||
|
|
||||||
@if (showPromotePrompt)
|
@if (showPromotePrompt)
|
||||||
{
|
{
|
||||||
@@ -33,7 +32,6 @@
|
|||||||
public WhichPlayer Perspective { get; set; }
|
public WhichPlayer Perspective { get; set; }
|
||||||
[Parameter, EditorRequired]
|
[Parameter, EditorRequired]
|
||||||
public Session Session { get; set; } = default!;
|
public Session Session { get; set; } = default!;
|
||||||
private bool IsMyTurn => Session?.BoardState.WhoseTurn == Perspective;
|
|
||||||
private string? selectedBoardPosition;
|
private string? selectedBoardPosition;
|
||||||
private WhichPiece? selectedPieceFromHand;
|
private WhichPiece? selectedPieceFromHand;
|
||||||
private bool showPromotePrompt;
|
private bool showPromotePrompt;
|
||||||
@@ -65,7 +63,7 @@
|
|||||||
|
|
||||||
async Task OnClickTile(string position)
|
async Task OnClickTile(string position)
|
||||||
{
|
{
|
||||||
if (!IsMyTurn || showPromotePrompt) return;
|
if (showPromotePrompt) return;
|
||||||
|
|
||||||
var pieceAtPosition = Session.BoardState.Board[position];
|
var pieceAtPosition = Session.BoardState.Board[position];
|
||||||
if (selectedBoardPosition == position)
|
if (selectedBoardPosition == position)
|
||||||
@@ -133,7 +131,7 @@
|
|||||||
|
|
||||||
void OnClickHand(Piece piece)
|
void OnClickHand(Piece piece)
|
||||||
{
|
{
|
||||||
if (!IsMyTurn || showPromotePrompt) return;
|
if (showPromotePrompt) return;
|
||||||
|
|
||||||
// Prevent selecting from both the hand and the board.
|
// Prevent selecting from both the hand and the board.
|
||||||
selectedBoardPosition = null;
|
selectedBoardPosition = null;
|
||||||
|
|||||||
@@ -15,12 +15,14 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Remove="Pages\Home\VisualAids\PromotedPieceVisualAid.razor.css" />
|
<None Remove="Pages\Home\VisualAids\PromotedPieceVisualAid.razor.css" />
|
||||||
|
<None Remove="Pages\Play\GameBoard\PlayerName.razor.css" />
|
||||||
<None Remove="Pages\Play\GameBrowserEntry.razor.css" />
|
<None Remove="Pages\Play\GameBrowserEntry.razor.css" />
|
||||||
<None Remove="Pages\SearchPage.razor.css" />
|
<None Remove="Pages\SearchPage.razor.css" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Content Include="Pages\Home\VisualAids\PromotedPieceVisualAid.razor.css" />
|
<Content Include="Pages\Home\VisualAids\PromotedPieceVisualAid.razor.css" />
|
||||||
|
<Content Include="Pages\Play\GameBoard\PlayerName.razor.css" />
|
||||||
<Content Include="Pages\Play\GameBrowserEntry.razor.css" />
|
<Content Include="Pages\Play\GameBrowserEntry.razor.css" />
|
||||||
<Content Include="Pages\SearchPage.razor.css" />
|
<Content Include="Pages\SearchPage.razor.css" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|||||||
Reference in New Issue
Block a user