mirror of
https://github.com/bra1n/townsquare.git
synced 2025-04-04 22:24:36 +00:00
Merge pull request #110 from MRegnard/bubbles
Correcting a bug with Night order bubbles
This commit is contained in:
commit
d8c3002ded
1 changed files with 20 additions and 20 deletions
|
@ -28,33 +28,33 @@ const getters = {
|
||||||
nightOrder({ players, fabled }) {
|
nightOrder({ players, fabled }) {
|
||||||
const firstNight = [0];
|
const firstNight = [0];
|
||||||
const otherNight = [0];
|
const otherNight = [0];
|
||||||
players.forEach(({ role }) => {
|
|
||||||
if (role.firstNight && !firstNight.includes(role.firstNight)) {
|
|
||||||
firstNight.push(role.firstNight);
|
|
||||||
}
|
|
||||||
if (role.otherNight && !otherNight.includes(role.otherNight)) {
|
|
||||||
otherNight.push(role.otherNight);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
fabled.forEach((role) => {
|
fabled.forEach((role) => {
|
||||||
if (role.firstNight && !firstNight.includes(role.firstNight)) {
|
if (role.firstNight && !firstNight.includes(role)) {
|
||||||
firstNight.push(role.firstNight);
|
firstNight.push(role);
|
||||||
}
|
}
|
||||||
if (role.otherNight && !otherNight.includes(role.otherNight)) {
|
if (role.otherNight && !otherNight.includes(role)) {
|
||||||
otherNight.push(role.otherNight);
|
otherNight.push(role);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
firstNight.sort((a, b) => a - b);
|
players.forEach(({ role }) => {
|
||||||
otherNight.sort((a, b) => a - b);
|
if (role.firstNight && !firstNight.includes(role)) {
|
||||||
|
firstNight.push(role);
|
||||||
|
}
|
||||||
|
if (role.otherNight && !otherNight.includes(role)) {
|
||||||
|
otherNight.push(role);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
firstNight.sort((a, b) => a.firstNight - b.firstNight);
|
||||||
|
otherNight.sort((a, b) => a.otherNight - b.otherNight);
|
||||||
const nightOrder = new Map();
|
const nightOrder = new Map();
|
||||||
players.forEach((player) => {
|
players.forEach(player => {
|
||||||
const first = Math.max(firstNight.indexOf(player.role.firstNight), 0);
|
const first = Math.max(firstNight.indexOf(player.role), 0);
|
||||||
const other = Math.max(otherNight.indexOf(player.role.otherNight), 0);
|
const other = Math.max(otherNight.indexOf(player.role), 0);
|
||||||
nightOrder.set(player, { first, other });
|
nightOrder.set(player, { first, other });
|
||||||
});
|
});
|
||||||
fabled.forEach((role) => {
|
fabled.forEach(role => {
|
||||||
const first = Math.max(firstNight.indexOf(role.firstNight), 0);
|
const first = Math.max(firstNight.indexOf(role), 0);
|
||||||
const other = Math.max(otherNight.indexOf(role.otherNight), 0);
|
const other = Math.max(otherNight.indexOf(role), 0);
|
||||||
nightOrder.set(role, { first, other });
|
nightOrder.set(role, { first, other });
|
||||||
});
|
});
|
||||||
return nightOrder;
|
return nightOrder;
|
||||||
|
|
Loading…
Add table
Reference in a new issue