Калькулятор Арканов
Верхняя строка
Нижняя строка
const ARCANA = {
1: ‘Маг’,
2: ‘Жрица’,
3: ‘Императрица’,
4: ‘Император’,
5: ‘Иерофант’,
6: ‘Влюблённые’,
7: ‘Колесница’,
8: ‘Справедливость’,
9: ‘Отшельник’,
10: ‘Колесо Фортуны’,
11: ‘Сила’,
12: ‘Повешенный’,
13: ‘Смерть’,
14: ‘Умеренность’,
15: ‘Дьявол’,
16: ‘Башня’,
17: ‘Звезда’,
18: ‘Луна’,
19: ‘Солнце’,
20: ‘Суд’,
21: ‘Мир’,
22: ‘Дурак’
};
// Привести число к аркану (1–22)
function toArcana(n) {
n = Math.abs(n);
if (n === 0) return 22;
while (n > 22) n -= 22;
if (n === 0) return 22;
return n;
}
// Привести год: сложить все цифры, потом toArcana
function yearToArcana(y) {
let s = String(y).split(»).reduce((a, c) => a + parseInt(c), 0);
return toArcana(s);
}
function calculate() {
const d = parseInt(document.getElementById(‘day-input’).value);
const m = parseInt(document.getElementById(‘month-input’).value);
const y = parseInt(document.getElementById(‘year-input’).value);
const err = document.getElementById(‘error-msg’);
// Validation
if (!d || !m || !y || isNaN(d) || isNaN(m) || isNaN(y)) {
err.textContent = ‘Пожалуйста, введите полную дату рождения’;
return;
}
if (d 31 || m 12 || y 2100) {
err.textContent = ‘Проверьте правильность даты’;
return;
}
err.textContent = »;
// Base values
const D = toArcana(d);
const M = toArcana(m);
const Y = yearToArcana(y);
// TOP ROW
const p1 = toArcana(D + M);
const p2 = toArcana(D + Y);
const p3 = toArcana(p1 + p2);
const p4 = toArcana(M + Y);
// BOTTOM ROW
const p5 = toArcana(Math.abs(D — M));
const p6 = toArcana(Math.abs(D — Y));
const p7 = toArcana(Math.abs(p5 — p6));
const p8 = toArcana(Math.abs(M — Y));
// Formulas display
const yDigits = String(y).split(»).join(‘+’);
const ySum = String(y).split(»).reduce((a, c) => a + parseInt(c), 0);
const formulas = [
`${d} + ${m}`,
`${d} + (${yDigits}=${ySum}→${Y})`,
`П1 + П2`,
`${m} + (год→${Y})`,
`|${d} − ${m}|`,
`|${d} − (год→${Y})|`,
`|П5 − П6|`,
`|${m} − (год→${Y})|`
];
const values = [p1, p2, p3, p4, p5, p6, p7, p8];
// Render top
const topRow = document.getElementById(‘top-row’);
topRow.innerHTML = »;
for (let i = 0; i < 4; i++) {
topRow.appendChild(makeCell(i + 1, values[i], formulas[i]));
}
// Render bottom
const bottomRow = document.getElementById('bottom-row');
bottomRow.innerHTML = '';
for (let i = 4; i < 8; i++) {
bottomRow.appendChild(makeCell(i + 1, values[i], formulas[i]));
}
// Birth display
document.getElementById('birth-display').textContent =
`${pad(d)}.${pad(m)}.${y}`;
// Show result
const section = document.getElementById('result-section');
section.classList.add('visible');
section.scrollIntoView({ behavior: 'smooth', block: 'start' });
}
function makeCell(pos, num, formula) {
const cell = document.createElement('div');
cell.className = 'arcana-cell';
cell.innerHTML = `
${pos}
${num}
${ARCANA[num]}
`;
return cell;
}
function pad(n) { return String(n).padStart(2, ‘0’); }
// Enter key support
document.addEventListener(‘keydown’, e => {
if (e.key === ‘Enter’) calculate();
});