update tarot frame settings UI
This commit is contained in:
@@ -43,6 +43,40 @@
|
||||
throw new Error("Tarot database assembly dependencies are incomplete");
|
||||
}
|
||||
|
||||
function buildTokenDateRange(startToken, endToken) {
|
||||
const parseToken = (value) => {
|
||||
const match = String(value || "").trim().match(/^(\d{2})-(\d{2})$/);
|
||||
if (!match) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const month = Number(match[1]);
|
||||
const day = Number(match[2]);
|
||||
if (!Number.isFinite(month) || !Number.isFinite(day)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new Date(2025, month - 1, day);
|
||||
};
|
||||
|
||||
const start = parseToken(startToken);
|
||||
const endBase = parseToken(endToken);
|
||||
if (!start || !endBase) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const wraps = endBase.getTime() < start.getTime();
|
||||
const end = wraps ? new Date(2026, endBase.getMonth(), endBase.getDate()) : endBase;
|
||||
|
||||
return {
|
||||
start,
|
||||
end,
|
||||
startToken: startToken || null,
|
||||
endToken: endToken || null,
|
||||
label: `${formatMonthDayLabel(start)}–${formatMonthDayLabel(end)}`
|
||||
};
|
||||
}
|
||||
|
||||
function buildMajorCards(referenceData, magickDataset) {
|
||||
const tarotDb = getTarotDbConfig(referenceData);
|
||||
const dynamicRelations = buildMajorDynamicRelations(referenceData);
|
||||
@@ -178,6 +212,10 @@
|
||||
const windowDecans = windowDecanIds
|
||||
.map((decanId) => decanById.get(decanId) || null)
|
||||
.filter(Boolean);
|
||||
const explicitWindowRange = buildTokenDateRange(
|
||||
tarotDb.courtDateRanges?.[cardName]?.start,
|
||||
tarotDb.courtDateRanges?.[cardName]?.end
|
||||
);
|
||||
|
||||
const dynamicRelations = [];
|
||||
const monthKeys = new Set();
|
||||
@@ -255,9 +293,17 @@
|
||||
if (windowDecans.length) {
|
||||
const firstRange = windowDecans[0].dateRange;
|
||||
const lastRange = windowDecans[windowDecans.length - 1].dateRange;
|
||||
const windowLabel = firstRange && lastRange
|
||||
? `${formatMonthDayLabel(firstRange.start)}–${formatMonthDayLabel(lastRange.end)}`
|
||||
: "--";
|
||||
const fallbackWindowRange = firstRange && lastRange
|
||||
? {
|
||||
start: firstRange.start,
|
||||
end: lastRange.end,
|
||||
startToken: firstRange.startToken,
|
||||
endToken: lastRange.endToken,
|
||||
label: `${formatMonthDayLabel(firstRange.start)}–${formatMonthDayLabel(lastRange.end)}`
|
||||
}
|
||||
: null;
|
||||
const windowRange = explicitWindowRange || fallbackWindowRange;
|
||||
const windowLabel = windowRange?.label || "--";
|
||||
|
||||
dynamicRelations.unshift(
|
||||
createRelation(
|
||||
@@ -265,8 +311,8 @@
|
||||
`${rankKey}-${suitKey}`,
|
||||
`Court date window: ${windowLabel}`,
|
||||
{
|
||||
dateStart: firstRange?.startToken || null,
|
||||
dateEnd: lastRange?.endToken || null,
|
||||
dateStart: windowRange?.startToken || null,
|
||||
dateEnd: windowRange?.endToken || null,
|
||||
dateRange: windowLabel,
|
||||
decanIds: windowDecanIds
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user