Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ Format follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

### Added

- **Where a type sits on the sheet.** Each item type on the builder's TYPES tab now has ON THE SHEET: EQUIPPED (worn or wielded), USABLE (used up or used often: potions, ammo, kits) or PACK. WEAPON and ARMOR presets start EQUIPPED, CONSUMABLE and SPELL start USABLE, and GEAR and every type you already have start in PACK. The sheet's GEAR tab sorts lines into these bands next.
- **EDIT CURRENT in SHOP_CATALOGUES.** A new button beside DOWNLOAD CURRENT puts what your shops sell now straight into the box, ready to change, PREVIEW and SAVE, with no file to download and upload again. If the box already has text in it, it asks before replacing it.
- **Publishing tidies the shop catalogue.** When you publish a system, any catalogue line that is now exactly one of your items, same name, price and columns, is taken out of the file, since the item sells itself. That includes lines that ADD NEW LINES TO ITEMS turned into items. The builder's publish message says how many. Lines naming an item kept out of the shops stay, so they sell again if you switch it back on.
- **Catalogue lines can become items.** In SHOP_CATALOGUES, PREVIEW now offers ADD NEW LINES TO ITEMS, off to start. Switched on, it lists what it will add and how many items your system will hold. SAVE then makes each line that isn't one of your items yet into an item: of its section's type (a shelf's lines go to your DEFAULT type), with its columns, price and words, in the shops. They go into the builder's draft and are kept once you publish; until then the catalogue line sells them. If the builder is open, it takes them in, so its next save keeps them.
Expand Down
6 changes: 3 additions & 3 deletions README.md

Large diffs are not rendered by default.

35 changes: 32 additions & 3 deletions backend/__tests__/system_builder_item_types.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { createRequire } from 'module';

const require_ = createRequire(import.meta.url);
const { checkDefinition } = require_('../systemBuilder/definition');
const { GEAR, typesOf, ownTypes, typeNamed, valueProblem, lineColumns, itemValues } = require_('../systemBuilder/itemTypes');
const { GEAR, typesOf, ownTypes, typeNamed, valueProblem, lineColumns, itemValues, bandOf, BANDS } = require_('../systemBuilder/itemTypes');
const { itemsRenderedOf, namesOf } = require_('../systemBuilder/choices');
const { buildFile, readFile } = require_('../systemBuilder/citysys');

Expand Down Expand Up @@ -147,7 +147,7 @@ describe('the sheet is told them', () => {
it('each type\'s columns by name and kind, a COUNT\'s button and the items it reloads from by name; each item\'s type and values', () => {
const shown = itemsRenderedOf(TYPED);
// Sold at the General Store where the GM said nowhere (8a7a2).
expect(shown.types[0]).toEqual({ id: 'weapons', label: 'WEAPONS', one: 'Weapon', sold_at: ['general_store'], columns: [
expect(shown.types[0]).toEqual({ id: 'weapons', label: 'WEAPONS', one: 'Weapon', sold_at: ['general_store'], on_sheet: 'pack', columns: [
{ id: 'damage', label: 'DAMAGE', kind: 'damage' },
{ id: 'heals', label: 'HEALS', kind: 'dice' },
{ id: 'range', label: 'RANGE', kind: 'text' },
Expand All @@ -163,7 +163,7 @@ describe('the sheet is told them', () => {
]);
// A COUNT with nothing said: USE, no rest, no reload; a type with no singular: its name.
const plain = itemsRenderedOf(withTypes([{ id: 'w', label: 'WANDS', columns: [{ id: 'charges', label: 'CHARGES', kind: 'count' }] }], []));
expect(plain.types).toEqual([{ id: 'w', label: 'WANDS', one: 'WANDS', sold_at: ['general_store'], columns: [{ id: 'charges', label: 'CHARGES', kind: 'count', button: 'USE' }] }]);
expect(plain.types).toEqual([{ id: 'w', label: 'WANDS', one: 'WANDS', sold_at: ['general_store'], on_sheet: 'pack', columns: [{ id: 'charges', label: 'CHARGES', kind: 'count', button: 'USE' }] }]);
// Types alone are enough to tell; nothing at all, nothing to tell. A system making none tells no types (8a3a): its
// sheet keeps the one list, its items still GEAR with their values.
const none = itemsRenderedOf({ ...TYPED, items: { list: [{ id: 'rope', label: 'Rope', values: { weight: 10 } }] } });
Expand Down Expand Up @@ -218,3 +218,32 @@ describe('the system file', () => {
expect(read.file.definition.items).toEqual(TYPED.items);
});
});

describe('a type\'s band on the sheet (G1)', () => {
const TYPED = (onSheet) => ({ format: 1, name: 'Banded', core: { health: { model: 'pool' } }, stats: [{ id: 'abilities', label: 'ABILITIES', stats: [{ id: 'might', label: 'Might' }] }],
items: { types: [{ id: 'kit', label: 'KIT', columns: [], ...(onSheet === undefined ? {} : { on_sheet: onSheet }) }], list: [] } });

it('EQUIPPED, USABLE or PACK; PACK where unsaid or not one of them', () => {
expect(BANDS).toEqual(['equipped', 'usable', 'pack']);
expect(bandOf({ on_sheet: 'equipped' })).toBe('equipped');
expect(bandOf({ on_sheet: 'usable' })).toBe('usable');
expect(bandOf({})).toBe('pack');
expect(bandOf({ on_sheet: 'belt' })).toBe('pack');
expect(bandOf(null)).toBe('pack');
});

it('checked: one of the three', () => {
const problems = (v) => checkDefinition(TYPED(v)).problems.filter((p) => /on_sheet/.test(p.where));
for (const v of ['equipped', 'usable', 'pack', undefined]) expect(problems(v), String(v)).toEqual([]);
expect(problems('belt')).toEqual([{ where: 'type kit, on_sheet', message: 'EQUIPPED, USABLE or PACK' }]);
});

it('told to the sheet, and carried by the system file unchanged', () => {
const def = TYPED('usable');
expect(itemsRenderedOf(def).types[0].on_sheet).toBe('usable');
expect(itemsRenderedOf(TYPED(undefined)).types[0].on_sheet).toBe('pack');
const read = readFile(JSON.stringify(buildFile({ definition: def, version: 1, origin: 'sys_bandbandbandband' })));
expect(read.problems).toEqual([]);
expect(read.file.definition.items.types[0].on_sheet).toBe('usable');
});
});
16 changes: 14 additions & 2 deletions backend/systemBuilder/itemTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,15 @@ const linesOf = (data) => {
/** What a column holds: a number, words, damage dice, any other dice, a count spent and refilled, one word of a few. */
const KINDS = ['number', 'text', 'damage', 'dice', 'count', 'pick'];
const LIMITS = { types: 10, columns: 20, options: 20, word: 30, text: 200, count: 1000, reload: 10, number: 1000000000, unit: 12 };
const TYPE_KEYS = new Set(['id', 'label', 'one', 'columns', 'sold_at']);
const TYPE_KEYS = new Set(['id', 'label', 'one', 'columns', 'sold_at', 'on_sheet']);
/**
* Where a type's lines sit on the sheet's GEAR tab (G1; approved mockup docs/mockups/sheet-gear-layout.html, 2026-11-20):
* EQUIPPED (worn or wielded), USABLE (used up or used often: potions, ammo, kits) or PACK. Unsaid, PACK, as GEAR starts.
*/
const BANDS = ['equipped', 'usable', 'pack'];
const DEFAULT_BAND = 'pack';
/** A type's band: what it says, else PACK. */
const bandOf = (type) => (type && BANDS.includes(type.on_sheet) ? type.on_sheet : DEFAULT_BAND);
const BASE = ['id', 'label', 'kind'];
const COLUMN_KEYS = {
number: new Set([...BASE, 'unit']), text: new Set(BASE), damage: new Set(BASE), dice: new Set(BASE),
Expand Down Expand Up @@ -111,6 +119,8 @@ const checkTypes = (definition, problems, { text, keys, labelMost, itemIds = new
text(t.label, `${where}, label`, labelMost, { required: true });
text(t.one, `${where}, one`, labelMost);
// Where its lines are sold (8a7a2): a list of the kinds of shop, each once.
// Its band on the sheet (G1): one of the three.
if (t.on_sheet !== undefined && !BANDS.includes(t.on_sheet)) problems.push({ where: `${where}, on_sheet`, message: 'EQUIPPED, USABLE or PACK' });
if (t.sold_at !== undefined) {
if (!Array.isArray(t.sold_at)) problems.push({ where: `${where}, sold_at`, message: 'A list of the kinds of shop that sell it' });
else t.sold_at.forEach((id, n) => {
Expand Down Expand Up @@ -175,6 +185,8 @@ const typesShown = (definition, items = []) => {
id: t.id, label: t.label || t.id, one: t.one || t.label || t.id,
// The kinds of shop that sell it, the General Store where unsaid (8a7a2): the shop window's shelves follow it.
sold_at: soldAt(t),
// Its band on the GEAR tab (G1), PACK where unsaid.
on_sheet: bandOf(t),
columns: t.columns.map((c) => ({
id: c.id, label: c.label || c.id, kind: c.kind,
...(c.kind === 'number' && typeof c.unit === 'string' && c.unit.trim() ? { unit: c.unit } : {}),
Expand Down Expand Up @@ -246,4 +258,4 @@ const lineColumns = (definition, line, items, names) => {
return { type: type.id, ...(item ? { item: item.id } : {}), values, counts };
};

module.exports = { PRICE_COLUMN, MOST_PRICE, isPrice, itemPrice, inShops, KINDS, LIMITS, GEAR, NAME, SHOP_TYPES, DEFAULT_SOLD_AT, soldAt, typeShelvesAt, linesOf, typesOf, ownTypes, typeNamed, valueProblem, checkTypes, checkItemType, typesShown, itemValues, lineColumns };
module.exports = { BANDS, DEFAULT_BAND, bandOf, PRICE_COLUMN, MOST_PRICE, isPrice, itemPrice, inShops, KINDS, LIMITS, GEAR, NAME, SHOP_TYPES, DEFAULT_SOLD_AT, soldAt, typeShelvesAt, linesOf, typesOf, ownTypes, typeNamed, valueProblem, checkTypes, checkItemType, typesShown, itemValues, lineColumns };
1 change: 1 addition & 0 deletions e2e/COVERAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ panel), so a control that looks fine but does nothing is caught for all of them.
| Shop catalogues by item type | a section per item type (8a7a1), its columns checked, blanks kept | `shop_catalogue_types`, `catalogueTypes` | `catalogue-types`, `shop-typed-lines` (bought at the General Store and given, landing typed, 8a7a2) | **AT THE TABLE** |
| The shops under load | 1000+ lines on a shelf, 200 items, a full cart, a long gear list (8n3); a long shelf drawn 200 rows at a time | `shop_stress`, `ShopWindow` | `shop-stress` | **AT THE TABLE** |
| An item type's SOLD AT | the kinds of shop that sell its lines (8a7a2), the General Store where unsaid; set in the builder in 8a7b | `shop_typed_lines`, `typedShelves` | `shop-typed-lines` (unsaid: the General Store) | **AT THE TABLE** unsaid; a kind of shop picked waits for 8a7b's box |
| An item type's ON THE SHEET band | EQUIPPED, USABLE or PACK (G1), PACK where unsaid; the sheet's GEAR bands come in G2 | `system_builder_item_types`, `itemTypes`, `ItemsPage` | `builder-item-types` (the WEAPON preset EQUIPPED) | **SET IN THE BUILDER**; at the table with G2 |
| An item's PRICE and IN SHOPS | priced and IN SHOPS, it sells itself at its type's shops (8a7a3a); off, never sold, not even from a file, but bought back at its price by a shop of its type (8a7a3c2); a type's PRICE column read as its price; set on ITEMS under TYPE, NOT SOLD in the list, a new item's price asked for (8a7a3b1); in the ITEMS import and downloads, price and in shops columns (8a7a3b2) | `shop_items_on_sale`, `itemPrice`, `ItemsPage`, `system_builder_items_import`, `itemsImport` | `shop-items-on-sale` (a type's PRICE column; a ring turned off; sold back from the window at 50%), `builder-item-price` (set by clicks), `builder-items-import` (imported priced and IN SHOPS) | **AT THE TABLE** |
| A catalogue file held against the game's items | an exact copy of an item left out, an item kept out of the shops left out, one of an item's name overruling it, ALSO ON SALE FROM ITEMS (8a7a3c1) | `shop_items_on_sale`, `CatalogueWindow` | `catalogue-and-items` | **AT THE TABLE** |
| ADD NEW LINES TO ITEMS | a catalogue's new lines made items in the draft (8a7a4a), off to start; on PUBLISH the lines now exactly an item leave the file (8a7a4b) | `catalogue_into_items`, `CatalogueWindow`, `catalogueItems`, `BuilderScreen` | `catalogue-and-items` (the Hand Cannon into the draft, then out of the file once published) | **AT THE TABLE** |
Expand Down
2 changes: 1 addition & 1 deletion e2e/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ kept; the job itself stops at 30 (`timeout-minutes`), for a hang outside the tes
| `tests/builder-item-price.spec.ts` | PRICE and IN SHOPS on the builder's ITEMS page (8a7a3b1). The Pistol's PRICE, kept in its WEAPONS type's PRICE column, shown once under TYPE and changed to 180; the Rope, of a type without one and NOT SOLD while unpriced, given its own 3; the Ring of Might switched out of the shops and tagged NOT SOLD; a new armor IN SHOPS, its price asked for until 40 is typed; saved, no problems. |
| `tests/builder-items.spec.ts` | ITEMS (7e2b): + SLOT named ATTUNED with three each; + ITEM named Ring of Constitution, worded, needing WORN AND ATTUNED, with a feature Hardy giving +2 Con that STOPS AT 20, and no level, list or increase on it; saved with no problems as made, and kept after a reload. A second test (7e4b): + INSTALL made CYBERWARE costing against Strain, NEVER PAST @might (read in words), and a Cranial Jack INSTALLED AS CYBERWARE at a COST of 0.25, saved as made and there after a reload; on their tabs since 8aL1, each item made from + beside GEAR since 8aL2 |
| `tests/builder-items-import.spec.ts` | Uploading items (8aL3b): on the ITEMS tab, DOWNLOAD EXAMPLE gives a file made from the system (WEAPONS with its DAMAGE and GRADE); edited (a Hand Crossbow named, a Bad Bow with a GRADE the column hasn't), pasted into IMPORT and PREVIEWed: the crossbow new, the bow skipped by its line; APPLY, the crossbow in WEAPONS, saved with no problems Since 8a7a3b2 the example has PRICE and IN SHOPS too, and the crossbow imported from it is priced 25 and IN SHOPS. |
| `tests/builder-item-types.spec.ts` | ITEM TYPES (8a2; on their tabs since 8aL1): GEAR said to start on TYPES, where the page opens; WEAPONS from its preset, opened beside it; its AMMO refilled by LONG REST and reloaded from Pistol Rounds; + COLUMN named GRADE, PICK ONE of LIGHT, HEAVY; + ITEM named Pistol, a WEAPON, its DAMAGE, RANGE, AMMO, WEIGHT and GRADE filled; saved with no problems, the types and items as made; after a reload the Pistol a WEAPON and WEAPONS beside GEAR; since 8aL2 the Pistol made from + WEAPON, its name focused to type over, and FIND narrowing the list to the rounds, 1 OF 2 |
| `tests/builder-item-types.spec.ts` | ITEM TYPES (8a2; on their tabs since 8aL1): GEAR said to start on TYPES, where the page opens; WEAPONS from its preset, opened beside it; its AMMO refilled by LONG REST and reloaded from Pistol Rounds; + COLUMN named GRADE, PICK ONE of LIGHT, HEAVY; + ITEM named Pistol, a WEAPON, its DAMAGE, RANGE, AMMO, WEIGHT and GRADE filled; saved with no problems, the types and items as made; after a reload the Pistol a WEAPON and WEAPONS beside GEAR; since 8aL2 the Pistol made from + WEAPON, its name focused to type over, and FIND narrowing the list to the rounds, 1 OF 2 Since G1 the WEAPON preset starts EQUIPPED, checked on its ON THE SHEET buttons and in the saved draft. |
| `tests/builder-encumbrance.spec.ts` | ENCUMBRANCE on the builder's ITEMS page (8a5c): COUNT ENCUMBRANCE starting on GEAR's WEIGHT, CAN CARRY set to five times Might, the first band renamed UNBURDENED up to 40%, a third band HEAVY, the word past them CRUSHED, and the CYBERWARE install still weighing while installed; saved as made, there after a reload; and (8a5d2) ENCUMBERED saying "Speed -10 ft." and putting EXHAUSTED on, past them saying "Speed -20 ft.", kept after a reload |
| `tests/builder-condition-modifiers.spec.ts` | A condition's modifiers on the builder's CONDITIONS page (8a5e2): SLOWED made by clicks with the SNAIL icon (8a5i), ITS MODIFIERS APPLIED, Speed TIMES 0.5 and Might less by `@speed / -10`; saved as made, APPLIED, its way and its formula there after a reload |
| `tests/builder-condition-each-turn.spec.ts` | A condition's EACH TURN on the builder's CONDITIONS page (8a9b): BURNING made by clicks, ending after 3 rounds, + EACH TURN giving 1d4 damage at the start of its turn onto the token; POISONED a save at the end of its turn, d20 + @con_mod, off on 13, rolled by the player, its line in words saying Con mod; STUNNED ending AT THE END OF ITS NEXT TURN. Saved with nothing to fix, each as made after a reload |
Expand Down
4 changes: 3 additions & 1 deletion e2e/tests/builder-item-types.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ test('ITEM TYPES: WEAPONS from its preset with AMMO and a GRADE, and a Pistol fi
await types.getByRole('group', { name: 'Add an item type' }).getByRole('button', { name: 'WEAPON', exact: true }).click();
const weapons = page.getByRole('region', { name: 'WEAPONS type' });
await expect(types.getByRole('group', { name: 'The item types' }).getByRole('button', { name: 'WEAPONS' })).toHaveAttribute('aria-pressed', 'true');
// ON THE SHEET (G1): the WEAPON preset starts EQUIPPED, worn or wielded.
await expect(weapons.getByRole('group', { name: 'WEAPONS band' }).getByRole('button', { name: 'EQUIPPED' })).toHaveAttribute('aria-pressed', 'true');

// AMMO: refilled by a long rest, reloaded from Pistol Rounds.
await weapons.getByRole('combobox', { name: 'AMMO refilled by' }).selectOption({ label: 'LONG REST' });
Expand Down Expand Up @@ -70,7 +72,7 @@ test('ITEM TYPES: WEAPONS from its preset with AMMO and a GRADE, and a Pistol fi
expect(saved.draft.items).toEqual({
types: [
{ id: 'gear', label: 'GEAR', one: 'Gear', columns: [{ id: 'weight', label: 'WEIGHT', kind: 'number', unit: 'LB' }, { id: 'price', label: 'PRICE', kind: 'number' }] },
{ id: 'weapons', label: 'WEAPONS', one: 'Weapon', columns: [
{ id: 'weapons', label: 'WEAPONS', one: 'Weapon', on_sheet: 'equipped', columns: [
{ id: 'damage', label: 'DAMAGE', kind: 'damage' }, { id: 'range', label: 'RANGE', kind: 'text' },
{ id: 'ammo', label: 'AMMO', kind: 'count', button: 'FIRE', refill: 'long_rest', reload: ['rounds'] },
{ id: 'weight', label: 'WEIGHT', kind: 'number', unit: 'LB' }, { id: 'price', label: 'PRICE', kind: 'number' },
Expand Down
13 changes: 12 additions & 1 deletion frontend/src/components/ItemTypesSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { Definition, systemsApi } from '../sheets/systemsApi';
import {
itemTypes, ownTypes, typeOf, itemValues, withNewType, withType, withoutType, withDefaultType, withNewColumn, withColumn, withoutColumn,
withItemType, withItemValue, wordsFrom, KINDS, PRESETS, LIMITS, type ItemColumn, type ItemType, type ColumnKind,
priceColumnOf, itemPriceOf, inShopsOf, priceNeeded, withItemPrice, withInShops, MOST_PRICE,
priceColumnOf, itemPriceOf, inShopsOf, priceNeeded, withItemPrice, withInShops, MOST_PRICE, BANDS, bandOf,
} from '../sheets/itemTypes';
import { ToggleSwitch } from './ToggleSwitch';
import { itemList, type Item } from '../sheets/items';
Expand Down Expand Up @@ -183,6 +183,17 @@ export function ItemTypesSection({ definition, edit, place = 'items' }: Props &
<FieldName beside htmlFor={`type-${type.id}-one`} hint={HINTS['items.one']} style={small}>ONE</FieldName>
<input id={`type-${type.id}-one`} type="text" maxLength={LIMITS.label} value={type.one ?? ''} placeholder={type.label} style={{ ...input, width: 200, justifySelf: 'start' }}
onChange={(e) => edit(withType(definition, type.id, { one: e.target.value }))} />
{/* Its band on the sheet's GEAR tab (G1; approved mockup sheet-gear-layout.html, 2026-11-20). */}
<FieldName beside hint={HINTS['items.onSheet']} style={small}>ON THE SHEET</FieldName>
<span style={{ display: 'flex', flexDirection: 'column', gap: 4, alignItems: 'flex-start' }}>
<span role="group" aria-label={`${nameOf(type)} band`} style={row}>
{BANDS.map((b) => (
<button key={b.id} type="button" className={`utility-btn${bandOf(type) === b.id ? ' active' : ''}`} style={{ ...btn, padding: '3px 9px' }} aria-pressed={bandOf(type) === b.id}
onClick={() => edit(withType(definition, type.id, { on_sheet: b.id }))}>{b.label}</button>
))}
</span>
<span style={{ ...why, fontSize: 11 }}>{BANDS.find((b) => b.id === bandOf(type))!.why}</span>
</span>
</div>
<div className="crt-scroll" style={{ overflowX: 'auto' }}>
<table style={{ borderCollapse: 'collapse', fontSize: 12 }}>
Expand Down
Loading
Loading