Skip to main content

Mod-Engine

A TypeScript library for typed attributes and modifiers with deterministic evaluation

🎯 Type-Safe

Full TypeScript support with intelligent autocompletion and compile-time validation. Catch errors early and build with confidence.

🔧 Flexible

Support for complex conditions, priorities, and stacking rules. Build simple systems or complex RPG mechanics with the same API.

⚡ Performance

Optimized evaluation engine with minimal overhead. Handle complex modifier systems without sacrificing performance.

Simple yet Powerful

Build complex modification systems with just a few lines of code

📝 Define Configuration

const config = defineConfig({
  metrics: ["Health", "Damage"] as const,
  operations: ["sum", "multiply"] as const,
  attributes: [{
    key: "Rarity",
    kind: "enum", 
    values: ["Common", "Epic"] as const
  }] as const,
});

⚡ Build & Evaluate

const sword = engine
  .builder("Epic Sword")
  .set("Rarity", "Epic")
  .increase("Damage").by(100)
  .when({ op: "eq", attr: "Rarity", value: "Epic" })
  .multiply("Damage").by(1.5)
  .build();

const result = engine.evaluate(sword);
// { Health: 0, Damage: 150 }