@sharpee/world-model
v0.9.92
Published
World model for Sharpee IF platform - entities, traits, and behaviors
Maintainers
Readme
@sharpee/world-model
Entity system, traits, and behaviors for the Sharpee Interactive Fiction platform.
Installation
npm install @sharpee/world-modelOverview
The world model provides the foundation for game state:
- Entities - Rooms, objects, NPCs, and the player
- Traits - Composable properties (Openable, Lockable, Container, etc.)
- Behaviors - Reusable logic (LightSource, Wearable, Edible, etc.)
- State Management - Immutable world state with entity relationships
Usage
import {
WorldModel,
IFEntity,
OpenableTrait,
ContainerTrait
} from '@sharpee/world-model';
// Create entities with traits
const chest = world.createEntity('object', {
id: 'treasure-chest',
name: 'treasure chest',
traits: [OpenableTrait, ContainerTrait]
});
// Query relationships
const contents = world.getContents(chest);
const location = world.getLocation(player);Traits
| Trait | Description |
|-------|-------------|
| OpenableTrait | Can be opened/closed |
| LockableTrait | Can be locked/unlocked with a key |
| ContainerTrait | Can contain other objects |
| SupporterTrait | Objects can be placed on top |
| WearableTrait | Can be worn by player/NPCs |
| EdibleTrait | Can be eaten |
| LightSourceTrait | Provides illumination |
Related Packages
- @sharpee/stdlib - Standard actions
- @sharpee/sharpee - Full platform bundle
License
MIT
