Skip to content

task 1 brief

Xopher edited this page Oct 28, 2026 · 1 revision

Task 1: Project quests on the quest schedule

Files:

  • Modify: src/lib/databases/AchievementDb.ts (the Achievement interface, L17-83)
  • Modify: src/lib/engine/quests/QuestSchedule.ts (deadlineDayOf L229, isQuestActiveOn L282)
  • Test: tests/unit/QuestScheduleProjectQuests.spec.ts

Interfaces:

  • Produces: interface ProjectQuestLink { projectId: string; floor: string; dueOn: string /* YYYY-MM-DD */; wokenAt?: string /* ISO */ } exported from AchievementDb.ts; Achievement.project?: ProjectQuestLink; isProjectQuest(quest): quest is Achievement & { project: ProjectQuestLink } exported from QuestSchedule.ts.

  • Step 1: Write the failing tests

describe("project quests", () => {
  const base = { ...AchievementDb.getDefault(), id: "pq-x", basicSchedule: "once", startsOn: "2027-04-03", dueByTime: "20:00" };
  it("hides a project quest until its floor wakes", () => {
    expect(isQuestActiveOn({ ...base, project: { projectId: "p", floor: "2F", dueOn: "2027-04-09" } }, new Date(2027, 3, 5))).toBe(false);
  });
  it("shows a woken project quest before its startsOn", () => {
    const woken = { ...base, project: { projectId: "p", floor: "2F", dueOn: "2027-04-09", wokenAt: "2027-04-01T10:00:00Z" } };
    expect(isQuestActiveOn(woken, new Date(2027, 3, 1))).toBe(true);
  });
  it("is due on project.dueOn at its due time", () => {
    const woken = { ...base, project: { projectId: "p", floor: "1F", dueOn: "2027-04-09", wokenAt: "2027-04-03T08:00:00Z" } };
    expect(effectiveDeadline(woken, undefined, new Date(2027, 3, 5))).toEqual(new Date(2027, 3, 9, 20, 0));
  });
  it("leaves a once quest without a project link as it was", () => { /* deadline day = startsOn, hidden before startsOn */ });
});
  • Step 2: Run chemx test tests/unit/QuestScheduleProjectQuests.spec.ts. Expected: FAIL (project unknown / assertions fail).
  • Step 3: Implement. Add ProjectQuestLink and the optional field. In QuestSchedule.ts add isProjectQuest; deadlineDayOf returns parseLocalDate(quest.project.dueOn) for a project quest (before the snooze/extension rules it already applies); isQuestActiveOn returns Boolean(quest.project.wokenAt) for a project quest, otherwise its current rule. Search every caller of isQuestActiveOn/deadlineDayOf (chemx q -g "isQuestActiveOn") and confirm none hides a once quest before startsOn by another path; if one does, route it through isQuestActiveOn.
  • Step 4: Run the spec and tests/unit/QuestSchedule.spec.ts. Expected: PASS.
  • Step 5: Lead commits feat(quests): project quests: hidden until their floor wakes, due on project.dueOn.

Table of Contents


Home - See Pages

Developer Docs

Start Screen

User Management

My Portal

My Home

The City (Hometown)

The World Map

The Dungeon

Game Master

Settings

Support & Glossary

About XP

Clone this wiki locally