1
0

Playing an Army activates robberInAction for active player to place Robber

Signed-off-by: James Ketrenos <james_eikona@ketrenos.com>
This commit is contained in:
James Ketrenos 2022-02-20 12:28:25 -08:00
parent ee3f96dc6f
commit 27cdcda2d4
2 changed files with 32 additions and 21 deletions

View File

@ -392,8 +392,7 @@ const Action = ({ table }) => {
player = game ? game.player : undefined, player = game ? game.player : undefined,
hasRolled = (game && game.turn && game.turn.roll) ? true : false, hasRolled = (game && game.turn && game.turn.roll) ? true : false,
isTurn = (game && game.turn && game.turn.color === game.color) ? true : false, isTurn = (game && game.turn && game.turn.color === game.color) ? true : false,
robberActions = (game && game.turn && game.turn.roll === 7 && robberActions = (game && game.turn && game.turn.robberInAction),
!game.turn.robberDone),
haveResources = player ? player.haveResources : false; haveResources = player ? player.haveResources : false;
return ( return (
@ -1057,6 +1056,13 @@ class Table extends React.Component {
table={this} table={this}
/> />
} }
{ game.largestArmy && game.largestArmy === game.color &&
<Placard
active={false}
type='largest-army'
table={this}
/>
}
<Placard <Placard
active={this.state.buildActive} active={this.state.buildActive}
disabled={!game || !game.turn || !game.turn.roll} disabled={!game || !game.turn || !game.turn.roll}

View File

@ -102,7 +102,7 @@ for (let i = 1; i <= 14; i++) {
}); });
} }
[ 'monopoly', 'road-1', 'road-2', 'yeard-of-plenty'].forEach(card => assetData.developmentCards.push({ [ 'monopoly', 'road-1', 'road-2', 'year-of-plenty'].forEach(card => assetData.developmentCards.push({
type: 'progress', type: 'progress',
card: card card: card
})); }));
@ -367,7 +367,7 @@ const processRoll = (game, dice) => {
game.turn.roll = game.dice[0] + game.dice[1]; game.turn.roll = game.dice[0] + game.dice[1];
if (game.turn.roll === 7) { if (game.turn.roll === 7) {
addChatMessage(game, null, `ROBBER! ${game.gender === 'female' ? 'Roberta' : 'Robert'} Robber Roberson!`); addChatMessage(game, null, `ROBBER! ${game.gender === 'female' ? 'Roberta' : 'Robert'} Robber Roberson!`);
game.turn.robberDone = false; game.turn.robberInAction = true;
delete game.turn.placedRobber; delete game.turn.placedRobber;
for (let id in game.sessions) { for (let id in game.sessions) {
const player = game.sessions[id].player; const player = game.sessions[id].player;
@ -1459,7 +1459,7 @@ router.put("/:id/:action/:value?", async (req, res) => {
/* If the current turn is a robber placement, and everyone has /* If the current turn is a robber placement, and everyone has
* discarded, set the limits for where the robber can be placed */ * discarded, set the limits for where the robber can be placed */
if (game.turn && game.turn.roll === 7 && !game.turn.robberDone) { if (game.turn && game.turn.robberInAction) {
error = `Robber is in action. Turn can not stop until all Robber tasks are resolved.`; error = `Robber is in action. Turn can not stop until all Robber tasks are resolved.`;
break; break;
} }
@ -1515,7 +1515,7 @@ router.put("/:id/:action/:value?", async (req, res) => {
addChatMessage(game, session, `${session.name} must select player to steal resource from.`); addChatMessage(game, session, `${session.name} must select player to steal resource from.`);
} else { } else {
game.turn.actions = []; game.turn.actions = [];
game.turn.robberDone = true; game.turn.robberInAction = false;
delete game.turn.limits; delete game.turn.limits;
addChatMessage(game, session, `The Robber was moved to a terrain with no other players.`); addChatMessage(game, session, `The Robber was moved to a terrain with no other players.`);
} }
@ -1552,7 +1552,7 @@ router.put("/:id/:action/:value?", async (req, res) => {
addChatMessage(game, session, addChatMessage(game, session,
`${session.name} randomly stole ${type} from ${playerNameFromColor(game, value)}.`); `${session.name} randomly stole ${type} from ${playerNameFromColor(game, value)}.`);
} }
game.turn.robberDone = true; game.turn.robberInAction = false;
break; break;
case 'buy-development': case 'buy-development':
@ -1569,7 +1569,7 @@ router.put("/:id/:action/:value?", async (req, res) => {
break; break;
} }
if (game.turn && game.turn.roll === 7 && !game.turn.robberDone) { if (game.turn && game.turn.robberInAction) {
error = `Robber is in action. You can not purchase until all Robber tasks are resolved.`; error = `Robber is in action. You can not purchase until all Robber tasks are resolved.`;
break; break;
} }
@ -1596,7 +1596,7 @@ router.put("/:id/:action/:value?", async (req, res) => {
case 'play-card': case 'play-card':
if (game.state !== 'normal') { if (game.state !== 'normal') {
error = `You cannot purchase a settlement unless the game is active.`; error = `You cannot play a development card unless the game is active.`;
break; break;
} }
if (session.color !== game.turn.color) { if (session.color !== game.turn.color) {
@ -1608,7 +1608,7 @@ router.put("/:id/:action/:value?", async (req, res) => {
break; break;
} }
if (game.turn && game.turn.roll === 7 && !game.turn.robberDone) { if (game.turn && game.turn.robberInAction) {
error = `Robber is in action. You can not play a card until all Robber tasks are resolved.`; error = `Robber is in action. You can not play a card until all Robber tasks are resolved.`;
break; break;
} }
@ -1650,15 +1650,20 @@ router.put("/:id/:action/:value?", async (req, res) => {
if (card.type === 'army') { if (card.type === 'army') {
player.army++; player.army++;
if (player.army > 2 &&
(!game.largestArmy || game.players[game.largestArmy].army < player.army)) {
if (game.largestArmy !== session.color) {
game.largestArmy = session.color;
addChatMessage(game, session, `${session.name} now has the largest army (${player.army})!`)
}
}
game.turn.robberInAction = true;
delete game.turn.placedRobber;
addChatMessage(game, session, `${session.name} must now move the robber.`);
} }
if (player.army > 2 &&
(!game.largestArmy || game.players[game.largestArmy].army < player.army)) {
if (game.largestArmy !== session.color) {
game.largestArmy = session.color;
addChatMessage(game, session, `${session.name} now has the largest army (${player.army})!`)
}
}
break; break;
case 'buy-settlement': case 'buy-settlement':
@ -1675,7 +1680,7 @@ router.put("/:id/:action/:value?", async (req, res) => {
break; break;
} }
if (game.turn && game.turn.roll === 7 && !game.turn.robberDone) { if (game.turn && game.turn.robberInAction) {
error = `Robber is in action. You can not purchase until all Robber tasks are resolved.`; error = `Robber is in action. You can not purchase until all Robber tasks are resolved.`;
break; break;
} }
@ -1808,7 +1813,7 @@ router.put("/:id/:action/:value?", async (req, res) => {
break; break;
} }
if (game.turn && game.turn.roll === 7 && !game.turn.robberDone) { if (game.turn && game.turn.robberInAction) {
error = `Robber is in action. You can not purchase until all Robber tasks are resolved.`; error = `Robber is in action. You can not purchase until all Robber tasks are resolved.`;
break; break;
} }
@ -1888,7 +1893,7 @@ router.put("/:id/:action/:value?", async (req, res) => {
break; break;
} }
if (game.turn && game.turn.roll === 7 && !game.turn.robberDone) { if (game.turn && game.turn.robberInAction) {
error = `Robber is in action. You can not purchase until all Robber tasks are resolved.`; error = `Robber is in action. You can not purchase until all Robber tasks are resolved.`;
break; break;
} }
@ -2118,7 +2123,7 @@ const sendGame = async (req, res, game, error) => {
/* If the current turn is a robber placement, and everyone has /* If the current turn is a robber placement, and everyone has
* discarded, set the limits for where the robber can be placed */ * discarded, set the limits for where the robber can be placed */
if (game.turn && game.turn.roll === 7) { if (game.turn && game.turn.robberInAction) {
let move = true; let move = true;
for (let color in game.players) { for (let color in game.players) {
const discard = game.players[color].mustDiscard; const discard = game.players[color].mustDiscard;