import org.hedgecode.chess.pgn.entity.DetailMove;
import org.hedgecode.chess.pgn.entity.MoveNumber;
import org.hedgecode.chess.pgn.entity.Moves;
-import org.hedgecode.chess.pgn.nag.Glyph;
import org.hedgecode.chess.pgn.token.san.CommonSANToken;
import org.hedgecode.chess.pgn.token.san.SANToken;
*/
public class MoveToken implements Token<Moves> {
- public static final String MOVE_REGEX = "^\\s*([PNBRQKa-hx1-8=+#\\-O!?]+)(\\s+\\$([0-9]+))?";
+ public static final String MOVE_REGEX = "^\\s*([PNBRQKa-hx1-8=+#\\-O!?]+)";
private static final Pattern MOVE_PATTERN = Pattern.compile(MOVE_REGEX);
private static final int MOVE_GROUP = 1, NAG_GROUP = 3;
MoveNumber moveNumber = new MoveNumber(
moves.currentMove().ply()
);
- int numberLength = moveNumberToken.token(moveNumber, pgn);
- if (numberLength > 0) {
- pgn = pgn.substring(numberLength);
+ int numLength = moveNumberToken.token(moveNumber, pgn);
+ if (numLength > 0) {
+ pgn = pgn.substring(numLength);
}
Matcher matcher = MOVE_PATTERN.matcher(pgn);
if (!matcher.find()) {
moves.addMove(
detailMove
);
- String glyph = matcher.group(NAG_GROUP); // todo: more then one NAG
- if (glyph != null) {
- detailMove.addGlyph(
- Glyph.byNumber(
- Integer.parseInt(glyph)
- )
- );
- }
}
- return numberLength + matcher.group().length();
+ return numLength + matcher.group().length();
}
}