can play game
This commit is contained in:
@@ -1,41 +1,26 @@
|
||||
import { useState } from "react";
|
||||
import "./App.css";
|
||||
import { type FC } from "react";
|
||||
import { UserInput } from "./game/UserInput";
|
||||
import { BoardDisplay } from "./game/BoardDisplay";
|
||||
import { ConnectionStatus } from "./game/ConnectionStatus";
|
||||
import { NameInput } from "./game/NameInput";
|
||||
import { SessionOverride } from "./game/SessionOverride";
|
||||
import { useGameChannelContext } from "./contexts/useGameChannelContext";
|
||||
|
||||
const getPlayerNameFromUrl = () => {
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
return params.get("name") || null;
|
||||
};
|
||||
const App: FC<{ playerName: string }> = ({ playerName }) => {
|
||||
const { isOverridden } = useGameChannelContext();
|
||||
|
||||
function App() {
|
||||
const [playerName, setPlayerName] = useState<string | null>(
|
||||
getPlayerNameFromUrl,
|
||||
);
|
||||
|
||||
if (!playerName) {
|
||||
return <NameInput onNameSubmit={setPlayerName} />;
|
||||
if (isOverridden) {
|
||||
return <SessionOverride />;
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<UserInput playerName={playerName} />
|
||||
<div
|
||||
style={{
|
||||
width: "100vw",
|
||||
height: "100vh",
|
||||
background: "#1a1a2e",
|
||||
overflow: "hidden",
|
||||
position: "relative",
|
||||
}}
|
||||
>
|
||||
<div className="w-screen h-screen bg-navy-900">
|
||||
<ConnectionStatus />
|
||||
<BoardDisplay playerName={playerName} />
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
export default App;
|
||||
|
||||
Reference in New Issue
Block a user