-
Notifications
You must be signed in to change notification settings - Fork 4
201 server host reassignment #254
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
Merged
Merged
Changes from all commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
7432542
Created Priority queue
ymmot239 249382f
Added comments
ymmot239 071655c
Fixed queue problem
ymmot239 6485c2e
Fixed reload
ymmot239 dab1559
Added host reassignment
ymmot239 636c577
Added game end reasoning
ymmot239 ad509f1
Queue names
ymmot239 9430db7
Sidebar formatting
ymmot239 c9dc430
Sidebar in-game formatting
ymmot239 6374d10
Readability Changes
ymmot239 7962d61
Update index.scss
ymmot239 3f43747
fixed lint check
ymmot239 e1667d4
Merge branch 'main' into 201-server-host-reassignment
ymmot239 3cee1b5
added dark mode support
ymmot239 f3f76ad
fixed theme buttons
ymmot239 a1c5ccc
Merge branch 'main' into 201-server-host-reassignment
jasonappah 663ea64
chore: merge fixes
jasonappah e065007
seems like the socket connection from the frontend simulator to backe…
MahdMalik 2bab495
took forever, but fixed the issue of simulator not updating when the …
MahdMalik c40271a
gonna merge having piece type attributes into this for my next ingeni…
MahdMalik 5d6256f
Piece type attribute (#269)
MahdMalik b847ac9
got the FEIN algorithm done for dynamically determinign robot default…
MahdMalik 4e9d530
fixed issue with board not being updated when default position was tu…
MahdMalik 1e41d47
alright checked everything, this should be good to push now
MahdMalik 4a0c992
added comments and ran the format + link checker
MahdMalik 1449c69
finished making changes
MahdMalik 17c3867
Merge branch 'main' of https://github.com/Comet-Robotics/chessbots-se…
MahdMalik 47c8e72
Merge branch 'main' of https://github.com/Comet-Robotics/chessbots-se…
MahdMalik 2a43ff6
Merge branch 'main' of https://github.com/Comet-Robotics/chessbots-se…
MahdMalik 96f3126
fixed some error
MahdMalik 553d0d7
alright queue actually works as expected, awesome sauce
MahdMalik 399dbec
fixed some of the PR things requested
MahdMalik 8349f40
fixed github's comment
MahdMalik c1d57cd
fixed formatting
MahdMalik 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
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
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 |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| import { Button, NonIdealState } from "@blueprintjs/core"; | ||
| import type { Dispatch } from "react"; | ||
| import { useState } from "react"; | ||
| import type { MessageHandler } from "../../common/message/message"; | ||
| import { JoinQueue, UpdateQueue } from "../../common/message/game-message"; | ||
| import { get, useEffectQuery, useSocket } from "../api"; | ||
| import { | ||
| bgColor, | ||
| buttonColor, | ||
| textBoxColor, | ||
| textColor, | ||
| } from "../check-dark-mode"; | ||
|
|
||
| function getMessageHandler(setQueue: Dispatch<string[]>): MessageHandler { | ||
| return (message) => { | ||
| if (message instanceof UpdateQueue) { | ||
| setQueue(message.updatedPlayerList.slice()); | ||
| } | ||
| }; | ||
| } | ||
|
|
||
| interface sidebarProps { | ||
| top?: number | undefined; | ||
| } | ||
|
|
||
| /** | ||
| * Creates a sidebar to hold the queue elements | ||
| * @returns sidebar container | ||
| */ | ||
| export function Sidebar(props: sidebarProps): JSX.Element { | ||
| const [queue, setQueue] = useState<string[]>([]); | ||
| const [name, setName] = useState<string>( | ||
| "player " + Math.floor(Math.random() * 10000), | ||
| ); | ||
|
|
||
| const sendMessage = useSocket(getMessageHandler(setQueue)); | ||
|
|
||
| const { isPending, isError } = useEffectQuery( | ||
| "get-queue", | ||
| async () => { | ||
| const newQueue = await get("/get-queue"); | ||
| setQueue(newQueue); | ||
| }, | ||
| true, | ||
| ); | ||
|
|
||
| const names = useEffectQuery( | ||
| "get-name", | ||
| async () => { | ||
| return get("/get-name").then((name) => { | ||
| if (name.message) setName(name.message); | ||
| return name; | ||
| }); | ||
| }, | ||
| true, | ||
| ); | ||
|
|
||
| if (names.isError) { | ||
| console.log(names.isError); | ||
| } | ||
| //ts wanted me to do something with my data | ||
| if (isPending || names.isPending) { | ||
| return <NonIdealState />; | ||
| } else if (isError) { | ||
| console.log(isError); | ||
| } | ||
|
|
||
| return ( | ||
| <div | ||
|
Member
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. is there any way we can do this with mostly blueprint js components? just for visual consistency |
||
| className={"sidebar flex-container " + bgColor()} | ||
| style={{ paddingTop: props.top }} | ||
| > | ||
| <h3 className={textColor()}>Player Queue</h3> | ||
| <ul style={{ listStyle: "decimal" }}> | ||
| {queue.map(function (data) { | ||
| return ( | ||
| <li className={textColor()} key={data}> | ||
| {data} | ||
| </li> | ||
| ); | ||
| })} | ||
| </ul> | ||
| <div className={"button-container"}> | ||
| <label className={textColor()}>Name:</label> | ||
| <input | ||
| className={textBoxColor() + " " + textColor()} | ||
| value={name} | ||
| maxLength={30} | ||
| onChange={(e) => setName(e.target.value)} | ||
| /> | ||
| <Button | ||
| type="submit" | ||
| style={{ textAlign: "start" }} | ||
| onClick={async () => { | ||
| sendMessage(new JoinQueue(name)); | ||
| }} | ||
| className={buttonColor()} | ||
| > | ||
| Join queue | ||
| </Button> | ||
| </div> | ||
| </div> | ||
| ); | ||
| } | ||
Oops, something went wrong.
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.
what this do