resolutions tick

This commit is contained in:
ntr 2019-04-11 11:51:22 +10:00
parent 419372b26f
commit c0303c5b61
8 changed files with 47 additions and 3 deletions

View File

@ -12,6 +12,7 @@
"author": "",
"license": "UNLICENSED",
"dependencies": {
"async": "^2.6.2",
"borc": "^2.0.3",
"bulma-toast": "^1.2.0",
"docco": "^0.7.0",

View File

@ -13,6 +13,9 @@ export const setInstance = value => ({ type: SET_INSTANCE, value });
export const SET_GAME = 'SET_GAME';
export const setGame = value => ({ type: SET_GAME, value });
export const SET_RESOLUTION = 'SET_RESOLUTION';
export const setResolution = value => ({ type: SET_RESOLUTION, value });
export const SET_SHOW_LOG = 'SET_SHOW_LOG';
export const setShowLog = value => ({ type: SET_SHOW_LOG, value });

View File

@ -10,6 +10,7 @@ const { STATS } = require('../utils');
function GamePanel(props) {
const {
game,
resolution,
activeSkill,
setActiveSkill,
setActiveCryp,
@ -228,7 +229,13 @@ function GamePanel(props) {
);
}
const selectedSkills = playerTeam.cryps.map((c, i) => stackElement(c, i));
function resolutionEl(r) {
return <div>{JSON.stringify(resolution)}</div>;
}
const selectedSkills = resolution
? resolutionEl(resolution)
: playerTeam.cryps.map((c, i) => stackElement(c, i));
const mobileSkills = activeCryp
? range(0, 3).map(i => Skill(activeCryp, i, true))

View File

@ -15,6 +15,7 @@ const addState = connect(
ws,
game,
account,
resolution,
showLog,
activeSkill,
activeCryp,
@ -36,6 +37,7 @@ const addState = connect(
game,
showLog,
account,
resolution,
activeSkill,
activeCryp,
selectSkillTarget,

View File

@ -1,4 +1,5 @@
const toast = require('izitoast');
const eachSeries = require('async/eachSeries');
const actions = require('./actions');
@ -12,11 +13,27 @@ function registerEvents(store) {
}
function setWs(ws) {
console.log('EVENT ->', 'ws', ws);
store.dispatch(actions.setWs(ws));
}
function setGame(game) {
const { game: currentGame } = store.getState();
if (game && currentGame) {
if (game.resolved.length !== currentGame.resolved.length) {
const newRes = game.resolved.slice(currentGame.resolved.length);
return eachSeries(newRes, (r, cb) => {
store.dispatch(actions.setResolution(r));
return setTimeout(cb, 500);
}, err => {
if (err) return console.error(err);
store.dispatch(actions.setResolution(null));
store.dispatch(actions.setGame(game));
return true;
});
}
}
return store.dispatch(actions.setGame(game));
// return console.log('EVENT ->', 'game', game);
}

View File

@ -23,6 +23,7 @@ const store = createStore(
combiner: reducers.combinerReducer,
cryps: reducers.crypsReducer,
game: reducers.gameReducer,
resolution: reducers.resolutionReducer,
showLog: reducers.showLogReducer,
info: reducers.infoReducer,
instance: reducers.instanceReducer,

View File

@ -100,6 +100,16 @@ function gameReducer(state = defaultGame, action) {
}
}
const defaultResolution = null;
function resolutionReducer(state = defaultResolution, action) {
switch (action.type) {
case actions.SET_RESOLUTION:
return action.value;
default:
return state;
}
}
const defaultShowLog = false;
function showLogReducer(state = defaultShowLog, action) {
switch (action.type) {
@ -153,6 +163,7 @@ module.exports = {
instancesReducer,
reclaimingReducer,
selectedCrypsReducer,
resolutionReducer,
wsReducer,
infoReducer,
};

View File

@ -39,6 +39,8 @@ var / skill info rpc
siphon might have a prob
put ticks on stack at start of phase
push events
make strike *really* hit first / resolve at same time?
## SOON