const state = {
  player: {
    x: 100,
    y: 100,
    angle: 0,
    targetAngle: 0,
    color: 'red'
  },
  players: {

  },
  settings: {
    playerSize: 10,
    playerSpeed: 2,
    playerTurnSpeed: 10,
    wallSize: 8,
    wallUpdate: 5,
    arenaSize: 1000
  },
  paused: true,
  socketConnected: false
}

const getters = {
}

const actions = {
  socketConnected ({ commit }) {
    commit('SET_CONNECTED')
  },
  login ({ commit }, player) {
    commit('SET_PLAYER', player)
  },
  settings ({ commit }, settings) {
    commit('SET_SETTINGS', settings)
  },
  update ({ commit }, update) {
    commit('SET_PLAYERS', update)
  },
  dead ({ commit }, player) {
    commit('SET_PLAYER', player)
  },
  error ({ commit }, error) {
    alert('Error: ' + error)
  }
}

const mutations = {
  SET_PLAYER (state, player) {
    state.player = player
  },
  SET_PLAYERS (state, players) {
    state.players = players
  },
  SET_SETTINGS (state, settings) {
    state.settings = settings
  },
  SET_PAUSE (state) {
    state.paused = !state.paused
  },
  SET_CONNECTED (state) {
    state.socketConnected = !state.socketConnected
  }
}

export default {
  namespaced: true,
  state,
  getters,
  actions,
  mutations
}
