import type { WorldDefinition } from "../engine";

export const modernWorld: WorldDefinition = {
  id: "modern",
  name: "Modern Semester",
  description:
    "A compact modern-world demo. The engine is phase-based, action-driven, and ready for other worlds with different stats and actions.",
  presentation: {
    label: "Modern / Semester Loop",
    headline:
      "Balance study, money, recovery, and social bandwidth in a compressed semester.",
    horizonLabel: "Semester horizon",
  },
  calendar: {
    daysPerAge: 120,
    maxDays: 12,
  },
  phases: [
    {
      id: "morning",
      label: "Morning",
      description: "Peak focus for disciplined actions.",
    },
    {
      id: "afternoon",
      label: "Afternoon",
      description: "Stable window for execution-heavy work.",
    },
    {
      id: "night",
      label: "Night",
      description: "Recovery and social actions swing harder here.",
    },
  ],
  stats: [
    { id: "knowledge", label: "Knowledge", min: 0, max: 100, initial: 4 },
    { id: "stress", label: "Stress", min: 0, max: 20, initial: 3 },
    { id: "social", label: "Social", min: 0, max: 20, initial: 2 },
    { id: "energy", label: "Energy", min: 0, max: 20, initial: 6 },
  ],
  resources: [{ id: "money", label: "Money", min: 0, max: 50, initial: 5 }],
  start: {
    age: 18,
    day: 1,
    phaseId: "morning",
    flags: {
      worldComplete: false,
    },
    tags: ["freshman"],
  },
  actions: [
    {
      id: "study",
      name: "Study",
      description:
        "Reliable knowledge growth at the cost of stress and energy.",
      effects: {
        stats: {
          knowledge: 2,
          stress: 1,
          energy: -1,
        },
      },
      timing: {
        morning: {
          label: "Best timing",
          tone: "best",
          effects: {
            stats: {
              knowledge: 2,
            },
          },
        },
        night: {
          label: "Late-night grind",
          tone: "risky",
          effects: {
            stats: {
              stress: 2,
              energy: -1,
            },
          },
        },
      },
    },
    {
      id: "part-time",
      name: "Part-time work",
      description: "Convert time into cash. Afternoon is the safest slot.",
      availability: {
        stat: "energy",
        gte: 2,
      },
      effects: {
        resources: {
          money: 2,
        },
        stats: {
          stress: 1,
          energy: -1,
        },
      },
      timing: {
        afternoon: {
          label: "Best timing",
          tone: "best",
          effects: {
            resources: {
              money: 2,
            },
          },
        },
        night: {
          label: "Overtime shift",
          tone: "risky",
          effects: {
            stats: {
              stress: 2,
              energy: -1,
            },
          },
        },
      },
    },
    {
      id: "socialize",
      name: "Socialize",
      description:
        "Build relationships, ease stress a bit, and spend some money.",
      effects: {
        stats: {
          social: 2,
          stress: -1,
        },
        resources: {
          money: -1,
        },
      },
      timing: {
        night: {
          label: "Best timing",
          tone: "best",
          effects: {
            stats: {
              social: 2,
            },
          },
        },
        morning: {
          label: "Slow start",
          tone: "neutral",
          effects: {
            stats: {
              social: -1,
            },
          },
        },
      },
    },
    {
      id: "rest",
      name: "Rest",
      description:
        "Recover energy and stabilize your state. Night is strongest.",
      effects: {
        stats: {
          stress: -2,
          energy: 2,
        },
      },
      timing: {
        night: {
          label: "Best timing",
          tone: "best",
          effects: {
            stats: {
              stress: -1,
              energy: 1,
            },
          },
        },
        afternoon: {
          label: "Soft reset",
          tone: "good",
          effects: {
            stats: {
              energy: 1,
            },
          },
        },
      },
    },
  ],
  events: [
    {
      id: "quiz",
      name: "Pop quiz",
      description: "A surprise quiz rewards disciplined study loops.",
      weight: 3,
      when: {
        all: [{ actionIn: ["study"] }, { phaseIn: ["morning", "afternoon"] }],
      },
      effects: {
        stats: {
          knowledge: 1,
        },
      },
    },
    {
      id: "deadline",
      name: "Deadline pressure",
      description: "A project milestone lands and your stress spikes.",
      weight: 2,
      when: {
        all: [{ day: { gte: 5 } }, { actionIn: ["study", "part-time"] }],
      },
      effects: {
        stats: {
          stress: 2,
        },
      },
    },
    {
      id: "referral",
      name: "Referral",
      description: "Your network turns into a real opportunity and pays off.",
      weight: 2,
      when: {
        all: [
          { actionIn: ["socialize", "part-time"] },
          { stat: "social", gte: 6 },
        ],
      },
      effects: {
        stats: {
          social: 1,
        },
        resources: {
          money: 3,
        },
      },
    },
    {
      id: "burnout-warning",
      name: "Burnout warning",
      description: "The pace catches up with you and forces a rethink.",
      weight: 1,
      once: true,
      when: {
        stat: "stress",
        gte: 10,
      },
      effects: {
        stats: {
          stress: -1,
          energy: -1,
        },
        flags: {
          burnoutWarning: true,
        },
      },
    },
  ],
};
