0
0
Fork 0

Add players array and related mutations

This commit is contained in:
Oliver-Akins 2021-01-01 16:09:40 -07:00
parent dd365dde86
commit f31341ffd8
2 changed files with 33 additions and 9 deletions

View file

@ -64,7 +64,10 @@ export default {
return;
};
history.replaceState(null, ``, `?game=${data.game_code}`);
// Save the data in the store
this.$store.commit(`playerList`, data.players);
this.$store.commit(`game_code`, this.game_code);
this.$store.commit(`player`, {
name: this.name,
@ -79,7 +82,10 @@ export default {
return;
};
history.replaceState(null, ``, `?game=${data.game_code}`);
// Update storage
this.$store.commit(`playerList`, data.players);
this.$store.commit(`game_code`, data.game_code);
this.$store.commit(`player`, {
name: this.name,

View file

@ -4,20 +4,22 @@
<div class="flex-row">
<button
class="clickable"
@click.stop=""
v-clipboard:copy="gameURL"
v-clipboard:success="copySuccess"
v-clipboard:error="copyError"
>
Click to Copy Game Link
{{ copyURLButtonText }}
</button>
</div>
<div class="flex-row">
<role-select
:team_name="$store.state.team_1.name"
:player_name="playerName"
:teamID="1"
@error="$emit(`error`, $event)"
/>
<player-list />
<player-list @error="$emit(`error`, $event)" />
<role-select
:team_name="$store.state.team_2.name"
:player_name="playerName"
:teamID="2"
@error="$emit(`error`, $event)"
/>
</div>
<div class="flex-row">
@ -41,12 +43,29 @@ export default {
"RoleSelect": TeamRoleSelect,
"PlayerList": PlayerList,
},
data() {return {
copyURLButtonText: `Click to Copy Game Link`,
}},
computed: {
playerName() {
return this.$store.state.name;
},
gameURL() {
return `${window.location.protocol}//${window.location.host}?game=${this.$store.state.game_code}`;
}
},
methods: {
copySuccess() {
this.copyURLButtonText = `Game Link Copied!`;
setTimeout(() => { this.copyURLButtonText = `Click to Copy Game Link`; }, 1000)
},
copyError(e) {
this.$emit(`error`, {
status: 418,
message: `Failed to copy game URL`,
});
}
},
methods: {},
}
</script>
@ -55,7 +74,6 @@ export default {
@import "../css/style.css";
#GameLobby {
justify-content: center;
flex-direction: column;
align-items: stretch;
display: flex;