用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/mbianchidev/2dnd --skill game-development命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
正在显示 SKILL.md
| name | game-development |
| description | Develop 2D&D features with Phaser 4, strict TypeScript, and D&D-inspired mechanics |
| license | MIT |
Use this skill for cross-cutting game features, new content, combat behavior, and changes spanning scenes, systems, data, renderers, or managers.
src/data/; keep reusable logic in
src/systems/.src/renderers/textures.ts and synthesize audio in
src/systems/audio.ts; do not add external assets.debugLog() and debug-panel APIs instead of console.log.Boot, Overworld, Battle, Shop, Codex, Cutscene,
Ending, and Defeatsrc/scenes/Overworld.tssrc/scenes/Battle.tssrc/systems/src/data/src/renderers/src/managers/src/systems/accessibility.tssrc/systems/input.tssrc/managers/input.tsThe versioned 2dnd_preferences document is separate from campaign saves and
backs both title and in-game settings. Install the scene accessibility adapter
in every scene, use its shared reduced-motion accessors, preserve
100%/125%/150% text usability, and pair important color states with a textual or
symbolic cue. Control presentation preferences cover touch visibility,
handedness, and prompt source without changing campaign saves. Stable mappings
are intentionally not remappable.
All release input routes through the semantic action layer. Standard gamepads use dead zones, digital fallback, repeat/debounce, source switching, and a visible right-stick cursor clicked by pressing the stick. Responsive touch controls use safe areas, pointer capture for held directions, click pulses for discrete actions, and mobile text entry. Clear held state on blur, visibility loss, disconnect, scene changes, and shutdown.
Cutscene contracts live in src/data/cutsceneTypes.ts, focused campaign and
boss definitions live in cutsceneCampaign.ts and cutsceneBosses.ts, and
src/data/cutscenes.ts is the stable-ID hub. Pure trigger snapshots, priority
ordering, queue lifecycle, recovery, Chronicle selection, and summary logic live
in src/systems/cutscenes.ts; src/managers/cutscene.ts owns step progression;
scenes and renderers own input and presentation.
EndingScene and DefeatScene share src/renderers/result.ts; defeat receives
an exact runtime-only PartyDefeatResult, while the recovered player state is
autosaved before presentation.
The map hub is src/data/map.ts; terrain/types, chunks, cities, and dungeons
are split into dedicated modules. Dungeon trap definitions live in
src/data/traps.ts, mechanics in src/systems/traps.ts, and scene orchestration
in src/managers/dungeonTraps.ts.
Group templates live in src/data/monsterGroups.ts; reusable initiative,
formation, synergy, reward, and per-combatant rules live in
src/systems/groupCombat.ts.
That module also owns party-ready BattleCombatantState, stable actor IDs,
actor-ID initiative, ally/enemy targeting, monster party-target selection, and
battle resolution hooks.
src/systems/battleActions.ts is the Phaser-free action planner for player
input and ranked gambits: actor enumeration, target binding, validation,
immutable plans, per-actor action/bonus consumption, and one-action dispatch.
executeValidatedBattleAction() binds a generic CombatActorState to a party
combatant and reuses existing attack, spell, ability, item, defend, element,
status, MP, and inventory mechanics.
Consumables consume the acting source's inventory while applying HP/MP/cures
to a selected ally source; execution contexts must include all party action
sources. Equipment actions remain self-targeted.
src/systems/animation.ts is the Phaser-free presentation contract for actor
states, deterministic timing, stable-ID target mapping, once-only lifecycle,
and explicit family/frame texture metadata. src/managers/actorAnimation.ts
owns reusable Phaser poses and cleanup; battle/world directors consume resolved
state without changing mechanics. src/renderers/actorTextures.ts supports
optional family frames from #49 and a generic existing-texture fallback.
Tutorial and Tips content lives in src/data/tutorial.ts as immutable steps,
semantic control actions, categories, and unlock requirements.
src/systems/tutorial.ts owns completion normalization and progression-aware
filtering. src/managers/tutorial.ts owns the Overworld overlay and renders prompts for
the active keyboard, pointer, gamepad, or touch source. New saves persist
player.progression.tutorial.completed; replay never resets it.
World Event content lives in src/data/worldEvents.ts, its deterministic
Phaser-free state machine in src/systems/worldEvents.ts, and accessible choice
presentation in src/managers/worldEvents.ts. Events short-circuit treasure,
exploration checks, and random encounters for their movement step, while
transitions, entrances, traps, interactions, and queued cutscenes retain
priority. Special event combats use normal Battle hooks and saves.
src/data/quests.ts.src/systems/quests.ts; questState.ts and questDebug.ts contain focused
normalization and debug-only mutation helpers.player.progression.quests; use quest-system APIs
instead of direct mutation.isQuestCompleted() and
keep their own persistent state separate from quest reward bookkeeping.{ id, type, targetId }. Replay them after load/mutations and make the
consumer idempotent rather than adding duplicate quest state.id; downstream systems use
getQuestStageIndex() or the debug-only setQuestStageById(), never display
titles.defeatedBosses so older saves can report
already-completed objectives.pendingCutsceneIds to seenCutsceneIds; reload resumes the
first pending entry, while Chronicle replay changes neither collection.QUEST_NPCS and assert exact coverage
of all 12 live city IDs; do not accept name-only references.Non-combat checks are split across:
src/data/skillChecks.ts: NPC challenges, negotiation choices, and terrain
event definitionssrc/systems/skillChecks.ts: pure d20 resolution, normalization, and helperssrc/managers/skillChecks.ts: Overworld rewards, hazards, chest checks, and
dialogue orchestrationmonsters.ts,
nightMonsters.ts, or monsterVariants.ts).family, stats, rewards, drops,
abilities, and isBoss.variantOf to a valid same-family monster,
use a distinct color and ability set, and assign a positive
encounterWeight.affinity and elementalProfile when the monster has a dominant
element, resistances, weaknesses, or
immunities.element and statusEffect to monster abilities when applicable.ALL_MONSTERS; debug spawning, Codex
browsing, and ID lookup depend on the master list.getMonsterTextureKey() and the family silhouette renderer rather than
adding scene-local textures or tints.Use getMonster(id) for exact ID lookup and findMonster(query) for
case-insensitive ID/name lookup with partial matching.
MONSTER_GROUP_TEMPLATES.front or back.minPlayerLevel high enough that total difficulty does not exceed
playerLevel * 3.Random groups start at level 2, cap at 50% of triggered encounters, and never replace bosses or explicit debug monster spawns.
Codex family completion is derived from the current CodexData.entries; family
metadata, affinity, and sort/filter presentation are not save fields.
World knowledge definitions live in src/data/codexKnowledge.ts. Persist only
stable unlocked knowledge IDs in CodexData; derive category counts, source
hints, search results, sorting, and grouping from canonical entries. Emit
idempotent location, quest, cutscene, item, NPC, readable, or worldEvent
signals without letting Codex state control gameplay. reputationMilestone
is owned by the schema-v12 reputation system and must remain idempotent.
rollSkillCheck(), quest starts through
startQuestById(), rewards through canonical item/XP helpers, and lore through
unlockCodexFromFutureSignal().src/data/reputation.ts; reusable mechanics belong in
src/systems/reputation.ts.lawChaos: -50, goodEvil: 0).SocialAchievementHook values for the achievement
consumer; do not persist achievements inside the social system.src/data/achievements.ts;
put normalization, deterministic progress, reconciliation, stable event
counters, debug exclusion, and title equip rules in
src/systems/achievements.ts.Element from src/data/elements.ts.selfEffect or targetEffect IDs defined by
src/systems/statusEffects.ts.statusEffect for effects applied to the player.useItem() without consuming the item when no matching ailment exists.targetType; resolve it through
getItemTargetType() so older inventory copies use canonical item metadata.Combat calculation order is:
Magic Missile remains auto-hit and does not roll disadvantage.
All definitions and lifecycle helpers live in
src/systems/statusEffects.ts. Do not duplicate status logic in data files or
scenes.
applyStatusEffect().normalizeActiveEffects().Supported elements are Fire, Ice, Lightning, Poison, Necrotic, Radiant, Thunder, Force, and Psychic.
Record observed non-neutral interactions with discoverElement() so the Codex
can persist and display them.
city.chunks directly.trapSeed; never mutate
dungeon maps or randomize layouts independently in scenes.FogOfWar.exploredKey() for exploration keys.isWalkable() and ENCOUNTER_RATES; do not hardcode terrain behavior.src/data/nautical.ts; state normalization,
ownership, and mechanics live in the focused nauticalState.ts,
nauticalOwnership.ts, and nautical.ts modules. Preserve all 90 legacy
chunk IDs and use s:zoneId,chunkX,chunkY,x,y for sea fog.player.progression.skillChecks.State-bearing transitions commonly pass:
{
player,
defeatedBosses,
codex,
timeStep,
weatherState,
savedSpecialNpcs,
}
Battle also receives a MonsterEncounter and biome; Shop receives shop/city
context.
Defeat receives the full shared state plus encounter name/type and the exact
applied party defeat receipt. It must not recalculate or reapply penalties.
Future party systems pass accessor-backed partyCombatants plus runtime-only
battleHooks; do not persist those wrapper objects.
Keep target init() contracts and every caller synchronized.
The new-player tutorial opens only after pending opening cutscenes have drained.
F1 and the Esc menu open the consultable Tips surface. Keep the external HTML
control rail collapsed by default and retain only contextual action prompts in
the game HUD.
Route camera fades and scene handoffs through
src/managers/sceneTransition.ts. Call prepare() when each scene creates,
wait for fade-complete events, and keep the duration-plus-grace watchdog as a
recovery path only. Restore the outgoing camera before queueing the next scene,
reject duplicate handoffs, and block state-changing Overworld input until the
queued start/restart is processed. Every Overworld restart must include a fresh
savedSpecialNpcs snapshot in the shared state payload.
Use the same guarded Battle exit cleanup for victory, flee, and defeat. Defeat
clears transient menus, input, effects, particles, and weather timers before
starting DefeatScene, which continues only to Overworld.
player.party; do not add a parallel scene
payload or companion combat model.guardian, scout, and mystic.createPartyCombatant() and
createBattleActionSource().battleActions.ts; one bonus action may precede or follow one main action.src/systems/inventory.ts; every view entry keeps
its original inventory index for actions and transfers.2dnd_inventory_prefs, outside the
campaign save schema. Recent acquisition is reverse append order.T remains mount control.src/renderers/itemVisuals.ts.Gathering content lives in src/data/gathering.ts, deterministic node/table/
minigame logic in src/systems/gathering.ts, schema normalization in
gatheringState.ts, and accessible Phaser presentation in
src/managers/gathering.ts. Persist selected outcomes before play, use safe
location-derived nodes, route guarded finds through normal Battle hooks, and
keep material identity limited to stable Item.material recipe-input metadata.
Crafting recipes live in src/data/crafting.ts, atomic mechanics and discovery
in src/systems/crafting.ts, persistence normalization in craftingState.ts,
and accessible Overworld presentation in src/managers/crafting.ts. Validate
the selected actor inventory, protected/equipped restrictions, batch, gold,
station, output, and transaction ID before mutation. Equipment upgrades replace
exact equipped object links with canonical outputs. Never pull companion
materials implicitly, reroll a craft, duplicate material identity, or let
recipes/achievements control quests, Codex, access, or rewards.
npm run typecheck
npm test
npm run test:browser
npm run build
For UI changes, run the committed Playwright flow in headless Chromium. Keep browser actions synchronized through debug-state transitions, and hold frame-polled Phaser keys across frames rather than using instantaneous presses.
createHeroCombatant().validateBattleAction().import * as Phaser from "phaser".missed state.