Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
7432542
Created Priority queue
ymmot239 Nov 16, 2024
249382f
Added comments
ymmot239 Nov 19, 2024
071655c
Fixed queue problem
ymmot239 Nov 19, 2024
6485c2e
Fixed reload
ymmot239 Nov 19, 2024
dab1559
Added host reassignment
ymmot239 Nov 22, 2024
636c577
Added game end reasoning
ymmot239 Nov 22, 2024
ad509f1
Queue names
ymmot239 Nov 22, 2024
9430db7
Sidebar formatting
ymmot239 Dec 2, 2024
c9dc430
Sidebar in-game formatting
ymmot239 Dec 3, 2024
6374d10
Readability Changes
ymmot239 Mar 31, 2025
7962d61
Update index.scss
ymmot239 Mar 31, 2025
3f43747
fixed lint check
ymmot239 Mar 31, 2025
e1667d4
Merge branch 'main' into 201-server-host-reassignment
ymmot239 Mar 31, 2025
3cee1b5
added dark mode support
ymmot239 Apr 1, 2025
f3f76ad
fixed theme buttons
ymmot239 Apr 1, 2025
a1c5ccc
Merge branch 'main' into 201-server-host-reassignment
jasonappah Sep 11, 2025
663ea64
chore: merge fixes
jasonappah Sep 11, 2025
e065007
seems like the socket connection from the frontend simulator to backe…
MahdMalik Feb 14, 2026
2bab495
took forever, but fixed the issue of simulator not updating when the …
MahdMalik Feb 15, 2026
c40271a
gonna merge having piece type attributes into this for my next ingeni…
MahdMalik Feb 15, 2026
5d6256f
Piece type attribute (#269)
MahdMalik Feb 15, 2026
b847ac9
got the FEIN algorithm done for dynamically determinign robot default…
MahdMalik Feb 15, 2026
4e9d530
fixed issue with board not being updated when default position was tu…
MahdMalik Feb 15, 2026
1e41d47
alright checked everything, this should be good to push now
MahdMalik Feb 16, 2026
4a0c992
added comments and ran the format + link checker
MahdMalik Feb 16, 2026
1449c69
finished making changes
MahdMalik Feb 21, 2026
17c3867
Merge branch 'main' of https://github.com/Comet-Robotics/chessbots-se…
MahdMalik Feb 21, 2026
47c8e72
Merge branch 'main' of https://github.com/Comet-Robotics/chessbots-se…
MahdMalik Feb 21, 2026
2a43ff6
Merge branch 'main' of https://github.com/Comet-Robotics/chessbots-se…
MahdMalik Feb 21, 2026
96f3126
fixed some error
MahdMalik Feb 21, 2026
553d0d7
alright queue actually works as expected, awesome sauce
MahdMalik Feb 21, 2026
399dbec
fixed some of the PR things requested
MahdMalik Feb 21, 2026
8349f40
fixed github's comment
MahdMalik Feb 21, 2026
c1d57cd
fixed formatting
MahdMalik Feb 21, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions src/client/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,7 @@ export function useSocket(
onMessage(message);
}
},

onClose: () => {
console.log("IT'S CLOSED BRO!");
},
share: true,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what this do

});

// handle how a message is sent
Expand Down
30 changes: 17 additions & 13 deletions src/client/game/game.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { ChessEngine } from "../../common/chess-engine";
import type { Move } from "../../common/game-types";
import { NonIdealState, Spinner } from "@blueprintjs/core";
import { AcceptDrawDialog, OfferDrawDialog } from "./draw-dialog";
import { Sidebar } from "../setup/sidebar";
import { bgColor } from "../check-dark-mode";
import "../colors.css";
import { NotificationDialog, PauseDialog } from "./admin-dialogs";
Expand Down Expand Up @@ -195,19 +196,22 @@ export function Game(): JSX.Element {
<PuzzleTipBox />
</div>

<div id="body-container" className={bgColor()}>
<ChessboardWrapper
side={side}
chess={chess}
onMove={handleMove}
rotation={rotation ? rotation : 0}
/>
{gameEndDialog}
{gameOfferDialog}
{gameAcceptDialog}
{gamePauseDialog}
{gameUnpauseDialog}
<Outlet />
<Sidebar top={50} />
<div className="main-dialog">
<div id="body-container" className={bgColor()}>
<ChessboardWrapper
side={side}
chess={chess}
onMove={handleMove}
rotation={rotation ? rotation : 0}
/>
{gameEndDialog}
{gameOfferDialog}
{gameAcceptDialog}
{gamePauseDialog}
{gameUnpauseDialog}
<Outlet />
</div>
</div>
</>
);
Expand Down
62 changes: 62 additions & 0 deletions src/client/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,65 @@
position: absolute;
// border: 3px solid blue;
}

.sidebar {
//w3 schools for the win
width: 20%;
height: 100%;
position: fixed; /* Fixed Sidebar (stay in place on scroll) */
z-index: 1; /* Stay on top */
top: 0; /* Stay at the top */
left: 0;
overflow-x: hidden; /* Disable horizontal scroll */
padding-top: 20px;
}

.main-dialog {
margin-left: 20%;
position: fixed;
width: 80%;
height: 100%;
padding-top: 50px;
}

.flex-container {
display: flex;
flex-direction: column;
padding: 5px;
background-color: #eee;
}

.button-container {
display: flex;
flex-direction: column;
gap: 5px;
margin-bottom: 5px;
margin-top: auto;
}

@media (max-width: 500px) {
.flex-container {
flex-direction: row;
}

.button-container {
margin-right: 5px;
margin-left: auto;
margin-bottom: auto;
margin-top: 0px;
}

.sidebar {
width: 100%;
height: 20%;
bottom: 0;
top: auto;
padding-top: 10px !important;
}

.main-dialog {
width: 100%;
margin-left: auto;
padding-top: 0px;
}
}
26 changes: 22 additions & 4 deletions src/client/setup/lobby.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useNavigate, Navigate } from "react-router-dom";
import { GameStartedMessage } from "../../common/message/game-message";
import { useSocket, useEffectQuery, get } from "../api";
import { ClientType } from "../../common/client-types";
import { ThemeButtons } from "./setup";

/**
* check for an active game and waits for one or forwards to setup
Expand Down Expand Up @@ -41,10 +42,27 @@ export function Lobby() {
} else {
return (
<SetupBase>
<NonIdealState
title="Waiting For Game to Start"
icon={<Spinner intent="primary" />}
/>
<>
<NonIdealState
title={
data.clientType === ClientType.CLIENT ?
"Waiting For Host to Start"
: "Waiting in line"
}
icon={<Spinner intent="primary" />}
/>
<div
style={{
alignItems: "center",
display: "flex",
flex: "1 0 auto",
flexDirection: "column",
justifyContent: "space-around",
}}
>
<ThemeButtons />
</div>
</>
</SetupBase>
);
}
Expand Down
48 changes: 27 additions & 21 deletions src/client/setup/setup-base.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { ChessboardWrapper } from "../chessboard/chessboard-wrapper";
import type { PropsWithChildren, ReactNode } from "react";
import { ChessEngine } from "../../common/chess-engine";
import { Side } from "../../common/game-types";
import { Sidebar } from "./sidebar";
import { bgColor } from "../check-dark-mode";
import "../colors.css";

Expand All @@ -20,27 +21,32 @@ interface SetupBaseProps extends PropsWithChildren {
export function SetupBase(props: SetupBaseProps): JSX.Element {
return (
<>
<Outlet />
<ChessboardWrapper
chess={new ChessEngine()}
side={Side.WHITE}
onMove={() => {}}
rotation={0}
/>
<Dialog
style={{
backgroundColor: "transparent",
boxShadow: "none",
}}
isOpen
canEscapeKeyClose={false}
canOutsideClickClose={false}
>
<div className={bgColor() + " " + "roundedBorder"}>
<DialogBody>{props.children}</DialogBody>
<DialogFooter minimal actions={props.actions} />
</div>
</Dialog>
<div className="main-dialog">
<Outlet />
<ChessboardWrapper
chess={new ChessEngine()}
side={Side.WHITE}
onMove={() => {}}
rotation={0}
/>
<Dialog
style={{
backgroundColor: "transparent",
boxShadow: "none",
}}
isOpen
canEscapeKeyClose={false}
canOutsideClickClose={false}
usePortal={false}
enforceFocus={false}
>
<div className={bgColor() + " " + "roundedBorder"}>
<DialogBody>{props.children}</DialogBody>
<DialogFooter minimal actions={props.actions} />
</div>
</Dialog>
</div>
<Sidebar />
</>
);
}
37 changes: 23 additions & 14 deletions src/client/setup/setup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,20 +132,7 @@ function SetupMain(props: SetupMainProps) {
onClick={() => props.onPageChange(SetupType.PUZZLE)}
className={buttonColor()}
/>
<h3 className={textColor()}>Display Settings:</h3>
<ButtonGroup variant="outlined">
{allSettings.map((item, idx) => (
<Button
key={item[0]}
textClassName={textColor()}
//changed for better visibility
icon={item[1]}
text={item[0]}
active={getUserSetting() === idx}
onClick={() => setUserSetting(idx)}
/>
))}
</ButtonGroup>
<ThemeButtons />
</>
);

Expand All @@ -163,8 +150,30 @@ function SetupMain(props: SetupMainProps) {
}}
>
<H3 className={textColor()}>Welcome to Chess Bot!</H3>

{actions}
</div>
</>
);
}

export function ThemeButtons(): JSX.Element {
return (
<>
<h3 className={textColor()}>Display Settings:</h3>
<ButtonGroup variant="outlined">
{allSettings.map((item, idx) => (
<Button
key={item[0]}
textClassName={textColor()}
//changed for better visibility
icon={item[1]}
text={item[0]}
active={getUserSetting() === idx}
onClick={() => setUserSetting(idx)}
/>
))}
</ButtonGroup>
</>
);
}
104 changes: 104 additions & 0 deletions src/client/setup/sidebar.tsx
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
Copy link
Member Author

Choose a reason for hiding this comment

The 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>
);
}
Loading