|
|
@ -24,7 +24,8 @@ import * as websocket from '../../websocket.js'
|
|
|
|
import { updateGame, updatePlayer, gameState, setSelectedCard, setCards,
|
|
|
|
import { updateGame, updatePlayer, gameState, setSelectedCard, setCards,
|
|
|
|
movePlayer, setOldMessages, markActionChangeHandled,
|
|
|
|
movePlayer, setOldMessages, markActionChangeHandled,
|
|
|
|
mpMouse, rolled, setNextAction, nextUIAction, nextUIActionSilent, alert,
|
|
|
|
mpMouse, rolled, setNextAction, nextUIAction, nextUIActionSilent, alert,
|
|
|
|
autoSkip, message, alertHandled, setHarvestTable, setCardError } from './actions.js'
|
|
|
|
autoSkip, message, alertHandled, setHarvestTable,
|
|
|
|
|
|
|
|
setCardError, setMovingSkip } from './actions.js'
|
|
|
|
import { itemCard, fateCard } from 'game.js'
|
|
|
|
import { itemCard, fateCard } from 'game.js'
|
|
|
|
|
|
|
|
|
|
|
|
export { initialize, buy, roll, endTurn, loan, trade, submitTradeAccept,
|
|
|
|
export { initialize, buy, roll, endTurn, loan, trade, submitTradeAccept,
|
|
|
@ -189,7 +190,9 @@ function initialize(st, sc) {
|
|
|
|
let lastAction = false,
|
|
|
|
let lastAction = false,
|
|
|
|
lastAutoSkip = false,
|
|
|
|
lastAutoSkip = false,
|
|
|
|
rollMessage = '',
|
|
|
|
rollMessage = '',
|
|
|
|
rollTimer = false;
|
|
|
|
rollTimer = false,
|
|
|
|
|
|
|
|
movingAction = { from: 99, to: 99 },
|
|
|
|
|
|
|
|
movingTimer = 0;
|
|
|
|
const unsubscribe = store.subscribe(
|
|
|
|
const unsubscribe = store.subscribe(
|
|
|
|
() => {
|
|
|
|
() => {
|
|
|
|
const state = store.getState();
|
|
|
|
const state = store.getState();
|
|
|
@ -265,6 +268,50 @@ function initialize(st, sc) {
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((state.farm.ui.action === 'move' || state.farm.ui.action === 'goto') &&
|
|
|
|
|
|
|
|
movingAction.from !== state.farm.ui.actionValue.from &&
|
|
|
|
|
|
|
|
movingAction.to !== state.farm.ui.actionValue.to) {
|
|
|
|
|
|
|
|
movingAction = state.farm.ui.actionValue;
|
|
|
|
|
|
|
|
const movingProc = (player, from, to) => {
|
|
|
|
|
|
|
|
let currentPos = from < 0 ? from + 49 : from;
|
|
|
|
|
|
|
|
const color = player.color;
|
|
|
|
|
|
|
|
const hurtBack = to === 2 && from === 11 ? true : false;
|
|
|
|
|
|
|
|
const delta = currentPos === 48 ? -48 : hurtBack ? -1 : 1;
|
|
|
|
|
|
|
|
store.dispatch(movePlayer(currentPos + delta, currentPos, color));
|
|
|
|
|
|
|
|
currentPos += delta;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const tick = () => {
|
|
|
|
|
|
|
|
if (store.getState().farm.ui.movingSkip ||
|
|
|
|
|
|
|
|
store.getState().farm.ui.autoSkip === 'moving') {
|
|
|
|
|
|
|
|
store.dispatch(setMovingSkip(false));
|
|
|
|
|
|
|
|
store.dispatch(movePlayer(to, currentPos, color));
|
|
|
|
|
|
|
|
currentPos = to;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
const delta = currentPos === 48 ? -48 : hurtBack ? -1 : 1;
|
|
|
|
|
|
|
|
store.dispatch(movePlayer(currentPos + delta, currentPos, color));
|
|
|
|
|
|
|
|
currentPos += delta;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (currentPos === to) {
|
|
|
|
|
|
|
|
clearInterval(movingTimer);
|
|
|
|
|
|
|
|
movingTimer = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (currentPos !== to) {
|
|
|
|
|
|
|
|
movingTimer = setInterval(tick, 500);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
movingProc(state.farm.player.name === state.farm.game.currentPlayer ?
|
|
|
|
|
|
|
|
state.farm.player : state.farm.game.otherPlayers
|
|
|
|
|
|
|
|
.find(p => p.player.name === state.farm.game.currentPlayer).player,
|
|
|
|
|
|
|
|
movingAction.from, movingAction.to);
|
|
|
|
|
|
|
|
} else if (state.farm.ui.action !== 'move' && state.farm.ui.action !== 'goto') {
|
|
|
|
|
|
|
|
if (movingTimer) {
|
|
|
|
|
|
|
|
clearInterval(movingTimer);
|
|
|
|
|
|
|
|
movingTimer = 0;
|
|
|
|
|
|
|
|
movingAction = { from: 99, to: 99 };
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
// mpDims.mouseX = e.clientX
|
|
|
|
// mpDims.mouseX = e.clientX
|
|
|
|