Skip to content

Commit 91f5ab4

Browse files
committed
add field requests to OpenGame
1 parent e8cdd30 commit 91f5ab4

File tree

3 files changed

+20
-7
lines changed

3 files changed

+20
-7
lines changed

src/main/client/src/feature/lobby/LobbyPanel.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ function Panel() {
3737
})
3838
return undefined
3939
}, [auth])
40-
return <>
40+
return (
4141
<Chat chatId="Lobby" />
42-
</>
42+
)
4343
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
package com.bernd.model;
22

33
public record AcceptRequest(
4+
String opponent,
45
OpenGame game,
56
boolean flip,
67
int handicap) {
8+
9+
public AcceptRequest withOpponent(String opponent) {
10+
return new AcceptRequest(opponent, game, flip, handicap);
11+
}
712
}

src/main/java/com/bernd/model/OpenGame.java

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,30 @@
11
package com.bernd.model;
22

33
import com.bernd.game.MoveList;
4+
import java.util.List;
45

56
import static com.bernd.LobbyController.createEmptyBoard;
67

78
public record OpenGame(
89
String id,
910
String user,
11+
List<AcceptRequest> requests,
1012
int dim,
11-
int timesetting,
12-
int handicap) {
13+
int timesetting) {
1314

1415
public OpenGame withId(String id) {
15-
return new OpenGame(id, user, dim, timesetting, handicap);
16+
return new OpenGame(id, user, requests, dim, timesetting).sanitize();
1617
}
1718

18-
public OpenGame withUser(String name) {
19-
return new OpenGame(id, name, dim, timesetting, handicap);
19+
public OpenGame withUser(String user) {
20+
return new OpenGame(id, user, requests, dim, timesetting).sanitize();
21+
}
22+
23+
private OpenGame sanitize() {
24+
if (requests == null) {
25+
return new OpenGame(id, user, List.of(), dim, timesetting);
26+
}
27+
return this;
2028
}
2129

2230
public Game accept(String opponent, AcceptRequest acceptRequest) {

0 commit comments

Comments
 (0)