Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion scripts/data/calendaria-calendar.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,8 @@ export default class CalendariaCalendar extends foundry.data.CalendarData {
dayOfMonth -= d;
month++;
}
return { year, month, dayOfMonth, hour, minute, second };
const dayOfWeek = this._computeDayOfWeek({ year, month, dayOfMonth });
return { year, month, dayOfMonth, dayOfWeek, hour, minute, second };
}

/** @override */
Expand Down
14 changes: 13 additions & 1 deletion scripts/hooks.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,17 @@ import { BigCal, Chronicle, HUD, MiniCal, Stopwatch, SunDial, TimeKeeper } from
import { CalendarManager } from './calendar/_module.mjs';
import { HOOKS, MODULE, SCENE_FLAGS, SETTINGS } from './constants.mjs';
import { FestivalManager } from './festivals/_module.mjs';
import { onDayChangeForBastions, onLongRest, onPF1eRest, onPF2eRest, onPreRest, onShortRest, patchBastionButton } from './integrations/_module.mjs';
import {
onDayChangeForBastions,
onItemPilesGetActiveHolidays,
onItemPilesGetHolidays,
onLongRest,
onPF1eRest,
onPF2eRest,
onPreRest,
onShortRest,
patchBastionButton
} from './integrations/_module.mjs';
import { NoteManager, clearComputedDateCache } from './notes/_module.mjs';
import { TimeClock, onMoonPhaseChange, onUpdateScene, onWeatherChange } from './time/_module.mjs';
import {
Expand Down Expand Up @@ -67,6 +77,8 @@ export function registerHooks() {
Hooks.on('dnd5e.preShortRest', onPreRest);
Hooks.on('pf1ActorRest', onPF1eRest);
Hooks.on('pf2e.restForTheNight', onPF2eRest);
Hooks.on('item-piles-getHolidays', onItemPilesGetHolidays);
Hooks.on('item-piles-getActiveHolidays', onItemPilesGetActiveHolidays);
Hooks.on('getSceneControlButtons', onGetSceneControlButtons);
Hooks.on('preCreateChatMessage', onPreCreateChatMessage);
Hooks.on('preDeleteFolder', NoteManager.onPreDeleteFolder.bind(NoteManager));
Expand Down
1 change: 1 addition & 0 deletions scripts/integrations/_module.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export * from './bastion-orders.mjs';
export * from './chat-commander.mjs';
export * from './fxmaster.mjs';
export * from './item-piles.mjs';
export * from './luxon-sync.mjs';
export * from './rest-time.mjs';
28 changes: 28 additions & 0 deletions scripts/integrations/item-piles.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { getAllPresets, NoteManager } from '../notes/_module.mjs';

/**
* Offer Calendaria note categories as selectable Item Piles merchant holidays.
* @param {object[]} holidays - Holiday definitions ({ id, label }) the hook collects
* @returns {void}
*/
export function onItemPilesGetHolidays(holidays) {
for (const preset of getAllPresets()) {
holidays.push({ id: preset.id, label: preset.label });
}
}

/**
* Report note categories that occur within an Item Piles time range. The query's
* startDate/endDate are Foundry TimeComponents, whose 0-based month and dayOfMonth
* match Calendaria's internal note dates directly.
* @param {object} query - Item Piles query with { startDate, endDate } time components
* @param {Set<string>} active - Active holiday ids the hook collects
* @returns {void}
*/
export function onItemPilesGetActiveHolidays(query, active) {
const start = { year: query.startDate.year, month: query.startDate.month, dayOfMonth: query.startDate.dayOfMonth };
const end = { year: query.endDate.year, month: query.endDate.month, dayOfMonth: query.endDate.dayOfMonth };
for (const note of NoteManager.getNotesInRange(start, end)) {
for (const category of note.flagData.categories ?? []) active.add(category);
}
}