<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Source: src/store/store.js | Source: src/store/store.js</title> <script src="scripts/prettify/prettify.js"> </script> <script src="scripts/prettify/lang-css.js"> </script> <!--[if lt IE 9]> <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <link type="text/css" rel="stylesheet" href="styles/bootstrap.min.css"> <link type="text/css" rel="stylesheet" href="styles/prettify-jsdoc.css"> <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css"> <link type="text/css" rel="stylesheet" href="styles/tui-doc.css"> </head> <body> <nav class="lnb" id="lnb"> <div class="logo" style=""> <img src="img/toast-ui.png" width="100%" height="100%"> </div> <div class="title"> <h1><a href="index.html" class="link">Source: src/store/store.js</a></h1> </div> <div class="search-container" id="search-container"> <input type="text" placeholder="Search"> <ul></ul> </div> <div class="lnb-api hidden"><h3>Modules</h3><ul><li><a href="module-GameStore%2520-%2520vuex%2520store%2520part%2520with%2520game%2520data.html">GameStore - vuex store part with game data</a><button type="button" class="hidden toggle-subnav btn btn-link"> <span class="glyphicon glyphicon-plus"></span></button><div class="hidden" id="module:GameStore - vuex store part with game data_sub"></div></li></ul></div><div class="lnb-api hidden"><h3>Namespaces</h3><ul><li><a href="constants.html">constants</a><button type="button" class="hidden toggle-subnav btn btn-link"> <span class="glyphicon glyphicon-plus"></span></button><div class="hidden" id="constants_sub"><div class="member-type">Members</div><ul class="inner"><li><a href="constants.html#.exports.JOJO">exports.JOJO</a></li><li><a href="constants.html#.POS_PILE">POS_PILE</a></li></ul></div></li></ul></div><div class="lnb-api hidden"><h3>Global</h3><ul><li class="hidden"><a href="global.html#Ability">Ability</a></li><li class="hidden"><a href="global.html#AbilityHook">AbilityHook</a></li><li class="hidden"><a href="global.html#AdvRule">AdvRule</a></li><li class="hidden"><a href="global.html#BattleTile">BattleTile</a></li><li class="hidden"><a href="global.html#Color">Color</a></li><li class="hidden"><a href="global.html#DeckMode">DeckMode</a></li><li class="hidden"><a href="global.html#Faction">Faction</a></li><li class="hidden"><a href="global.html#GameGlobalState">GameGlobalState</a></li><li class="hidden"><a href="global.html#GameStateEnum">GameStateEnum</a></li><li><a href="global.html#Getters">Getters</a></li><li class="hidden"><a href="global.html#HeroAction">HeroAction</a></li><li class="hidden"><a href="global.html#HeroCard">HeroCard</a></li><li class="hidden"><a href="global.html#HeroInGame">HeroInGame</a></li><li class="hidden"><a href="global.html#HeroPosition">HeroPosition</a></li><li class="hidden"><a href="global.html#PlayerAction">PlayerAction</a></li><li class="hidden"><a href="global.html#PlayerGameState">PlayerGameState</a></li><li class="hidden"><a href="global.html#Popularity">Popularity</a></li><li class="hidden"><a href="global.html#StoreData">StoreData</a></li></ul></div> </nav> <div id="resizer"></div> <div class="main" id="main"> <section> <article> <pre class="prettyprint source linenums"><code>'use strict'; import Vue from 'vue'; import Vuex from 'vuex'; Vue.use(Vuex); import menu from './menu/menu'; import game from './game/game'; import { socketService } from '../main'; const state = { username: '', isConnected: false, gameId: -1, isGameRunning: false, messages: [] }; /** * The module 'getters' object. * * @name Getters * @type {object} * @getter {Array<string>} messages=messages Returns the messages for chat. * @getter {number} gameId=gameId Returns the id of current online game playing (-1 if no online game). * @getter {boolean} isGameRunning=isGameRunning Returns true if a game is running (online or local). */ const getters = { messages(state) { return state.messages; }, gameId(state) { return state.gameId; }, isGameRunning(state) { return state.isGameRunning; }, username(state) { return state.username; }, isConnected(state) { return state.isConnected; } }; const mutations = { ADD_MESSAGE: (state, payload) => { state.messages.push(payload); }, SET_GAME_ID: (state, payload) => { state.gameId = payload; }, SET_IS_GAME_RUNNING: (state, payload) => { state.isGameRunning = payload; }, SET_USERNAME: (state, payload) => { state.username = payload; }, SET_IS_CONNECTED: (state, payload) => { state.isConnected = payload; } }; const actions = { addMessageToQueue: ({ commit }, payload) => { commit('ADD_MESSAGE', payload); }, stopGame: ({ commit, rootState }) => { socketService.leaveGame(rootState.username); commit('SET_IS_GAME_RUNNING', false); localStorage.removeItem('gameId'); }, disconnect: ({ commit }) => { socketService.disconnect(); commit('SET_GAME_ID', -1); commit('SET_IS_GAME_RUNNING', false); commit('SET_USERNAME', ''); commit('SET_IS_CONNECTED', false); commit('menu/RESET_ALL_STATUS'); localStorage.removeItem('username'); localStorage.removeItem('gameId'); } }; export const store = new Vuex.Store({ state, getters, mutations, actions, modules: { menu, game } }); </code></pre> </article> </section> </div> <footer> <img class="logo" src="img/toast-ui.png" style=""> <div class="footer-text">NHN Entertainment. Frontend Development Lab</div> </footer> <script>prettyPrint();</script> <script src="scripts/jquery.min.js"></script> <script src="scripts/tui-doc.js"></script> <script src="scripts/linenumber.js"></script> <script> var id = '_sub'.replace(/"/g, '_'); var selectedApi = document.getElementById(id); // do not use jquery selector var $selectedApi = $(selectedApi); $selectedApi.removeClass('hidden'); $selectedApi.parent().find('.glyphicon').removeClass('glyphicon-plus').addClass('glyphicon-minus'); showLnbApi(); </script> </body> </html>