Fix human player able to make illegal move during bot's turn
This commit is contained in:
parent
3711d23f1e
commit
85219733d3
1 changed files with 7 additions and 1 deletions
|
@ -14,6 +14,7 @@ namespace ChessChallenge.Application
|
||||||
// State
|
// State
|
||||||
bool isDragging;
|
bool isDragging;
|
||||||
int selectedSquare;
|
int selectedSquare;
|
||||||
|
bool isTurnToMove;
|
||||||
|
|
||||||
|
|
||||||
public HumanPlayer(BoardUI boardUI)
|
public HumanPlayer(BoardUI boardUI)
|
||||||
|
@ -25,7 +26,7 @@ namespace ChessChallenge.Application
|
||||||
|
|
||||||
public void NotifyTurnToMove()
|
public void NotifyTurnToMove()
|
||||||
{
|
{
|
||||||
|
isTurnToMove = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetPosition(string fen)
|
public void SetPosition(string fen)
|
||||||
|
@ -35,6 +36,10 @@ namespace ChessChallenge.Application
|
||||||
|
|
||||||
public void Update()
|
public void Update()
|
||||||
{
|
{
|
||||||
|
if (!isTurnToMove)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
Vector2 mouseScreenPos = Raylib.GetMousePosition();
|
Vector2 mouseScreenPos = Raylib.GetMousePosition();
|
||||||
Vector2 mouseWorldPos = Program.ScreenToWorldPos(mouseScreenPos);
|
Vector2 mouseWorldPos = Program.ScreenToWorldPos(mouseScreenPos);
|
||||||
|
|
||||||
|
@ -98,6 +103,7 @@ namespace ChessChallenge.Application
|
||||||
|
|
||||||
if (isLegal)
|
if (isLegal)
|
||||||
{
|
{
|
||||||
|
isTurnToMove = false;
|
||||||
MoveChosen?.Invoke(move);
|
MoveChosen?.Invoke(move);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue