fix: 代码审查问题修复 — rebuildBoard 参数修正 + 玩家座位号排序
This commit is contained in:
@@ -471,7 +471,7 @@ public class GameServiceImpl implements GameService {
|
|||||||
.toList();
|
.toList();
|
||||||
|
|
||||||
// 从走棋记录重建棋盘
|
// 从走棋记录重建棋盘
|
||||||
boardState = GomokuGameService.rebuildBoard(moveEntities, room.getMaxPlayers());
|
boardState = GomokuGameService.rebuildBoard(moveEntities, GomokuGameService.BOARD_SIZE);
|
||||||
// currentTurn 由服务端运行时管理,HTTP 快照中暂不返回
|
// currentTurn 由服务端运行时管理,HTTP 快照中暂不返回
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -60,7 +60,11 @@ public class GomokuGameServiceImpl implements GomokuGameService {
|
|||||||
int moveCount = moves.size();
|
int moveCount = moves.size();
|
||||||
|
|
||||||
// 判定当前玩家应该下哪一方(黑先白后)
|
// 判定当前玩家应该下哪一方(黑先白后)
|
||||||
List<RoomPlayerEntity> players = roomPlayerRepository.findByRoomId(roomId);
|
// 按座位号排序,确保黑方/白方分配与座位对应(seat=1 为黑方先手)
|
||||||
|
List<RoomPlayerEntity> players = roomPlayerRepository.findByRoomId(roomId)
|
||||||
|
.stream()
|
||||||
|
.sorted(java.util.Comparator.comparingInt(RoomPlayerEntity::getSeatNumber))
|
||||||
|
.toList();
|
||||||
int playerIndex = -1;
|
int playerIndex = -1;
|
||||||
for (int i = 0; i < players.size(); i++) {
|
for (int i = 0; i < players.size(); i++) {
|
||||||
if (players.get(i).getUserId().equals(userId)) {
|
if (players.get(i).getUserId().equals(userId)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user