Fix stone resources not being distributed
Signed-off-by: James Ketrenos <james_eikona@ketrenos.com>
This commit is contained in:
parent
40481d79fd
commit
3285b216e4
@ -174,6 +174,15 @@ const playerNameFromColor = (game, color) => {
|
|||||||
return '';
|
return '';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const playerFromColor = (game, color) => {
|
||||||
|
for (let id in game.sessions) {
|
||||||
|
if (game.sessions[id].color === color) {
|
||||||
|
return game.sessions[id].player;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
};
|
||||||
|
|
||||||
const processGameOrder = (game, player, dice) => {
|
const processGameOrder = (game, player, dice) => {
|
||||||
let message;
|
let message;
|
||||||
|
|
||||||
@ -296,10 +305,10 @@ const distributeResources = (game, roll) => {
|
|||||||
console.log(`Matched tiles: ${tiles.join(',')}.`);
|
console.log(`Matched tiles: ${tiles.join(',')}.`);
|
||||||
|
|
||||||
const receives = {
|
const receives = {
|
||||||
"O": { wood: 0, brick: 0, sheep: 0, wheat: 0 },
|
"O": { wood: 0, brick: 0, sheep: 0, wheat: 0, stone: 0 },
|
||||||
"R": { wood: 0, brick: 0, sheep: 0, wheat: 0 },
|
"R": { wood: 0, brick: 0, sheep: 0, wheat: 0, stone: 0 },
|
||||||
"W": { wood: 0, brick: 0, sheep: 0, wheat: 0 },
|
"W": { wood: 0, brick: 0, sheep: 0, wheat: 0, stone: 0 },
|
||||||
"B": { wood: 0, brick: 0, sheep: 0, wheat: 0 },
|
"B": { wood: 0, brick: 0, sheep: 0, wheat: 0, stone: 0 },
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Find which corners are on each tile */
|
/* Find which corners are on each tile */
|
||||||
@ -317,11 +326,13 @@ const distributeResources = (game, roll) => {
|
|||||||
|
|
||||||
for (let color in receives) {
|
for (let color in receives) {
|
||||||
const entry = receives[color];
|
const entry = receives[color];
|
||||||
if (!entry.wood && !entry.brick && !entry.sheep && !entry.wheat) {
|
if (!entry.wood && !entry.brick && !entry.sheep && !entry.wheat && !entry.stone) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
let message = [];
|
let message = [];
|
||||||
for (let type in receives[color]) {
|
for (let type in receives[color]) {
|
||||||
|
const player = playerFromColor(game, color);
|
||||||
|
player[type] += receives[color][type];
|
||||||
if (receives[color][type]) {
|
if (receives[color][type]) {
|
||||||
message.push(`${receives[color][type]} ${type}`);
|
message.push(`${receives[color][type]} ${type}`);
|
||||||
}
|
}
|
||||||
@ -339,7 +350,12 @@ const getPlayer = (game, color) => {
|
|||||||
points: 0,
|
points: 0,
|
||||||
status: "Not active",
|
status: "Not active",
|
||||||
lastActive: 0,
|
lastActive: 0,
|
||||||
order: 0
|
order: 0,
|
||||||
|
stone: 0,
|
||||||
|
wheat: 0,
|
||||||
|
sheep: 0,
|
||||||
|
wood: 0,
|
||||||
|
brick: 0
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -899,8 +915,11 @@ router.put("/:id/:action/:value?", async (req, res) => {
|
|||||||
|
|
||||||
/* Figure out which players received which resources */
|
/* Figure out which players received which resources */
|
||||||
for (let id in game.sessions) {
|
for (let id in game.sessions) {
|
||||||
const session = game.sessions[id],
|
const session = game.sessions[id], player = session.player,
|
||||||
receives = {};
|
receives = {};
|
||||||
|
if (!player) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (session.initialSettlement) {
|
if (session.initialSettlement) {
|
||||||
layout.tiles.forEach((tile, index) => {
|
layout.tiles.forEach((tile, index) => {
|
||||||
if (tile.corners.indexOf(session.initialSettlement) !== -1) {
|
if (tile.corners.indexOf(session.initialSettlement) !== -1) {
|
||||||
@ -913,6 +932,7 @@ router.put("/:id/:action/:value?", async (req, res) => {
|
|||||||
});
|
});
|
||||||
let message = [];
|
let message = [];
|
||||||
for (let type in receives) {
|
for (let type in receives) {
|
||||||
|
player[type] += receives[type];
|
||||||
message.push(`${receives[type]} ${type}`);
|
message.push(`${receives[type]} ${type}`);
|
||||||
}
|
}
|
||||||
addChatMessage(game, null, `${session.name} receives ${message.join(', ')}.`);
|
addChatMessage(game, null, `${session.name} receives ${message.join(', ')}.`);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user