@sharpee/ext-basic-combat
v1.1.1
Published
Generic skill-based combat extension for Sharpee IF engine
Readme
@sharpee/ext-basic-combat
Generic skill-based combat extension for the Sharpee Interactive Fiction platform.
Installation
npm install @sharpee/ext-basic-combatOverview
This extension provides opt-in combat resolution for both attack directions:
- PC→NPC -
BasicCombatInterceptor, registered onCombatantTrait+if.action.attacking - NPC→PC -
basicNpcResolver, registered as the NPC combat resolver - CombatService - skill-based hit/damage resolution with validation
- Combat messages - message IDs and health-status helpers for reporting
- One-call setup -
registerBasicCombat()wires both directions at once
Stories with custom combat register their own interceptor and resolver instead of calling registerBasicCombat().
Usage
import { registerBasicCombat } from '@sharpee/ext-basic-combat';
// In your story's initializeWorld():
registerBasicCombat();To wire only one direction, register the individual components yourself:
import { TraitType, registerActionInterceptor } from '@sharpee/world-model';
import { registerNpcCombatResolver } from '@sharpee/stdlib';
import {
BasicCombatInterceptor,
basicNpcResolver,
} from '@sharpee/ext-basic-combat';
// PC→NPC only
registerActionInterceptor(
TraitType.COMBATANT,
'if.action.attacking',
BasicCombatInterceptor
);
// NPC→PC only
registerNpcCombatResolver(basicNpcResolver);The CombatService can be used directly for custom resolution:
import { createCombatService, applyCombatResult } from '@sharpee/ext-basic-combat';
const combat = createCombatService();
const result = combat.resolve(context);
applyCombatResult(result, info);Related Packages
- @sharpee/sharpee - Full platform bundle
- @sharpee/stdlib - Standard actions and NPC combat resolver
- @sharpee/world-model - Entity system, traits, action interceptors
License
MIT
