aboutsummaryrefslogtreecommitdiff
path: root/pages
diff options
context:
space:
mode:
authorlonkaars <l.leblansch@gmail.com>2021-02-17 22:35:41 +0100
committerlonkaars <l.leblansch@gmail.com>2021-02-17 22:35:41 +0100
commit27c1340dbbf18638f680be8557a531180abfd53a (patch)
treee7a2114f6ccf87655d5bdf87cfd8f83f5b93a8cb /pages
parent2a0e24e24f728bbb858e11c47a08ad9d672d840e (diff)
supposed-to-work thingy
Diffstat (limited to 'pages')
-rw-r--r--pages/game.tsx27
1 files changed, 24 insertions, 3 deletions
diff --git a/pages/game.tsx b/pages/game.tsx
index a206d7a..1c66f92 100644
--- a/pages/game.tsx
+++ b/pages/game.tsx
@@ -6,6 +6,13 @@ import * as cookies from 'react-cookies';
var socket = io("http://localhost:2080/api/game/socket/");
+socket.on("connect", () => {
+ console.log("connect")
+})
+socket.on("disconnect", () => {
+ console.log("disconnect")
+})
+
import { NavBar } from '../components/navbar';
import { CenteredPage } from '../components/page';
import { VoerBord } from '../components/voerBord';
@@ -52,12 +59,21 @@ class VoerGame extends Component<VoerGameProps> {
super(props);
}
- board = [...Array(7 * 6)].map(() => 0);
+ width = 7;
+ height = 6;
+
+ state: {
+ userID: string;
+ } = {
+ userID: ""
+ }
+
+ board = [...Array(this.width * this.height)].map(() => 0);
userID = "";
move(column: number) {
console.log(column)
- if(this.userID == "") {
+ if(this.state.userID == "") {
axios.request<userInfo>({
method: "get",
url: `/api/user/info`,
@@ -66,6 +82,11 @@ class VoerGame extends Component<VoerGameProps> {
.then(request => this.setState({ userID: request.data.id }))
.catch(() => {});
}
+ console.log("emitted this", {
+ move: column,
+ token: cookies.load("token"),
+ gameID: "fortnite"
+ })
socket.emit("new_move", {
move: column,
token: cookies.load("token"),
@@ -81,7 +102,7 @@ class VoerGame extends Component<VoerGameProps> {
maxWidth: "100vh",
margin: "0 auto"
}}>
- <VoerBord width={7} height={6} onMove={m => this.move(Number(m))}/>
+ <VoerBord width={this.width} height={this.height} onMove={m => this.move(m % this.width + 1)}/>
<GameBar/>
</div>
}