@adatechnology/game-stories

中文文档
0.3.10发布于 2026/11/08MITTypeScriptES Module构建来源已验证近 30 天下载 1795

Pure, seeded story generator for games: roles cast from people or name pools at world creation, stories as data that cross each other through flags and the player's actions, a chronicle, a character sheet that keeps the decisions and stories each person l

原始使用文档
文档目录4 节
  1. Install
  2. Usage
  3. Test area
  4. Em português

@adatechnology/game-stories

Stories as data for games, pure and seeded: stories of beats with roles, conditions, text pieces and changes; the casting that decides who plays each role; the chronicle; the character sheet that keeps everything a person lived; and the life simulation that runs between the stories (people get hurt, fall in love, have children, fight, betray, trade, are raided and arrive). No three.js, no game content: the game gives the people, the stories and the places, and reads the chronicle and the sheets.

It is a literal port of two team deliveries:

  • Os Vivos do Vale (site/pages/sobreviventes/os-vivos-do-vale.html): life(), simulate() and the event engine (EV, ACTS, fill), made generic. The valley's people and its 47 events are not here: they are the zombiada slice (specs/001-migracao-entregas-dos-times/game-slice/stories/).
  • Personagens (site/pages/zumbis-personagens/personagens.html): the sheet (point buy, derived values, skills and milestones, memory and opinion). The ruleset itself (attributes, skills, professions, traits, formulas) and the name pools are content in @adatechnology/game-characters-people; the game passes names and ruleset (the recommended path; defaultStoryContent() of @adatechnology/game-kit-defaults has the pack's). Without them the core falls back to that pack, a deprecated default removed in the next major.

The golden game-stories-life.json (7 full lives line by line, 40 more by hash, 96 sets of player actions without the life simulation and 48 sheets, all recorded by running the team code in node:vm with tools/characters-catalog) is replayed by the tests.

  • The normal world comes first. life.numbers.infection is false by default: an outing can hurt or kill, nobody is bitten and nobody turns. infection: true turns on the team's bitten band and the turn after two days.
  • Everything is a number with its source (LIFE_DEFAULTS, SHEET_DEFAULTS) and every text is a table (LIFE_TEXT, pt-BR word for word and en); a game patches what it wants through life.numbers and life.text.
  • Stories cross by role: a role with the same id in two stories is one person, and a beat reads the states, flags, actions and what each person remembers.
  • Casting (P9): a role is a pinned person, or someone who fits its needs, or a person made from the name pools. It draws from its own stream, so the life simulation keeps the team's sequence.

Install

pnpm add @adatechnology/game-stories

Browser without a bundler (the global is GameStories):

<script src="https://unpkg.com/@adatechnology/game-stories/dist/index.global.js"></script>

Usage

import { createStoryWorld, createSheet } from '@adatechnology/game-stories'
import { getNamePools, SHEET_RULESET } from '@adatechnology/game-characters-people'   // or defaultStoryContent() of @adatechnology/game-kit-defaults

const world = createStoryWorld({ names: getNamePools('pt-BR'), ruleset: SHEET_RULESET, people, stories, life: { groups, relations, couples }, fill: 80, seed: 7, locale: 'pt-BR' })
world.act('fix_well') // a player action: the stories read it from today on
world.runTo(30)
world.chronicle.entries // every line, by day
world.states // the state of every person: ok, hurt, dead, missing, party, hostile, moved, left...
const sheet = world.sheet(world.cast('keeper')) // the same world, the same sheet
sheet.history // the stories and events the person lived
sheet.derived() // max health, stamina, load, running speed... from the ruleset

const mine = createSheet({ ruleset: SHEET_RULESET, profession: 'nurse', attributes: { agility: 6 }, traits: ['athlete'] })
mine.pool() // points left of the 14

A story:

{
  id: 'well',
  roles: [{ id: 'keeper', needs: { base: 'farm' }, create: true }],
  beats: [
    { id: 'well_dry', day: 10, roles: ['keeper'], variants: [{ text: [{ name: 'keeper' }, ' finds the well dry.'], flags: { well_dry: 1 } }] },
    {
      id: 'well_after', day: 14, roles: ['keeper', 'newcomer'],
      variants: [
        { when: { all: [{ action: 'fix_well' }, { living: 'newcomer' }] }, text: [{ name: 'newcomer' }, ' fixes the pump.'] },
        { text: [{ name: 'keeper' }, ' carries water from the river.'], changes: [{ role: 'keeper', state: 'hurt' }] },
      ],
    },
  ],
}

Test area

createStoriesTestModule({ names?, ruleset?, professionName? }) (stories_area, only the generic contracts) puts the seed, the day, the life simulation, the infection layer, the player actions and a person's sheet on the bench, with six scenarios (determinism, casting, the normal world, the sheet keeps what was lived, the point buy and two stories crossing). It runs the kit's example content (two small stories on a farm and a town, marked example) until a game loads its own (module.load(content)). examples/stories-test-area loads it into the shared test room (sala-historias.html, with a button for a JSON file such as the zombiada slice), and examples/interactables-test-area carries it too.

Em português

Histórias como dados, determinísticas por semente: histórias de momentos com papéis, condições, pedaços de texto e mudanças; a escalação de quem faz cada papel; a crônica; a ficha que guarda tudo o que a pessoa viveu; e a vida sorteada entre as histórias. Porte literal de Os Vivos do Vale (life(), simulate(), eventos) e da ficha de Personagens. O mundo normal vem primeiro (sem mordida por padrão). O conteúdo do vale (as 45 pessoas e os 47 eventos) fica no repositório do jogo; o kit traz só um exemplo marcado example.

版本与发布记录

@adatechnology/game-stories 共发布 21 个版本,首次发布于 2026/10/25;过去 12 个月发布了 21 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.3.10latest2026/11/08今天
0.3.92026/11/08今天
0.3.82026/11/071 天前
0.3.72026/11/071 天前
0.3.62026/11/071 天前
0.3.52026/11/071 天前

关于 @adatechnology/game-stories 的常见问题

@adatechnology/game-stories 是什么?

Pure, seeded story generator for games: roles cast from people or name pools at world creation, stories as data that cross each other through flags and the player's actions, a chronicle, a character sheet that keeps the decisions and stories each person l

如何安装 @adatechnology/game-stories?

在项目目录运行 npm install @adatechnology/game-stories,或使用 pnpm add / yarn add / bun add。

@adatechnology/game-stories 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@adatechnology/game-stories 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@adatechnology/game-stories 可以商用吗?

@adatechnology/game-stories 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@adatechnology/game-stories 的下载量有多少?

根据 npm 官方下载统计,@adatechnology/game-stories 在 2026/10/05 – 2026/11/03 这 30 天内被下载 1,795 次,日均约 60 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@adatechnology/game-stories 还在维护吗?

最新版本 0.3.10 发布于 2026/11/08(今天);至今共发布 21 个版本,其中过去 12 个月发布了 21 个;首次发布于 2026/10/25。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。