From dbacb5d4da09310d438a5f2665c64b959554277b Mon Sep 17 00:00:00 2001 From: James Ketrenos Date: Sun, 6 Mar 2022 17:56:40 -0800 Subject: [PATCH] Sort players in trade as Negotiator, Self, then rest alphabetically Signed-off-by: James Ketrenos --- client/src/Trade.css | 6 +++--- client/src/Trade.js | 29 +++++++++++++++++++++++------ 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/client/src/Trade.css b/client/src/Trade.css index e71d59d..7af5714 100644 --- a/client/src/Trade.css +++ b/client/src/Trade.css @@ -139,7 +139,7 @@ .Trade .Transfers .GiveGet div:nth-child(1) { position: absolute; top: 0; - border: 1px solid white; + border: 1px solid #888; background-color: rgb(36, 148, 46); color: white; border-radius: 0.25rem; @@ -151,7 +151,7 @@ .Trade .Transfers .GiveGet div:nth-child(2) { position: absolute; top: 7.5rem; - border: 1px solid white; + border: 1px solid #888; background-color: rgb(36, 148, 46); color: white; border-radius: 0.25rem; @@ -162,7 +162,7 @@ .Trade .Transfers .GiveGet div:last-child { position: absolute; - border: 1px solid #f0f0f0; + border: 1px solid #888; background-color: #444; color: white; font-size: 1rem; diff --git a/client/src/Trade.js b/client/src/Trade.js index d9f5b2b..6bc66f0 100644 --- a/client/src/Trade.js +++ b/client/src/Trade.js @@ -240,6 +240,7 @@ const Trade = ({table}) => { } const tmp = { + negotiator: table.game.turn.name === name, self: table.game.name === name, name: name, color: color, @@ -250,11 +251,27 @@ const Trade = ({table}) => { }; tmp.canSubmit = (tmp.gets.length && tmp.gives.length); - + players.push(tmp); } players.sort((A, B) => { + if (A.negotiator) { + return -1; + } + + if (B.negotiator) { + return +1; + } + + if (A.self) { + return -1; + } + + if (B.self) { + return +1; + } + return A.name.localeCompare(B.name); }); @@ -365,7 +382,7 @@ const Trade = ({table}) => { } { !youWereRejected && _gets === 'nothing' && _gives === 'nothing' && - You have not s a trade offer. + You have not made a trade offer. } { !isTurn && isSameOffer && isOfferValid && _gets !== 'nothing' && _gives !== 'nothing' && @@ -379,7 +396,7 @@ const Trade = ({table}) => { } { !isBank && <> - { isTurn && !isSameOffer && isOfferValid && _gets !== 'nothing' && _gives !== 'nothing' && + { isTurn && !isSameOffer && isOfferValid && !youRejectedOffer && _gets !== 'nothing' && _gives !== 'nothing' && This is a counter offer. } @@ -387,7 +404,7 @@ const Trade = ({table}) => { {item.name} will meet your terms. } - { (_gets === 'nothing' || _gives === 'nothing') && + { (!isTurn || !youWereRejected) && (_gets === 'nothing' || _gives === 'nothing') && {item.name} has not submitted a trade offer. } @@ -412,9 +429,9 @@ const Trade = ({table}) => { onClick={() => agreeClicked(item)}>agree } - { item.name !== 'The bank' && !item.self && + { item.name !== 'The bank' && !item.self && (isTurn || item.name === table.game.turn.name) && }