diff --git a/client/package.json b/client/package.json index 54e7db0..c945364 100644 --- a/client/package.json +++ b/client/package.json @@ -4,8 +4,13 @@ "private": true, "proxy": "http://localhost:8930", "dependencies": { + "@emotion/react": "^11.8.1", + "@emotion/styled": "^11.8.1", "@material-ui/core": "^4.12.3", "@material-ui/lab": "^4.0.0-alpha.60", + "@mui/icons-material": "^5.4.4", + "@mui/material": "^5.4.4", + "@mui/utils": "^5.4.4", "@testing-library/jest-dom": "^5.16.1", "@testing-library/react": "^12.1.2", "@testing-library/user-event": "^13.5.0", diff --git a/client/src/Activities.js b/client/src/Activities.js index 633e810..cd46503 100644 --- a/client/src/Activities.js +++ b/client/src/Activities.js @@ -63,8 +63,8 @@ const Activities = ({ table }) => { normalPlay = (game.state === 'initial-placement' || game.state === 'normal'), mustDiscard = game.player ? parseInt(game.player.mustDiscard ? game.player.mustDiscard : 0) : 0, mustPlaceRobber = (game.turn && !game.turn.placedRobber && game.turn.robberInAction), - isInitialPlacement = (game.state === 'initial-placement'), - placeRoad = isInitialPlacement && game.turn && game.turn.actions && game.turn.actions.indexOf('place-road') !== -1, + placement = (game.state === 'initial-placement' || game.turn.active === 'road-building'), + placeRoad = placement && game.turn && game.turn.actions && game.turn.actions.indexOf('place-road') !== -1, mustStealResource = game.turn && game.turn.actions && game.turn.actions.indexOf('steal-resource') !== -1; const list = game.activities @@ -86,7 +86,7 @@ const Activities = ({ table }) => {
Steal 1 resource card from the owner of an adjacent settlement or city.
You may only play one development card during your turn -- either one - knight or one progress card.
>, - vp: <>1 victory point. + knight or one progress card.>; + break; + case 'vp': + description = <>1 victory point.You only reveal your victory point cards when the game is over, either when you or an opponent reaches 10+ victory points on their turn and declares - victory!
>, - 'progress-road-1': <> + victory!>; + break; + case 'progress-road-1': + case 'progress-road-2': + description = <>Play 2 new roads as if you had just built them.
-This is still limited by the number of roads you have (a maximum of 15.)
-NOTE: This card is not yet implemented. The server will give you 2 wood - and 2 brick and we trust you will use them to build 2 roads.
-If - you do not have enough roads remaining, you may end up with extra resources... - but the game is in beta, so... be happy :) -
-As an FYI, you currently have {15 - table.game.player.roads} roads remaining.
- >, - 'progress-road-2': <> -Play 2 new roads as if you had just built them.
-This is still limited by the number of roads you have (a maximum of 15.)
-NOTE: This card is not yet implemented. The server will give you 2 wood - and 2 brick and we trust you will use them to build 2 roads.
-If - you do not have enough roads remaining, you may end up with extra resources... - but the game is in beta, so... be happy :) -
-As an FYI, you currently have {15 - table.game.player.roads} roads remaining.
- >, - 'progress-monopoly': <> +This is still limited by the number of roads you have. If you do not have enough roads + remaining, or if there are no valid road building locations, the number of roads + you can place will be reduced.
+You currently have {table.game.player.roads} roads remaining.
+ >; + break; + case 'progress-monopoly': + description = <> When you play this card, you will select 1 type of resource. All other players must give you all their resource cards of that type. - >, - 'progress-year-of-plenty': <> - Take any 2 resources from the bank. Add them to your hand. They can be - 2 of the same resource or 2 different resources. -Unfortunately the current implementation only lets you pick a single - resource and you will then get 2 of those.
- > + >; + break; + case 'progress-year-of-plenty': + description = <> + Take any 2 resources from the bank. Add them to your hand. They can be + 2 of the same resource or 2 different resources. +Unfortunately the current implementation only lets you pick a single + resource and you will then get 2 of those.
+ >; + break; }; - let description; - if (card.type == 'progress') { - description = descriptions[`${card.type}-${card.card}`]; - } else { - description = descriptions[card.type]; - } - if (description === undefined) { console.log(`No description for ${card.type}-${card.card}`); } diff --git a/server/routes/games.js b/server/routes/games.js index 873551e..4cd0236 100755 --- a/server/routes/games.js +++ b/server/routes/games.js @@ -1598,7 +1598,7 @@ router.put("/:id/:action/:value?", async (req, res) => { } game.turn.offer = offer; } -// addActivity(game, session, `${session.name} submitted an offer to give ${offerToString(offer)}.`); + addActivity(game, session, `${session.name} submitted an offer to give ${offerToString(offer)}.`); break; } @@ -1674,8 +1674,8 @@ router.put("/:id/:action/:value?", async (req, res) => { player[item.type] -= item.count; }); - addChatMessage(game, session, `${session.name} has accepted a trade ` + - `offer to give ${offerToString(session.player)} ` + + addChatMessage(game, session, `${session.name} traded ` + + ` ${offerToString(session.player)} ` + `from ${(offer.name === 'The bank') ? 'the bank' : offer.name}.`); delete game.turn.offer; @@ -1923,10 +1923,21 @@ router.put("/:id/:action/:value?", async (req, res) => { switch (card.card) { case 'road-1': case 'road-2': - addActivity(game, session, `${session.name} played a Road Building card. The server is giving them 2 brick and 2 wood to build those roads!`); - addChatMessage(game, session, `${server.name} received 2 wood, 2 brick from the bank.`); - player.brick += 2; - player.wood += 2; + const allowed = Math.min(player.roads, 2); + if (!allowed) { + addActivity(game, session, `${session.name} played a Road Building card, but has no roads to build.`); + break; + } + let roads = getValidRoads(game, session.color); + if (roads.length === 0) { + addActivity(game, session, `${session.name} played a Road Building card, but they do not have any valid locations to place them.`); + break; + } + game.turn.active = 'road-building'; + game.turn.free = true; + game.turn.freeRoads = allowed; + addActivity(game, session, `${session.name} played a Road Building card. They now place ${allowed} roads for free.`); + placeRoad(game, roads); break; case 'monopoly': game.turn.actions = [ 'select-resource' ]; @@ -2369,18 +2380,39 @@ router.put("/:id/:action/:value?", async (req, res) => { player.roads--; if (!game.turn.free) { - addChatMessage(game, session, `${session.name} spent 1 brick, 1 wood to purchase a road.`) + addChatMessage(game, session, `${name} spent 1 brick, 1 wood to purchase a road.`) player.brick--; player.wood--; } - delete game.turn.free; + debugChat(game, 'After road purchase'); + road.color = session.color; - game.turn.actions = []; - game.turn.limits = {}; addActivity(game, session, `${name} placed a road.`); calculateRoadLengths(game, session); + if (game.turn.active === 'road-building') { + game.turn.freeRoads--; + if (game.turn.freeRoads === 0) { + delete game.turn.free; + delete game.turn.active; + delete game.turn.freeRaods; + } + + let roads = getValidRoads(game, session.color); + if (roads.length === 0) { + delete game.turn.active; + delete game.turn.freeRaods; + addActivity(game, session, `${name} has another road to play, but there are no more valid locations.`); + } else if (game.turn.freeRoads !== 0) { + game.turn.free = true; + placeRoad(game, roads); + break; /* do not reset actions or limits -- player has another road to place! */ + } + } + delete game.turn.free; + game.turn.actions = []; + game.turn.limits = {}; } else if (game.state === 'initial-placement') { road.color = session.color; addActivity(game, session, `${name} placed a road.`);