const { createStore, combineReducers } = require('redux');

const renderCryps = require('./scenes/cryps');

const reducers = require('./reducers');
const actions = require('./actions');
const setupKeys = require('./keyboard');
const createSocket = require('./socket');

// Redux Store
const store = createStore(
    combineReducers({
        activeItem: reducers.activeItemReducer,
        activeSkill: reducers.activeSkillReducer,
        activeIncoming: reducers.activeIncomingReducer,
        account: reducers.accountReducer,
        game: reducers.gameReducer,
        cryps: reducers.crypsReducer,
        items: reducers.itemsReducer,
        ws: reducers.wsReducer,
    })
);

store.subscribe(() => console.log(store.getState()));
setupKeys(store);

const ws = createSocket(store);
store.dispatch(actions.setWs(ws));
ws.connect();

renderCryps(store);
