Many updates.
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -20,6 +20,8 @@ import React from 'react'
|
||||
import { connect } from 'react-redux'
|
||||
|
||||
import PlayerIcon from './PlayerIcon.jsx'
|
||||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
|
||||
import { faCreditCard, faQuestionCircle } from '@fortawesome/free-solid-svg-icons'
|
||||
|
||||
import { setMessagePanelSpace, mpMouse } from './actions.js'
|
||||
|
||||
@@ -55,8 +57,10 @@ class SpaceNode extends React.Component {
|
||||
: (null)}
|
||||
{ this.props.space.players.length ? <PlayerIcon colors={this.props.space.players} /> : ''}
|
||||
<div className='space-description'>
|
||||
{this.props.space.description}
|
||||
</div>
|
||||
{this.props.space.description}
|
||||
</div>
|
||||
{this.props.showIcons && space.card === 'otb' ? (<div className='space-icon'><FontAwesomeIcon icon={faCreditCard} /></div>) : (<></>)}
|
||||
{this.props.showIcons && space.card === 'fate' ? (<div className='space-icon'><FontAwesomeIcon icon={faQuestionCircle} /></div>) : (<></>)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -36,3 +36,4 @@ export const ALERT = 'alert'
|
||||
export const ALERT_HANDLED = 'alert-handled'
|
||||
export const AUTO_SKIP = 'auto-skip'
|
||||
export const MESSAGE = 'message'
|
||||
export const SET_HARVEST_TABLE = 'set-harvest-table'
|
||||
|
||||
@@ -20,13 +20,13 @@ 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 } from './actionTypes.js'
|
||||
AUTO_SKIP, MESSAGE, SET_HARVEST_TABLE } from './actionTypes.js'
|
||||
|
||||
export { updateGame, updatePlayer, gameState, setSelectedCard, setCards,
|
||||
spacePushPlayer, spaceClearPlayers, setOldMessages, setMessagePanelSpace,
|
||||
mpMouse, setMPDims, movePlayer, setNextAction, nextUIAction,
|
||||
markActionChangeHandled, nextUIActionSilent, alert, alertHandled,
|
||||
autoSkip, message }
|
||||
autoSkip, message, setHarvestTable }
|
||||
|
||||
function updateGame(update) {
|
||||
return { type: UPDATE_GAME,
|
||||
@@ -107,12 +107,12 @@ function markActionChangeHandled() {
|
||||
return { type: MARK_ACTION_CHANGE_HANDLED };
|
||||
}
|
||||
|
||||
function alert(value, contents) {
|
||||
return { type: ALERT, value, contents };
|
||||
function alert(value, contents, id) {
|
||||
return { type: ALERT, value, contents, id };
|
||||
}
|
||||
|
||||
function alertHandled() {
|
||||
return { type: ALERT_HANDLED };
|
||||
function alertHandled(id) {
|
||||
return { type: ALERT_HANDLED, id };
|
||||
}
|
||||
|
||||
function autoSkip(component) {
|
||||
@@ -122,3 +122,7 @@ function autoSkip(component) {
|
||||
function message(message) {
|
||||
return { type: MESSAGE, message };
|
||||
}
|
||||
|
||||
function setHarvestTable(table) {
|
||||
return { type: SET_HARVEST_TABLE, table };
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ import * as websocket from '../../websocket.js'
|
||||
import { updateGame, updatePlayer, gameState, setSelectedCard, setCards,
|
||||
movePlayer, setOldMessages, markActionChangeHandled,
|
||||
mpMouse, rolled, setNextAction, nextUIAction, nextUIActionSilent, alert,
|
||||
autoSkip, message, alertHandled } from './actions.js'
|
||||
autoSkip, message, alertHandled, setHarvestTable } from './actions.js'
|
||||
import { itemCard, fateCard } from 'game.js'
|
||||
|
||||
export { initialize, buy, roll, endTurn, loan, trade, submitTradeAccept,
|
||||
@@ -47,12 +47,16 @@ function handleMessage(evt) {
|
||||
if (data.player.state === GAME_STATES.preTurn &&
|
||||
data.game.otherPlayers.length > 0 &&
|
||||
store.getState().farm.player.state !== GAME_STATES.preTurn) {
|
||||
store.dispatch(alert(ALERTS.beginTurn));
|
||||
store.dispatch(alert(ALERTS.beginTurn, '', 'beginTurn' + data.game.turn));
|
||||
}
|
||||
if (data.game.calledAudit && !store.getState().farm.game.calledAudit) {
|
||||
store.dispatch(alert(ALERTS.auditCalled, data.game.calledAudit,
|
||||
'auditCalled' + data.game.turn));
|
||||
}
|
||||
if (data.player.trade.player && data.player.trade.originator !== data.player.name) {
|
||||
store.dispatch(alert(ALERTS.proposedTrade, data.player.trade.originator,
|
||||
'tradeProposed' + data.player.trade.number));
|
||||
}
|
||||
// else if (data.game.otherPlayers.length > 0 &&
|
||||
// data.game.currentPlayer !== store.getState().farm.game.currentPlayer) {
|
||||
// store.dispatch(alert(ALERTS.otherPlayersTurn));
|
||||
// }
|
||||
// new turn clear actions
|
||||
if (data.event === 'update' &&
|
||||
data.game.currentPlayer !== store.getState().farm.game.currentPlayer) {
|
||||
@@ -62,6 +66,7 @@ function handleMessage(evt) {
|
||||
store.dispatch(updatePlayer(data.player));
|
||||
if (data.event === 'init') {
|
||||
store.dispatch(movePlayer(data.player.space, 0, data.player.color));
|
||||
store.dispatch(setHarvestTable(data.harvestTable));
|
||||
}
|
||||
// new player(s) added to game, put them on the board
|
||||
if (data.game.otherPlayers.length !== store.getState().farm.game.otherPlayers.length) {
|
||||
@@ -75,11 +80,6 @@ function handleMessage(evt) {
|
||||
const oldMessages = store.getState().farm.game.messages.slice(0, 20);
|
||||
store.dispatch(updateGame(data.game));
|
||||
store.dispatch(setOldMessages(oldMessages));
|
||||
if (data.player.cards.length > 0) {
|
||||
store.dispatch(setSelectedCard(data.player.cards[0]));
|
||||
} else {
|
||||
store.dispatch(setSelectedCard());
|
||||
}
|
||||
store.dispatch(setCards(data.player.cards));
|
||||
if (data.event === 'action') {
|
||||
if (data.player.name !== data.game.currentPlayer &&
|
||||
@@ -94,15 +94,25 @@ function handleMessage(evt) {
|
||||
if (data.player.state === GAME_STATES.midTurn &&
|
||||
data.player.cash < 0 &&
|
||||
!store.getState().farm.ui.nextAction) {
|
||||
store.dispatch(alert(ALERTS.raiseMoney));
|
||||
} else if (data.player.state === GAME_STATES.midTurn) {
|
||||
store.dispatch(alertHandled());
|
||||
}
|
||||
store.dispatch(alert(ALERTS.raiseMoney, '', 'raiseMoney' + data.game.turn));
|
||||
}// else if (data.player.state === GAME_STATES.midTurn &&
|
||||
// !data.game.state === 'finished') {
|
||||
// store.dispatch(alertHandled());
|
||||
// }
|
||||
if (data.event === 'auto-skip') {
|
||||
store.dispatch(autoSkip(data.component));
|
||||
}
|
||||
if (data.event === 'end-of-game') {
|
||||
store.dispatch(alert(ALERTS.endOfGame, data.results));
|
||||
store.dispatch(alert(ALERTS.endOfGame, data.results, 'endOfGame' + data.game.turn));
|
||||
}
|
||||
if (data.event === 'action' && data.action === false) {
|
||||
const playerSpaces = store.getState().farm.ui.playerSpaces;
|
||||
data.game.otherPlayers.map(x => x.player).concat([data.player]).forEach(player => {
|
||||
if (player.space !== playerSpaces[player.color]) {
|
||||
store.dispatch(movePlayer(player.space, playerSpaces[player.color],
|
||||
player.color));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -21,62 +21,63 @@ 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 } from './actionTypes.js'
|
||||
AUTO_SKIP, MESSAGE, SET_HARVEST_TABLE } from './actionTypes.js'
|
||||
import { GAME_STATES } from '../../constants.js'
|
||||
import { spaceContent, corners } from 'game.js'
|
||||
|
||||
const spaces =
|
||||
[[corners[0], 'buy'],
|
||||
['January', 'buy'],
|
||||
['January', 'buy'],
|
||||
['January', 'buy'],
|
||||
['January', 'buy'],
|
||||
['February','buy'],
|
||||
['February', 'buy'],
|
||||
['February', 'buy'],
|
||||
['February', 'buy'],
|
||||
['March', 'buy'],
|
||||
['March', 'buy'],
|
||||
['March', 'buy'],
|
||||
['March', 'buy'],
|
||||
['April', 'buy'],
|
||||
[corners[1], 'buy'],
|
||||
['April', 'none'],
|
||||
['April', 'none'],
|
||||
['May', 'none'],
|
||||
['May', 'none'],
|
||||
['May', 'hay'],
|
||||
['May', 'hay'],
|
||||
['June', 'hay'],
|
||||
['June', 'hay'],
|
||||
['June', 'cherry'],
|
||||
['June', 'cherry'],
|
||||
[corners[2], 'cherry'],
|
||||
['July', 'hay'],
|
||||
['July', 'hay'],
|
||||
['July', 'hay'],
|
||||
['July', 'wheat'],
|
||||
['August', 'wheat'],
|
||||
['August', 'wheat'],
|
||||
['August', 'wheat'],
|
||||
['August', 'wheat'],
|
||||
['September', 'hay'],
|
||||
['September', 'hay'],
|
||||
['September', 'cows'],
|
||||
[corners[3], 'cows'],
|
||||
['September', 'cows'],
|
||||
['October', 'cows'],
|
||||
['October', 'hay'],
|
||||
['October', 'hay'],
|
||||
['October', 'apple'],
|
||||
['November', 'apple'],
|
||||
['November', 'apple'],
|
||||
['November', 'apple'],
|
||||
['November', 'corn'],
|
||||
['December', 'corn'],
|
||||
['December', 'corn']]
|
||||
[[corners[0], 'buy', false],
|
||||
['January', 'buy', false],
|
||||
['January', 'buy', 'otb'],
|
||||
['January', 'buy', false],
|
||||
['January', 'buy', false],
|
||||
['February','buy', false],
|
||||
['February', 'buy', 'fate'],
|
||||
['February', 'buy', false],
|
||||
['February', 'buy', 'otb'],
|
||||
['March', 'buy', false],
|
||||
['March', 'buy', false],
|
||||
['March', 'buy', false],
|
||||
['March', 'buy', false],
|
||||
['April', 'buy', 'otb'],
|
||||
[corners[1], 'buy', false],
|
||||
['April', 'none', false],
|
||||
['April', 'none', false],
|
||||
['May', 'none', false],
|
||||
['May', 'none', false],
|
||||
['May', 'hay', false],
|
||||
['May', 'hay', 'otb'],
|
||||
['June', 'hay', false],
|
||||
['June', 'hay', false],
|
||||
['June', 'cherry', false],
|
||||
['June', 'cherry', 'fate'],
|
||||
[corners[2], 'cherry', false],
|
||||
['July', 'hay', false],
|
||||
['July', 'hay', 'otb'],
|
||||
['July', 'hay', false],
|
||||
['July', 'wheat', false],
|
||||
['August', 'wheat', false],
|
||||
['August', 'wheat', false],
|
||||
['August', 'wheat', false],
|
||||
['August', 'wheat', false],
|
||||
['September', 'hay', false],
|
||||
['September', 'hay', 'otb'],
|
||||
['September', 'cows', false],
|
||||
[corners[3], 'cows', false],
|
||||
['September', 'cows', false],
|
||||
['October', 'cows', false],
|
||||
['October', 'hay', 'fate'],
|
||||
['October', 'hay', 'otb'],
|
||||
['October', 'apple', 'fate'],
|
||||
['November', 'apple', 'otb'],
|
||||
['November', 'apple', false],
|
||||
['November', 'apple', false],
|
||||
['November', 'corn', false],
|
||||
['December', 'corn', false],
|
||||
['December', 'corn', 'fate']]
|
||||
.map((s, i) => {
|
||||
return { month: s[0], description: spaceContent[i],
|
||||
card: s[2],
|
||||
type: s[1], key: i, players: [] }});
|
||||
|
||||
const initialState = {
|
||||
@@ -112,10 +113,11 @@ const initialState = {
|
||||
nextActionValue: null,
|
||||
actionChangeHandled: true,
|
||||
message: '',
|
||||
alert: false,
|
||||
alertContents: false,
|
||||
alerts: {},
|
||||
unhandledAlert: false,
|
||||
autoSkip: false,
|
||||
alertHandled: false },
|
||||
playerSpaces: {},
|
||||
harvestTable: false },
|
||||
spaces: spaces,
|
||||
space: null,
|
||||
// message panel dimenions
|
||||
@@ -150,7 +152,10 @@ export default function(state = initialState, action) {
|
||||
.filter(x => x !== action.player) };
|
||||
}
|
||||
return item;
|
||||
})
|
||||
}),
|
||||
ui: { ...state.ui,
|
||||
playerSpaces: { ...state.ui.playerSpaces,
|
||||
[action.player]: action.newSpace }}
|
||||
};
|
||||
case SET_OLD_MESSAGES:
|
||||
return { ...state, oldMessages: action.messages };
|
||||
@@ -179,16 +184,34 @@ export default function(state = initialState, action) {
|
||||
case MARK_ACTION_CHANGE_HANDLED:
|
||||
return { ...state, ui: { ...state.ui, actionChangeHandled: true }};
|
||||
case ALERT:
|
||||
let alerts = { ...state.ui.alerts,
|
||||
[action.id]: { type: action.value,
|
||||
id: action.id,
|
||||
contents: action.contents,
|
||||
handled: false }
|
||||
};
|
||||
return { ...state, ui: { ...state.ui,
|
||||
alert: action.value,
|
||||
alertContents: action.contents,
|
||||
alertHandled: action.value === false ? true : false }};
|
||||
alerts,
|
||||
unhandledAlert: Object.values(alerts).find(x => !x.handled)
|
||||
}
|
||||
};
|
||||
case ALERT_HANDLED:
|
||||
return { ...state, ui: { ...state.ui, alertHandled: true }};
|
||||
alerts = { ...state.ui.alerts,
|
||||
[action.id]: { ...state.ui.alerts[action.id],
|
||||
handled: true
|
||||
}
|
||||
};
|
||||
return { ...state, ui: { ...state.ui,
|
||||
alerts,
|
||||
unhandledAlert: Object.values(alerts).find(x => !x.handled)
|
||||
}
|
||||
};
|
||||
case AUTO_SKIP:
|
||||
return { ...state, ui: { ...state.ui, autoSkip: action.component }};
|
||||
case MESSAGE:
|
||||
return { ...state, ui: { ...state.ui, message: action.message }};
|
||||
case SET_HARVEST_TABLE:
|
||||
return { ...state, ui: { ...state.ui, harvestTable: action.table }};
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
|
||||
@@ -57,19 +57,23 @@ class NewGame extends React.Component {
|
||||
checkedColor: props.colors[0],
|
||||
gameId: typeof props.gameId === 'undefined' ? -1 : props.gameId,
|
||||
gameName: props.gameName || '',
|
||||
downPayment: 0.2,
|
||||
loanInterest: 0.2,
|
||||
downPayment: 0,
|
||||
loanInterest: 0,
|
||||
maxDebt: 50000,
|
||||
auditThreshold: 250000,
|
||||
startingCash: 5000,
|
||||
startingDebt: 5000
|
||||
startingDebt: 5000,
|
||||
trade: true
|
||||
};
|
||||
}
|
||||
|
||||
handleInputChange = e => {
|
||||
const target = e.target,
|
||||
value = target.type === 'checkbox' ? target.name : target.value,
|
||||
name = target.type === 'checkbox' ? 'checkedColor' : target.name;
|
||||
value = target.type === 'checkbox' && target.name !== 'trade'
|
||||
? target.name : target.value,
|
||||
|
||||
name = target.type === 'checkbox' && target.name !== 'trade'
|
||||
? 'checkedColor' : target.name;
|
||||
|
||||
this.setState({
|
||||
[name]: value
|
||||
@@ -183,6 +187,17 @@ class NewGame extends React.Component {
|
||||
step={1000}
|
||||
value={this.state.startingDebt}
|
||||
onChange={this.handleInputChange} />
|
||||
<Row>
|
||||
<Col width='12'>
|
||||
<label>
|
||||
<input type='checkbox'
|
||||
checked={this.state.trade}
|
||||
onChange={this.handleInputChange}
|
||||
name='trade' />
|
||||
Enable Trading
|
||||
</label>
|
||||
</Col>
|
||||
</Row>
|
||||
</div>
|
||||
<Row>
|
||||
<Col width='12'>
|
||||
|
||||
Reference in New Issue
Block a user