import type { EventDefinition } from '../types.js';

function choice(
  choiceId: string,
  text: string,
  resolutionText: string,
  overrides?: Partial<EventDefinition['choices'][number]>
): EventDefinition['choices'][number] {
  return {
    choiceId,
    text,
    resolutionText,
    ...overrides,
  };
}

export const adulthoodCatalog: EventDefinition[] = [
  {
    id: 'firstJob',
    category: 'adulthood',
    prompt: 'You got your first job offer. What is your approach?',
    minAge: 18,
    // PACING (T011b): a "first job offer" is an early-career beat. Previously it
    // had no maxAge and stayed eligible into old age, crowding out late-life
    // content. Capped at 40 so it stops competing in the senior years.
    maxAge: 40,
    choices: [
      choice(
        'accept_and_learn',
        'Accept and focus on learning',
        'You accepted and grew quickly through hands-on experience.',
        { effects: { stats: { happiness: 8, social: 6 }, resources: { money: 100 } } }
      ),
      choice(
        'negotiate_terms',
        'Negotiate pay and schedule',
        'You negotiated better terms and started with stronger boundaries.',
        { energyCost: 5, effects: { stats: { social: 4 }, resources: { money: 200 } } }
      ),
      choice(
        'wait_for_better_fit',
        'Wait for a better fit',
        'You delayed start for a more aligned role and accepted short-term uncertainty.',
        { effects: { stats: { happiness: -4 } } }
      ),
    ],
  },
  {
    id: 'workLifeBalance',
    category: 'adulthood',
    prompt: 'Work demands are escalating and your personal life is slipping. What do you do?',
    minAge: 22,
    // PACING (T011b): a working-career squeeze. Capped at typical working age
    // (67) so it does not keep firing for retirees in the late-life span.
    maxAge: 67,
    choices: [
      choice(
        'set_boundaries',
        'Set firm boundaries',
        'You protected personal time and improved long-term sustainability.',
        { effects: { stats: { happiness: 12, social: 8 } } }
      ),
      choice(
        'short_term_push',
        'Push hard for a short period',
        'You delivered in the short term but felt exhausted after.',
        { energyCost: 20, effects: { stats: { happiness: -6 }, resources: { money: 250 } } }
      ),
      choice(
        'ask_support',
        'Ask manager for support',
        'You asked for support and workloads were rebalanced.',
        { effects: { stats: { social: 10, happiness: 8 } } }
      ),
    ],
  },
  {
    id: 'promotionOpportunity',
    category: 'adulthood',
    prompt: 'You have a promotion opportunity with higher stress. What do you choose?',
    minAge: 24,
    // PACING (T011b): a workplace-advancement beat. Capped at working age (65)
    // so promotions stop being offered to retirees.
    maxAge: 65,
    choices: [
      choice(
        'take_promotion',
        'Take the promotion',
        'You took the role and expanded your responsibilities and income.',
        { effects: { stats: { happiness: 6 }, resources: { money: 400 } } }
      ),
      choice(
        'decline_for_balance',
        'Decline to preserve balance',
        'You declined to preserve quality of life and consistency.',
        { effects: { stats: { happiness: 10 } } }
      ),
      choice(
        'accept_trial_period',
        'Request a trial period',
        'You tested the role before committing and made a clearer decision.',
        { energyCost: 10, effects: { stats: { social: 5, happiness: 5 }, resources: { money: 150 } } }
      ),
    ],
  },
  {
    id: 'unexpectedBill',
    category: 'adulthood',
    prompt: 'An unexpected bill hits your budget. How do you handle it?',
    minAge: 18,
    choices: [
      choice(
        'pay_immediately',
        'Pay immediately',
        'You paid immediately and avoided penalties.',
        { effects: { resources: { money: -300 }, stats: { happiness: 3 } } }
      ),
      choice(
        'payment_plan',
        'Set up a payment plan',
        'You created a payment plan and protected cash flow.',
        { effects: { resources: { money: -100 }, stats: { happiness: 1 } } }
      ),
      choice(
        'ignore_temporarily',
        'Ignore it for now',
        'You delayed action and stress increased as fees accumulated.',
        { effects: { stats: { happiness: -12 } } }
      ),
    ],
  },

  // ===========================================================================
  // T011b: deepened adulthood — more specific, emotional mid-life beats.
  // Following the recipe: independent one-shots gated by minAge/maxAge.
  // ===========================================================================
  {
    id: 'firstHome',
    category: 'adulthood',
    prompt:
      'You have saved enough to stop renting. Standing in an empty apartment you might actually own, the weight of a down payment and a thirty-year commitment settles in. What do you do?',
    minAge: 25,
    maxAge: 55,
    choices: [
      choice(
        'buy_starter',
        'Buy a modest starter place',
        'You signed the papers and got the keys to a home that is yours. Smaller than you dreamed, but the first night sleeping under your own roof felt enormous.',
        { moneyCost: 5000, effects: { stats: { happiness: 16, stress: 6 } } }
      ),
      choice(
        'stretch_for_dream',
        'Stretch for the place you really want',
        'You reached past comfortable for the home you actually pictured. The mortgage is daunting, but every morning in it feels like proof you bet on yourself.',
        { moneyCost: 9000, effects: { stats: { happiness: 18, stress: 15 } } }
      ),
      choice(
        'keep_renting',
        'Keep renting and stay flexible',
        'You decided roots could wait. Renting keeps your options open and your savings liquid - and there is freedom in not being tied down.',
        { effects: { stats: { happiness: 4, stress: -4 } } }
      ),
    ],
  },
  {
    id: 'midlifeCrossroads',
    category: 'adulthood',
    prompt:
      'You wake up one ordinary morning and realize you are not sure the life you built is the one you wanted. The job, the routine, the path - was any of it your choice, or just momentum? What do you do?',
    minAge: 38,
    maxAge: 55,
    choices: [
      choice(
        'reinvent',
        'Make a real change while there is time',
        'You did the terrifying thing - changed course, chased the version of your life you had shelved. The ground is unsteady, but for the first time in years you feel awake.',
        { energyCost: 10, effects: { stats: { happiness: 12, stress: 12 } } }
      ),
      choice(
        'small_shifts',
        'Keep the structure, change the texture',
        'You did not blow up your life - you adjusted it. New hobby, new boundaries, a standing date with what you love. Small shifts, but the restlessness eased.',
        { effects: { stats: { happiness: 8, stress: -5 } } }
      ),
      choice(
        'reframe',
        'Find peace with the life you have',
        'You sat with the discontent and, instead of fleeing it, learned to see what was already good. The grass, it turned out, was greener than you had let yourself notice.',
        { effects: { stats: { happiness: 6, stress: -6 } } }
      ),
    ],
  },
  {
    id: 'fadingFriendship',
    category: 'adulthood',
    prompt:
      'A friendship that once felt unbreakable has gone quiet - different cities, different lives, fewer calls. You both keep meaning to reach out and neither of you does. What do you do?',
    minAge: 28,
    maxAge: 65,
    choices: [
      choice(
        'rekindle',
        'Make the effort to bridge the distance',
        'You booked the flight, made the call, refused to let it drift. The reunion was awkward for ten minutes and then exactly like always. Some bonds are worth the work.',
        { energyCost: 5, effects: { stats: { happiness: 12, social: 10 }, resources: { money: -300 } } }
      ),
      choice(
        'stay_in_touch',
        'Keep it alive in small ways',
        'You started sending the little texts - a song, a memory, a "thinking of you." Not the same as before, but enough to keep the thread from snapping.',
        { effects: { stats: { happiness: 6, social: 5 } } }
      ),
      choice(
        'let_drift',
        'Let it become a fond memory',
        'You accepted that some friendships belong to a season. It is wistful, but you carry the good of it forward without resentment.',
        { effects: { stats: { happiness: -4, social: -3 } } }
      ),
    ],
  },
  {
    id: 'sandwichSqueeze',
    category: 'adulthood',
    prompt:
      'Your aging parent needs more help just as your career hits its most demanding stretch. There are not enough hours, and everyone needs a piece of you. How do you handle being pulled in every direction?',
    minAge: 40,
    maxAge: 60,
    choices: [
      choice(
        'prioritize_family',
        'Step back at work to be there for family',
        'You eased off the accelerator at work to show up for your parent. The career took a hit, but you will never regret the time you bought with someone running out of it.',
        { effects: { stats: { happiness: 8, stress: 6 }, resources: { money: -200 } } }
      ),
      choice(
        'hire_help',
        'Bring in support to share the load',
        'You arranged care so the weight did not all fall on you. It cost money and a sliver of guilt, but it kept you standing and kept your parent cared for.',
        { moneyCost: 1200, effects: { stats: { stress: -6, happiness: 4 } } }
      ),
      choice(
        'try_to_do_it_all',
        'Try to carry all of it yourself',
        'You refused to drop any ball - and exhausted yourself catching them all. Something has to give before you do.',
        { energyCost: 20, effects: { stats: { happiness: -8, stress: 18 } } }
      ),
    ],
  },
];
