From 2ab7cfe761b47eed848becbc9386f6a94ef44d3d Mon Sep 17 00:00:00 2001 From: lonkaars Date: Mon, 8 Mar 2021 15:43:25 +0100 Subject: game/resign thingy --- pages/game.tsx | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) (limited to 'pages') diff --git a/pages/game.tsx b/pages/game.tsx index 660156d..58eb639 100644 --- a/pages/game.tsx +++ b/pages/game.tsx @@ -51,6 +51,10 @@ class VoerGame extends Component { if (data.boardFull) outcome = 0; this.setState({ outcome }); }); + + this.io.on("resign", () => { + alert("resign") + }); } io: Socket; @@ -93,9 +97,22 @@ class VoerGame extends Component { maxWidth: "100vh", margin: "0 auto" }}> - this.move(m % this.width + 1)} active={this.props.active == true && this.state.outcome == -1}/> - - + this.move(m % this.width + 1)} + active={this.props.active == true && this.state.outcome == -1} + /> + {this.io.emit("resign", { game_id: this.props.gameID })}} + /> + } } @@ -167,6 +184,9 @@ var InviteButtonLabelStyle: CSSProperties = { export default class GamePage extends Component { constructor(props: {}) { super(props); + + if (typeof document === "undefined") return; + // gert } state: { -- cgit v1.2.3