Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Hiraoka committed Jan 31, 2021
2 parents 17dd216 + c448a30 commit 342326f
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/main/java/featurecat/lizzie/rules/SGFParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ private static BoardHistoryList parseValue(
}

String blackPlayer = "", whitePlayer = "";
String blackPlayerRank = "", whitePlayerRank = "";

// Support unicode characters (UTF-8)
for (int i = 0; i < value.length(); i++) {
Expand Down Expand Up @@ -387,6 +388,10 @@ private static BoardHistoryList parseValue(
} else {
history.getGameInfo().setPlayerWhite(whitePlayer);
}
} else if (tag.equals("BR")) {
blackPlayerRank = tagContent;
} else if (tag.equals("WR")) {
whitePlayerRank = tagContent;
} else if (tag.equals("KM")) {
try {
if (tagContent.trim().isEmpty()) {
Expand Down Expand Up @@ -503,6 +508,24 @@ private static BoardHistoryList parseValue(
}
}

// adjust player name
if (!Utils.isBlank(blackPlayerRank)) {
blackPlayer = blackPlayer + " " + blackPlayerRank;
if (history == null) {
Lizzie.board.getHistory().getGameInfo().setPlayerBlack(blackPlayer);
} else {
history.getGameInfo().setPlayerBlack(blackPlayer);
}
}
if (!Utils.isBlank(whitePlayerRank)) {
whitePlayer = whitePlayer + " " + whitePlayerRank;
if (history == null) {
Lizzie.board.getHistory().getGameInfo().setPlayerWhite(whitePlayer);
} else {
history.getGameInfo().setPlayerWhite(whitePlayer);
}
}

if (isBranch) {
history.toBranchTop();
} else {
Expand Down

0 comments on commit 342326f

Please sign in to comment.