@randsum/salvageunion
v1.0.1
Published
A flexible, type-safe dice roller for the Salvage Union system
Maintainers
Readme
A type-safe implementation of Salvage Union dice rolling mechanics that supports:
- 🎲 Standard 2d10 rolls with modifiers
- 🎯 Automatic outcome determination
- 📊 Built-in roll tables
- 🔒 Full TypeScript support
- 🪶 Tree-shakeable implementation
Installation
npm install @randsum/salvageunion
# or
yarn add @randsum/salvageunion
# or
bun add @randsum/salvageunionUsage
import { rollTable } from "@randsum/salvageunion"
import type { SalvageUnionTableResult } from "@randsum/salvageunion"
// Basic roll with default table
const result = rollTable()
// Returns table result with hit type, label, description, and roll value
// Roll with specific table
const result = rollTable("Morale")
// Type-safe result handling
const { hit, label, description, roll } = rollTable("Core Mechanic")
switch (hit) {
case "Nailed It":
// 20
break
case "Success":
// 11-19
break
case "Tough Choice":
// 6-10
break
case "Failure":
// 2-5
break
case "Cascade Failure":
// 1
break
}API Reference
rollTable
Makes a d20 roll following Salvage Union rules, returning a table result object with hit type, label, description, and roll value.
function rollTable(tableName?: SalvageUnionTableName): SalvageUnionTableResultRoll Tables
The package includes all official Salvage Union roll tables, organized into collections:
PCTables
Core Mechanic: Standard action resolutionCritical Damage: Vehicle critical hitsCritical Injury: Character injuriesReactor Overload: Mech reactor issuesArea Salvage: Random salvage findsMech Salvage: Salvageable mech parts
NPCTables
NPC Action: Random NPC actionsReaction: NPC reactions to PCsMorale: NPC morale checksGroup Initiative: Group combat initiativeRetreat: NPC retreat behavior
Related Packages
- @randsum/roller: Core dice rolling implementation
