Add main game view

This commit is contained in:
Oliver-Akins 2020-10-22 23:38:47 -06:00
parent d3dd0ccfa8
commit 50f0fac1f2

View file

@ -0,0 +1,61 @@
<template>
<div id="game">
<h1>
Secret Hitler Online
</h1>
<h2>
Role: {{ role.slice(0, 1).toUpperCase() }}{{ role.slice(1) }}
</h2>
</div>
</template>
<script>
export default {
name: 'GameView',
components: {},
data() {return {
game_code: ``,
is_host: false,
username: ``,
role: `Unknown`,
}},
mounted() {
this.game_code = sessionStorage.getItem(`game-code`);
this.is_host = JSON.parse(sessionStorage.getItem(`is-host`));
this.username = sessionStorage.getItem(`user-name`);
this.$socket.emit(`GetPlayerInfo`, {
game_code: this.game_code,
user: this.username,
});
},
methods: {},
sockets: {
PlayerInfo(data) {
if (!data.success) {
this.$emit(`alert`, {
message: data.message,
classes: [`warning`]
});
setTimeout(() => {
this.$emit(`alert`, { message: ``, classes: [] })
this.$socket.emit(`GetPlayerInfo`, {
game_code: this.game_code,
user: this.username,
});
}, 2000);
} else {
this.role = data.role;
};
},
},
}
</script>
<style scoped>
@import "../css/colours.css";
#game {
text-align: center;
}
</style>