-
+
+
@@ -1792,7 +2081,8 @@ class BoardApp extends React.Component {
export default connect(
state => state.farm,
- { setMessagePanelSpace, setMPDims, nextUIAction, movePlayer, alert, alertHandled, setCardError }
+ { setMessagePanelSpace, setMPDims, nextUIAction, movePlayer, alert, alertHandled,
+ setCardError, setMovingSkip }
)(BoardApp)
class Card extends React.Component {
@@ -1873,19 +2163,19 @@ class Card extends React.Component {
); break;
- case 'no-card': action =
+ case 'no-card': action =
(
); break;
}
return (
-
- {card.id}
-
- {this.props.hideBuying ? () : action}
-
+
+ {card.id}
+
+ {this.props.hideBuying ? () : action}
+
- );
+ );
}
}
@@ -1907,11 +2197,11 @@ class CardListComp extends React.Component {
));
return (
-
+
-
+
);
}
}
diff --git a/src/components/farm/actionTypes.js b/src/components/farm/actionTypes.js
index b31c71c..77d31af 100644
--- a/src/components/farm/actionTypes.js
+++ b/src/components/farm/actionTypes.js
@@ -38,3 +38,4 @@ export const ALERT_HANDLED = 'alert-handled'
export const AUTO_SKIP = 'auto-skip'
export const MESSAGE = 'message'
export const SET_HARVEST_TABLE = 'set-harvest-table'
+export const SET_MOVING_SKIP = 'set-moving-skip'
diff --git a/src/components/farm/actions.js b/src/components/farm/actions.js
index 2af7f2b..43a241e 100644
--- a/src/components/farm/actions.js
+++ b/src/components/farm/actions.js
@@ -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,
MP_MOUSE, SET_MP_DIMS, MARK_ACTION_CHANGE_HANDLED, SET_NEXT_ACTION,
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,
spacePushPlayer, spaceClearPlayers, setOldMessages, setMessagePanelSpace,
mpMouse, setMPDims, movePlayer, setNextAction, nextUIAction,
markActionChangeHandled, nextUIActionSilent, alert, alertHandled,
- autoSkip, message, setHarvestTable, setCardError }
+ autoSkip, message, setHarvestTable, setCardError, setMovingSkip }
function updateGame(update) {
return { type: UPDATE_GAME,
@@ -130,3 +131,7 @@ function message(message) {
function setHarvestTable(table) {
return { type: SET_HARVEST_TABLE, table };
}
+
+function setMovingSkip(skip) {
+ return { type: SET_MOVING_SKIP, skip };
+}
diff --git a/src/components/farm/interface.js b/src/components/farm/interface.js
index c7b29ad..59fd45e 100644
--- a/src/components/farm/interface.js
+++ b/src/components/farm/interface.js
@@ -24,7 +24,8 @@ import * as websocket from '../../websocket.js'
import { updateGame, updatePlayer, gameState, setSelectedCard, setCards,
movePlayer, setOldMessages, markActionChangeHandled,
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'
export { initialize, buy, roll, endTurn, loan, trade, submitTradeAccept,
@@ -189,7 +190,9 @@ function initialize(st, sc) {
let lastAction = false,
lastAutoSkip = false,
rollMessage = '',
- rollTimer = false;
+ rollTimer = false,
+ movingAction = { from: 99, to: 99 },
+ movingTimer = 0;
const unsubscribe = store.subscribe(
() => {
const state = store.getState();
@@ -265,6 +268,50 @@ function initialize(st, sc) {
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
diff --git a/src/components/farm/reducers.js b/src/components/farm/reducers.js
index 83808e8..cfe7eae 100644
--- a/src/components/farm/reducers.js
+++ b/src/components/farm/reducers.js
@@ -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_MP_DIMS, MOVE_PLAYER, SET_NEXT_ACTION, NEXT_UI_ACTION,
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 { spaceContent, corners } from 'game.js'
@@ -121,6 +122,7 @@ const initialState = {
unhandledAlert: false,
autoSkip: false,
playerSpaces: {},
+ movingSkip: false,
harvestTable: false },
spaces: spaces,
space: null,
@@ -219,6 +221,8 @@ export default function(state = initialState, action) {
return { ...state, ui: { ...state.ui, message: action.message }};
case SET_HARVEST_TABLE:
return { ...state, ui: { ...state.ui, harvestTable: action.table }};
+ case SET_MOVING_SKIP:
+ return { ...state, ui: { ...state.ui, movingSkip: action.skip }};
default:
return state;
}
diff --git a/src/server/farm.scm b/src/server/farm.scm
index be74496..c52dce4 100644
--- a/src/server/farm.scm
+++ b/src/server/farm.scm
@@ -584,6 +584,16 @@
(when (alist-ref ridge params)
(if (> (player-ridge player ridge) 0)
(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)
(alist-update ridge
(alist-ref ridge (player-ridges player))
@@ -591,6 +601,16 @@
(safe-set! (player-ridges player)
(alist-update ridge 0 (player-ridges player))))
(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)
(alist-update ridge
(alist-ref ridge (player-ridges originator))
@@ -1903,17 +1923,11 @@
;; TODO
;; make sure two players can't have the same name
;; info actions should look better
-;; you can get $50 from harvest
-;; moving bug 5 from oct 2 saw by player 2
-;; from harvest moon rolled 5
-;; finished
-;; infinite loop ((?action . end-game) (?value . #
))
+;; you can get $50 from operating expense
;; auto-skip loop
;; harvester / tractor don't say total price
;; mark spaces
-;; trade notification keeps popping up
-
-;; show harvest multiplier
+;; can't trade other player's ridge
diff --git a/src/style.scss b/src/style.scss
index 2732007..c602a94 100644
--- a/src/style.scss
+++ b/src/style.scss
@@ -268,8 +268,77 @@ $tab-margin: 0.3rem;
.player-trade-resources .resource-unit {
display: inline-block;
+ margin-bottom: 0.3rem;
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 {
position: absolute;
top: 10px;
@@ -305,6 +374,7 @@ $tab-margin: 0.3rem;
}
.resource-unit {
+ position: relative;
text-align: center;
margin-right: 0.5rem;
width: 40px;
@@ -313,6 +383,19 @@ $tab-margin: 0.3rem;
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 {
display: flex;
flex-direction: row; }
@@ -556,12 +639,17 @@ $tab-margin: 0.3rem;
max-height: 80vh;
@include breakpoint(medium down) {
flex-grow: 2;
+ max-width: 82vw;
}
@include breakpoint(large) {
width: 26rem;
}
}
+.trade-tab {
+ min-width: 26rem;
+}
+
.static-tab-container {
overflow-y: auto;
max-height: 80vh;
diff --git a/webpack.common.js b/webpack.common.js
index 5bd0cc7..33fc4b8 100644
--- a/webpack.common.js
+++ b/webpack.common.js
@@ -46,7 +46,8 @@ module.exports = {
chunkFilename: '[id].css',
}),
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/' }
]),
new webpack.LoaderOptionsPlugin({