Implement object selection on the client side.
This commit is contained in:
parent
34e1a19a64
commit
8162396c5d
1 changed files with 12 additions and 20 deletions
|
|
@ -29,6 +29,9 @@ export default {
|
||||||
buttonLabel() {
|
buttonLabel() {
|
||||||
return this.$store.state.writer_object_choose_button;
|
return this.$store.state.writer_object_choose_button;
|
||||||
},
|
},
|
||||||
|
gameCode() {
|
||||||
|
return this.$store.state.game_code;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
selectObject(objectIndex) {
|
selectObject(objectIndex) {
|
||||||
|
|
@ -36,22 +39,19 @@ export default {
|
||||||
* Sends the chosen object to the server so that the game can begin properly.
|
* Sends the chosen object to the server so that the game can begin properly.
|
||||||
*/
|
*/
|
||||||
let data = {
|
let data = {
|
||||||
|
game_code: this.gameCode,
|
||||||
choice: this.objects[objectIndex - 1],
|
choice: this.objects[objectIndex - 1],
|
||||||
};
|
};
|
||||||
|
this.$socket.client.emit(`SelectObject`, data);
|
||||||
this.$store.state.chosen_object = data.choice;
|
|
||||||
|
|
||||||
console.debug(data)
|
|
||||||
// TODO -> Send data to the server
|
|
||||||
},
|
},
|
||||||
getObjects() {
|
getObjects() {
|
||||||
/**
|
/**
|
||||||
* Gets the objects on the card from the server. This method will
|
* Gets the objects on the card from the server. This method will
|
||||||
* return the same values for all spirit.
|
* return the same values for all spirit.
|
||||||
*/
|
*/
|
||||||
this.objects = [ `Potato`, `Salad`, `Foo`, `Bar` ];
|
this.$socket.client.emit(`ObjectList`, {
|
||||||
|
game_code: this.$store.state.game_code,
|
||||||
// TODO -> Actually get the data from the server
|
});
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
sockets: {
|
sockets: {
|
||||||
|
|
@ -60,11 +60,6 @@ export default {
|
||||||
* The response event from the server for the list of objects that
|
* The response event from the server for the list of objects that
|
||||||
* are on the card which we have drawn for the round.
|
* are on the card which we have drawn for the round.
|
||||||
*/
|
*/
|
||||||
/**
|
|
||||||
* data = {
|
|
||||||
* objects: String[],
|
|
||||||
* }
|
|
||||||
*/
|
|
||||||
this.objects = data.objects;
|
this.objects = data.objects;
|
||||||
},
|
},
|
||||||
ChosenObject(data) {
|
ChosenObject(data) {
|
||||||
|
|
@ -73,13 +68,10 @@ export default {
|
||||||
* turn stay synchronized on what object they are trying to get
|
* turn stay synchronized on what object they are trying to get
|
||||||
* their teammate to guess.
|
* their teammate to guess.
|
||||||
*/
|
*/
|
||||||
/**
|
if (data.status < 200 || 300 <= data.status) {
|
||||||
* data = {
|
this.$emit(`error`, data);
|
||||||
* choice: String,
|
};
|
||||||
* }
|
this.$store.commit(`setObject`, data.choice);
|
||||||
*/
|
|
||||||
console.debug(data)
|
|
||||||
this.$store.state.chosen_object = data.choice;
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue