1
0

Sort players in trade as Negotiator, Self, then rest alphabetically

Signed-off-by: James Ketrenos <james_eikona@ketrenos.com>
This commit is contained in:
James Ketrenos 2022-03-06 17:56:40 -08:00
parent 1a334721a4
commit dbacb5d4da
2 changed files with 26 additions and 9 deletions

View File

@ -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;

View File

@ -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}) => {
</span> }
{ !youWereRejected && _gets === 'nothing' && _gives === 'nothing' && <span>
You have not s a trade offer.
You have not made a trade offer.
</span>}
{ !isTurn && isSameOffer && isOfferValid && _gets !== 'nothing' && _gives !== 'nothing' && <span style={{fontWeight: 'bold'}}>
@ -379,7 +396,7 @@ const Trade = ({table}) => {
</span> }
{ !isBank && <>
{ isTurn && !isSameOffer && isOfferValid && _gets !== 'nothing' && _gives !== 'nothing' && <span style={{fontWeight: 'bold'}}>
{ isTurn && !isSameOffer && isOfferValid && !youRejectedOffer && _gets !== 'nothing' && _gives !== 'nothing' && <span style={{fontWeight: 'bold'}}>
This is a counter offer.
</span> }
@ -387,7 +404,7 @@ const Trade = ({table}) => {
{item.name} will meet your terms.
</span> }
{ (_gets === 'nothing' || _gives === 'nothing') && <span>
{ (!isTurn || !youWereRejected) && (_gets === 'nothing' || _gives === 'nothing') && <span>
{item.name} has not submitted a trade offer.
</span> }
@ -412,9 +429,9 @@ const Trade = ({table}) => {
onClick={() => agreeClicked(item)}>agree</Button>
}
{ item.name !== 'The bank' && !item.self &&
{ item.name !== 'The bank' && !item.self && (isTurn || item.name === table.game.turn.name) &&
<Button disabled={!item.gets.length ||
!item.gives.length || youRejectedOffer}
!item.gives.length || youRejectedOffer }
onClick={() => rejectClicked(item)}>reject</Button>
}