From 0b540cd5ecf076e063864b9e4e74726fc11f044f Mon Sep 17 00:00:00 2001 From: James Ketrenos Date: Thu, 3 Mar 2022 18:14:44 -0800 Subject: [PATCH] Fixed broken trading with bank Signed-off-by: James Ketrenos --- client/src/Trade.js | 11 ++++++++--- client/src/ViewCard.js | 4 ++-- server/routes/games.js | 6 +++++- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/client/src/Trade.js b/client/src/Trade.js index 3b899b4..8f54ee6 100644 --- a/client/src/Trade.js +++ b/client/src/Trade.js @@ -104,7 +104,11 @@ const Trade = ({table}) => { const canMeetOffer = (player, offer) => { for (let i = 0; i < offer.gets.length; i++) { const get = offer.gets[i]; - if (player[get.type] < get.count) { + if (get.type === 'bank') { + if (player[player.gives[0].type] < get.count) { + return false; + } + } else if (player[get.type] < get.count) { return false; } } @@ -291,6 +295,7 @@ const Trade = ({table}) => { if (item.self) { /* Order direction is reversed for self */ source = { + name: item.name, gets: trade.gives, gives: trade.gets }; @@ -298,11 +303,11 @@ const Trade = ({table}) => { source = item; } const _gets = source.gets.length ? source.gets.map((get, index) =>
- { get.type === 'bank' &&
4 of any resource
} + { get.type === 'bank' &&
4 of any resource
} { get.type !== 'bank' && }
) : 'nothing', _gives = source.gives.length ? source.gives.map((give, index) =>
- { give.type === '*' && <>1 of any resource} + { give.type === '*' && <>1 of any resource } { give.type !== '*' && }
) : 'nothing'; diff --git a/client/src/ViewCard.js b/client/src/ViewCard.js index 0aaa53a..6753f80 100644 --- a/client/src/ViewCard.js +++ b/client/src/ViewCard.js @@ -60,8 +60,8 @@ const ViewCard = ({table, card}) => { 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. +

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.

; break; case 'progress-year-of-plenty': diff --git a/server/routes/games.js b/server/routes/games.js index 8b621f2..68d76f9 100755 --- a/server/routes/games.js +++ b/server/routes/games.js @@ -1299,7 +1299,11 @@ const getValidRoads = (game, color) => { const canMeetOffer = (player, offer) => { for (let i = 0; i < offer.gets.length; i++) { const get = offer.gets[i]; - if (player[get.type] < get.count) { + if (get.type === 'bank') { + if (player[player.gives[0].type] < get.count) { + return false; + } + } else if (player[get.type] < get.count) { return false; } }