yep
This commit is contained in:
@@ -68,10 +68,10 @@
|
||||
<aside class="side-board">
|
||||
<div class="player-area">
|
||||
<div class="hand">
|
||||
@if (OpponentHand.Any())
|
||||
@if (opponentHand.Any())
|
||||
{
|
||||
|
||||
@foreach (var piece in OpponentHand)
|
||||
@foreach (var piece in opponentHand)
|
||||
{
|
||||
<div class="tile">
|
||||
<GamePiece Piece="piece" Perspective="Perspective" />
|
||||
@@ -86,6 +86,8 @@
|
||||
</div>
|
||||
|
||||
<div class="spacer place-self-center">
|
||||
<p>@opponentName</p>
|
||||
<p>@userName</p>
|
||||
</div>
|
||||
|
||||
<div class="player-area">
|
||||
@@ -93,15 +95,15 @@
|
||||
{
|
||||
<div class="place-self-center">
|
||||
<p>Seat is Empty</p>
|
||||
<button @onclick="OnClickJoinGameInternal()">Join Game</button>
|
||||
<button @onclick="OnClickJoinGameInternal">Join Game</button>
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="hand">
|
||||
@if (UserHand.Any())
|
||||
@if (userHand.Any())
|
||||
{
|
||||
@foreach (var piece in UserHand)
|
||||
@foreach (var piece in userHand)
|
||||
{
|
||||
<div class="title" @onclick="OnClickHandInternal(piece)">
|
||||
<GamePiece Piece="piece" Perspective="Perspective" />
|
||||
@@ -121,6 +123,11 @@
|
||||
</article>
|
||||
|
||||
@code {
|
||||
static readonly string[] Files = new[] { "A", "B", "C", "D", "E", "F", "G", "H", "I" };
|
||||
|
||||
/// <summary>
|
||||
/// When true, an icon is displayed indicating that the user is spectating.
|
||||
/// </summary>
|
||||
[Parameter] public bool IsSpectating { get; set; } = false;
|
||||
[Parameter] public WhichPlayer Perspective { get; set; }
|
||||
[Parameter] public Session? Session { get; set; }
|
||||
@@ -130,32 +137,48 @@
|
||||
[Parameter] public Func<Piece, Task>? OnClickHand { get; set; }
|
||||
[Parameter] public Func<Task>? OnClickJoinGame { get; set; }
|
||||
|
||||
static readonly string[] Files = new[] { "A", "B", "C", "D", "E", "F", "G", "H", "I" };
|
||||
private IReadOnlyCollection<Piece> opponentHand;
|
||||
private IReadOnlyCollection<Piece> userHand;
|
||||
private string? userName;
|
||||
private string? opponentName;
|
||||
|
||||
private IReadOnlyCollection<Piece> OpponentHand
|
||||
public GameBoardPresentation()
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.Session == null) return Array.Empty<Piece>();
|
||||
|
||||
return Perspective == WhichPlayer.Player1
|
||||
? this.Session.BoardState.Player1Hand
|
||||
: this.Session.BoardState.Player2Hand;
|
||||
}
|
||||
opponentHand = Array.Empty<Piece>();
|
||||
userHand = Array.Empty<Piece>();
|
||||
userName = string.Empty;
|
||||
opponentName = string.Empty;
|
||||
}
|
||||
IReadOnlyCollection<Piece> UserHand
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.Session == null) return Array.Empty<Piece>();
|
||||
|
||||
return Perspective == WhichPlayer.Player1
|
||||
protected override void OnParametersSet()
|
||||
{
|
||||
Console.WriteLine("Params changed. SelectedPosition = {0}", SelectedPosition);
|
||||
base.OnParametersSet();
|
||||
if (Session == null)
|
||||
{
|
||||
opponentHand = Array.Empty<Piece>();
|
||||
userHand = Array.Empty<Piece>();
|
||||
userName = string.Empty;
|
||||
opponentName = string.Empty;
|
||||
}
|
||||
else
|
||||
{
|
||||
opponentHand = Perspective == WhichPlayer.Player1
|
||||
? this.Session.BoardState.Player2Hand
|
||||
: this.Session.BoardState.Player1Hand;
|
||||
userHand = Perspective == WhichPlayer.Player1
|
||||
? this.Session.BoardState.Player1Hand
|
||||
: this.Session.BoardState.Player2Hand;
|
||||
userName = Perspective == WhichPlayer.Player1
|
||||
? this.Session.Player1
|
||||
: this.Session.Player2;
|
||||
opponentName = Perspective == WhichPlayer.Player1
|
||||
? this.Session.Player2
|
||||
: this.Session.Player1;
|
||||
}
|
||||
}
|
||||
|
||||
private Action OnClickTileInternal(Piece? piece, string position) => () => OnClickTile?.Invoke(piece, position);
|
||||
private Action OnClickHandInternal(Piece piece) => () => OnClickHand?.Invoke(piece);
|
||||
private Action OnClickJoinGameInternal() => () => OnClickJoinGame?.Invoke();
|
||||
private void OnClickJoinGameInternal() => OnClickJoinGame?.Invoke();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user