Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

adding-mod-parsers

БесплатноБез исполняемых скриптовНе проверен

Use when adding new mod parsers to convert game mod strings to typed Mod objects - guides the template-based parsing pattern (project)

acliniaот aclinia★ 46 звёзд на GitHub19 установок в других каталогах

Об этом скилле

Adding Mod Parsers

Overview

The mod parser converts raw mod strings (e.g., "+10% all stats") into typed Mod objects used by the calculation engine. It uses a template-based system for pattern matching.

When to Use

  • Adding support for new mod string patterns
  • Extending existing mod types to handle new variants
  • Adding new mod types to the engine

Project File Locations

Purpose File Path
Mod type definitions src/tli/mod.ts
Parser templates src/tli/mod-parser/templates.ts
Enum registrations src/tli/mod-parser/enums.ts
Calculation handlers src/tli/calcs/offense.ts
Tests src/tli/mod-parser.test.ts

Implementation Checklist

1. Check if Mod Type Exists

Look in src/tli/mod.ts under ModDefinitions. If the mod type doesn't exist, add it:

interface ModDefinitions {
  // ... existing types ...
  NewModType: { value: number; someField: string };
}

2. Add Template in templates.ts

Templates use a DSL for pattern matching. Do not add comments to templates.ts - the template string itself is self-documenting.

t("{value:dec%} all stats").output((c) => ({
  type: "StatPct",
  value: c.value,
  statModType: "all",
})),
t("{value:dec%} {statModType:StatWord}")
  .enum("StatWord", StatWordMapping)
  .output((c) => ({ type: "StatPct", value: c.value, statModType: c.statModType })),
t("{value:dec%} [additional] [{modType:DmgModType}] damage").output((c) => ({
  type: "DmgPct",
  value: c.value,
  dmgModType: c.modType ?? "global",
  addn: c.additional !== undefined,
})),
t("{value:dec%} attack and cast speed").outputMany([
  spec((c) => ({ type: "AspdPct", value: c.value, addn: false })),
  spec((c) => ({ type: "CspdPct", value: c.value, addn: false })),
]),

Template capture types:

Type Matches Example Input → Output
{name:int} Unsigned integer "5" → 5
{name:dec} Unsigned decimal "21.5" → 21.5
{name:int%} Unsigned integer percent "30%" → 30
{name:dec%} Unsigned decimal percent "96%" → 96
{name:+int} Signed integer (requires + or -) "+5" → 5, "-3" → -3
{name:+dec} Signed decimal (requires + or -) "+21.5" → 21.5
{name:+int%} Signed integer percent "+30%" → 30, "-15%" → -15
{name:+dec%} Signed decimal percent "+96%" → 96
{name:?int} Optional-sign integer (matches with or without +/-) "5" → 5, "+5" → 5, "-3" → -3
{name:?dec} Optional-sign decimal "21.5" → 21.5, "+21.5" → 21.5
{name:?int%} Optional-sign integer percent "30%" → 30, "+30%" → 30
{name:?dec%} Optional-sign decimal percent "96%" → 96, "+96%" → 96
{name:EnumType} Enum lookup {dmgType:DmgChunkType}

Signed vs Unsigned vs Optional-sign Types:

  • Use unsigned (dec%, int) when input NEVER has + or - (e.g., "8% additional damage applied to Life")
  • Use signed (+dec%, +int) when input ALWAYS has + or - (e.g., "+25% additional damage")
  • Use optional-sign (?dec%, ?int) when input MAY OR MAY NOT have a sign — this avoids needing two separate templates for signed/unsigned variants
  • Signed types will NOT match unsigned inputs, and unsigned will NOT match signed inputs
  • Prefer ?dec% over two separate dec%/+dec% templates when the same mod can appear with or without a sign

Optional syntax:

  • [additional] - Optional literal, sets c.additional?: true
  • [{modType:DmgModType}] - Optional capture, sets c.modType?: DmgModType
  • {(effect|damage)} - Alternation (regex-style)

3. Add Enum Mapping (if needed)

If you need custom word → value mapping, add to enums.ts:

export const StatWordMapping: Record<string, string> = {
  strength: "str",
  dexterity: "dex",
  intelligence: "int",
};

registerEnum("StatWord", ["strength", "dexterity", "intelligence"]);

4. Add Handler in offense.ts (if new mod type)

If you added a new mod type, add handling in calculateOffense() or relevant helper:

case "NewModType": {
  break;
}

For existing mod types with new variants (like adding statModType: "all"), update existing handlers to also filter for the new variant:

const flat = sumByValue(
  statMods.filter((m) => m.statModType === statType || m.statModType === "all"),
);

5. Add Tests

Add test cases in src/tli/mod_parser.test.ts:

test("parse percentage all stats", () => {
  const result = parseMod("+10% all stats");
  expect(result).toEqual([
    {
      type: "StatPct",
      statModType: "all",
      value: 10,
    },
  ]);
});

6. Verify

pnpm test src/tli/mod_parser.test.ts
pnpm typecheck
pnpm check

Template Ordering

IMPORTANT: More specific patterns must come be

Полный SKILL.md на GitHub

Установить adding-mod-parsers в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

FAQ

Что делает скилл adding-mod-parsers?

Use when adding new mod parsers to convert game mod strings to typed Mod objects - guides the template-based parsing pattern (project)

Как установить скилл adding-mod-parsers?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл adding-mod-parsers запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить adding-mod-parsers с