AgentSkillsCN

choice-effects

端到端实现并维护“选择:〈选项〉或〈选项〉”卡牌效果(内容 → UI提示 → 钩子应用)。在添加或修改基于选择的计量差值事件卡时使用,或在调试为何“选择”卡未能改变紧张感或连贯性时使用。

SKILL.md
--- frontmatter
name: choice-effects
description: "Implement and maintain Choose: <opt> OR <opt> card effects end-to-end (content → UI prompt → hook application). Use when adding or modifying event cards with choice-based meter deltas, or when debugging why a Choose card didn't change tension/coherence."
argument-hint: "Card id/name or genre (e.g., scifi-event-6)"
user-invocable: true

Choice Effects (Choose: A OR B)

When to use

  • Adding an event card whose effect starts with Choose:
  • Debugging a Choose card where meters didn’t change
  • Refactoring the effect parser or PlayCardModal

Outcome

After applying this skill, a Choose-based event card will:

  1. prompt the player to pick one option in the modal,
  2. pass the chosen option through the UI callback chain,
  3. apply the meter delta in useGameState.playCard,
  4. record narration that includes the chosen option.

Contract (hard rules)

Effect string encoding

Encode choices like:

  • Choose: +1 Tension OR +1 Coherence. <optional flavor sentence>

Rules:

  • Use literal Choose:
  • Use uppercase OR as the delimiter
  • Each option must be parseable by the engine’s substring checks (e.g., +1 Tension, -1 Coherence)

Plumbing contract

  • PlayCardModal must pass chosenEffect to its onConfirm
  • GameplayScreen must pass chosenEffect to onPlayCard
  • useGameState.playCard must accept chosenEffect and apply it for Choose events

Procedure

  1. Find Choose cards

    • Search src/data/gameContent.ts for Choose:.
  2. Verify effect format

    • Ensure it matches: Choose: <opt> OR <opt>. ...
    • If not, fix content first.
  3. Confirm modal prompts for choice

    • In src/components/game/PlayCardModal.tsx, derive choiceOptions from card.effect.
    • Render a selection control (radio group) and block confirm until selected.
  4. Plumb the chosen option

    • Update callback signatures:
      • PlayCardModal.onConfirm(..., chosenEffect)
      • GameplayScreen.onPlayCard(..., chosenEffect)
      • useGameState.playCard(..., chosenEffect)
  5. Apply the chosen effect

    • In useGameState.playCard, if card.type === 'event' and card.effect.includes('Choose:'), parse deltas from chosenEffect.
    • Keep meter caps $[0,10]$.
  6. Update documentation

    • Update .github/instructions/game-content.instructions.md and .github/instructions/game-state.instructions.md.
    • Update docs/PROJECT_REFERENCE.md if it describes choice behavior.
  7. Verify

    • npm run lint (warnings OK; no errors)
    • npm run build
    • Manual smoke: play a Choose event and confirm the selected meter changes.

Helper script