in the middle of relearning msal
This commit is contained in:
@@ -15,10 +15,10 @@
|
||||
var position = $"{file}{rank}";
|
||||
var piece = session?.BoardState.Board[position];
|
||||
<div class="tile"
|
||||
data-position="@(position)"
|
||||
data-selected="@(piece != null && selectedPosition == position)"
|
||||
style="grid-area: @(position)"
|
||||
@onclick="() => OnClickTile(piece, position)">
|
||||
data-position="@(position)"
|
||||
data-selected="@(piece != null && selectedPosition == position)"
|
||||
style="grid-area: @(position)"
|
||||
@onclick="() => OnClickTile(piece, position)">
|
||||
<GamePiece Piece="piece" Perspective="Perspective" />
|
||||
</div>
|
||||
}
|
||||
@@ -46,7 +46,7 @@
|
||||
<span>I</span>
|
||||
</div>
|
||||
<!-- Promote prompt -->
|
||||
<div class="promote-prompt">
|
||||
<div class="promote-prompt" data-visible="@PromotePrompt.IsVisible">
|
||||
<p>Do you wish to promote?</p>
|
||||
<div>
|
||||
<button type="button">Yes</button>
|
||||
@@ -114,6 +114,7 @@
|
||||
: this.session.BoardState.Player2Hand;
|
||||
}
|
||||
}
|
||||
bool IsMyTurn => session?.BoardState.WhoseTurn == Perspective;
|
||||
|
||||
string? selectedPosition;
|
||||
WhichPiece? selectedPiece;
|
||||
@@ -138,21 +139,24 @@
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
async void OnClickTile(Piece? piece, string position)
|
||||
{
|
||||
if (SessionName == null) return;
|
||||
if (SessionName == null || !IsMyTurn) return;
|
||||
|
||||
if (selectedPosition == null)
|
||||
if (selectedPosition == null || piece?.Owner == Perspective)
|
||||
{
|
||||
// Select a position.
|
||||
selectedPosition = position;
|
||||
return;
|
||||
}
|
||||
else if (selectedPosition == position)
|
||||
if (selectedPosition == position)
|
||||
{
|
||||
// Deselect the selected position.
|
||||
selectedPosition = null;
|
||||
return;
|
||||
}
|
||||
else if (piece != null)
|
||||
if (piece == null)
|
||||
{
|
||||
if (ShouldPromptForPromotion(position) || ShouldPromptForPromotion(selectedPosition))
|
||||
{
|
||||
@@ -164,7 +168,7 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
await ShogiApi.PostMove(SessionName, new MovePieceCommand
|
||||
await ShogiApi.Move(SessionName, new MovePieceCommand
|
||||
{
|
||||
From = selectedPosition,
|
||||
IsPromotion = false,
|
||||
@@ -173,6 +177,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OnClickHand(Piece piece)
|
||||
{
|
||||
selectedPiece = piece.WhichPiece;
|
||||
|
||||
Reference in New Issue
Block a user