-
Notifications
You must be signed in to change notification settings - Fork 50
feat: customizable lobby size for bot games (Fixes #180) #197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: development
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -146,6 +146,7 @@ type AppState = { | |
| lobbyFromURL: boolean; | ||
| usernames: string[]; | ||
| icons: { [key: string]: string }; | ||
| targetLobbySize: number; | ||
| gameState: GameState; | ||
| /* Stores the last gameState[PARAM_STATE] value to check for changes. */ | ||
| lastState: any; | ||
|
|
@@ -177,6 +178,7 @@ const defaultAppState: AppState = { | |
| lobbyFromURL: false, | ||
| usernames: [], | ||
| icons: {}, | ||
| targetLobbySize: 5, | ||
| gameState: DEFAULT_GAME_STATE, | ||
| lastState: {}, | ||
| liberalPolicies: 0, | ||
|
|
@@ -429,6 +431,7 @@ class App extends Component<{}, AppState> { | |
| usernames: message[PARAM_USERNAMES], | ||
| icons: message[PARAM_ICON], | ||
| page: PAGE.LOBBY, | ||
| targetLobbySize: message["targetLobbySize"] || 5, | ||
| }); | ||
| if (message[PARAM_ICON][this.state.name] === defaultPortrait) { | ||
| this.showChangeIconAlert(); | ||
|
|
@@ -917,9 +920,32 @@ class App extends Component<{}, AppState> { | |
| <div id={"lobby-lower-container"}> | ||
| <div id={"lobby-player-area-container"}> | ||
| <div id={"lobby-player-text-choose-container"}> | ||
| <p id={"lobby-player-count-text"}> | ||
| Players ({this.state.usernames.length}/10) | ||
| </p> | ||
| <div style={{ display: "flex", flexDirection: "column", alignItems: "flex-start" }}> | ||
| <p id={"lobby-player-count-text"}> | ||
| Players ({this.state.usernames.length}/{this.state.targetLobbySize}) | ||
| </p> | ||
|
|
||
| {isVIP ? ( | ||
| <div style={{ marginTop: "5px", display: "flex", alignItems: "center", color: "white" }}> | ||
| <label style={{ marginRight: "10px" }}>Target Game Size:</label> | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm trying to decide on the best language here, since I worry that "Target game size" isn't immediately obvious, and you can actually have more players than the target size. My next thought is "Minimum game size", but that might suggest to players that they have to hit a minimum # of players before they can start a game. What do you think about changing this to "Game Size" and changing the options in the dropdown to
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "Game Size" sounds good. Changed the label to "Game Size" with "{n}+ Players" options, and wrapped the I also added a quick ternary check so it correctly says "10 Players" instead of "10+ Players" when maxed out, along with a small subtitle reminding players about the bots.
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you please change the
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wrapped the |
||
| <select | ||
| value={this.state.targetLobbySize} | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't do this anywhere else on the app but I wonder if this value needs to be set optimistically in case of high latency. Not something that needs to be changed now!
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Left this as it is for now as suggested, but happy to revisit later if latency becomes an issue. |
||
| onChange={(e) => this.sendWSCommand({ | ||
| command: WSCommandType.SET_LOBBY_SIZE, | ||
| size: parseInt(e.target.value) | ||
| })} | ||
| style={{ padding: "5px", borderRadius: "4px", backgroundColor: "#333", color: "white", border: "1px solid #555" }} | ||
| > | ||
| {[5, 6, 7, 8, 9, 10].map(n => <option key={n} value={n}>{n} Players</option>)} | ||
| </select> | ||
| </div> | ||
| ) : ( | ||
| <p style={{ marginTop: "5px", color: "gray", fontSize: "0.9em" }}> | ||
| Target Game Size: {this.state.targetLobbySize} | ||
| </p> | ||
| )} | ||
| </div> | ||
|
|
||
| <button | ||
| id={"lobby-change-icon-button"} | ||
| onClick={this.onClickChangeIcon} | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider renaming to
minLobbySize?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed targetLobbySize to minLobbySize across both the Java backend and the React frontend state.