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_MOVING_SKIP = 'set-moving-skip'
|
||||
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,
|
||||
MOVE_PLAYER, NEXT_UI_ACTION, NEXT_UI_ACTION_SILENT, ALERT, ALERT_HANDLED,
|
||||
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,
|
||||
spacePushPlayer, spaceClearPlayers, setOldMessages, setMessagePanelSpace,
|
||||
mpMouse, setMPDims, movePlayer, setNextAction, nextUIAction,
|
||||
markActionChangeHandled, nextUIActionSilent, alert, alertHandled,
|
||||
autoSkip, message, setHarvestTable, setCardError, setMovingSkip,
|
||||
serverError, removePlayer }
|
||||
serverError }
|
||||
|
||||
function updateGame(update) {
|
||||
return { type: UPDATE_GAME,
|
||||
@@ -96,11 +96,6 @@ function movePlayer(newSpace, oldSpace, player) {
|
||||
newSpace, oldSpace, player };
|
||||
}
|
||||
|
||||
function removePlayer(color) {
|
||||
return { type: REMOVE_PLAYER,
|
||||
color };
|
||||
}
|
||||
|
||||
function nextUIAction() {
|
||||
return { type: NEXT_UI_ACTION };
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ import { updateGame, updatePlayer, gameState, setSelectedCard, setCards,
|
||||
movePlayer, setOldMessages, markActionChangeHandled,
|
||||
mpMouse, rolled, setNextAction, nextUIAction, nextUIActionSilent, alert,
|
||||
autoSkip, message, alertHandled, setHarvestTable,
|
||||
setCardError, setMovingSkip, serverError, removePlayer } from './actions.js'
|
||||
setCardError, setMovingSkip, serverError } from './actions.js'
|
||||
import { itemCard, fateCard } from 'game.js'
|
||||
|
||||
export { initialize, buy, roll, endTurn, loan, trade, submitTradeAccept,
|
||||
@@ -49,9 +49,6 @@ function handleMessage(evt) {
|
||||
if (data.event === 'left-game') {
|
||||
window.location.href = window.location.pathname;
|
||||
}
|
||||
if (data.event === 'player-left-game') {
|
||||
store.dispatch(removePlayer(data.color));
|
||||
}
|
||||
if (data.game.state === GAME_STATES.preGame) {
|
||||
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,
|
||||
MARK_ACTION_CHANGE_HANDLED, NEXT_UI_ACTION_SILENT, ALERT, ALERT_HANDLED,
|
||||
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 { spaceContent, corners } from 'game.js'
|
||||
|
||||
@@ -176,21 +176,6 @@ export default function(state = initialState, action) {
|
||||
[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:
|
||||
return { ...state, oldMessages: action.messages };
|
||||
case MESSAGE_PANEL_SPACE:
|
||||
|
||||
@@ -1466,8 +1466,7 @@
|
||||
(when (not (null? (game-players (*game*))))
|
||||
(safe-set! (game-current-player (*game*)) (car (game-players (*game*)))))
|
||||
(db-remove-user-game (player-user-id (*player*)) (game-id (*game*)))
|
||||
(message-players! (*game*) (*player*) `((color . ,(symbol->string (player-color (*player*)))))
|
||||
type: "player-left-game")
|
||||
(message-players! (*game*) (*player*) '() type: "left-game")
|
||||
(create-ws-response (*player*) "left-game" '()))
|
||||
((string=? type "start-game")
|
||||
(safe-set! (game-state (*game*)) 'pre-turn)
|
||||
|
||||
Reference in New Issue
Block a user