@@ -114,33 +131,70 @@ export function Lobby() {
)
}
-function NewGameDialog({onNewGame, onStartEdit, setNewGameOpen}) {
+function NewGameDialog({onNewGame, onStartEdit, setNewGameOpen, onRef}) {
let dimRef = useRef(9)
+ let timeRef = useRef(0)
let [edit, setEdit] = useState(false)
return (
)
}
diff --git a/src/main/java/com/bernd/LobbyController.java b/src/main/java/com/bernd/LobbyController.java
index af95c37..c9158e6 100644
--- a/src/main/java/com/bernd/LobbyController.java
+++ b/src/main/java/com/bernd/LobbyController.java
@@ -72,6 +72,7 @@ public ViewGame startEdit(@RequestBody MatchRequest request) {
false,
createEmptyBoard(request.dim()),
request.dim(),
+ request.timesetting(),
request.handicap(),
new int[]{-1, -1},
MoveList.create(request.dim())));
diff --git a/src/main/java/com/bernd/model/Game.java b/src/main/java/com/bernd/model/Game.java
index ee87b70..5c74baa 100644
--- a/src/main/java/com/bernd/model/Game.java
+++ b/src/main/java/com/bernd/model/Game.java
@@ -20,6 +20,7 @@ public record Game(
boolean counting,
int[][] board,
int dim,
+ int timesetting,
int handicap,
int[] forbidden,
MoveList moves
diff --git a/src/main/java/com/bernd/model/GameBuilder.java b/src/main/java/com/bernd/model/GameBuilder.java
index d925832..716e87d 100644
--- a/src/main/java/com/bernd/model/GameBuilder.java
+++ b/src/main/java/com/bernd/model/GameBuilder.java
@@ -46,6 +46,7 @@ public Game build() {
counting,
board,
game.dim(),
+ game.timesetting(),
game.handicap(),
forbidden,
game.moves()
diff --git a/src/main/java/com/bernd/model/MatchRequest.java b/src/main/java/com/bernd/model/MatchRequest.java
index 3956c0f..c80d0f1 100644
--- a/src/main/java/com/bernd/model/MatchRequest.java
+++ b/src/main/java/com/bernd/model/MatchRequest.java
@@ -2,6 +2,7 @@
public record MatchRequest(
int dim,
+ int timesetting,
boolean editMode,
int handicap) {
}
diff --git a/src/main/java/com/bernd/model/OpenGame.java b/src/main/java/com/bernd/model/OpenGame.java
index 595e16d..ee38e1a 100644
--- a/src/main/java/com/bernd/model/OpenGame.java
+++ b/src/main/java/com/bernd/model/OpenGame.java
@@ -8,14 +8,15 @@ public record OpenGame(
String id,
String user,
int dim,
+ int timesetting,
int handicap) {
public OpenGame withId(String id) {
- return new OpenGame(id, user, dim, handicap);
+ return new OpenGame(id, user, dim, timesetting, handicap);
}
public OpenGame withUser(String name) {
- return new OpenGame(id, name, dim, handicap);
+ return new OpenGame(id, name, dim, timesetting, handicap);
}
public Game accept(String opponent, AcceptRequest acceptRequest) {
@@ -28,6 +29,7 @@ public Game accept(String opponent, AcceptRequest acceptRequest) {
false,
createEmptyBoard(dim),
dim,
+ timesetting,
acceptRequest.handicap(),
new int[]{-1, -1},
MoveList.create(dim));
diff --git a/src/main/java/com/bernd/model/ViewGame.java b/src/main/java/com/bernd/model/ViewGame.java
index a943d16..6afa84c 100644
--- a/src/main/java/com/bernd/model/ViewGame.java
+++ b/src/main/java/com/bernd/model/ViewGame.java
@@ -7,6 +7,7 @@ public record ViewGame(
String black,
String white,
int dim,
+ int timesetting,
int handicap,
List
moves
) {
@@ -17,6 +18,7 @@ static ViewGame fromGame(Game game) {
game.black(),
game.white(),
game.dim(),
+ game.timesetting(),
game.handicap(),
game.moves().moves());
}
diff --git a/src/test/java/com/bernd/model/GameBuilderTest.java b/src/test/java/com/bernd/model/GameBuilderTest.java
index 2e032ef..4343b80 100644
--- a/src/test/java/com/bernd/model/GameBuilderTest.java
+++ b/src/test/java/com/bernd/model/GameBuilderTest.java
@@ -18,6 +18,7 @@ void unchanged() {
createEmptyBoard(9),
9,
2,
+ 0,
new int[]{-1, -1},
MoveList.create(2));
Game game2 = GameBuilder.builder(game).build();
diff --git a/src/test/java/com/bernd/util/SgfCreatorTest.java b/src/test/java/com/bernd/util/SgfCreatorTest.java
index 576ae12..3acc33c 100644
--- a/src/test/java/com/bernd/util/SgfCreatorTest.java
+++ b/src/test/java/com/bernd/util/SgfCreatorTest.java
@@ -17,7 +17,7 @@ void testCreate() {
MoveList moveList = MoveList.create(20);
moveList.add(new Move(Board.B, 0, null, 3, 4));
moveList.add(new Move(Board.W, 0, null, 6, 4));
- Game game = new Game("1234", "B", "W", false, new int[9][], 9, 0, null, moveList);
+ Game game = new Game("1234", "B", "W", false, new int[9][], 9, 0, 0, new int[]{-1, -1}, moveList);
String sgf = SgfCreator.createSgf(game, LocalDate.of(2024, Month.AUGUST, 30));
assertEquals("(;FF[4]CA[UTF-8]GM[1]DT[2024-08-30]GN[1234]PB[B]PW[W]RE[?]SZ[9];B[de];W[ge])",
sgf.replace("\n", ""));