Move from the hand.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
@using Shogi.Contracts.Types;
|
||||
@using System.Text.Json;
|
||||
@inject PromotePrompt PromotePrompt;
|
||||
@inject AccountState AccountState;
|
||||
|
||||
@@ -70,7 +71,6 @@
|
||||
<div class="hand">
|
||||
@if (opponentHand.Any())
|
||||
{
|
||||
|
||||
@foreach (var piece in opponentHand)
|
||||
{
|
||||
<div class="tile">
|
||||
@@ -78,20 +78,29 @@
|
||||
</div>
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
<i class="place-self-center">Hand is empty.</i>
|
||||
}
|
||||
</div>
|
||||
<p class="text-center">Opponent Hand</p>
|
||||
</div>
|
||||
|
||||
<div class="spacer place-self-center">
|
||||
<div class="spacer place-self-center text-center">
|
||||
<p>@opponentName</p>
|
||||
<p title="It is @(IsMyTurn ? "your" : "their") turn.">
|
||||
<svg width="32" height="32" fill="currentColor">
|
||||
@if (IsMyTurn)
|
||||
{
|
||||
<use xlink:href="css/bootstrap/bootstrap-icons.svg#chevron-down" />
|
||||
}
|
||||
else
|
||||
{
|
||||
<use xlink:href="css/bootstrap/bootstrap-icons.svg#chevron-up" />
|
||||
}
|
||||
</svg>
|
||||
</p>
|
||||
<p>@userName</p>
|
||||
</div>
|
||||
|
||||
<div class="player-area">
|
||||
@if (Session.Player2 == null && Session.Player1 != AccountState.User?.Id)
|
||||
@if (Session.Player2 == null && Session.Player1.Id != AccountState.User?.Id)
|
||||
{
|
||||
<div class="place-self-center">
|
||||
<p>Seat is Empty</p>
|
||||
@@ -100,20 +109,19 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
<p class="text-center">Hand</p>
|
||||
<div class="hand">
|
||||
@if (userHand.Any())
|
||||
{
|
||||
@foreach (var piece in userHand)
|
||||
{
|
||||
<div class="title" @onclick="OnClickHandInternal(piece)">
|
||||
<div @onclick="OnClickHandInternal(piece)"
|
||||
class="tile"
|
||||
data-selected="@(piece.WhichPiece == SelectedPieceFromHand)">
|
||||
<GamePiece Piece="piece" Perspective="Perspective" />
|
||||
</div>
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
<i class="place-self-center">Hand is empty.</i>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
@@ -132,10 +140,12 @@
|
||||
[Parameter] public WhichPlayer Perspective { get; set; }
|
||||
[Parameter] public Session? Session { get; set; }
|
||||
[Parameter] public string? SelectedPosition { get; set; }
|
||||
[Parameter] public WhichPiece? SelectedPieceFromHand { get; set; }
|
||||
// TODO: Exchange these OnClick actions for events like "SelectionChangedEvent" and "MoveFromBoardEvent" and "MoveFromHandEvent".
|
||||
[Parameter] public Func<Piece?, string, Task>? OnClickTile { get; set; }
|
||||
[Parameter] public Func<Piece, Task>? OnClickHand { get; set; }
|
||||
[Parameter] public Func<Task>? OnClickJoinGame { get; set; }
|
||||
[Parameter] public bool IsMyTurn { get; set; }
|
||||
|
||||
private IReadOnlyCollection<Piece> opponentHand;
|
||||
private IReadOnlyCollection<Piece> userHand;
|
||||
@@ -152,7 +162,6 @@
|
||||
|
||||
protected override void OnParametersSet()
|
||||
{
|
||||
Console.WriteLine("Params changed. SelectedPosition = {0}", SelectedPosition);
|
||||
base.OnParametersSet();
|
||||
if (Session == null)
|
||||
{
|
||||
@@ -163,6 +172,7 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine(JsonSerializer.Serialize(new { this.Session.Player1, this.Session.Player2, Perspective, this.Session.SessionName }));
|
||||
opponentHand = Perspective == WhichPlayer.Player1
|
||||
? this.Session.BoardState.Player2Hand
|
||||
: this.Session.BoardState.Player1Hand;
|
||||
@@ -170,11 +180,11 @@
|
||||
? this.Session.BoardState.Player1Hand
|
||||
: this.Session.BoardState.Player2Hand;
|
||||
userName = Perspective == WhichPlayer.Player1
|
||||
? this.Session.Player1
|
||||
: this.Session.Player2;
|
||||
? this.Session.Player1.Name
|
||||
: this.Session.Player2?.Name ?? "Empty Seat";
|
||||
opponentName = Perspective == WhichPlayer.Player1
|
||||
? this.Session.Player2
|
||||
: this.Session.Player1;
|
||||
? this.Session.Player2?.Name ?? "Empty Seat"
|
||||
: this.Session.Player1.Name;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user