From 72d8c0178a8b21a8f0d19da9689a5bac30ccbcbb Mon Sep 17 00:00:00 2001 From: lonkaars Date: Wed, 17 Feb 2021 12:37:03 +0100 Subject: beginsels website game dings --- pages/game.tsx | 67 ++++++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 54 insertions(+), 13 deletions(-) (limited to 'pages') diff --git a/pages/game.tsx b/pages/game.tsx index 513fc7a..f56452f 100644 --- a/pages/game.tsx +++ b/pages/game.tsx @@ -1,4 +1,10 @@ -import { CSSProperties } from 'react'; +import { CSSProperties, Component } from 'react'; +import { io } from 'socket.io-client'; +import axios from 'axios'; +import { userInfo } from '../api/api'; +import * as cookies from 'react-cookies'; + +var socket = io("http://localhost:5000/game/socket"); import { NavBar } from '../components/navbar'; import { CenteredPage } from '../components/page'; @@ -37,22 +43,57 @@ var InviteButtonLabelStyle: CSSProperties = { userSelect: "none" } +interface VoerGameProps { + +} + +class VoerGame extends Component { + constructor(props: VoerGameProps) { + super(props); + } + + board = [...Array(7 * 6)].map(() => 0); + userID = ""; + + move(column: number) { + console.log(column) + if(this.userID == "") { + axios.request({ + method: "get", + url: `/api/user/info`, + headers: {"content-type": "application/json"} + }) + .then(request => this.setState({ userID: request.data.id })) + .catch(() => {}); + } + socket.emit("new_move", { + move: column, + token: cookies.load("token"), + gameID: "fortnite" + }) + } + + render() { + return
+ + +
+ } +} + export default function GamePage() { return (
-
- - -
- + + {false &&
-
+
}
); -- cgit v1.2.3