1
0

Started mapping into trader and banks

Signed-off-by: James Ketrenos <james_eikona@ketrenos.com>
This commit is contained in:
James Ketrenos 2022-02-14 18:00:39 -08:00
parent 6fa528ade3
commit 5c5baa6522
3 changed files with 36 additions and 17 deletions

View File

@ -1038,10 +1038,8 @@ class Table extends React.Component {
if (player) { if (player) {
let stacks = {}; let stacks = {};
game.player.development.forEach(item => (item.type in stacks) ? stacks[item.type].push(item.card) : stacks[item.type] = [item.card]); game.player.development.forEach(item => (item.type in stacks) ? stacks[item.type].push(item.card) : stacks[item.type] = [item.card]);
console.log(stacks);
development = []; development = [];
for (let type in stacks) { for (let type in stacks) {
console.log(type, stacks[type]);
const cards = stacks[type].map(card => <Development table={this} type={`${type}-${card}`}/>); const cards = stacks[type].map(card => <Development table={this} type={`${type}-${card}`}/>);
development.push(<div key={type} className="Stack">{ cards }</div>); development.push(<div key={type} className="Stack">{ cards }</div>);
} }

View File

@ -225,7 +225,7 @@ const processGameOrder = (game, player, dice) => {
message = `Initial settlement placement has started!`; message = `Initial settlement placement has started!`;
game.direction = 'forward'; game.direction = 'forward';
game.turn = { game.turn = {
actions: ['place-settlement'], actions: [ 'place-settlement' ],
limits: { corners: getValidCorners(game) }, limits: { corners: getValidCorners(game) },
name: getPlayerName(game, players[0]), name: getPlayerName(game, players[0]),
color: getPlayerColor(game, players[0]) color: getPlayerColor(game, players[0])
@ -1125,7 +1125,7 @@ router.put("/:id/:action/:value?", async (req, res) => {
error = `There are no valid locations for you to place a settlement.`; error = `There are no valid locations for you to place a settlement.`;
break; break;
} }
game.turn.actions = ['place-settlement']; game.turn.actions = [ 'place-settlement' ];
game.turn.limits = { corners }; game.turn.limits = { corners };
addChatMessage(game, session, `${game.turn.name} is considering placing a settlement.`); addChatMessage(game, session, `${game.turn.name} is considering placing a settlement.`);
break; break;
@ -1154,6 +1154,11 @@ router.put("/:id/:action/:value?", async (req, res) => {
error = `This location already has a settlement belonging to ${playerNameFromColor(game, corner.color)}!`; error = `This location already has a settlement belonging to ${playerNameFromColor(game, corner.color)}!`;
break; break;
} }
if (!player.banks) {
player.banks = [];
}
if (game.state === 'normal') { if (game.state === 'normal') {
if (player.brick < 1 || player.wood < 1 || player.wheat < 1 || player.sheep < 1) { if (player.brick < 1 || player.wood < 1 || player.wheat < 1 || player.sheep < 1) {
error = `You have insufficient resources to build a settlement.`; error = `You have insufficient resources to build a settlement.`;
@ -1170,6 +1175,13 @@ router.put("/:id/:action/:value?", async (req, res) => {
player.sheep--; player.sheep--;
corner.color = session.color; corner.color = session.color;
corner.type = 'settlement'; corner.type = 'settlement';
if (layout.corners[index].banks.length) {
layout.corners[index].banks.forEach(bank => {
if (player.banks.indexOf(bank) === -1) {
player.banks.push(bank);
}
});
}
game.turn.actions = []; game.turn.actions = [];
game.turn.limits = {}; game.turn.limits = {};
addChatMessage(game, session, `${name} placed a settlement.`); addChatMessage(game, session, `${name} placed a settlement.`);
@ -1179,6 +1191,13 @@ router.put("/:id/:action/:value?", async (req, res) => {
} }
corner.color = session.color; corner.color = session.color;
corner.type = 'settlement'; corner.type = 'settlement';
if (layout.corners[index].banks.length) {
layout.corners[index].banks.forEach(bank => {
if (player.banks.indexOf(bank) === -1) {
player.banks.push(bank);
}
});
}
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.`);
@ -1699,6 +1718,8 @@ const shuffleBoard = (game) => {
seq.push(i); seq.push(i);
} }
shuffle(seq); shuffle(seq);
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.');
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);

View File

@ -200,13 +200,13 @@ const layout = {
], ],
corners: [ corners: [
/* 0 */ /* 0 */
/* 0 */ Corner([2, 0],[17,0]), /* 0 */ Corner([2, 0],[0]),
/* 1 */ Corner([0, 1],[0,1]), /* 1 */ Corner([0, 1],[0]),
/* 2 */ Corner([1,3,5],[1]), /* 2 */ Corner([1,3,5],[1]),
/* 3 */ Corner([3,4],[1,2]), /* 3 */ Corner([3,4],[1,2]),
/* 4 */ Corner([8,4,6],[2]), /* 4 */ Corner([8,4,6],[2]),
/* 5 */ Corner([6,7],[2,3]), /* 5 */ Corner([6,7],[3]),
/* 6 */ Corner([7,9],[3,4]), /* 6 */ Corner([7,9],[3]),
/* 7 */ Corner([12,10],[16,17]), /* 7 */ Corner([12,10],[16,17]),
/* 8 */ Corner([2,10,11],[17]), /* 8 */ Corner([2,10,11],[17]),
/* 9 */ Corner([11,13,15],[]), /* 9 */ Corner([11,13,15],[]),
@ -216,8 +216,8 @@ const layout = {
/* 12 */ Corner([8,16,17],[]), /* 12 */ Corner([8,16,17],[]),
/* 13 */ Corner([17,19,21],[]), /* 13 */ Corner([17,19,21],[]),
/* 14 */ Corner([9,19,20],[4]), /* 14 */ Corner([9,19,20],[4]),
/* 15 */ Corner([20,22],[4,5]), /* 15 */ Corner([20,22],[5]),
/* 16 */ Corner([23,25],[16,15]), /* 16 */ Corner([23,25],[15]),
/* 17 */ Corner([12,23,24],[16]), /* 17 */ Corner([12,23,24],[16]),
/* 18 */ Corner([24,26,28],[]), /* 18 */ Corner([24,26,28],[]),
/* 19 */ Corner([15,26,27],[]), /* 19 */ Corner([15,26,27],[]),
@ -228,8 +228,8 @@ const layout = {
/* 23 */ Corner([21,32,33],[]), /* 23 */ Corner([21,32,33],[]),
/* 24 */ Corner([33,35,37],[]), /* 24 */ Corner([33,35,37],[]),
/* 25 */ Corner([22,35,36],[5]), /* 25 */ Corner([22,35,36],[5]),
/* 26 */ Corner([36,38],[5,6]), /* 26 */ Corner([36,38],[6]),
/* 27 */ Corner([25,39],[15,14]), /* 27 */ Corner([25,39],[15]),
/* 28 */ Corner([39,40,42],[14]), /* 28 */ Corner([39,40,42],[14]),
/* 29 */ Corner([28,40,41],[]), /* 29 */ Corner([28,40,41],[]),
/* 30 */ /* 30 */
@ -240,7 +240,7 @@ const layout = {
/* 34 */ Corner([47,49,51],[]), /* 34 */ Corner([47,49,51],[]),
/* 35 */ Corner([37,49,50],[]), /* 35 */ Corner([37,49,50],[]),
/* 36 */ Corner([50,53,52],[7]), /* 36 */ Corner([50,53,52],[7]),
/* 37 */ Corner([38,53],[6,7]), /* 37 */ Corner([38,53],[6]),
/* 38 */ Corner([42,54],[14,13]), /* 38 */ Corner([42,54],[14,13]),
/* 39 */ Corner([54,55,57],[13]), /* 39 */ Corner([54,55,57],[13]),
/* 40 */ /* 40 */
@ -251,14 +251,14 @@ const layout = {
/* 44 */ Corner([51,61,62],[]), /* 44 */ Corner([51,61,62],[]),
/* 45 */ Corner([62,65,64],[8]), /* 45 */ Corner([62,65,64],[8]),
/* 46 */ Corner([52,65],[7,8]), /* 46 */ Corner([52,65],[7,8]),
/* 47 */ Corner([57,66],[13,12]), /* 47 */ Corner([57,66],[12]),
/* 48 */ Corner([67,66],[12,11]), /* 48 */ Corner([67,66],[12]),
/* 49 */ Corner([60,67,68],[11]), /* 49 */ Corner([60,67,68],[11]),
/* 50 */ /* 50 */
/* 50 */ Corner([68,69],[11,10]), /* 50 */ Corner([68,69],[11,10]),
/* 51 */ Corner([69,70,63],[10]), /* 51 */ Corner([69,70,63],[10]),
/* 52 */ Corner([70,71],[10,9]), /* 52 */ Corner([70,71],[9]),
/* 53 */ Corner([64,71],[8,9]), /* 53 */ Corner([64,71],[9]),
] ]
}; };