-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
server side refactoring, add field color to move
- Loading branch information
1 parent
794a329
commit 7234baf
Showing
11 changed files
with
176 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
package com.bernd.model; | ||
|
||
public final class GameBuilder { | ||
private final Game game; | ||
|
||
private boolean counting; | ||
private int countingAgreed; | ||
private boolean opponentPassed; | ||
private int[][] board; | ||
private int dim; | ||
private int handicap; | ||
private int[] forbidden; | ||
|
||
private GameBuilder(Game game) { | ||
this.game = game; | ||
} | ||
|
||
public GameBuilder withCounting(boolean counting) { | ||
this.counting = counting; | ||
return this; | ||
} | ||
|
||
public GameBuilder withCountingAgreed(int countingAgreed) { | ||
this.countingAgreed = countingAgreed; | ||
return this; | ||
} | ||
|
||
public GameBuilder withOpponentPassed(boolean opponentPassed) { | ||
this.opponentPassed = opponentPassed; | ||
return this; | ||
} | ||
|
||
public GameBuilder withBoard(int[][] board) { | ||
this.board = board; | ||
return this; | ||
} | ||
|
||
public GameBuilder withDim(int dim) { | ||
this.dim = dim; | ||
return this; | ||
} | ||
|
||
public GameBuilder withHandicap(int handicap) { | ||
this.handicap = handicap; | ||
return this; | ||
} | ||
|
||
public GameBuilder withForbidden(int[] forbidden) { | ||
this.forbidden = forbidden; | ||
return this; | ||
} | ||
|
||
public GameBuilder withForbidden(int x, int y) { | ||
return withForbidden(new int[]{x, y}); | ||
} | ||
|
||
static GameBuilder builder(Game game) { | ||
GameBuilder builder = new GameBuilder(game); | ||
builder.counting = game.counting(); | ||
builder.countingAgreed = game.countingAgreed(); | ||
builder.opponentPassed = game.opponentPassed(); | ||
builder.board = game.board(); | ||
builder.dim = game.dim(); | ||
builder.handicap = game.handicap(); | ||
builder.forbidden = game.forbidden(); | ||
return builder; | ||
} | ||
|
||
public Game build() { | ||
return new Game( | ||
game.id(), | ||
game.black(), | ||
game.white(), | ||
counting, | ||
countingAgreed, | ||
opponentPassed, | ||
board, | ||
dim, | ||
handicap, | ||
forbidden, | ||
game.moves() | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.