New trading interface and moving bug fixes.

logins
Thomas Hintz 5 years ago
parent 1dc5d53f0d
commit 16897679e3

File diff suppressed because it is too large Load Diff

@ -38,3 +38,4 @@ export const ALERT_HANDLED = 'alert-handled'
export const AUTO_SKIP = 'auto-skip' export const AUTO_SKIP = 'auto-skip'
export const MESSAGE = 'message' export const MESSAGE = 'message'
export const SET_HARVEST_TABLE = 'set-harvest-table' export const SET_HARVEST_TABLE = 'set-harvest-table'
export const SET_MOVING_SKIP = 'set-moving-skip'

@ -20,13 +20,14 @@ import { UPDATE_GAME, UPDATE_PLAYER, GAME_STATE, SET_SELECTED_CARD, SET_CARDS,
SPACE_PUSH_PLAYER, SPACE_CLEAR_PLAYERS, SET_OLD_MESSAGES, MESSAGE_PANEL_SPACE, SPACE_PUSH_PLAYER, SPACE_CLEAR_PLAYERS, SET_OLD_MESSAGES, MESSAGE_PANEL_SPACE,
MP_MOUSE, SET_MP_DIMS, MARK_ACTION_CHANGE_HANDLED, SET_NEXT_ACTION, MP_MOUSE, SET_MP_DIMS, MARK_ACTION_CHANGE_HANDLED, SET_NEXT_ACTION,
MOVE_PLAYER, NEXT_UI_ACTION, NEXT_UI_ACTION_SILENT, ALERT, ALERT_HANDLED, MOVE_PLAYER, NEXT_UI_ACTION, NEXT_UI_ACTION_SILENT, ALERT, ALERT_HANDLED,
AUTO_SKIP, MESSAGE, SET_HARVEST_TABLE, SET_CARD_ERROR } from './actionTypes.js' AUTO_SKIP, MESSAGE, SET_HARVEST_TABLE, SET_CARD_ERROR,
SET_MOVING_SKIP } from './actionTypes.js'
export { updateGame, updatePlayer, gameState, setSelectedCard, setCards, export { updateGame, updatePlayer, gameState, setSelectedCard, setCards,
spacePushPlayer, spaceClearPlayers, setOldMessages, setMessagePanelSpace, spacePushPlayer, spaceClearPlayers, setOldMessages, setMessagePanelSpace,
mpMouse, setMPDims, movePlayer, setNextAction, nextUIAction, mpMouse, setMPDims, movePlayer, setNextAction, nextUIAction,
markActionChangeHandled, nextUIActionSilent, alert, alertHandled, markActionChangeHandled, nextUIActionSilent, alert, alertHandled,
autoSkip, message, setHarvestTable, setCardError } autoSkip, message, setHarvestTable, setCardError, setMovingSkip }
function updateGame(update) { function updateGame(update) {
return { type: UPDATE_GAME, return { type: UPDATE_GAME,
@ -130,3 +131,7 @@ function message(message) {
function setHarvestTable(table) { function setHarvestTable(table) {
return { type: SET_HARVEST_TABLE, table }; return { type: SET_HARVEST_TABLE, table };
} }
function setMovingSkip(skip) {
return { type: SET_MOVING_SKIP, skip };
}

@ -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

@ -21,7 +21,8 @@ import { UPDATE_GAME, UPDATE_PLAYER, GAME_STATE, SET_SELECTED_CARD, SET_CARDS,
SET_OLD_MESSAGES, MESSAGE_PANEL_SPACE, MP_MOUSE, SET_OLD_MESSAGES, MESSAGE_PANEL_SPACE, MP_MOUSE,
SET_MP_DIMS, MOVE_PLAYER, SET_NEXT_ACTION, NEXT_UI_ACTION, SET_MP_DIMS, MOVE_PLAYER, SET_NEXT_ACTION, NEXT_UI_ACTION,
MARK_ACTION_CHANGE_HANDLED, NEXT_UI_ACTION_SILENT, ALERT, ALERT_HANDLED, MARK_ACTION_CHANGE_HANDLED, NEXT_UI_ACTION_SILENT, ALERT, ALERT_HANDLED,
AUTO_SKIP, MESSAGE, SET_HARVEST_TABLE, SET_CARD_ERROR } from './actionTypes.js' AUTO_SKIP, MESSAGE, SET_HARVEST_TABLE, SET_CARD_ERROR,
SET_MOVING_SKIP } from './actionTypes.js'
import { GAME_STATES } from '../../constants.js' import { GAME_STATES } from '../../constants.js'
import { spaceContent, corners } from 'game.js' import { spaceContent, corners } from 'game.js'
@ -121,6 +122,7 @@ const initialState = {
unhandledAlert: false, unhandledAlert: false,
autoSkip: false, autoSkip: false,
playerSpaces: {}, playerSpaces: {},
movingSkip: false,
harvestTable: false }, harvestTable: false },
spaces: spaces, spaces: spaces,
space: null, space: null,
@ -219,6 +221,8 @@ export default function(state = initialState, action) {
return { ...state, ui: { ...state.ui, message: action.message }}; return { ...state, ui: { ...state.ui, message: action.message }};
case SET_HARVEST_TABLE: case SET_HARVEST_TABLE:
return { ...state, ui: { ...state.ui, harvestTable: action.table }}; return { ...state, ui: { ...state.ui, harvestTable: action.table }};
case SET_MOVING_SKIP:
return { ...state, ui: { ...state.ui, movingSkip: action.skip }};
default: default:
return state; return state;
} }

@ -584,6 +584,16 @@
(when (alist-ref ridge params) (when (alist-ref ridge params)
(if (> (player-ridge player ridge) 0) (if (> (player-ridge player ridge) 0)
(begin (begin
(safe-set!
(player-assets originator)
(alist-update 'cows (+ (alist-ref 'cows (player-assets originator))
(alist-ref ridge (player-ridges player)))
(player-assets originator)))
(safe-set!
(player-assets player)
(alist-update 'cows (- (alist-ref 'cows (player-assets player))
(alist-ref ridge (player-ridges player)))
(player-assets player)))
(safe-set! (player-ridges originator) (safe-set! (player-ridges originator)
(alist-update ridge (alist-update ridge
(alist-ref ridge (player-ridges player)) (alist-ref ridge (player-ridges player))
@ -591,6 +601,16 @@
(safe-set! (player-ridges player) (safe-set! (player-ridges player)
(alist-update ridge 0 (player-ridges player)))) (alist-update ridge 0 (player-ridges player))))
(begin (begin
(safe-set!
(player-assets originator)
(alist-update 'cows (- (alist-ref 'cows (player-assets originator))
(alist-ref ridge (player-ridges originator)))
(player-assets originator)))
(safe-set!
(player-assets player)
(alist-update 'cows (+ (alist-ref 'cows (player-assets player))
(alist-ref ridge (player-ridges originator)))
(player-assets player)))
(safe-set! (player-ridges player) (safe-set! (player-ridges player)
(alist-update ridge (alist-update ridge
(alist-ref ridge (player-ridges originator)) (alist-ref ridge (player-ridges originator))
@ -1903,17 +1923,11 @@
;; TODO ;; TODO
;; make sure two players can't have the same name ;; make sure two players can't have the same name
;; info actions should look better ;; info actions should look better
;; you can get $50 from harvest ;; you can get $50 from operating expense
;; moving bug 5 from oct 2 saw by player 2
;; from harvest moon rolled 5
;; finished
;; infinite loop ((?action . end-game) (?value . #<procedure (a10302)>))
;; auto-skip loop ;; auto-skip loop
;; harvester / tractor don't say total price ;; harvester / tractor don't say total price
;; mark spaces ;; mark spaces
;; trade notification keeps popping up ;; can't trade other player's ridge
;; show harvest multiplier

@ -268,8 +268,77 @@ $tab-margin: 0.3rem;
.player-trade-resources .resource-unit { .player-trade-resources .resource-unit {
display: inline-block; display: inline-block;
margin-bottom: 0.3rem;
width: 4rem; } width: 4rem; }
.resource-unit.double-width {
width: 84px;
}
.resource-unit.double-width .button:last-child {
margin-left: 0.2rem;
}
.player-trade-resources img {
margin-top: 0.2rem;
margin-bottom: 0.2rem; }
.trade-player-container {
border: 0.2rem solid $dark-color;
border-radius: 0.2rem;
background: #ccc;
padding: 0.3rem;
.button {
margin: 0; }
}
$trade-margin: 3rem;
.resources-to-trade {
margin-left: 0.5rem;
visibility: hidden;
.resource-unit {
position: relative;
margin-top: $trade-margin / 2;
margin-bottom: $trade-margin / 2;
}
.trade-asset-cancel {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
color: red;
padding: 0.2rem;
display: none;
cursor: pointer;
opacity: 0.7;
svg {
width: 100%;
height: 100%;
}
}
.trade-to {
margin-top: ($trade-margin / 2) - 1.2;
margin-bottom: ($trade-margin / 2) + 1.2;
visibility: visible;
}
.trade-to:hover .trade-asset-cancel {
display: block;
}
.trade-from:hover .trade-asset-cancel {
display: block;
}
.trade-from {
margin-bottom: ($trade-margin / 2) - 1.2;
margin-top: ($trade-margin / 2) + 1.2;
visibility: visible;
}
}
.card-id { .card-id {
position: absolute; position: absolute;
top: 10px; top: 10px;
@ -305,6 +374,7 @@ $tab-margin: 0.3rem;
} }
.resource-unit { .resource-unit {
position: relative;
text-align: center; text-align: center;
margin-right: 0.5rem; margin-right: 0.5rem;
width: 40px; width: 40px;
@ -313,6 +383,19 @@ $tab-margin: 0.3rem;
height: 34px; } height: 34px; }
} }
.resource-doubled {
position: absolute;
top: -0.7rem;
right: -0.2rem;
color: blue;
font-size: 1.4rem;
padding: 0.1rem;
transform: rotate(17deg);
svg {
filter: drop-shadow( 1px 1px 1px rgba(0, 0, 0, .7));
}
}
.resource-unit-container { .resource-unit-container {
display: flex; display: flex;
flex-direction: row; } flex-direction: row; }
@ -556,12 +639,17 @@ $tab-margin: 0.3rem;
max-height: 80vh; max-height: 80vh;
@include breakpoint(medium down) { @include breakpoint(medium down) {
flex-grow: 2; flex-grow: 2;
max-width: 82vw;
} }
@include breakpoint(large) { @include breakpoint(large) {
width: 26rem; width: 26rem;
} }
} }
.trade-tab {
min-width: 26rem;
}
.static-tab-container { .static-tab-container {
overflow-y: auto; overflow-y: auto;
max-height: 80vh; max-height: 80vh;

@ -46,7 +46,8 @@ module.exports = {
chunkFilename: '[id].css', chunkFilename: '[id].css',
}), }),
new CopyPlugin([ new CopyPlugin([
{ from: './src/server/', to: './' }, { from: './src/server/farm.scm', to: './[name].[ext]' },
{ from: './src/server/farm', to: './[name]' },
{ from: './assets/game/', to: './assets/game/' } { from: './assets/game/', to: './assets/game/' }
]), ]),
new webpack.LoaderOptionsPlugin({ new webpack.LoaderOptionsPlugin({

Loading…
Cancel
Save