Trading now lists bank offers
Signed-off-by: James Ketrenos <james_eikona@ketrenos.com>
This commit is contained in:
parent
d7191acec9
commit
f9b4c3699a
@ -408,7 +408,8 @@ const Action = ({ table }) => {
|
|||||||
const inLobby = table.game.state === 'lobby',
|
const inLobby = table.game.state === 'lobby',
|
||||||
player = table.game ? table.game.player : undefined,
|
player = table.game ? table.game.player : undefined,
|
||||||
hasRolled = (table.game && table.game.turn && table.game.turn.roll) ? true : false,
|
hasRolled = (table.game && table.game.turn && table.game.turn.roll) ? true : false,
|
||||||
isTurn = (table.game && table.game.turn && table.game.turn.color === table.game.color) ? true : false;
|
isTurn = (table.game && table.game.turn && table.game.turn.color === table.game.color) ? true : false,
|
||||||
|
robberActions = (table.game && table.game.turn && table.game.turn.roll === 7 && !table.game.turn.robberDone);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Paper className="Action">
|
<Paper className="Action">
|
||||||
@ -417,13 +418,13 @@ const Action = ({ table }) => {
|
|||||||
<Button disabled={table.game.color ? false : true} onClick={newTableClick}>New table</Button>
|
<Button disabled={table.game.color ? false : true} onClick={newTableClick}>New table</Button>
|
||||||
<Button disabled={table.game.color ? true : false} onClick={() => {table.setState({ pickName: true})}}>Change name</Button> </> }
|
<Button disabled={table.game.color ? true : false} onClick={() => {table.setState({ pickName: true})}}>Change name</Button> </> }
|
||||||
{ table.game.state === 'normal' && <>
|
{ table.game.state === 'normal' && <>
|
||||||
<Button disabled={!isTurn || hasRolled} onClick={rollClick}>Roll Dice</Button>
|
<Button disabled={robberActions || !isTurn || hasRolled} onClick={rollClick}>Roll Dice</Button>
|
||||||
<Button disabled={!isTurn || !hasRolled} onClick={tradeClick}>Trade</Button>
|
<Button disabled={robberActions || !isTurn || !hasRolled} onClick={tradeClick}>Trade</Button>
|
||||||
<Button disabled={!isTurn || !hasRolled} onClick={buildClicked}>Build</Button>
|
<Button disabled={robberActions || !isTurn || !hasRolled} onClick={buildClicked}>Build</Button>
|
||||||
{ table.game.turn.roll === 7 && player && player.mustDiscard > 0 &&
|
{ table.game.turn.roll === 7 && player && player.mustDiscard > 0 &&
|
||||||
<Button onClick={discardClick}>Discard</Button>
|
<Button onClick={discardClick}>Discard</Button>
|
||||||
}
|
}
|
||||||
<Button disabled={!isTurn || !hasRolled} onClick={passClick}>Done</Button>
|
<Button disabled={robberActions || !isTurn || !hasRolled} onClick={passClick}>Done</Button>
|
||||||
</> }
|
</> }
|
||||||
{ !inLobby &&
|
{ !inLobby &&
|
||||||
<Button onClick={quitClick}>Quit</Button>
|
<Button onClick={quitClick}>Quit</Button>
|
||||||
@ -613,7 +614,6 @@ class Table extends React.Component {
|
|||||||
return this.sendAction('chat', undefined, {message: message});
|
return this.sendAction('chat', undefined, {message: message});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
setPlayerName(name) {
|
setPlayerName(name) {
|
||||||
return this.sendAction('player-name', name)
|
return this.sendAction('player-name', name)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
margin: 0.5em 0;
|
margin: 0.5em 0;
|
||||||
}
|
}
|
||||||
.Trade > * {
|
.Trade > * {
|
||||||
width: 20em;
|
min-width: 40em;
|
||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
padding: 0.5em;
|
padding: 0.5em;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
@ -52,7 +52,15 @@
|
|||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
flex: 1;
|
flex: 1;
|
||||||
justify-content: space-between;
|
}
|
||||||
|
|
||||||
|
.TradeLine > div {
|
||||||
|
display: flex;
|
||||||
|
flex-grow: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.TradeLine > div > div {
|
||||||
|
margin-left: 0.25em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.TradeLine *:last-child {
|
.TradeLine *:last-child {
|
||||||
|
@ -31,17 +31,29 @@ const Trade = ({table}) => {
|
|||||||
|
|
||||||
if (isTurn && table.game.player && table.game.player.banks) {
|
if (isTurn && table.game.player && table.game.player.banks) {
|
||||||
table.game.player.banks.forEach(bank => {
|
table.game.player.banks.forEach(bank => {
|
||||||
players.push({ name: `Bank ${bank}`, color: undefined, gives: '1 *', gets: '2 wheat'});
|
const type = (bank === 'bank') ? 'of a kind' : bank,
|
||||||
|
count = (bank === 'bank') ? 3 : 2;
|
||||||
|
players.push({ name: `Bank`, color: undefined, gives: `1 of anything`, gets: `${count} ${type}`});
|
||||||
})
|
})
|
||||||
|
|
||||||
players.push({ name: `Bank`, color: undefined, gives: '1 *', gets: '3 *'})
|
players.push({ name: `Bank`, color: undefined, gives: '1 of anything', gets: '4 of a kind'})
|
||||||
}
|
}
|
||||||
|
|
||||||
players = players.map(item =>
|
players = players.map((item, index) =>
|
||||||
<div className="TradePlayer" key={`player-${item.name}`}>
|
<div className="TradePlayer" key={`player-${item.name}-${index}`}>
|
||||||
<PlayerColor color={item.color}/>
|
<PlayerColor color={item.color}/>
|
||||||
<div>{item.name}</div>
|
<div>{item.name}</div>
|
||||||
<div className='TradeLine'>will take <div>{item.gets}</div> for <div>{item.gives}</div>.<Button>accept</Button></div>
|
<div className='TradeLine'>
|
||||||
|
{ item.gets && item.gives &&
|
||||||
|
<div>will take {item.gets} for {item.gives}.
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
{ (!item.gets || !item.gives) &&
|
||||||
|
<div>has not submitted a trade offer.
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
<Button>accept</Button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -81,12 +81,12 @@ const assetData = {
|
|||||||
{ roll: 7, pips: 0 }, /* Robber is at the end or indexing gets off */
|
{ roll: 7, pips: 0 }, /* Robber is at the end or indexing gets off */
|
||||||
],
|
],
|
||||||
borders: [
|
borders: [
|
||||||
{ left: "sheep", right: "bank" },
|
[ "bank", undefined, "sheep" ],
|
||||||
{ center: "sheep" },
|
[ undefined, "bank", undefined ],
|
||||||
{ left: "wheat", right: "bank" },
|
[ "bank", undefined, "brick" ],
|
||||||
{ center: "wood" },
|
[ undefined, "wood", undefined ],
|
||||||
{ left: "sheep", right: "bank" },
|
[ "bank", undefined, "wheat" ],
|
||||||
{ center: "bank" }
|
[ undefined, "stone", undefined ]
|
||||||
],
|
],
|
||||||
developmentCards: [
|
developmentCards: [
|
||||||
]
|
]
|
||||||
@ -362,7 +362,7 @@ const processRoll = (game, dice) => {
|
|||||||
addChatMessage(game, session, `${session.name} rolled ${game.dice[0]}, ${game.dice[1]}.`);
|
addChatMessage(game, session, `${session.name} rolled ${game.dice[0]}, ${game.dice[1]}.`);
|
||||||
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! ROBBER! ROBBER!`);
|
addChatMessage(game, null, `ROBBER! Robber Roberson!`);
|
||||||
game.turn.robberDone = false;
|
game.turn.robberDone = false;
|
||||||
delete game.turn.placedRobber;
|
delete game.turn.placedRobber;
|
||||||
for (let id in game.sessions) {
|
for (let id in game.sessions) {
|
||||||
@ -1217,8 +1217,15 @@ router.put("/:id/:action/:value?", async (req, res) => {
|
|||||||
corner.type = 'settlement';
|
corner.type = 'settlement';
|
||||||
if (layout.corners[index].banks.length) {
|
if (layout.corners[index].banks.length) {
|
||||||
layout.corners[index].banks.forEach(bank => {
|
layout.corners[index].banks.forEach(bank => {
|
||||||
if (player.banks.indexOf(bank) === -1) {
|
const border = game.borderOrder[Math.floor(bank / 3)],
|
||||||
player.banks.push(bank);
|
type = game.borders[border][bank % 3];
|
||||||
|
console.log(`Bank ${bank} = ${type}`);
|
||||||
|
if (!type) {
|
||||||
|
console.log(`Bank ${bank}`)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (player.banks.indexOf(type) === -1) {
|
||||||
|
player.banks.push(type);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -1233,11 +1240,20 @@ router.put("/:id/:action/:value?", async (req, res) => {
|
|||||||
corner.type = 'settlement';
|
corner.type = 'settlement';
|
||||||
if (layout.corners[index].banks.length) {
|
if (layout.corners[index].banks.length) {
|
||||||
layout.corners[index].banks.forEach(bank => {
|
layout.corners[index].banks.forEach(bank => {
|
||||||
if (player.banks.indexOf(bank) === -1) {
|
console.log(game.borderOrder);
|
||||||
player.banks.push(bank);
|
console.log(game.borders);
|
||||||
|
const border = game.borderOrder[Math.floor(bank / 3)],
|
||||||
|
type = game.borders[border][bank % 3];
|
||||||
|
console.log(`Bank ${bank} = ${type}`);
|
||||||
|
if (!type) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (player.banks.indexOf(type) === -1) {
|
||||||
|
player.banks.push(type);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
player.maritime = player.banks.map(bank => game.borders[Math.floor(bank / 3) + bank % 3]);
|
||||||
game.turn.actions = ['place-road'];
|
game.turn.actions = ['place-road'];
|
||||||
game.turn.limits = { roads: layout.corners[index].roads }; /* road placement is limited to be near this corner */
|
game.turn.limits = { roads: layout.corners[index].roads }; /* road placement is limited to be near this corner */
|
||||||
addChatMessage(game, session, `Placed a settlement. Next, they need to place a road.`);
|
addChatMessage(game, session, `Placed a settlement. Next, they need to place a road.`);
|
||||||
@ -1759,7 +1775,7 @@ const shuffleBoard = (game) => {
|
|||||||
}
|
}
|
||||||
shuffle(seq);
|
shuffle(seq);
|
||||||
console.log('TODO: Map borderOrder to an array of the border values; each border has 3 slots.');
|
console.log('TODO: Map borderOrder to an array of the border values; each border has 3 slots.');
|
||||||
consoel.log('This is then used in generating "banks" to determine maritime trading values for each player.');
|
console.log('This is then used in generating "banks" to determine maritime trading values for each player.');
|
||||||
game.borderOrder = seq.slice();
|
game.borderOrder = seq.slice();
|
||||||
for (let i = 6; i < 19; i++) {
|
for (let i = 6; i < 19; i++) {
|
||||||
seq.push(i);
|
seq.push(i);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user