Skip to content

Commit

Permalink
Update UI
Browse files Browse the repository at this point in the history
  • Loading branch information
ThatOneShortGuy committed Dec 12, 2023
1 parent d48b1a6 commit 794e28d
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 14 deletions.
Binary file modified TestChessGame/.plastic/plastic.changes
Binary file not shown.
Binary file modified TestChessGame/.plastic/plastic.wktree
Binary file not shown.
10 changes: 5 additions & 5 deletions TestChessGame/Assets/Scripts/Chessman.cs
Original file line number Diff line number Diff line change
Expand Up @@ -226,13 +226,13 @@ public void canCastle()
{

Game sc = controller.GetComponent<Game>();
GameObject cp = sc.GetPosition(xBoard, yBoard);//Clicked Piece
GameObject cp = sc.GetPosition(xBoard, yBoard); //Clicked Piece

switch (player)
{
case ("white"):
if (cp.GetComponent<Chessman>().hasMoved == false && (sc.GetPosition(0, 0).GetComponent<Chessman>().hasMoved == false ||
sc.GetPosition(7, 0).GetComponent<Chessman>().hasMoved == false))
if (cp.GetComponent<Chessman>().hasMoved == false && ((sc.GetPosition(0, 0) != null && sc.GetPosition(0, 0).GetComponent<Chessman>().hasMoved == false) ||
(sc.GetPosition(7, 0) != null && sc.GetPosition(7, 0).GetComponent<Chessman>().hasMoved == false)))
{
if (sc.GetPosition(xBoard - 3, yBoard) == null && sc.GetPosition(xBoard - 2, yBoard) == null && sc.GetPosition(xBoard - 1, yBoard) == null && sc.GetPosition(0, 0).GetComponent<Chessman>().hasMoved == false)
MovePlateSpawn(xBoard - 3, yBoard);
Expand All @@ -241,8 +241,8 @@ public void canCastle()
}
return;
case ("black"):
if (cp.GetComponent<Chessman>().hasMoved == false && (sc.GetPosition(0, 7).GetComponent<Chessman>().hasMoved == false ||
sc.GetPosition(7, 7).GetComponent<Chessman>().hasMoved == false))
if (cp.GetComponent<Chessman>().hasMoved == false && ((sc.GetPosition(0, 7) != null && sc.GetPosition(0, 7).GetComponent<Chessman>().hasMoved == false) ||
(sc.GetPosition(7, 7) != null && sc.GetPosition(7, 7).GetComponent<Chessman>().hasMoved == false)))
{
if (sc.GetPosition(xBoard - 3, yBoard) == null && sc.GetPosition(xBoard - 2, yBoard) == null && sc.GetPosition(xBoard - 1, yBoard) == null && sc.GetPosition(0, 7).GetComponent<Chessman>().hasMoved == false)
MovePlateSpawn(xBoard - 3, yBoard);
Expand Down
2 changes: 1 addition & 1 deletion TestChessGame/Assets/Scripts/FreezePlate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public void OnMouseUp()

Game game = controller.GetComponent<Game>();

string FrozenPos = BoardPosLetter[matrixX] + (matrixY).ToString();
string FrozenPos = BoardPosLetter[matrixX + 1] + (matrixY).ToString();
game.frozenPiece = FrozenPos;

Game sc = controller.GetComponent<Game>();
Expand Down
9 changes: 6 additions & 3 deletions TestChessGame/Assets/Scripts/Game.cs
Original file line number Diff line number Diff line change
Expand Up @@ -284,9 +284,9 @@ public void GenerateFen()
for (int j = 0; j < 8; j++)
{

if(EmptyPos == 8)
if (EmptyPos == 8)
{
Fen += EmptyPos.ToString();
Fen += EmptyPos.ToString() + "/";
EmptyPos = 0;
}
if (GetPosition(j, i) != null)
Expand All @@ -297,6 +297,8 @@ public void GenerateFen()
EmptyPos = 0;
}
Fen = Fen + FenCodes[GetPosition(j, i).name.ToString()];
if (j == 7 && i != 0)
Fen += "/";

}
else
Expand All @@ -307,7 +309,8 @@ public void GenerateFen()
if (EmptyPos != 0)
{
Fen += EmptyPos.ToString();
Fen += '/';
if (i != 0)
Fen += "/";
}
EmptyPos = 0;
}
Expand Down
2 changes: 1 addition & 1 deletion TestChessGame/Assets/Scripts/JumpPlate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public void OnMouseUp()
Game sc = controller.GetComponent<Game>();
Spells spellsScript = reference.GetComponent<Spells>();

string jumpPos = BoardPosLetter[matrixX] + (matrixY).ToString();
string jumpPos = BoardPosLetter[matrixX] + (matrixY + 1).ToString();
game.jumpPiece = jumpPos;

GameObject plate = sc.jumpPlates[matrixX, matrixY];
Expand Down
14 changes: 10 additions & 4 deletions TestChessGame/Assets/Scripts/MovePlate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -173,19 +173,25 @@ public void OnMouseUp()
}
if (MovingPiece.name == "black_rook")
{
if(matrixX == 7)
controller.GetComponent<Game>().k = false;
else
controller.GetComponent<Game>().q = false;
MovingPiece.hasMoved = true;
print(matrixX);
}
if (MovingPiece.name == "white_King")
{
MovingPiece.hasMoved = true;
controller.GetComponent<Game>().k = false;
controller.GetComponent<Game>().q = false;
controller.GetComponent<Game>().K = false;
controller.GetComponent<Game>().Q = false;
}
if (MovingPiece.name == "white_rook")
{
if (matrixX == 7)
controller.GetComponent<Game>().K = false;
else
controller.GetComponent<Game>().Q = false;
MovingPiece.hasMoved = true;
print(matrixX);
}

controller.GetComponent<Game>().NextTurn();
Expand Down

0 comments on commit 794e28d

Please sign in to comment.