Skip to content

Commit

Permalink
Merge pull request #104 from dcolazin/ISSUE-99-pgn-parsing-order
Browse files Browse the repository at this point in the history
Issue 99 pgn parsing order
  • Loading branch information
bhlangonijr authored Feb 1, 2023
2 parents 4df8d6f + 2360dc6 commit 4959990
Show file tree
Hide file tree
Showing 7 changed files with 225 additions and 211 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
*/
public class Event {

private final Map<Integer, Round> round = new HashMap<Integer, Round>();
private final Map<Integer, Round> round = new HashMap<>();
private String id;
private String name;
private EventType eventType;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/github/bhlangonijr/chesslib/game/Game.java
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ private int translateVariation(StringBuilder sb, MoveList variation, int parent,
@Override
public String toString() {
try {
return toPgn(true, true);
return toPgn(true, true); //TODO this throws NPE in debugger sometimes
} catch (MoveConversionException e) {
return null;
}
Expand Down Expand Up @@ -802,7 +802,7 @@ public void loadMoveText(StringBuilder moveText) throws Exception {
onCommentBlock = false;
if (comment != null) {
if (getComments() == null) {
setComments(new HashMap<Integer, String>());
setComments(new HashMap<>());
}
getComments().put(variantIndex, comment.toString());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,7 @@ public static Round newRound(Event event, int number) {
*/
public static Game newGame(String gameId, Round round) {

Game game = new Game(gameId, round);

return game;
return new Game(gameId, round);
}

/**
Expand All @@ -73,7 +71,9 @@ public static Game newGame(String gameId, Round round) {
* @return he newly created instance of a player
*/
public static Player newPlayer(PlayerType type, String name) {
return new GenericPlayer(name, name);
Player player = new GenericPlayer(name, name);
player.setType(type);
return player;
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* A round of a chess event.
*/
public class Round {
private final List<Game> game = new ArrayList<Game>();
private final List<Game> game = new ArrayList<>();
private final Event event;
private int number;

Expand Down
Loading

0 comments on commit 4959990

Please sign in to comment.