Files
Shogi/Shogi.UI/Pages/Play/GamePiece.razor

58 lines
1.3 KiB
Plaintext

@using Shogi.Contracts.Types
<div class="game-piece" title="@HtmlTitle">
@switch (Piece)
{
case WhichPiece.Bishop:
<Bishop IsPromoted="@IsPromoted" />
break;
case WhichPiece.GoldGeneral:
<GoldGeneral />
break;
case WhichPiece.King:
<ChallengingKing />
break;
case WhichPiece.Knight:
<Knight IsPromoted="@IsPromoted" />
break;
case WhichPiece.Lance:
<Lance IsPromoted="@IsPromoted" />
break;
case WhichPiece.Pawn:
<Pawn IsPromoted="@IsPromoted" />
break;
case WhichPiece.Rook:
<Rook IsPromoted="@IsPromoted" />
break;
case WhichPiece.SilverGeneral:
<SilverGeneral IsPromoted="@IsPromoted" />
break;
default:
@*render nothing*@
break;
}
@if (Count > 0)
{
<span class="counter">@Count</span>
}
</div>
@code {
[Parameter] public WhichPiece? Piece { get; set; }
[Parameter] public bool IsPromoted { get; set; }
[Parameter] public int Count { get; set; }
private string HtmlTitle => Piece switch
{
WhichPiece.Bishop => "Bishop",
WhichPiece.GoldGeneral => "Gold General",
WhichPiece.King => "King",
WhichPiece.Knight => "Knight",
WhichPiece.Lance => "Lance",
WhichPiece.Pawn => "Pawn",
WhichPiece.Rook => "Rook",
WhichPiece.SilverGeneral => "Silver General",
_ => string.Empty
};
}