Skip to content

Commit

Permalink
add field requests to OpenGame
Browse files Browse the repository at this point in the history
  • Loading branch information
h908714124 committed Oct 7, 2024
1 parent e8cdd30 commit 91f5ab4
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/main/client/src/feature/lobby/LobbyPanel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function Panel() {
})
return undefined
}, [auth])
return <>
return (
<Chat chatId="Lobby" />
</>
)
}
5 changes: 5 additions & 0 deletions src/main/java/com/bernd/model/AcceptRequest.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
package com.bernd.model;

public record AcceptRequest(
String opponent,
OpenGame game,
boolean flip,
int handicap) {

public AcceptRequest withOpponent(String opponent) {
return new AcceptRequest(opponent, game, flip, handicap);
}
}
18 changes: 13 additions & 5 deletions src/main/java/com/bernd/model/OpenGame.java
Original file line number Diff line number Diff line change
@@ -1,22 +1,30 @@
package com.bernd.model;

import com.bernd.game.MoveList;
import java.util.List;

import static com.bernd.LobbyController.createEmptyBoard;

public record OpenGame(
String id,
String user,
List<AcceptRequest> requests,
int dim,
int timesetting,
int handicap) {
int timesetting) {

public OpenGame withId(String id) {
return new OpenGame(id, user, dim, timesetting, handicap);
return new OpenGame(id, user, requests, dim, timesetting).sanitize();
}

public OpenGame withUser(String name) {
return new OpenGame(id, name, dim, timesetting, handicap);
public OpenGame withUser(String user) {
return new OpenGame(id, user, requests, dim, timesetting).sanitize();
}

private OpenGame sanitize() {
if (requests == null) {
return new OpenGame(id, user, List.of(), dim, timesetting);
}
return this;
}

public Game accept(String opponent, AcceptRequest acceptRequest) {
Expand Down

0 comments on commit 91f5ab4

Please sign in to comment.