-
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
Open
subha0319
wants to merge
3
commits into
ShrimpCryptid:development
Choose a base branch
from
subha0319:development
base: development
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -146,6 +146,7 @@ type AppState = { | |
| lobbyFromURL: boolean; | ||
| usernames: string[]; | ||
| icons: { [key: string]: string }; | ||
| minLobbySize: 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: {}, | ||
| minLobbySize: 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, | ||
| minLobbySize: message["minLobbySize"] || 5, | ||
| }); | ||
| if (message[PARAM_ICON][this.state.name] === defaultPortrait) { | ||
| this.showChangeIconAlert(); | ||
|
|
@@ -918,7 +921,7 @@ class App extends Component<{}, AppState> { | |
| <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) | ||
| Players ({this.state.usernames.length}/{this.state.minLobbySize}) | ||
| </p> | ||
| <button | ||
| id={"lobby-change-icon-button"} | ||
|
|
@@ -927,6 +930,40 @@ class App extends Component<{}, AppState> { | |
| CHANGE ICON | ||
| </button> | ||
|
Comment on lines
927
to
932
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.
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. Moved the new controls completely out of the top flex container, so the 'Change Icon' button is back to its normal size. |
||
| </div> | ||
|
|
||
| <div style={{ marginBottom: "15px", display: "flex", flexDirection: "column", alignItems: "flex-start" }}> | ||
| {isVIP ? ( | ||
| <> | ||
| <label style={{ color: "white", display: "flex", alignItems: "center", cursor: "pointer" }}> | ||
| <span style={{ marginRight: "10px" }}>Game Size:</span> | ||
| <select | ||
| value={this.state.minLobbySize} | ||
| 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", cursor: "pointer" }} | ||
| > | ||
| {[5, 6, 7, 8, 9, 10].map(n => ( | ||
| <option key={n} value={n}> | ||
| {n === 10 ? "10 Players" : `${n}+ Players`} | ||
| </option> | ||
| ))} | ||
| </select> | ||
| </label> | ||
| <span style={{ color: "#aaaaaa", fontSize: "0.8em", marginTop: "4px" }}> | ||
| (Empty spots will be filled by bots) | ||
| </span> | ||
| </> | ||
| ) : ( | ||
| <p style={{ color: "gray", fontSize: "0.9em", margin: 0 }}> | ||
| Game Size: {this.state.minLobbySize === 10 ? "10 Players" : `${this.state.minLobbySize}+ Players`} | ||
| <br/> | ||
| <span style={{ fontSize: "0.9em" }}>(Empty spots will be filled by bots)</span> | ||
| </p> | ||
| )} | ||
| </div> | ||
|
|
||
| <div id={"lobby-player-container"}>{this.renderPlayerList()}</div> | ||
| </div> | ||
|
|
||
|
|
||
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.

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.
Could you please make
minLobbySizeinto a constant?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.
I've extracted the string key into a
PARAM_MIN_LOBBY_SIZEconstant on both theconstants/index.tsand theSecretHitlerServer.java.