Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

後手番で成駒が反転する挙動を修正 #42

Merged
merged 1 commit into from
Feb 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions Assets/Scripts/Data/PieceData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,34 +106,34 @@ public static string PieceTypeToStr(PieceType pieceType)
/// </summary>
/// <param name="pieceType"></param>
/// <returns></returns>
public static string PieceTypeToPromoteStr(PieceType pieceType)
public static string PieceTypeToPromoteStr(PieceType pieceType, bool isAIFirst)
{
switch (pieceType)
{
case PieceType.WhitePawn:
return "white_prom_pawn";
return isAIFirst? "black_prom_pawn" : "white_prom_pawn";
case PieceType.WhiteLance:
return "white_prom_lance";
return isAIFirst ? "black_prom_lance" : "white_prom_lance";
case PieceType.WhiteKnight:
return "white_prom_knight";
return isAIFirst ? "black_prom_knight" : "white_prom_knight";
case PieceType.WhiteSilver:
return "white_prom_silver";
return isAIFirst ? "black_prom_silver" : "white_prom_silver";
case PieceType.WhiteBishop:
return "white_horse";
return isAIFirst ? "black_horse" : "white_horse";
case PieceType.WhiteRook:
return "white_dragon";
return isAIFirst ? "black_dragon" : "white_dragon";
case PieceType.BlackPawn:
return "black_prom_pawn";
return isAIFirst ? "white_prom_pawn" : "black_prom_pawn";
case PieceType.BlackLance:
return "black_prom_lance";
return isAIFirst ? "white_prom_lance" : "black_prom_lance";
case PieceType.BlackKnight:
return "black_prom_knight";
return isAIFirst ? "white_prom_knight" : "black_prom_knight";
case PieceType.BlackSilver:
return "black_prom_silver";
return isAIFirst ? "white_prom_silver" : "black_prom_silver";
case PieceType.BlackBishop:
return "black_horse";
return isAIFirst ? "white_horse" : "black_horse";
case PieceType.BlackRook:
return "black_dragon";
return isAIFirst ? "white_dragon" : "black_dragon";
default:
throw new Exception("成れない駒です。");
}
Expand Down
12 changes: 6 additions & 6 deletions Assets/Scripts/GameSceneScreen/GameSceneController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ private async UniTask SelectPiece(Piece piece)
{
// この場合は強制的に成る
decidedMove = movePromote;
PromotePiece(selectedPiece);
PromotePiece(selectedPiece, isAIFirst);
}
else
{
Expand All @@ -253,7 +253,7 @@ private async UniTask SelectPiece(Piece piece)
if (shouldPromote)
{
decidedMove = movePromote;
PromotePiece(selectedPiece);
PromotePiece(selectedPiece, isAIFirst);
}

// 変数を初期化
Expand Down Expand Up @@ -334,7 +334,7 @@ private async UniTask MovePiece(Cell cell, bool isBlack)
{
// この場合は強制的に成る
decidedMove = movePromote;
PromotePiece(selectedPiece);
PromotePiece(selectedPiece, isAIFirst);
}
else
{
Expand All @@ -358,7 +358,7 @@ private async UniTask MovePiece(Cell cell, bool isBlack)
if (shouldPromote)
{
decidedMove = movePromote;
PromotePiece(selectedPiece);
PromotePiece(selectedPiece, isAIFirst);
}

// 変数を初期化
Expand Down Expand Up @@ -496,10 +496,10 @@ private void CapturePiece(Piece piece, bool isBlack)
Destroy(piece.gameObject);
}

private void PromotePiece(Piece piece)
private void PromotePiece(Piece piece, bool isAIFirst)
{
piece.isPromoted = true;
piece.GetComponent<Image>().sprite = Resources.Load<Sprite>("ShogiUI/Piece/" + PieceData.PieceTypeToPromoteStr(piece.pieceType));
piece.GetComponent<Image>().sprite = Resources.Load<Sprite>("ShogiUI/Piece/" + PieceData.PieceTypeToPromoteStr(piece.pieceType, isAIFirst));
}

/// <summary>
Expand Down
Loading