You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
2.2 KiB
55 lines
2.2 KiB
// Classic board: three equal sectors on each axis, eight rectangular cells per arm.
|
|
export const parchisStarts = [4, 21, 38, 55];
|
|
export const parchisHomes = [
|
|
[400, 400],
|
|
[400, 0],
|
|
[0, 0],
|
|
[0, 400],
|
|
];
|
|
const laneWidth = 200 / 3;
|
|
function cell(x, y, width, height, angle) {
|
|
const center = [x + width / 2, y + height / 2];
|
|
const label = [...center];
|
|
if (height === 25 && x !== 200 + laneWidth)
|
|
label[0] = x === 200 ? x + width - 11 : x + 11;
|
|
if (width === 25 && y !== 200 + laneWidth)
|
|
label[1] = y === 200 ? y + height - 11 : y + 11;
|
|
return { x, y, width, height, angle, center, label };
|
|
}
|
|
const track = [];
|
|
for (let i = 7; i >= 0; i--)
|
|
track.push(cell(200 + 2 * laneWidth, 400 + i * 25, laneWidth, 25, 0));
|
|
for (let i = 0; i < 8; i++)
|
|
track.push(cell(400 + i * 25, 200 + 2 * laneWidth, 25, laneWidth, 90));
|
|
track.push(cell(575, 200 + laneWidth, 25, laneWidth, 90));
|
|
for (let i = 7; i >= 0; i--)
|
|
track.push(cell(400 + i * 25, 200, 25, laneWidth, 90));
|
|
for (let i = 7; i >= 0; i--)
|
|
track.push(cell(200 + 2 * laneWidth, i * 25, laneWidth, 25, 180));
|
|
track.push(cell(200 + laneWidth, 0, laneWidth, 25, 180));
|
|
for (let i = 0; i < 8; i++) track.push(cell(200, i * 25, laneWidth, 25, 180));
|
|
for (let i = 7; i >= 0; i--) track.push(cell(i * 25, 200, 25, laneWidth, 270));
|
|
track.push(cell(0, 200 + laneWidth, 25, laneWidth, 270));
|
|
for (let i = 0; i < 8; i++)
|
|
track.push(cell(i * 25, 200 + 2 * laneWidth, 25, laneWidth, 270));
|
|
for (let i = 0; i < 8; i++)
|
|
track.push(cell(200, 400 + i * 25, laneWidth, 25, 0));
|
|
track.push(cell(200 + laneWidth, 575, laneWidth, 25, 0));
|
|
export const parchisTrack = track;
|
|
export function parchisLane(house, step, outer = 65) {
|
|
const edge = outer === 65 ? 6 : 7;
|
|
const begin = outer === 65 ? 1 : 0;
|
|
return [
|
|
() => cell(200 + laneWidth, 400 + (edge - step) * 25, laneWidth, 25, 0),
|
|
() => cell(400 + (edge - step) * 25, 200 + laneWidth, 25, laneWidth, 90),
|
|
() => cell(200 + laneWidth, (begin + step) * 25, laneWidth, 25, 180),
|
|
() => cell((begin + step) * 25, 200 + laneWidth, 25, laneWidth, 270),
|
|
][house]();
|
|
}
|
|
export function parchisHomePoint(house, piece) {
|
|
return [
|
|
parchisHomes[house][0] + 57 + (piece % 2) * 86,
|
|
parchisHomes[house][1] + 57 + Math.floor(piece / 2) * 86,
|
|
];
|
|
}
|