Adjust prop names and add event distribution
This commit is contained in:
parent
66518cebaa
commit
dd365dde86
1 changed files with 40 additions and 13 deletions
|
|
@ -1,15 +1,15 @@
|
||||||
<template>
|
<template>
|
||||||
<div :id="`${team_name}-role-select`" class="team-select">
|
<div :id="`${teamName}-role-select`" class="team-select">
|
||||||
<h2 class="centre">{{ team_name }} Team</h2>
|
<h2 class="centre">{{ teamName }} Team</h2>
|
||||||
<button
|
<button
|
||||||
class="clickable"
|
class="clickable"
|
||||||
@click.stop="joinWriterRole"
|
@click.stop="joinRole(`writer`)"
|
||||||
>
|
>
|
||||||
{{ $store.state.writer_name }}
|
{{ $store.state.writer_name }}
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
class="clickable"
|
class="clickable"
|
||||||
@click.stop="joinGuesserRole"
|
@click.stop="joinRole(`guesser`)"
|
||||||
>
|
>
|
||||||
{{ $store.state.guesser_name }}
|
{{ $store.state.guesser_name }}
|
||||||
</button>
|
</button>
|
||||||
|
|
@ -21,19 +21,46 @@ export default {
|
||||||
name: `TeamRoleSelection`,
|
name: `TeamRoleSelection`,
|
||||||
components: {},
|
components: {},
|
||||||
props: {
|
props: {
|
||||||
team_name: {
|
teamID: {
|
||||||
type: String,
|
type: Number,
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
player_name: {
|
|
||||||
type: String,
|
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
computed: {},
|
computed: {
|
||||||
|
teamName() {
|
||||||
|
return this.$store.state[`team_${this.teamID}`].name;
|
||||||
|
}
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
joinWriterRole() {},
|
joinRole(role) {
|
||||||
joinGuesserRole() {},
|
|
||||||
|
if (this.teamID == this.$store.state.team && this.$store.state.role == role) {
|
||||||
|
this.$emit(`error`, {
|
||||||
|
status: 403,
|
||||||
|
message: `You are already that role on that team.`,
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
|
let response = {
|
||||||
|
action: `modify`,
|
||||||
|
game_code: this.$store.state.game_code,
|
||||||
|
name: this.$store.state.name,
|
||||||
|
to: {
|
||||||
|
team: this.teamID,
|
||||||
|
role: role,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.$store.state.team != null) {
|
||||||
|
response.from = {
|
||||||
|
team: this.$store.state.team,
|
||||||
|
role: this.$store.state.role,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
this.$socket.client.emit(`UpdatePlayer`, response);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue