townsquare/src/store/modules/session.js

49 lines
935 B
JavaScript
Raw Normal View History

2020-05-30 22:47:42 +02:00
const state = () => ({
sessionId: "",
isSpectator: false,
playerCount: 0,
playerId: "",
2020-05-31 23:42:08 +02:00
claimedSeat: -1,
2020-06-03 22:25:23 +02:00
nomination: false,
votes: [],
lockedVote: -1
2020-05-30 22:47:42 +02:00
});
const getters = {};
const actions = {};
const mutations = {
setSessionId(state, sessionId) {
state.sessionId = sessionId;
},
setPlayerId(state, playerId) {
state.playerId = playerId;
},
setSpectator(state, spectator) {
state.isSpectator = spectator;
},
setPlayerCount(state, playerCount) {
state.playerCount = playerCount;
2020-05-31 00:18:31 +02:00
},
claimSeat(state, claimedSeat) {
state.claimedSeat = claimedSeat;
2020-05-31 23:42:08 +02:00
},
nomination(state, nomination) {
state.nomination = nomination;
2020-06-03 22:25:23 +02:00
state.votes = [];
},
vote(state, [index, vote]) {
state.votes = [...state.votes];
state.votes[index] = vote === undefined ? !state.votes[index] : vote;
2020-05-30 22:47:42 +02:00
}
};
export default {
namespaced: true,
state,
getters,
actions,
mutations
};