Compare commits
1 Commits
leave-game
...
leave-game
| Author | SHA1 | Date | |
|---|---|---|---|
| b947c646cf |
@@ -40,4 +40,3 @@ 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'
|
export const SET_MOVING_SKIP = 'set-moving-skip'
|
||||||
export const SERVER_ERROR = 'server-error'
|
export const SERVER_ERROR = 'server-error'
|
||||||
export const REMOVE_PLAYER = 'remove-player'
|
|
||||||
|
|||||||
@@ -21,14 +21,14 @@ import { UPDATE_GAME, UPDATE_PLAYER, GAME_STATE, SET_SELECTED_CARD, SET_CARDS,
|
|||||||
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,
|
AUTO_SKIP, MESSAGE, SET_HARVEST_TABLE, SET_CARD_ERROR,
|
||||||
SET_MOVING_SKIP, SERVER_ERROR, REMOVE_PLAYER } from './actionTypes.js'
|
SET_MOVING_SKIP, SERVER_ERROR } 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, setMovingSkip,
|
autoSkip, message, setHarvestTable, setCardError, setMovingSkip,
|
||||||
serverError, removePlayer }
|
serverError }
|
||||||
|
|
||||||
function updateGame(update) {
|
function updateGame(update) {
|
||||||
return { type: UPDATE_GAME,
|
return { type: UPDATE_GAME,
|
||||||
@@ -96,11 +96,6 @@ function movePlayer(newSpace, oldSpace, player) {
|
|||||||
newSpace, oldSpace, player };
|
newSpace, oldSpace, player };
|
||||||
}
|
}
|
||||||
|
|
||||||
function removePlayer(color) {
|
|
||||||
return { type: REMOVE_PLAYER,
|
|
||||||
color };
|
|
||||||
}
|
|
||||||
|
|
||||||
function nextUIAction() {
|
function nextUIAction() {
|
||||||
return { type: NEXT_UI_ACTION };
|
return { type: NEXT_UI_ACTION };
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ 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,
|
autoSkip, message, alertHandled, setHarvestTable,
|
||||||
setCardError, setMovingSkip, serverError, removePlayer } from './actions.js'
|
setCardError, setMovingSkip, serverError } 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,
|
||||||
@@ -49,9 +49,6 @@ function handleMessage(evt) {
|
|||||||
if (data.event === 'left-game') {
|
if (data.event === 'left-game') {
|
||||||
window.location.href = window.location.pathname;
|
window.location.href = window.location.pathname;
|
||||||
}
|
}
|
||||||
if (data.event === 'player-left-game') {
|
|
||||||
store.dispatch(removePlayer(data.color));
|
|
||||||
}
|
|
||||||
if (data.game.state === GAME_STATES.preGame) {
|
if (data.game.state === GAME_STATES.preGame) {
|
||||||
store.dispatch(alert(ALERTS.preGame, '', 'pre-game'));
|
store.dispatch(alert(ALERTS.preGame, '', 'pre-game'));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import { UPDATE_GAME, UPDATE_PLAYER, GAME_STATE, SET_SELECTED_CARD, SET_CARDS,
|
|||||||
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,
|
AUTO_SKIP, MESSAGE, SET_HARVEST_TABLE, SET_CARD_ERROR,
|
||||||
SET_MOVING_SKIP, SERVER_ERROR, REMOVE_PLAYER } from './actionTypes.js'
|
SET_MOVING_SKIP, SERVER_ERROR } 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'
|
||||||
|
|
||||||
@@ -176,21 +176,6 @@ export default function(state = initialState, action) {
|
|||||||
[action.player]: action.newSpace }}
|
[action.player]: action.newSpace }}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
case REMOVE_PLAYER:
|
|
||||||
const playerSpace = state.ui.playerSpaces[action.color];
|
|
||||||
return { ...state,
|
|
||||||
spaces: state.spaces.map((item, index) => {
|
|
||||||
if (index === playerSpace) {
|
|
||||||
return { ...item,
|
|
||||||
players: item.players
|
|
||||||
.filter(x => x !== action.color) };
|
|
||||||
}
|
|
||||||
return item;
|
|
||||||
}),
|
|
||||||
ui: { ...state.ui,
|
|
||||||
playerSpaces: { ...state.ui.playerSpaces,
|
|
||||||
[action.player]: -1 }}
|
|
||||||
};
|
|
||||||
case SET_OLD_MESSAGES:
|
case SET_OLD_MESSAGES:
|
||||||
return { ...state, oldMessages: action.messages };
|
return { ...state, oldMessages: action.messages };
|
||||||
case MESSAGE_PANEL_SPACE:
|
case MESSAGE_PANEL_SPACE:
|
||||||
|
|||||||
@@ -1466,8 +1466,7 @@
|
|||||||
(when (not (null? (game-players (*game*))))
|
(when (not (null? (game-players (*game*))))
|
||||||
(safe-set! (game-current-player (*game*)) (car (game-players (*game*)))))
|
(safe-set! (game-current-player (*game*)) (car (game-players (*game*)))))
|
||||||
(db-remove-user-game (player-user-id (*player*)) (game-id (*game*)))
|
(db-remove-user-game (player-user-id (*player*)) (game-id (*game*)))
|
||||||
(message-players! (*game*) (*player*) `((color . ,(symbol->string (player-color (*player*)))))
|
(message-players! (*game*) (*player*) '() type: "left-game")
|
||||||
type: "player-left-game")
|
|
||||||
(create-ws-response (*player*) "left-game" '()))
|
(create-ws-response (*player*) "left-game" '()))
|
||||||
((string=? type "start-game")
|
((string=? type "start-game")
|
||||||
(safe-set! (game-state (*game*)) 'pre-turn)
|
(safe-set! (game-state (*game*)) 'pre-turn)
|
||||||
|
|||||||
Reference in New Issue
Block a user