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": "", "author": "",
"license": "UNLICENSED", "license": "UNLICENSED",
"dependencies": { "dependencies": {
"async": "^2.6.2",
"borc": "^2.0.3", "borc": "^2.0.3",
"bulma-toast": "^1.2.0", "bulma-toast": "^1.2.0",
"docco": "^0.7.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 SET_GAME = 'SET_GAME';
export const setGame = value => ({ type: SET_GAME, value }); 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 SET_SHOW_LOG = 'SET_SHOW_LOG';
export const setShowLog = value => ({ type: SET_SHOW_LOG, value }); export const setShowLog = value => ({ type: SET_SHOW_LOG, value });

View File

@ -10,6 +10,7 @@ const { STATS } = require('../utils');
function GamePanel(props) { function GamePanel(props) {
const { const {
game, game,
resolution,
activeSkill, activeSkill,
setActiveSkill, setActiveSkill,
setActiveCryp, 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 const mobileSkills = activeCryp
? range(0, 3).map(i => Skill(activeCryp, i, true)) ? range(0, 3).map(i => Skill(activeCryp, i, true))

View File

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

View File

@ -1,4 +1,5 @@
const toast = require('izitoast'); const toast = require('izitoast');
const eachSeries = require('async/eachSeries');
const actions = require('./actions'); const actions = require('./actions');
@ -12,11 +13,27 @@ function registerEvents(store) {
} }
function setWs(ws) { function setWs(ws) {
console.log('EVENT ->', 'ws', ws); store.dispatch(actions.setWs(ws));
} }
function setGame(game) { function setGame(game) {
store.dispatch(actions.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); // return console.log('EVENT ->', 'game', game);
} }

View File

@ -23,6 +23,7 @@ const store = createStore(
combiner: reducers.combinerReducer, combiner: reducers.combinerReducer,
cryps: reducers.crypsReducer, cryps: reducers.crypsReducer,
game: reducers.gameReducer, game: reducers.gameReducer,
resolution: reducers.resolutionReducer,
showLog: reducers.showLogReducer, showLog: reducers.showLogReducer,
info: reducers.infoReducer, info: reducers.infoReducer,
instance: reducers.instanceReducer, 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; const defaultShowLog = false;
function showLogReducer(state = defaultShowLog, action) { function showLogReducer(state = defaultShowLog, action) {
switch (action.type) { switch (action.type) {
@ -153,6 +163,7 @@ module.exports = {
instancesReducer, instancesReducer,
reclaimingReducer, reclaimingReducer,
selectedCrypsReducer, selectedCrypsReducer,
resolutionReducer,
wsReducer, wsReducer,
infoReducer, infoReducer,
}; };

View File

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