From 87def731b55cc79224392082b04832001580384a Mon Sep 17 00:00:00 2001 From: Developer Date: Sun, 22 Nov 2026 10:44:30 -0600 Subject: [PATCH 1/2] feat: UNIQUE on GEAR, a line changed from its item saying so with the item's value and who changed it when on hover; in its card UNIQUE, the item's value and THE ITEM'S beside each column made its own; n UNIQUE at the top listing them in FIND --- CHANGELOG.md | 1 + README.md | 14 +++--- e2e/COVERAGE.md | 2 +- e2e/README.md | 2 +- e2e/tests/sheet-item-types.spec.ts | 13 +++++ frontend/src/components/GearTypeTables.tsx | 30 +++++++++++- .../__tests__/GearTypeTables.test.tsx | 42 +++++++++++++++++ .../src/sheets/__tests__/gearTypes.test.ts | 47 ++++++++++++++++++- .../src/sheets/__tests__/inventory.test.ts | 11 +++++ frontend/src/sheets/gearTypes.ts | 38 +++++++++++++-- frontend/src/sheets/inventory.ts | 16 +++++++ 11 files changed, 200 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c403effe..3b0f0636 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -106,6 +106,7 @@ Format follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### Added +- **UNIQUE on GEAR.** A thing changed from the item it is named after (the Cutlass made 2d8) now says UNIQUE on its line; hover it for the item's own value and who changed it, and when (a player by name, or the GM). In its card, each column made its own says UNIQUE with the item's value beside it and a THE ITEM'S button to put it back. The top of GEAR counts them ("1 UNIQUE"); click it, or type unique in FIND, to list them. SHEET.EXE and the sheet's own tab are the same. - **FIND on GEAR.** A find box at the top of the sheet's GEAR tab, always there, keeps only the things that match as you type: a name, a type (GUNS), a value (2d6, 30 m) or a column (AMMO), in any case, every word somewhere on the line. Each band counts its matches and opens while you search, so nothing in a closed STASH is missed; clear it with its × or Esc and the bands are as you left them. When nothing matches, it says so. SHEET.EXE and the sheet's own tab are the same. - **GEAR in bands.** The sheet's GEAR tab now sorts what you carry into EQUIPPED, USABLE and PACK, by each item type's ON THE SHEET, with a count on each band and what's in hand first. A fourth band, STASH, holds everything left in the stash whatever its type, and says each one's type; it starts closed. Click a band's head to close or open it, and the sheet remembers. The + buttons for adding a thing by hand sit in one row at the top, and the band it lands in opens. SHEET.EXE and the sheet's own tab are the same. - **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. diff --git a/README.md b/README.md index dbfdeef8..0f3023d1 100644 --- a/README.md +++ b/README.md @@ -798,7 +798,7 @@ CITY_NET/ │ │ │ ├── SystemPicker.tsx # GAME tab's system picker: a searchable dropdown, BUILT-IN then YOUR SYSTEMS, portalled into the theme, asking before it switches the game for everyone │ │ │ ├── systemPickerRules.ts # The picker's rules on their own: grouping and order, search, arrow-key movement, what the button says │ │ │ ├── InventorySection.tsx # The inventory table, on every system. Its own file because SheetRenderer is long enough, and generic: which rows carry an extra button, and what pressing it does, is supplied from outside - so a drug offers CONSUME and a skillplug offers LOAD without either knowing about the other A custom system's items (7e3b): the slot counters over it, and WEAR and ATTUNE under a line of an item's name (GearItemLine); an installed item's line locked, named and in place, until REMOVE (7e4c); a custom system with item types gets a table per type instead (8a3a, GearTypeTables.tsx); tells GEAR's bands which lines are worn, attuned or installed, from what the server worked out (G3); only the slot and install counters something on the sheet uses, 8px apart from FIND on a typed GEAR tab -│ │ │ ├── GearTypeTables.tsx # The GEAR tab as a table per item type (8a3a; approved mockup item-types, 2026-11-14): each type's lines under its own column heads, units said; a line's own value over its item's, shown faint until typed over; + a type's one to add a line of it by hand; name, quantity, where and location as the one list has them; ROLL beside each DAMAGE and DICE (8a3b), read only or not, where the viewer may roll; since 8a3c1 a compact line per thing (name, QTY, WHERE, ✎, ×; only the columns it has as words under it, its item's faint, ROLL beside DAMAGE and DICE, a stashed one's place), ✎ opening every column as a box, one line at a time, a line made by hand opened; under ✎ a DAMAGE or DICE with eˣ (8a3c2): what it reads on this character, a name the system hasn't got flagged, SHAPE and INSERT; a COUNT as "AMMO 4 / 6" with its button (FIRE) and RELOAD beside it (8a4b), held while the server answers, RELOAD FROM asking which carried line where there are several, a refusal said on the line; in bands (G2): EQUIPPED, USABLE and PACK by each type's ON THE SHEET, a group per type with lines, in hand first, and STASH, closed to start, each line's type said; a band's head closes it, remembered; a row of + at the top adds a thing of any type by hand, opening its band; one line a thing (G3): its name, how many, its columns as words with ROLL, FIRE and RELOAD, where it is carried, ✎ at its end (or a click on the line) opening its card (NAME, HOW MANY, every column, LOCATION, DONE, REMOVE), FILL IN where nothing at all is filled in opening the card at its first box, a PICK ONE box as wide as its words; a closed band something lands in (worn, bought, given) pulses three times and stays lit in the theme's own color until opened (G3); FIND at the top, always shown (G4): only the lines it matches, each band counted by its matches and open while it has words, heads readable but not toggling, its own × and Esc to clear, "Nothing on this sheet matches" when nothing does +│ │ │ ├── GearTypeTables.tsx # The GEAR tab as a table per item type (8a3a; approved mockup item-types, 2026-11-14): each type's lines under its own column heads, units said; a line's own value over its item's, shown faint until typed over; + a type's one to add a line of it by hand; name, quantity, where and location as the one list has them; ROLL beside each DAMAGE and DICE (8a3b), read only or not, where the viewer may roll; since 8a3c1 a compact line per thing (name, QTY, WHERE, ✎, ×; only the columns it has as words under it, its item's faint, ROLL beside DAMAGE and DICE, a stashed one's place), ✎ opening every column as a box, one line at a time, a line made by hand opened; under ✎ a DAMAGE or DICE with eˣ (8a3c2): what it reads on this character, a name the system hasn't got flagged, SHAPE and INSERT; a COUNT as "AMMO 4 / 6" with its button (FIRE) and RELOAD beside it (8a4b), held while the server answers, RELOAD FROM asking which carried line where there are several, a refusal said on the line; in bands (G2): EQUIPPED, USABLE and PACK by each type's ON THE SHEET, a group per type with lines, in hand first, and STASH, closed to start, each line's type said; a band's head closes it, remembered; a row of + at the top adds a thing of any type by hand, opening its band; one line a thing (G3): its name, how many, its columns as words with ROLL, FIRE and RELOAD, where it is carried, ✎ at its end (or a click on the line) opening its card (NAME, HOW MANY, every column, LOCATION, DONE, REMOVE), FILL IN where nothing at all is filled in opening the card at its first box, a PICK ONE box as wide as its words; a closed band something lands in (worn, bought, given) pulses three times and stays lit in the theme's own color until opened (G3); FIND at the top, always shown (G4): only the lines it matches, each band counted by its matches and open while it has words, heads readable but not toggling, its own × and Esc to clear, "Nothing on this sheet matches" when nothing does; UNIQUE (G5b): on a line changed from its item, the item's and who changed it when on hover; in the card, beside each column made its own, UNIQUE, THE ITEM'S to put it back and what the item had; "n UNIQUE" at the top listing them in FIND │ │ │ ├── GearItemLine.tsx # A system's item on its GEAR line (7e3b): its NEEDS tag, WEAR or WORN · TAKE OFF, ATTUNE (ATTUNED · END, the GM's ATTUNE ANYWAY), what it is doing, and its features' uses; the slot counters over the gear (ATTUNED 2 OF 3, amber when full) with the GM's box for one character's own count; and each install's counter, amber at its limit (7e4c) │ │ │ ├── PharmaSection.tsx # What is currently in the bloodstream, drawn in the sheet HEADER rather than a tab: a drug that wears off at the end of a scene and bills System Strain for it is not something to hide behind a tab somebody might not open. Draws nothing at all while a character is on nothing │ │ │ ├── XpWindow.tsx # AWARD_EXPERIENCE — points each rather than a pot to divide, with LEVEL_UP and LEVEL_DOWN for correcting a level on purpose; in a game that spends XP, given to spend, with no level buttons where there are no levels (7f2c2) @@ -1085,7 +1085,7 @@ CITY_NET/ │ │ │ ├── SheetCyberware.test.tsx # The sheet showing what the chrome does, so a correct effects layer is actually read │ │ │ ├── InventorySection.test.tsx # The inventory table editing one field cleanly, though every keystroke rewrites the whole list │ │ │ ├── GearItemLine.test.tsx # WEAR and ATTUNE on GEAR (7e3b): the counter, an item's line under its own row, what pressing asks, a full slot disabled and why, the GM's ATTUNE ANYWAY and own count, read-only, uses ticking, a refusal said, a system without items unchanged; installs (7e4c): the counter, an installed line locked, REMOVE and INSTALL asked, a player's disabled past the limit, the GM's anyway, amber when full -│ │ │ ├── GearTypeTables.test.tsx # The GEAR tab as a table per type (8a3a): each type's lines and heads, an empty type its heading and + only, an item's values faint until typed over, + a type's one by hand staying in its table, read only, a system without types keeping the one list; ROLL beside DAMAGE sending its line and column, nothing to roll nothing to press, read only still there (8a3b); compact lines (8a3c1): only the columns a line has, ✎ one at a time with "none" where it has none, a hand-made line opened, read only without ✎; a DAMAGE under ✎ read on this character, a bad name flagged, never an older text's words, eˣ SHAPE and INSERT (8a3c2); a COUNT's "4 / 6" with FIRE and RELOAD, held while waiting, none left or full, USE by default, RELOAD FROM asked and CANCEL, a refusal on its line (8a4b); in bands (G2): the four in order and counted, in hand first, STASH closed, a head closing and opening its band remembered, the STASH saying each type, an empty band saying so, a thing made by hand opening its band; one line a thing (G3): a click on the line opening its card but not on ROLL or where it is carried, one card at a time, ✎ opening and closing it (none read only), FILL IN only where nothing is filled in, naming the columns and opening at the first (a DAMAGE too), none where something is or a type has no columns, UNNAMED, a PICK ONE box as wide as its words; a worn Cutlass of a PACK type in EQUIPPED, back in PACK taken off; a closed band lit when the server puts something in it, not on opening the sheet, not an open band, cleared when opened, not when the player opens it by hand; FIND (G4): as you type, counted, every band open, heads not toggling, × and Esc clearing, as left once cleared and nothing lit, a value and a column, nothing found, read only too; the slot and install counters only where something uses them +│ │ │ ├── GearTypeTables.test.tsx # The GEAR tab as a table per type (8a3a): each type's lines and heads, an empty type its heading and + only, an item's values faint until typed over, + a type's one by hand staying in its table, read only, a system without types keeping the one list; ROLL beside DAMAGE sending its line and column, nothing to roll nothing to press, read only still there (8a3b); compact lines (8a3c1): only the columns a line has, ✎ one at a time with "none" where it has none, a hand-made line opened, read only without ✎; a DAMAGE under ✎ read on this character, a bad name flagged, never an older text's words, eˣ SHAPE and INSERT (8a3c2); a COUNT's "4 / 6" with FIRE and RELOAD, held while waiting, none left or full, USE by default, RELOAD FROM asked and CANCEL, a refusal on its line (8a4b); in bands (G2): the four in order and counted, in hand first, STASH closed, a head closing and opening its band remembered, the STASH saying each type, an empty band saying so, a thing made by hand opening its band; one line a thing (G3): a click on the line opening its card but not on ROLL or where it is carried, one card at a time, ✎ opening and closing it (none read only), FILL IN only where nothing is filled in, naming the columns and opening at the first (a DAMAGE too), none where something is or a type has no columns, UNNAMED, a PICK ONE box as wide as its words; a worn Cutlass of a PACK type in EQUIPPED, back in PACK taken off; a closed band lit when the server puts something in it, not on opening the sheet, not an open band, cleared when opened, not when the player opens it by hand; FIND (G4): as you type, counted, every band open, heads not toggling, × and Esc clearing, as left once cleared and nothing lit, a value and a column, nothing found, read only too; the slot and install counters only where something uses them; UNIQUE (G5b): the line's tag and hover, none as the item has it; in the card, what the item had and who changed it, THE ITEM'S putting it back; the count listing them in FIND │ │ │ ├── conditionNote.test.tsx # The conditions on the token under the number they change (8a5e3): SLOWED: Speed ×0.5 · typed 30 with the halved Speed the big number, clicked to edit what is typed, a skill's line, two on one number, a system with no picks or items, none on the token │ │ │ ├── PharmaSection.test.tsx # Taking a dose from a Readied inventory row, and what is running shown in the sheet header │ │ │ ├── Skillplugs.test.tsx # LOAD on a Readied plug, the granted skill on SKILLS, and what is loaded in the header @@ -1235,7 +1235,7 @@ CITY_NET/ │ │ │ ├── bookPlacement.ts # Where a CWN book item lands, as the shop's shelves place it, taken out of ShopWindow into one pure function: a carried weapon row Stowed, a vehicle row from its preset with the immunity note, cyberware unplaced, inventory lines with Encumbrance (blank, never "undefined", when an upload gives none), a dose stacked by any of its names; asBookRow for a GM's upload on a book shelf │ │ │ ├── cwnWeaponStash.ts # Weapons you own but are not carrying. No Encumbrance, a location note, and one move each way - the move clears every field including atk, because a zero counts as data and would leave a ghost row │ │ │ ├── cwnEncumbrance.ts # Readied and Stowed against Strength-derived limits, counted always and charged only where the house rule asks. Being overloaded in CWN costs Move and nothing else, which makes this a much smaller feature than the word usually implies -│ │ │ ├── inventory.ts # Everything carried that is not a weapon, on all four systems - structured rows, because a textarea cannot be counted. CWN adds the book's bundling rule, where three small items are one item of Encumbrance; a line keeps a custom system's type, values and counts where it has them (8a3a) +│ │ │ ├── inventory.ts # Everything carried that is not a weapon, on all four systems - structured rows, because a textarea cannot be counted. CWN adds the book's bundling rule, where three small items are one item of Encumbrance; a line keeps a custom system's type, values and counts where it has them (8a3a); a line keeps `changed`, who changed which column from its item and when, where well formed (G5b) │ │ │ ├── cwnAdvancement.ts # The experience bar's arithmetic and the slow-advancement house rule, which is table-wide rather than a per-character field: one table advances at one pace │ │ │ ├── cwnLanguages.ts # Thirty-four real languages grouped by region, plus the Connect/Know allowance that pays for them. Typed entry is the load-bearing part - the two a character starts with are invented per campaign and no fixed list could hold them │ │ │ ├── cwnPharma.ts # The drug table mirrored, plus what the sheet owns: which doses you are carrying (inventory rows), taking one, and ending the doses a scene ends. Cross-checked against the server copy entry by entry @@ -1291,7 +1291,7 @@ CITY_NET/ │ │ │ ├── encumbrance.ts # The builder's ENCUMBRANCE as logic (8a5c; approved mockup item-types, 2026-11-14, decision 7): read and written back tidy, the NUMBER columns it can count with their types, how it starts (WEIGHT, ten times the first stat, LIGHT 50 / ENCUMBERED 100 / OVERLOADED), the bands, and the names formulas read of the gear for INSERT; a band's words and condition, and past them, kept through every edit (8a5d1); blank words and NONE kept as nothing, words cut at 200 (8a5d2) │ │ │ ├── ranks.ts # The builder's ranks as logic (7f1b): lists from four presets or empty, renamed and removed (their stats back to numbers), ranks added, changed, moved and removed (a stat's highest at the start following), a stat's HOLDS and AT START │ │ │ ├── gearItems.ts # Items on the GEAR tab as logic (7e3b): which gear line draws which item (by name, the first carried), what the last save worked out, each line's buttons and words (WEAR, ATTUNE, the GM's ATTUNE ANYWAY, WORKING, why it does nothing), a slot's verb from its name (ATTUNED → ATTUNE), the counters, the GM's own count asked, an item's uses; installed items (7e4c): INSTALL with room, a player's disabled past the limit and why, the GM's INSTALL ANYWAY, INSTALLED · REMOVE, each install's counter (CYBERWARE · STRAIN 2.75 OF 3, or NEVER BELOW), the names installed; the render copy's item types, and each item's type and values (8a3a); countersInUse (2026-11-22): the slots and installs a sheet has a use for, one an item on a line needs or one with something still counted against it -│ │ │ ├── gearTypes.ts # The GEAR tab's tables as logic (8a3a): the types from the render copy, what fits each column, a line's type (its own, its item's, the first) and its cells (its own value over its item's, the item's only on a line of its type), the tables in the system's order, a value typed, a new line of a type; mirrors the server's lineColumns; shownCells and cellWords, what a compact line shows (8a3c1); countOf, a COUNT left as the server counts it, and "4 / 6" in words (8a4b); gearBands, the GEAR tab's bands (G2): each type's lines in its ON THE SHEET band, in hand first, groups only for types with lines, and every stashed line in STASH; a line worn, attuned or installed in EQUIPPED whatever its type's band (G3); landedIn, the closed bands something landed in between two drawings (G3); lineWords and foundIn, FIND on GEAR (G4): a line found by its name, type, band, where it is carried and is, and each column with its words, every word typed somewhere on it +│ │ │ ├── gearTypes.ts # The GEAR tab's tables as logic (8a3a): the types from the render copy, what fits each column, a line's type (its own, its item's, the first) and its cells (its own value over its item's, the item's only on a line of its type), the tables in the system's order, a value typed, a new line of a type; mirrors the server's lineColumns; shownCells and cellWords, what a compact line shows (8a3c1); countOf, a COUNT left as the server counts it, and "4 / 6" in words (8a4b); gearBands, the GEAR tab's bands (G2): each type's lines in its ON THE SHEET band, in hand first, groups only for types with lines, and every stashed line in STASH; a line worn, attuned or installed in EQUIPPED whatever its type's band (G3); landedIn, the closed bands something landed in between two drawings (G3); lineWords and foundIn, FIND on GEAR (G4): a line found by its name, type, band, where it is carried and is, and each column with its words, every word typed somewhere on it; UNIQUE (G5b): a cell `unique` where the line is its item's, of its type, with its own value not the item's (the server's uniqueLines, mirrored), uniqueCells, changedWords, itemWas, uniqueTitle, uniqueCount, and "unique" in FIND │ │ │ ├── gearDice.ts # A gear line's DAMAGE or DICE in words (8a3c2): ON THIS CHARACTER with each name's value and the range, or what is wrong; the eˣ shapes and INSERT at the cursor │ │ │ ├── rollTotal.ts # A roll line's final total, found for the dice history to bold: after the last = in its first [ ], or the lone number; never what follows a · │ │ │ ├── catalogueItems.ts # A system's items in the shops' catalogues (7e3c): the preview's lines read against the items (named as one, landing as gear or not; nearly named, the closest said), the shelf a starter file uses (the gear's, or the first landing as gear), and the starter file itself, prices left blank; with types of its own, DOWNLOAD ITEMS puts each item in its type's section with its columns, and a type's section counts as gear in the preview (8a7a1); ITEMS_ADDED_EVENT and withAddedItems, a catalogue's new items merged into a draft by id (8a7a4a) @@ -1345,7 +1345,7 @@ CITY_NET/ │ │ │ ├── encumbrance.test.ts # The builder's ENCUMBRANCE as logic (8a5c): written tidy with the items kept, what it can count, how it starts held to the server's check, COUNTED BY's unit, the bands, the names formulas read held to the server's; a band's words and condition kept through every edit (8a5d1); blank words and NONE kept as nothing, cut at 200, held to the server's check (8a5d2) │ │ │ ├── ranks.test.ts # Ranks as logic (7f1b): each preset sound as the server checks it, copies never the preset, lists and ranks changed, moved and removed with AT START following, HOLDS and AT START │ │ │ ├── gearItems.test.ts # Items on GEAR as logic (7e3b): the line each item draws on, what a save worked out read safely, the slot's verb, every state's buttons and words for player, GM and read-only, the counters, the GM's box, uses; installs (7e4c): room each way with rounding, every state's buttons and words, the counters, the names installed; countersInUse: a slot or install an item on a line needs, or still counted against with its line gone, not one nothing uses -│ │ │ ├── gearTypes.test.ts # The GEAR tab's tables as logic (8a3a): the types read, what fits each kind as the server's check, each line's type and values as the server's lineColumns on the same lines, the tables, values typed, a line's type, values and counts kept on the sheet and on the server, bought one more of; a COUNT left held to the server's lineColumns on the same lines (8a4b); gearBands (G2): each band's lines and count, in hand first then as listed, no group for a type with none there, an unknown band as PACK, stashed lines in STASH whatever the type; a line on you in EQUIPPED in a group of its type, the rest by type, stashed still the STASH, no empty group for an EQUIPPED type whose lines are all stashed (G3); landedIn: a closed band whose count went up, not an open one or one that fell, nothing before the first drawing (G3); foundIn (G4): by name, type, band, place, a column and its words, any case, every word, no group for a type with nothing found, blank as they are +│ │ │ ├── gearTypes.test.ts # The GEAR tab's tables as logic (8a3a): the types read, what fits each kind as the server's check, each line's type and values as the server's lineColumns on the same lines, the tables, values typed, a line's type, values and counts kept on the sheet and on the server, bought one more of; a COUNT left held to the server's lineColumns on the same lines (8a4b); gearBands (G2): each band's lines and count, in hand first then as listed, no group for a type with none there, an unknown band as PACK, stashed lines in STASH whatever the type; a line on you in EQUIPPED in a group of its type, the rest by type, stashed still the STASH, no empty group for an EQUIPPED type whose lines are all stashed (G3); landedIn: a closed band whose count went up, not an open one or one that fell, nothing before the first drawing (G3); foundIn (G4): by name, type, band, place, a column and its words, any case, every word, no group for a type with nothing found, blank as they are; UNIQUE (G5b): which cells, read loosely, blank as nothing, none made by hand or of another type; who and when in words, the GM as the GM; what the item had; the hover; the count; "unique" in FIND │ │ │ ├── rollTotal.test.ts # A roll line's final total: the new and old forms, the tray's own, symbols, a later [ ] or · passed over, the line put back unchanged │ │ │ ├── catalogueItems.test.ts # Items in catalogues (7e3c): how far apart two names are, a line named as an item, one landing in its own rows, near misses by marks or a letter or two, the closest named, nothing without items, the starter file on the gear's shelf or the next │ │ │ ├── levels.test.ts # The table held to the server's, the ranges staying joined, adding and taking one off, typing over, what the boxes show, how they advance, the word @@ -1395,7 +1395,7 @@ CITY_NET/ │ │ │ ├── serverBookPlacement.test.ts # The server's CWN book placement held to the shop's: every book item and uploaded rows on every book shelf placed both ways on the same sheets (rows full and blank-named, stacks and stashes, doses under other names, chrome with mods, junk), a row for every item the book sells and none for one it doesn't, and no "undefined" Encumbrance │ │ │ ├── ownedItems.test.ts # What a character owns, worked out by both sides on the same sheets and compared │ │ │ ├── sheetSlots.test.ts # Where each system keeps weapons and vehicles, the template's shape and the server's copy compared entry for entry -│ │ │ ├── inventory.test.ts # Inventory rows on all four systems, sharing Readied, Stowed and Stash with weapons +│ │ │ ├── inventory.test.ts # Inventory rows on all four systems, sharing Readied, Stowed and Stash with weapons; `changed` kept where well formed, dropped where not (G5b) │ │ │ ├── modTargets.test.ts # What a cyberware modifier may point at, derived from three differently shaped templates, never a target that could not work │ │ │ ├── cyberwareEffects.test.ts # The sheet's chrome sums agreeing with the server's on the same cases │ │ │ ├── cyberwarePlacement.test.ts # Placing a piece as its own decision, so naming its type never installs it; every row read the same way as the server's normaliseRow, fitted mods included @@ -1546,7 +1546,7 @@ CITY_NET/ │ ├── sheet-increases.spec.ts # Ability increases at the table (7d6b2): points spread in ABILITY INCREASE within what it allows, named on the stat's badge, taken off by LEVEL_DOWN; a Feat taken instead, under the feature and on the badge (7d6c2) │ ├── sheet-bonus-ways.spec.ts # The ways a bonus counts at the table (7e1): two +2s each stopping at 20, the cut one named on the badge; an AT LEAST lifts what they leave │ ├── sheet-worn-items.spec.ts # Items at the table (7e3b): WEAR and ATTUNE on GEAR, the ring's +2 CON once attuned and the slot full, a second worn with nothing to press, the GM's ATTUNE ANYWAY and own count, END, taken off still attuned; GIVE.EXE's ITEMS handing the ring to a player, who wears it; TERMINATE_SESSION closing GIVE.EXE at once; no ATTUNED bar until a line needing the slot is on the sheet -│ ├── sheet-item-types.spec.ts # The GEAR tab as a table per type (8a3a): a stick made by hand with its own DAMAGE and GRADE, a line named like the Pistol showing its values faint, RANGE typed over, a rope in GEAR, saved as made, each in its table after a reload; compact lines with ✎ and DONE, and nothing on the GEAR tab scrolling sideways in SHEET.EXE (8a3c1); the Pistol's DAMAGE read on this character under ✎, a bad name flagged, eˣ INSERT (8a3c2); in bands (G2), PACK saying "Nothing here." and things added from the row of + at the top; the Pistol's card opened by a click on its name (G3) +│ ├── sheet-item-types.spec.ts # The GEAR tab as a table per type (8a3a): a stick made by hand with its own DAMAGE and GRADE, a line named like the Pistol showing its values faint, RANGE typed over, a rope in GEAR, saved as made, each in its table after a reload; compact lines with ✎ and DONE, and nothing on the GEAR tab scrolling sideways in SHEET.EXE (8a3c1); the Pistol's DAMAGE read on this character under ✎, a bad name flagged, eˣ INSERT (8a3c2); in bands (G2), PACK saying "Nothing here." and things added from the row of + at the top; the Pistol's card opened by a click on its name (G3); the Pistol UNIQUE after the reload, its hover naming the player, 1 UNIQUE; THE ITEM'S on DAMAGE and RANGE, saved a plain Pistol (G5b) │ ├── sheet-gear-bands.spec.ts # The GEAR tab in bands (G2): a Sword, a Draught and a Rope added by hand land in EQUIPPED, USABLE and PACK, counted; the Sword stashed moves to STASH, which opens and says WEAPONS; USABLE closed by its head stays closed on the next visit; the Draught's blank HEALS filled from FILL IN, its card opened at that box (G3); a Cloak of GEAR worn into EQUIPPED and taken off back into PACK, EQUIPPED closed first and lit when the Cloak is worn; FIND 2d4 showing the Draught in a closed USABLE, nothing for lantern, cleared and USABLE closed again (G4) │ ├── sheet-gear-counts.spec.ts # A gear line's COUNT at the table (8a4): the Pistol's AMMO 2 / 6, FIRE spending one, RELOAD asking between Pistol Rounds and AP Rounds and using the AP Rounds up, then full from the Pistol Rounds; the Wand's CHARGES filled by a short rest from the sheet │ ├── sheet-standalone-tab.spec.ts # The sheet in a new tab (8s1a): opened with ⧉, in the theme, WEAR there works and SHEET.EXE says so, a weapon's DAMAGE rolled from it; the roll from the tab opening the main app's dice tray (8s1b); a character being made: CREATING · CONTINUE on the tab opening NEW_CHARACTER.EXE there (8s1c); Cash on the tab opening BANK.EXE in the main window, and with that window closed the tab saying to open it (8s1d); gear added from the row of + at the top of GEAR (G2) diff --git a/e2e/COVERAGE.md b/e2e/COVERAGE.md index 1b11a1e6..eeaaf263 100644 --- a/e2e/COVERAGE.md +++ b/e2e/COVERAGE.md @@ -125,7 +125,7 @@ panel), so a control that looks fine but does nothing is caught for all of them. | Items | An item's INSTALLED AS and COST (7e4) | `items.list[].needs`, `items.list[].cost` | `builder-items`, `sheet-installed-items` | Proven at the table (7e4c): installed, its cost on Strain named by it, its line locked, removed; fractions by server and unit tests | | Items | ITEM TYPES: a name, one of them, columns of NUMBER (a unit), TEXT, DAMAGE, DICE, COUNT (a button, a rest, items it reloads from) and PICK ONE (its words), from a preset or blank (8a1, 8a2) | `items.types` | `builder-item-types`, `builder-clicks`, `sheet-item-types`, `sheet-gear-counts` | Made in the builder (8a2): WEAPONS from its preset, a COUNT's rest and reload, a PICK ONE's words. At the table (8a3a): a table per type on GEAR with its columns; DAMAGE rolled (8a3b): a stick's 1d4 in the dice tray's history; a COUNT at the table (8a4b): its button (FIRE) spending one, RELOAD from items it names (asked which of two carried, taken from the quantity, a line used up gone) and a rest it names refilling it | | Items | The DEFAULT type: MAKE DEFAULT moves one to the top (8aL1) | `items.types` order | `builder-clicks` | Builder only so far (8aL1): the items that said nothing keep their type, held by tests; at the table, a line that is no item lands in the first type (8a3a) | -| Items | An item's TYPE and its VALUES, one per column (8a1, 8a2) | `items.list[].type`, `items.list[].values` | `builder-item-types`, `sheet-item-types` | Filled in the builder (8a2): a Pistol of WEAPONS with DAMAGE, RANGE, AMMO, WEIGHT and GRADE. At the table (8a3a): a line named like it shows them faint, its own typed over. A line with nothing filled in, on it or its item (G3): FILL IN, opening the card at its first box (`sheet-gear-bands`, the Draught's HEALS); a blank beside others filled doesn't apply and says nothing | +| Items | An item's TYPE and its VALUES, one per column (8a1, 8a2) | `items.list[].type`, `items.list[].values` | `builder-item-types`, `sheet-item-types` | Filled in the builder (8a2): a Pistol of WEAPONS with DAMAGE, RANGE, AMMO, WEIGHT and GRADE. At the table (8a3a): a line named like it shows them faint, its own typed over. A line with nothing filled in, on it or its item (G3): FILL IN, opening the card at its first box (`sheet-gear-bands`, the Draught's HEALS); a blank beside others filled doesn't apply and says nothing. A line changed from its item (G5a, G5b): UNIQUE on it with who changed it when, THE ITEM'S putting a column back (`sheet-item-types`, the Pistol's RANGE and DAMAGE) | | Items | Uploading items: IMPORT, DOWNLOAD EXAMPLE (made from the system), DOWNLOAD THIS LIST (8aL3) | the draft's `items` | `builder-items-import` | Proven in the builder (8aL3b): the example downloaded, edited, imported with a mistake skipped by its line, saved; the list back unchanged held by tests | | Items | A line of gear made by hand: its TYPE and its own VALUES (8a3a) | the sheet's `inventory[].type`, `inventory[].values` | `sheet-item-types` | Proven at the table (8a3a): + WEAPON made A stick with its own DAMAGE and GRADE, kept in its table after a reload | | Items | ENCUMBRANCE: COUNTED BY a column, its unit, CAN CARRY, bands at a share of it and the word past them; an install's WEIGHS WHILE INSTALLED (8a5a, 8a5c) | `items.encumbrance`, `items.installs[].weighs` | `builder-encumbrance`, `builder-clicks`, `sheet-carrying` | Made in the builder (8a5c): counted by WEIGHT, CAN CARRY, bands renamed, moved and added, the word past them, an install that still weighs, saved and kept. Server tests (8a5a): @carried and @capacity on every save. At the table (8a6a): Might 5 carrying three 10 LB Packs reads CARRYING 30 / 50 LB, ENCUMBERED, its meter and LIGHT ≤ 25 · ENCUMBERED ≤ 50 · OVERLOADED; one stashed, 20 LB and LIGHT | diff --git a/e2e/README.md b/e2e/README.md index e107ca25..6a1f92c5 100644 --- a/e2e/README.md +++ b/e2e/README.md @@ -205,7 +205,7 @@ kept; the job itself stops at 30 (`timeout-minutes`), for a hang outside the tes | `tests/sheet-ranks.spec.ts` | A rank on the sheet (7f1c1): a player with Level 3 sees Athletics as a picker of UNTRAINED, TRAINED and EXPERT, picks EXPERT, its worth = 7 shows beside it, the formula Climb reading it shows 8, and the server keeps the step 2 with Athletics 7 and Climb 8 | | `tests/sheet-ranks-start.spec.ts` | Ranks making a character (7f1c2): a player in NEW CHARACTER types Grit, finds Lore under RANKS with UP TO TRAINED TO START and EXPERT off, picks TRAINED, and the server keeps the step 1 with Lore worth 2 | | `tests/sheet-worn-items.spec.ts` | Items at the table (7e3b): two GEAR lines named like items get WEAR and ATTUNE; the ring worn does nothing yet, attuned it is WORKING, ATTUNED 1 OF 1, CON 14 → 16; the cloak worn with no slot free says so and can't attune; the GM, on the player's sheet, ATTUNES it ANYWAY (2 OF 1) and gives them 2 of their own; END frees the ring's slot and its +2 goes; the cloak taken off stays attuned and does nothing. A second test: the GM's GIVE.EXE lists the ring under ITEMS with NEEDS ATTUNED and its words, gives it to the player as a stowed gear line, the player is told and WEARS it; TERMINATE_SESSION closes GIVE.EXE while the session is still ending; and (2026-11-22) no ATTUNED bar on GEAR until the Ring's line is there | -| `tests/sheet-item-types.spec.ts` | The GEAR tab as a table per item type (8a3a): a player's sheet with WEAPONS and GEAR tables, each empty with its +; + WEAPON made A stick with DAMAGE 1d4 and GRADE HEAVY; a second line named Pistol showing 2d6 + @might faint, its RANGE typed over to 50 m; + GEAR made Rope at 10 lb; saved as made, each in its table after a reload; since 8a3b the stick's DAMAGE rolled with ROLL, "rolled A stick DAMAGE 1d4" in the dice tray's history; and (8a3c1) as compact lines: a line made by hand opened under ✎, DONE showing its words with ROLL, the Pistol's RANGE read as words after the reload, and no box on the GEAR tab scrolling sideways in SHEET.EXE; and (8a3c2) the Pistol's DAMAGE under ✎ said ON THIS CHARACTER: 2d6 + Might (12): 14 to 24, @strength flagged as not the system's, eˣ INSERT putting in @might; and (G2) in bands: PACK says "Nothing here." with no WEAPONS group before anything is carried, and things are added from the row of + at the top; and (G3) the Pistol's card opened by a click on its name; and (G5a) the Pistol, its RANGE its own, saved with who changed it and when | +| `tests/sheet-item-types.spec.ts` | The GEAR tab as a table per item type (8a3a): a player's sheet with WEAPONS and GEAR tables, each empty with its +; + WEAPON made A stick with DAMAGE 1d4 and GRADE HEAVY; a second line named Pistol showing 2d6 + @might faint, its RANGE typed over to 50 m; + GEAR made Rope at 10 lb; saved as made, each in its table after a reload; since 8a3b the stick's DAMAGE rolled with ROLL, "rolled A stick DAMAGE 1d4" in the dice tray's history; and (8a3c1) as compact lines: a line made by hand opened under ✎, DONE showing its words with ROLL, the Pistol's RANGE read as words after the reload, and no box on the GEAR tab scrolling sideways in SHEET.EXE; and (8a3c2) the Pistol's DAMAGE under ✎ said ON THIS CHARACTER: 2d6 + Might (12): 14 to 24, @strength flagged as not the system's, eˣ INSERT putting in @might; and (G2) in bands: PACK says "Nothing here." with no WEAPONS group before anything is carried, and things are added from the row of + at the top; and (G3) the Pistol's card opened by a click on its name; and (G5a) the Pistol, its RANGE its own, saved with who changed it and when; and (G5b) after the reload the Pistol says UNIQUE, its hover "RANGE 50 m, the item's: 30 m · changed by" the player, with 1 UNIQUE at the top; THE ITEM'S on its DAMAGE and RANGE leaves a plain Pistol, saved so | | `tests/sheet-gear-bands.spec.ts` | The GEAR tab in bands (G2): a game with WEAPONS EQUIPPED, POTIONS USABLE and GEAR unsaid; a player adds a Sword, a Draught and a Rope from the row of + at the top, each in its band and counted (EQUIPPED · 1, USABLE · 1, PACK · 1, STASH · 0 closed), saved as made; the Sword moved to the stash goes to STASH, which opens and says WEAPONS, EQUIPPED left at 0; USABLE closed by its head, and on the next visit USABLE is still closed and PACK open; and (G3) one line a thing: the Draught's HEALS blank, so FILL IN, which opens its card at that box, ready to type; 2d4 typed, DONE, the line says HEALS 2d4 and FILL IN is gone, saved; a Cloak, GEAR, made by hand sits in PACK, WEAR puts it in EQUIPPED (EQUIPPED · 1), taken off it is back in PACK; with EQUIPPED closed, WEAR lights its head (▸ EQUIPPED · 1), opened it is plain again; and (G4) FIND: 2d4 shows the Draught in USABLE, closed, opened while it shows (PACK · 0), lantern says nothing matches, cleared USABLE is closed again | | `tests/sheet-gear-counts.spec.ts` | A gear line's COUNT at the table (8a4): a player's Pistol at AMMO 2 / 6 spends one with FIRE; RELOAD, with Pistol Rounds and AP Rounds both carried, asks which and takes all 3 AP Rounds, their line gone; RELOAD again takes 2 of the Pistol Rounds alone, full, RELOAD held; the Wand's CHARGES, with no RELOAD, filled by a SHORT REST from the sheet | | `tests/sheet-standalone-tab.spec.ts` | The sheet in a new tab is the window (8s1a): a player makes two gear lines in SHEET.EXE, opens the tab with ⧉ (a `.crt-container`, so in the theme), WEARs the boots there and SHEET.EXE says WORKING too, and rolls the club's DAMAGE from the tab, said on it once the dice land; since 8s1b the roll from the tab opens DICE_TRAY.EXE in the main app's window; and (8s1c) a character being made: the flow left, SHEET.EXE says CREATING · CONTINUE, the tab says it too and opens NEW_CHARACTER.EXE on itself; and (8s1d) Cash on the tab opens BANK.EXE in the main window and the tab says so, then with the main window closed the tab says to open it; and (G2) gear added from the row of + at the top of GEAR | diff --git a/e2e/tests/sheet-item-types.spec.ts b/e2e/tests/sheet-item-types.spec.ts index 5b075767..9072ceef 100644 --- a/e2e/tests/sheet-item-types.spec.ts +++ b/e2e/tests/sheet-item-types.spec.ts @@ -89,6 +89,11 @@ test('GEAR as a table per type: a stick made by hand and its DAMAGE rolled, the await expect(weapons.getByText('WEAPONS · 2')).toBeVisible({ timeout: 15_000 }); await expect(gear.getByText('GEAR · 1')).toBeVisible(); await expect(weapons.getByRole('note', { name: 'Item 2 RANGE: 50 m' })).toBeVisible(); + // UNIQUE (G5b): its RANGE its own, so the line says so, with the item's and who changed it when on hover; counted at the top. + const unique = weapons.getByRole('note', { name: 'Item 2 is unique' }); + await expect(unique).toHaveText('UNIQUE'); + await expect(unique).toHaveAttribute('title', new RegExp(`RANGE 50 m, the item's: 30 m · changed by ${player.username}, \\d{4}-\\d{2}-\\d{2}`)); + await expect(mine.getByRole('button', { name: '1 UNIQUE', exact: true })).toBeVisible(); // Compact lines (8a3c1): in SHEET.EXE's width, nothing on the GEAR tab scrolls sideways. // The sheet and any box inside it (the old table scrolled in a box of its own). const sideways = await mine.locator('.sheet-scroll').evaluate((root) => [root, ...root.querySelectorAll('*')] @@ -109,5 +114,13 @@ test('GEAR as a table per type: a stick made by hand and its DAMAGE rolled, the await weapons.getByRole('group', { name: 'Help writing Item 2 DAMAGE' }).getByRole('button', { name: /^@might/ }).click(); await expect(weapons.getByLabel('Item 2 DAMAGE', { exact: true })).toHaveValue('1d6 + @might'); await expect(reads).toHaveText('ON THIS CHARACTER: 1d6 + Might (12): 13 to 18', { timeout: 15_000 }); + + // THE ITEM'S (G5b): DAMAGE and RANGE each put back to the item's; no longer unique, saved as a plain Pistol. + await weapons.getByRole('group', { name: 'Item 2 DAMAGE is unique' }).getByRole('button', { name: "Item 2 DAMAGE: the item's" }).click(); + await expect(weapons.getByLabel('Item 2 DAMAGE', { exact: true })).toHaveValue(''); + await weapons.getByRole('group', { name: 'Item 2 RANGE is unique' }).getByRole('button', { name: "Item 2 RANGE: the item's" }).click(); + await expect(unique).toHaveCount(0); + await expect(mine.getByRole('button', { name: /UNIQUE$/ })).toHaveCount(0); + await expect.poll(async () => JSON.parse(String((await sheetOf()).inventory ?? '[]'))[1], { timeout: 15_000 }).toEqual(line('Pistol', { type: 'weapons' })); await context.close(); }); diff --git a/frontend/src/components/GearTypeTables.tsx b/frontend/src/components/GearTypeTables.tsx index cd1129b3..0d85c66a 100644 --- a/frontend/src/components/GearTypeTables.tsx +++ b/frontend/src/components/GearTypeTables.tsx @@ -1,7 +1,7 @@ import React, { useEffect, useEffectEvent, useRef, useState } from 'react'; import { CARRY_STATES, type InventoryItem } from '../sheets/inventory'; import type { ItemsShown } from '../sheets/gearItems'; -import { gearTables, gearBands, foundIn, valueText, withLineValue, newLineOf, shownCells, cellWords, countOf, type Cell, type CountAnswer, type CountKind, type TableRow, type TypeShown } from '../sheets/gearTypes'; +import { gearTables, gearBands, foundIn, uniqueCells, uniqueTitle, uniqueCount, itemWas, valueText, withLineValue, newLineOf, shownCells, cellWords, countOf, type Cell, type CountAnswer, type CountKind, type TableRow, type TypeShown } from '../sheets/gearTypes'; import { useGearBands } from '../hooks/useGearBands'; import { diceWords, SHAPES, shapeText, insertName, type GearDiceRead } from '../sheets/gearDice'; import { FormulaIcon } from './FormulaIcon'; @@ -17,7 +17,8 @@ import { FormulaIcon } from './FormulaIcon'; // docs/mockups/sheet-gear-layout.html, layout A): EQUIPPED, USABLE and PACK by each type's ON THE SHEET, a group per type, // in hand first; STASH, closed to start, whatever the type; a band's head closes it and the sheet remembers. A thing is // made by hand from the row of + buttons at the top; a closed band something lands in pulses, then stays bright until -// opened; FIND at the top, always shown, keeps only the lines it matches, every band open while it has words (G4); +// opened; a line changed from its item says UNIQUE, each column it made its own too, with THE ITEM'S to put it back and +// the item's value and who changed it when, and the count of them at the top lists them in FIND (G5b); FIND at the top, always shown, keeps only the lines it matches, every band open while it has words (G4); // a thing worn, attuned or installed is in EQUIPPED whatever its type. One line a thing (G3; the same mockup, decision 3): its name, how many, // the columns it has as words with ROLL, FIRE and RELOAD, where it is carried; a click on it opens the card, every column a // box with NAME, HOW MANY, LOCATION and REMOVE, one card at a time; ✎ at the end of every line opens it too. A line with @@ -193,6 +194,7 @@ export function GearTypeTables({ items, itemsShown, readOnly, write, locked, on, const blank = lc.cells.filter((c) => c.own === undefined && c.given === undefined); const nothingFilled = blank.length > 0 && blank.length === lc.cells.length; const editing = open === i; + const unique = uniqueCells(lc).length > 0; const stashed = line.carry === 'stash'; const lockedTitle = locked(i) ? 'Installed: REMOVE it first' : undefined; const name = line.name.trim() || 'UNNAMED'; @@ -210,6 +212,11 @@ export function GearTypeTables({ items, itemsShown, readOnly, write, locked, on, onClick={() => openAt(null)} style={{ background: 'none', border: 0, padding: 0, color: 'var(--green)', fontFamily: 'inherit', fontSize: '0.75rem', textAlign: 'left', cursor: 'pointer', overflowWrap: 'anywhere', textDecoration: editing ? 'underline' : 'none', opacity: line.name.trim() ? 1 : 0.6 }}>{name}} {line.qty > 1 && ×{line.qty}} + {/* Changed from its item (G5b): the GM sees it at a glance, the item's value and who changed it on hover. */} + {unique && ( + UNIQUE + )} {/* Only the columns it has, as words: its item's faint, ROLL beside a DAMAGE or DICE (8a3b). */} {cells.map((cell) => { const label = `Item ${i + 1} ${cell.column.label}`; @@ -294,6 +301,18 @@ export function GearTypeTables({ items, itemsShown, readOnly, write, locked, on, {(cell.column.kind === 'damage' || cell.column.kind === 'dice') && onReadDice ? patch(i, withLineValue(line, cell.column, typed))} onRead={onReadDice} /> : patch(i, withLineValue(line, cell.column, typed))} />} + {/* Made its own (G5b): said, with the item's value, who changed it when, and THE ITEM'S to put it back. */} + {cell.unique && ( + <> + + + UNIQUE + + {itemWas(cell, line)} + + + )} ))} LOCATION @@ -314,6 +333,13 @@ export function GearTypeTables({ items, itemsShown, readOnly, write, locked, on, }; return (
+ {/* How many lines are their item made unique (G5b): a click lists them in FIND. */} + {uniqueCount(tables) > 0 && ( + + )} {/* The box, and its own × in the theme (the browser's is blue in every theme): Esc clears it too. */} { expect(counters()).toEqual(['CYBERWARE installs']); }); }); + +describe('UNIQUE on the line and in its card (G5b)', () => { + const AT = '2026-11-20T10:00:00.000Z'; + const at = (i: number) => within(screen.getByTestId(`gear-line-${i}`)); + // ITEMS' Pistol: DAMAGE 2d6, RANGE 30 m. + const made = line('Pistol', { values: { damage: '3d6' }, changed: { damage: { by: 'kes', at: AT } } }); + + it('the line says UNIQUE, the item\'s and who changed it on hover; a Pistol as the item has it says nothing', () => { + show([made, line('Pistol')]); + const tag = at(0).getByRole('note', { name: 'Item 1 is unique' }); + expect(tag.textContent).toBe('UNIQUE'); + expect(tag.title).toBe("Unique: changed from its item\nDAMAGE 3d6, the item's: 2d6 · changed by kes, 2026-11-20"); + expect(at(1).queryByRole('note', { name: 'Item 2 is unique' })).toBeNull(); + }); + + it('in the card, each column made its own: UNIQUE, what the item had, who changed it; THE ITEM\'S puts it back', async () => { + const last = show([made]); + await userEvent.click(at(0).getByRole('button', { name: 'Edit item 1' })); + const damage = within(at(0).getByRole('group', { name: 'Item 1 DAMAGE is unique' })); + expect(damage.getByText("the item's: 2d6 · changed by kes, 2026-11-20")).toBeTruthy(); + // RANGE is the item's: nothing said of it. + expect(at(0).queryByRole('group', { name: 'Item 1 RANGE is unique' })).toBeNull(); + await userEvent.click(damage.getByRole('button', { name: "Item 1 DAMAGE: the item's" })); + expect(last()[0].values).toBeUndefined(); + expect(at(0).queryByRole('note', { name: 'Item 1 is unique' })).toBeNull(); + expect(at(0).queryByRole('group', { name: 'Item 1 DAMAGE is unique' })).toBeNull(); + }); + + it('the count at the top, which lists them in FIND; none where none are', async () => { + show([made, line('Rope'), line('Pistol', { values: { range: '50 m' } })]); + const count = screen.getByRole('button', { name: '2 UNIQUE' }); + expect(count.title).toBe('Lines that differ from their item: click to list them'); + await userEvent.click(count); + expect((screen.getByRole('searchbox', { name: 'Find in your gear' }) as HTMLInputElement).value).toBe('unique'); + expect(screen.getByRole('button', { name: 'Pistol, item 1' })).toBeTruthy(); + expect(screen.getByRole('button', { name: 'Pistol, item 3' })).toBeTruthy(); + expect(screen.queryByRole('button', { name: 'Rope, item 2' })).toBeNull(); + cleanup(); + show([line('Pistol'), line('Rope')]); + expect(screen.queryByRole('button', { name: /UNIQUE$/ })).toBeNull(); + }); +}); diff --git a/frontend/src/sheets/__tests__/gearTypes.test.ts b/frontend/src/sheets/__tests__/gearTypes.test.ts index 98f29c1d..d4321fce 100644 --- a/frontend/src/sheets/__tests__/gearTypes.test.ts +++ b/frontend/src/sheets/__tests__/gearTypes.test.ts @@ -1,6 +1,6 @@ import { describe, it, expect } from 'vitest'; import { createRequire } from 'module'; -import { typesOf, fits, itemOfLine, lineColumns, gearTables, valueText, withLineValue, newLineOf, countOf, cellWords, LIMITS, type ColumnShown , gearBands, landedIn, foundIn } from '../gearTypes'; +import { typesOf, fits, itemOfLine, lineColumns, gearTables, valueText, withLineValue, newLineOf, countOf, cellWords, LIMITS, type ColumnShown , gearBands, landedIn, foundIn, uniqueCells, changedWords, itemWas, uniqueTitle, uniqueCount } from '../gearTypes'; import { normaliseItem, readInventory, type InventoryItem } from '../inventory'; import type { ItemsShown } from '../gearItems'; @@ -258,3 +258,48 @@ describe('FIND on GEAR (G4)', () => { expect(foundIn(bands, ' ')).toBe(bands); }); }); + +describe('UNIQUE on the sheet (G5b)', () => { + const SHOWN = { + slots: [], + list: [{ id: 'cutlass', label: 'Cutlass', needs: 'carried', features: [], type: 'weapons', values: { damage: '1d8 + @might', weight: 3 } }], + types: [ + { id: 'weapons', label: 'WEAPONS', one: 'Weapon', columns: [{ id: 'damage', label: 'DAMAGE', kind: 'damage' }, { id: 'range', label: 'RANGE', kind: 'text' }, { id: 'weight', label: 'WEIGHT', kind: 'number' }] }, + { id: 'gear', label: 'GEAR', one: 'Gear', columns: [{ id: 'weight', label: 'WEIGHT', kind: 'number' }] }, + ], + } as never; + const at = (name: string, more = {}) => ({ name, qty: 1, enc: '', bundled: false, carry: 'stowed', location: '', ...more }) as never; + const ids = (line: object) => uniqueCells(lineColumns(SHOWN, line as never)!).map((c) => c.column.id); + const AT = '2026-11-20T10:00:00.000Z'; + + it('a column of its own that isn\'t its item\'s, one the item hasn\'t filled too; none for a thing made by hand or of another type; read loosely', () => { + expect(ids(at('Cutlass', { values: { damage: '2d8 + @might', range: '2 m', weight: 3 } }))).toEqual(['damage', 'range']); + expect(ids(at('Cutlass', { values: { damage: ' 1d8 + @might ' } }))).toEqual([]); + // Blank words over a column the item hasn't filled: nothing of its own, as the server reads it. + expect(ids(at('Cutlass', { values: { range: ' ' } }))).toEqual([]); + expect(ids(at('A stick', { type: 'weapons', values: { damage: '1d4' } }))).toEqual([]); + expect(ids(at('Cutlass', { type: 'gear', values: { weight: 9 } }))).toEqual([]); + }); + + it('who and when as words: a player by name, the GM as the GM, no one where none; what the item had', () => { + const changed = { damage: { by: 'kes', at: AT }, range: { by: 'gm', gm: true as const, at: AT } }; + expect(changedWords(changed, 'damage')).toBe('changed by kes, 2026-11-20'); + expect(changedWords(changed, 'range')).toBe('changed by the GM, 2026-11-20'); + expect(changedWords(undefined, 'damage')).toBe(''); + const line = at('Cutlass', { values: { damage: '2d8', range: '2 m' }, changed: { damage: changed.damage } }); + const [damage, range] = uniqueCells(lineColumns(SHOWN, line)!); + expect(itemWas(damage, line)).toBe("the item's: 1d8 + @might · changed by kes, 2026-11-20"); + // Made unique by no one (a catalogue's line), and over a column the item hadn't filled. + expect(itemWas(range, line)).toBe("the item's: none"); + expect(uniqueTitle({ index: 0, line, columns: lineColumns(SHOWN, line)! })) + .toBe("Unique: changed from its item\nDAMAGE 2d8, the item's: 1d8 + @might · changed by kes, 2026-11-20\nRANGE 2 m, the item's: none"); + }); + + it('how many lines are unique; "unique" in FIND lists them', () => { + const lines = [at('Cutlass', { values: { damage: '2d8' } }), at('Cutlass'), at('Rope', { type: 'gear', values: { weight: 1 } })]; + expect(uniqueCount(gearTables(SHOWN, lines))).toBe(1); + expect(uniqueCount(gearTables(SHOWN, [at('Cutlass')]))).toBe(0); + const found = foundIn(gearBands(SHOWN, lines), 'unique'); + expect(found.flatMap((b) => b.groups.flatMap((g) => g.rows.map((r) => r.index)))).toEqual([0]); + }); +}); diff --git a/frontend/src/sheets/__tests__/inventory.test.ts b/frontend/src/sheets/__tests__/inventory.test.ts index cc392457..69a56ebe 100644 --- a/frontend/src/sheets/__tests__/inventory.test.ts +++ b/frontend/src/sheets/__tests__/inventory.test.ts @@ -127,3 +127,14 @@ describe('where it lives', () => { } }); }); + +describe('who changed a line from its item (G5b)', () => { + it('kept where well formed, a name and a time, the GM said; dropped where not; none where none', () => { + const at = '2026-11-20T10:00:00.000Z'; + expect(normaliseItem({ name: 'Cutlass', changed: { damage: { by: 'kes', at }, range: { by: 'gm', gm: true, at }, weight: { by: 3 }, grade: 'x' } }).changed) + .toEqual({ damage: { by: 'kes', at }, range: { by: 'gm', gm: true, at } }); + expect(normaliseItem({ name: 'Cutlass', changed: { weight: { by: 'kes' } } })).not.toHaveProperty('changed'); + expect(normaliseItem({ name: 'Rope' })).not.toHaveProperty('changed'); + expect(normaliseItem({ name: 'Rope', changed: 'yes' })).not.toHaveProperty('changed'); + }); +}); diff --git a/frontend/src/sheets/gearTypes.ts b/frontend/src/sheets/gearTypes.ts index fdbb0d4e..f8cf77e5 100644 --- a/frontend/src/sheets/gearTypes.ts +++ b/frontend/src/sheets/gearTypes.ts @@ -49,8 +49,11 @@ const key = (name: string) => name.trim().toLowerCase(); export const itemOfLine = (shown: ItemsShown | null | undefined, line: InventoryItem): ItemShown | undefined => (shown?.list ?? []).find((i) => key(i.label || i.id) === key(line.name)); -/** One column of a line: its own value, its item's, and the one that counts (its own where it fits). */ -export interface Cell { column: ColumnShown; own?: Value; given?: Value; value?: Value } +/** + * One column of a line: its own value, its item's, and the one that counts (its own where it fits). `unique` where the line + * is its item's, of its type, and its own isn't the item's (G5b; the server's uniqueLines.js, mirrored): the item made unique. + */ +export interface Cell { column: ColumnShown; own?: Value; given?: Value; value?: Value; unique?: true } /** A line's type, the item it is named like, and its cells in its type's order. */ export interface LineColumns { type: TypeShown; item?: ItemShown; cells: Cell[] } @@ -62,14 +65,17 @@ export const lineColumns = (shown: ItemsShown | null | undefined, line: Inventor const type = types.find((t) => t.id === line.type) ?? (item ? types.find((t) => t.id === item.type) : undefined) ?? types[0]; const own = isObject(line.values) ? line.values : {}; // An item's values count only on a line of its own type: made a WEAPON, the Pistol Rounds keep none. - const given = item && (types.find((t) => t.id === item.type) ?? types[0]).id === type.id && isObject(item.values) ? item.values : {}; + const ofItem = !!item && (types.find((t) => t.id === item.type) ?? types[0]).id === type.id; + const given = ofItem && isObject(item.values) ? item.values : {}; return { type, ...(item ? { item } : {}), cells: type.columns.map((column) => { const o = fits(column, own[column.id]) ? own[column.id] as Value : undefined; const g = fits(column, given[column.id]) ? given[column.id] as Value : undefined; const value = o ?? g; - return { column, ...(o !== undefined ? { own: o } : {}), ...(g !== undefined ? { given: g } : {}), ...(value !== undefined ? { value } : {}) }; + // Read loosely, as the server does: 3 and "3", and spaces around, are the item's own; blank is nothing of its own. + const unique = ofItem && o !== undefined && String(o).trim() !== String(g ?? '').trim(); + return { column, ...(o !== undefined ? { own: o } : {}), ...(g !== undefined ? { given: g } : {}), ...(value !== undefined ? { value } : {}), ...(unique ? { unique: true as const } : {}) }; }), }; }; @@ -135,6 +141,8 @@ export const landedIn = (before: Partial> | null, after */ export const lineWords = (row: TableRow, type: TypeShown, band: string): string => [row.line.name, type.label, type.one, band, row.line.carry === 'stash' ? 'stash' : row.line.carry, row.line.location, + // A line made unique (G5b): "unique" in FIND lists them. + uniqueCells(row.columns).length ? 'unique' : '', ...shownCells(row.columns).map((c) => `${c.column.label} ${cellWords(c, row.line)}`)].join(' ').toLowerCase(); /** The bands showing only what FIND matches, each counted by its matches; blank, the bands as they are. */ @@ -149,6 +157,28 @@ export const foundIn = (bands: BandShown[], text: string): BandShown[] => { }); }; +/** A line's unique cells (G5b): the columns it made its own, away from its item's. */ +export const uniqueCells = (columns: LineColumns): Cell[] => columns.cells.filter((c) => c.unique); + +/** Who changed a column, and when, as words (G5b): "changed by kes, 2026-11-20", "changed by the GM, …"; none where no one did. */ +export const changedWords = (changed: InventoryItem['changed'], column: string): string => { + const c = changed?.[column]; + return c ? `changed by ${c.gm ? 'the GM' : c.by}, ${c.at.slice(0, 10)}` : ''; +}; + +/** What a unique column was (G5b): "the item's: 1d8 + @might · changed by kes, 2026-11-20"; "the item's: none" where it had none. */ +export const itemWas = (cell: Cell, line: InventoryItem): string => { + const who = changedWords(line.changed, cell.column.id); + return `the item's: ${cell.given !== undefined ? valueText(cell.given) : 'none'}${who ? ` · ${who}` : ''}`; +}; + +/** The hover on a unique line (G5b): each column it made its own, what the item's was, who changed it and when. */ +export const uniqueTitle = (row: TableRow): string => + ['Unique: changed from its item', ...uniqueCells(row.columns).map((c) => `${c.column.label.toUpperCase()} ${valueText(c.own)}, ${itemWas(c, row.line)}`)].join('\n'); + +/** How many lines are their item made unique (G5b): at the top of GEAR. */ +export const uniqueCount = (tables: { rows: TableRow[] }[]): number => tables.reduce((n, t) => n + t.rows.filter((r) => uniqueCells(r.columns).length > 0).length, 0); + /** A value as a box shows it. */ export const valueText = (v: Value | undefined): string => (v === undefined ? '' : String(v)); diff --git a/frontend/src/sheets/inventory.ts b/frontend/src/sheets/inventory.ts index 6ba0e94e..44d83233 100644 --- a/frontend/src/sheets/inventory.ts +++ b/frontend/src/sheets/inventory.ts @@ -48,6 +48,11 @@ export interface InventoryItem { values?: Record; /** How many each COUNT column has left (8a1): { ammo: 4 }. Full where it says nothing. */ counts?: Record; + /** + * Who changed each column made its own, away from its item, and when (G5a): the server's, from what was stored; the sheet + * only shows it (UNIQUE), and what it sends back is never taken. + */ + changed?: Record; } const str = (v: unknown): string => @@ -65,6 +70,16 @@ const carryOf = (v: unknown): CarryState => { return s === 'readied' || s === 'stowed' ? s : 'stash'; }; +/** Who changed which column (G5a), those well formed: a name and a time; none where none are. */ +const changedOf = (v: unknown): { changed?: InventoryItem['changed'] } => { + if (!isObject(v)) return {}; + const out: NonNullable = {}; + for (const [id, c] of Object.entries(v)) { + if (isObject(c) && typeof c.by === 'string' && typeof c.at === 'string') out[id] = { by: c.by, ...(c.gm === true ? { gm: true as const } : {}), at: c.at }; + } + return Object.keys(out).length ? { changed: out } : {}; +}; + /** An item with every field present, whatever it was handed. */ export const normaliseItem = (raw: unknown): InventoryItem => { const r = (raw && typeof raw === 'object' ? raw : {}) as Record; @@ -81,6 +96,7 @@ export const normaliseItem = (raw: unknown): InventoryItem => { ...(typeof r.type === 'string' && r.type ? { type: r.type } : {}), ...(isObject(r.values) ? { values: { ...r.values } as Record } : {}), ...(isObject(r.counts) ? { counts: { ...r.counts } as Record } : {}), + ...changedOf(r.changed), }; }; From b49b9ff6a7068044d0420041fda4f6184301bb60 Mon Sep 17 00:00:00 2001 From: Developer Date: Sun, 22 Nov 2026 10:59:58 -0600 Subject: [PATCH 2/2] feat: no UNIQUE count at the top of GEAR, unique in FIND lists them (the user: saves the room) --- CHANGELOG.md | 2 +- README.md | 10 +++++----- e2e/README.md | 2 +- e2e/tests/sheet-item-types.spec.ts | 9 ++++++--- frontend/src/components/GearTypeTables.tsx | 12 +++--------- .../src/components/__tests__/GearTypeTables.test.tsx | 11 +++-------- frontend/src/sheets/__tests__/gearTypes.test.ts | 6 ++---- frontend/src/sheets/gearTypes.ts | 3 --- 8 files changed, 21 insertions(+), 34 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b0f0636..947a1e6d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -106,7 +106,7 @@ Format follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### Added -- **UNIQUE on GEAR.** A thing changed from the item it is named after (the Cutlass made 2d8) now says UNIQUE on its line; hover it for the item's own value and who changed it, and when (a player by name, or the GM). In its card, each column made its own says UNIQUE with the item's value beside it and a THE ITEM'S button to put it back. The top of GEAR counts them ("1 UNIQUE"); click it, or type unique in FIND, to list them. SHEET.EXE and the sheet's own tab are the same. +- **UNIQUE on GEAR.** A thing changed from the item it is named after (the Cutlass made 2d8) now says UNIQUE on its line; hover it for the item's own value and who changed it, and when (a player by name, or the GM). In its card, each column made its own says UNIQUE with the item's value beside it and a THE ITEM'S button to put it back. Type unique in FIND to list them. SHEET.EXE and the sheet's own tab are the same. - **FIND on GEAR.** A find box at the top of the sheet's GEAR tab, always there, keeps only the things that match as you type: a name, a type (GUNS), a value (2d6, 30 m) or a column (AMMO), in any case, every word somewhere on the line. Each band counts its matches and opens while you search, so nothing in a closed STASH is missed; clear it with its × or Esc and the bands are as you left them. When nothing matches, it says so. SHEET.EXE and the sheet's own tab are the same. - **GEAR in bands.** The sheet's GEAR tab now sorts what you carry into EQUIPPED, USABLE and PACK, by each item type's ON THE SHEET, with a count on each band and what's in hand first. A fourth band, STASH, holds everything left in the stash whatever its type, and says each one's type; it starts closed. Click a band's head to close or open it, and the sheet remembers. The + buttons for adding a thing by hand sit in one row at the top, and the band it lands in opens. SHEET.EXE and the sheet's own tab are the same. - **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. diff --git a/README.md b/README.md index 0f3023d1..837b8444 100644 --- a/README.md +++ b/README.md @@ -798,7 +798,7 @@ CITY_NET/ │ │ │ ├── SystemPicker.tsx # GAME tab's system picker: a searchable dropdown, BUILT-IN then YOUR SYSTEMS, portalled into the theme, asking before it switches the game for everyone │ │ │ ├── systemPickerRules.ts # The picker's rules on their own: grouping and order, search, arrow-key movement, what the button says │ │ │ ├── InventorySection.tsx # The inventory table, on every system. Its own file because SheetRenderer is long enough, and generic: which rows carry an extra button, and what pressing it does, is supplied from outside - so a drug offers CONSUME and a skillplug offers LOAD without either knowing about the other A custom system's items (7e3b): the slot counters over it, and WEAR and ATTUNE under a line of an item's name (GearItemLine); an installed item's line locked, named and in place, until REMOVE (7e4c); a custom system with item types gets a table per type instead (8a3a, GearTypeTables.tsx); tells GEAR's bands which lines are worn, attuned or installed, from what the server worked out (G3); only the slot and install counters something on the sheet uses, 8px apart from FIND on a typed GEAR tab -│ │ │ ├── GearTypeTables.tsx # The GEAR tab as a table per item type (8a3a; approved mockup item-types, 2026-11-14): each type's lines under its own column heads, units said; a line's own value over its item's, shown faint until typed over; + a type's one to add a line of it by hand; name, quantity, where and location as the one list has them; ROLL beside each DAMAGE and DICE (8a3b), read only or not, where the viewer may roll; since 8a3c1 a compact line per thing (name, QTY, WHERE, ✎, ×; only the columns it has as words under it, its item's faint, ROLL beside DAMAGE and DICE, a stashed one's place), ✎ opening every column as a box, one line at a time, a line made by hand opened; under ✎ a DAMAGE or DICE with eˣ (8a3c2): what it reads on this character, a name the system hasn't got flagged, SHAPE and INSERT; a COUNT as "AMMO 4 / 6" with its button (FIRE) and RELOAD beside it (8a4b), held while the server answers, RELOAD FROM asking which carried line where there are several, a refusal said on the line; in bands (G2): EQUIPPED, USABLE and PACK by each type's ON THE SHEET, a group per type with lines, in hand first, and STASH, closed to start, each line's type said; a band's head closes it, remembered; a row of + at the top adds a thing of any type by hand, opening its band; one line a thing (G3): its name, how many, its columns as words with ROLL, FIRE and RELOAD, where it is carried, ✎ at its end (or a click on the line) opening its card (NAME, HOW MANY, every column, LOCATION, DONE, REMOVE), FILL IN where nothing at all is filled in opening the card at its first box, a PICK ONE box as wide as its words; a closed band something lands in (worn, bought, given) pulses three times and stays lit in the theme's own color until opened (G3); FIND at the top, always shown (G4): only the lines it matches, each band counted by its matches and open while it has words, heads readable but not toggling, its own × and Esc to clear, "Nothing on this sheet matches" when nothing does; UNIQUE (G5b): on a line changed from its item, the item's and who changed it when on hover; in the card, beside each column made its own, UNIQUE, THE ITEM'S to put it back and what the item had; "n UNIQUE" at the top listing them in FIND +│ │ │ ├── GearTypeTables.tsx # The GEAR tab as a table per item type (8a3a; approved mockup item-types, 2026-11-14): each type's lines under its own column heads, units said; a line's own value over its item's, shown faint until typed over; + a type's one to add a line of it by hand; name, quantity, where and location as the one list has them; ROLL beside each DAMAGE and DICE (8a3b), read only or not, where the viewer may roll; since 8a3c1 a compact line per thing (name, QTY, WHERE, ✎, ×; only the columns it has as words under it, its item's faint, ROLL beside DAMAGE and DICE, a stashed one's place), ✎ opening every column as a box, one line at a time, a line made by hand opened; under ✎ a DAMAGE or DICE with eˣ (8a3c2): what it reads on this character, a name the system hasn't got flagged, SHAPE and INSERT; a COUNT as "AMMO 4 / 6" with its button (FIRE) and RELOAD beside it (8a4b), held while the server answers, RELOAD FROM asking which carried line where there are several, a refusal said on the line; in bands (G2): EQUIPPED, USABLE and PACK by each type's ON THE SHEET, a group per type with lines, in hand first, and STASH, closed to start, each line's type said; a band's head closes it, remembered; a row of + at the top adds a thing of any type by hand, opening its band; one line a thing (G3): its name, how many, its columns as words with ROLL, FIRE and RELOAD, where it is carried, ✎ at its end (or a click on the line) opening its card (NAME, HOW MANY, every column, LOCATION, DONE, REMOVE), FILL IN where nothing at all is filled in opening the card at its first box, a PICK ONE box as wide as its words; a closed band something lands in (worn, bought, given) pulses three times and stays lit in the theme's own color until opened (G3); FIND at the top, always shown (G4): only the lines it matches, each band counted by its matches and open while it has words, heads readable but not toggling, its own × and Esc to clear, "Nothing on this sheet matches" when nothing does; UNIQUE (G5b): on a line changed from its item, the item's and who changed it when on hover; in the card, beside each column made its own, UNIQUE, THE ITEM'S to put it back and what the item had; "unique" in FIND lists them, with no count at the top │ │ │ ├── GearItemLine.tsx # A system's item on its GEAR line (7e3b): its NEEDS tag, WEAR or WORN · TAKE OFF, ATTUNE (ATTUNED · END, the GM's ATTUNE ANYWAY), what it is doing, and its features' uses; the slot counters over the gear (ATTUNED 2 OF 3, amber when full) with the GM's box for one character's own count; and each install's counter, amber at its limit (7e4c) │ │ │ ├── PharmaSection.tsx # What is currently in the bloodstream, drawn in the sheet HEADER rather than a tab: a drug that wears off at the end of a scene and bills System Strain for it is not something to hide behind a tab somebody might not open. Draws nothing at all while a character is on nothing │ │ │ ├── XpWindow.tsx # AWARD_EXPERIENCE — points each rather than a pot to divide, with LEVEL_UP and LEVEL_DOWN for correcting a level on purpose; in a game that spends XP, given to spend, with no level buttons where there are no levels (7f2c2) @@ -1085,7 +1085,7 @@ CITY_NET/ │ │ │ ├── SheetCyberware.test.tsx # The sheet showing what the chrome does, so a correct effects layer is actually read │ │ │ ├── InventorySection.test.tsx # The inventory table editing one field cleanly, though every keystroke rewrites the whole list │ │ │ ├── GearItemLine.test.tsx # WEAR and ATTUNE on GEAR (7e3b): the counter, an item's line under its own row, what pressing asks, a full slot disabled and why, the GM's ATTUNE ANYWAY and own count, read-only, uses ticking, a refusal said, a system without items unchanged; installs (7e4c): the counter, an installed line locked, REMOVE and INSTALL asked, a player's disabled past the limit, the GM's anyway, amber when full -│ │ │ ├── GearTypeTables.test.tsx # The GEAR tab as a table per type (8a3a): each type's lines and heads, an empty type its heading and + only, an item's values faint until typed over, + a type's one by hand staying in its table, read only, a system without types keeping the one list; ROLL beside DAMAGE sending its line and column, nothing to roll nothing to press, read only still there (8a3b); compact lines (8a3c1): only the columns a line has, ✎ one at a time with "none" where it has none, a hand-made line opened, read only without ✎; a DAMAGE under ✎ read on this character, a bad name flagged, never an older text's words, eˣ SHAPE and INSERT (8a3c2); a COUNT's "4 / 6" with FIRE and RELOAD, held while waiting, none left or full, USE by default, RELOAD FROM asked and CANCEL, a refusal on its line (8a4b); in bands (G2): the four in order and counted, in hand first, STASH closed, a head closing and opening its band remembered, the STASH saying each type, an empty band saying so, a thing made by hand opening its band; one line a thing (G3): a click on the line opening its card but not on ROLL or where it is carried, one card at a time, ✎ opening and closing it (none read only), FILL IN only where nothing is filled in, naming the columns and opening at the first (a DAMAGE too), none where something is or a type has no columns, UNNAMED, a PICK ONE box as wide as its words; a worn Cutlass of a PACK type in EQUIPPED, back in PACK taken off; a closed band lit when the server puts something in it, not on opening the sheet, not an open band, cleared when opened, not when the player opens it by hand; FIND (G4): as you type, counted, every band open, heads not toggling, × and Esc clearing, as left once cleared and nothing lit, a value and a column, nothing found, read only too; the slot and install counters only where something uses them; UNIQUE (G5b): the line's tag and hover, none as the item has it; in the card, what the item had and who changed it, THE ITEM'S putting it back; the count listing them in FIND +│ │ │ ├── GearTypeTables.test.tsx # The GEAR tab as a table per type (8a3a): each type's lines and heads, an empty type its heading and + only, an item's values faint until typed over, + a type's one by hand staying in its table, read only, a system without types keeping the one list; ROLL beside DAMAGE sending its line and column, nothing to roll nothing to press, read only still there (8a3b); compact lines (8a3c1): only the columns a line has, ✎ one at a time with "none" where it has none, a hand-made line opened, read only without ✎; a DAMAGE under ✎ read on this character, a bad name flagged, never an older text's words, eˣ SHAPE and INSERT (8a3c2); a COUNT's "4 / 6" with FIRE and RELOAD, held while waiting, none left or full, USE by default, RELOAD FROM asked and CANCEL, a refusal on its line (8a4b); in bands (G2): the four in order and counted, in hand first, STASH closed, a head closing and opening its band remembered, the STASH saying each type, an empty band saying so, a thing made by hand opening its band; one line a thing (G3): a click on the line opening its card but not on ROLL or where it is carried, one card at a time, ✎ opening and closing it (none read only), FILL IN only where nothing is filled in, naming the columns and opening at the first (a DAMAGE too), none where something is or a type has no columns, UNNAMED, a PICK ONE box as wide as its words; a worn Cutlass of a PACK type in EQUIPPED, back in PACK taken off; a closed band lit when the server puts something in it, not on opening the sheet, not an open band, cleared when opened, not when the player opens it by hand; FIND (G4): as you type, counted, every band open, heads not toggling, × and Esc clearing, as left once cleared and nothing lit, a value and a column, nothing found, read only too; the slot and install counters only where something uses them; UNIQUE (G5b): the line's tag and hover, none as the item has it; in the card, what the item had and who changed it, THE ITEM'S putting it back; "unique" in FIND listing them, no count │ │ │ ├── conditionNote.test.tsx # The conditions on the token under the number they change (8a5e3): SLOWED: Speed ×0.5 · typed 30 with the halved Speed the big number, clicked to edit what is typed, a skill's line, two on one number, a system with no picks or items, none on the token │ │ │ ├── PharmaSection.test.tsx # Taking a dose from a Readied inventory row, and what is running shown in the sheet header │ │ │ ├── Skillplugs.test.tsx # LOAD on a Readied plug, the granted skill on SKILLS, and what is loaded in the header @@ -1291,7 +1291,7 @@ CITY_NET/ │ │ │ ├── encumbrance.ts # The builder's ENCUMBRANCE as logic (8a5c; approved mockup item-types, 2026-11-14, decision 7): read and written back tidy, the NUMBER columns it can count with their types, how it starts (WEIGHT, ten times the first stat, LIGHT 50 / ENCUMBERED 100 / OVERLOADED), the bands, and the names formulas read of the gear for INSERT; a band's words and condition, and past them, kept through every edit (8a5d1); blank words and NONE kept as nothing, words cut at 200 (8a5d2) │ │ │ ├── ranks.ts # The builder's ranks as logic (7f1b): lists from four presets or empty, renamed and removed (their stats back to numbers), ranks added, changed, moved and removed (a stat's highest at the start following), a stat's HOLDS and AT START │ │ │ ├── gearItems.ts # Items on the GEAR tab as logic (7e3b): which gear line draws which item (by name, the first carried), what the last save worked out, each line's buttons and words (WEAR, ATTUNE, the GM's ATTUNE ANYWAY, WORKING, why it does nothing), a slot's verb from its name (ATTUNED → ATTUNE), the counters, the GM's own count asked, an item's uses; installed items (7e4c): INSTALL with room, a player's disabled past the limit and why, the GM's INSTALL ANYWAY, INSTALLED · REMOVE, each install's counter (CYBERWARE · STRAIN 2.75 OF 3, or NEVER BELOW), the names installed; the render copy's item types, and each item's type and values (8a3a); countersInUse (2026-11-22): the slots and installs a sheet has a use for, one an item on a line needs or one with something still counted against it -│ │ │ ├── gearTypes.ts # The GEAR tab's tables as logic (8a3a): the types from the render copy, what fits each column, a line's type (its own, its item's, the first) and its cells (its own value over its item's, the item's only on a line of its type), the tables in the system's order, a value typed, a new line of a type; mirrors the server's lineColumns; shownCells and cellWords, what a compact line shows (8a3c1); countOf, a COUNT left as the server counts it, and "4 / 6" in words (8a4b); gearBands, the GEAR tab's bands (G2): each type's lines in its ON THE SHEET band, in hand first, groups only for types with lines, and every stashed line in STASH; a line worn, attuned or installed in EQUIPPED whatever its type's band (G3); landedIn, the closed bands something landed in between two drawings (G3); lineWords and foundIn, FIND on GEAR (G4): a line found by its name, type, band, where it is carried and is, and each column with its words, every word typed somewhere on it; UNIQUE (G5b): a cell `unique` where the line is its item's, of its type, with its own value not the item's (the server's uniqueLines, mirrored), uniqueCells, changedWords, itemWas, uniqueTitle, uniqueCount, and "unique" in FIND +│ │ │ ├── gearTypes.ts # The GEAR tab's tables as logic (8a3a): the types from the render copy, what fits each column, a line's type (its own, its item's, the first) and its cells (its own value over its item's, the item's only on a line of its type), the tables in the system's order, a value typed, a new line of a type; mirrors the server's lineColumns; shownCells and cellWords, what a compact line shows (8a3c1); countOf, a COUNT left as the server counts it, and "4 / 6" in words (8a4b); gearBands, the GEAR tab's bands (G2): each type's lines in its ON THE SHEET band, in hand first, groups only for types with lines, and every stashed line in STASH; a line worn, attuned or installed in EQUIPPED whatever its type's band (G3); landedIn, the closed bands something landed in between two drawings (G3); lineWords and foundIn, FIND on GEAR (G4): a line found by its name, type, band, where it is carried and is, and each column with its words, every word typed somewhere on it; UNIQUE (G5b): a cell `unique` where the line is its item's, of its type, with its own value not the item's (the server's uniqueLines, mirrored), uniqueCells, changedWords, itemWas, uniqueTitle, and "unique" in FIND │ │ │ ├── gearDice.ts # A gear line's DAMAGE or DICE in words (8a3c2): ON THIS CHARACTER with each name's value and the range, or what is wrong; the eˣ shapes and INSERT at the cursor │ │ │ ├── rollTotal.ts # A roll line's final total, found for the dice history to bold: after the last = in its first [ ], or the lone number; never what follows a · │ │ │ ├── catalogueItems.ts # A system's items in the shops' catalogues (7e3c): the preview's lines read against the items (named as one, landing as gear or not; nearly named, the closest said), the shelf a starter file uses (the gear's, or the first landing as gear), and the starter file itself, prices left blank; with types of its own, DOWNLOAD ITEMS puts each item in its type's section with its columns, and a type's section counts as gear in the preview (8a7a1); ITEMS_ADDED_EVENT and withAddedItems, a catalogue's new items merged into a draft by id (8a7a4a) @@ -1345,7 +1345,7 @@ CITY_NET/ │ │ │ ├── encumbrance.test.ts # The builder's ENCUMBRANCE as logic (8a5c): written tidy with the items kept, what it can count, how it starts held to the server's check, COUNTED BY's unit, the bands, the names formulas read held to the server's; a band's words and condition kept through every edit (8a5d1); blank words and NONE kept as nothing, cut at 200, held to the server's check (8a5d2) │ │ │ ├── ranks.test.ts # Ranks as logic (7f1b): each preset sound as the server checks it, copies never the preset, lists and ranks changed, moved and removed with AT START following, HOLDS and AT START │ │ │ ├── gearItems.test.ts # Items on GEAR as logic (7e3b): the line each item draws on, what a save worked out read safely, the slot's verb, every state's buttons and words for player, GM and read-only, the counters, the GM's box, uses; installs (7e4c): room each way with rounding, every state's buttons and words, the counters, the names installed; countersInUse: a slot or install an item on a line needs, or still counted against with its line gone, not one nothing uses -│ │ │ ├── gearTypes.test.ts # The GEAR tab's tables as logic (8a3a): the types read, what fits each kind as the server's check, each line's type and values as the server's lineColumns on the same lines, the tables, values typed, a line's type, values and counts kept on the sheet and on the server, bought one more of; a COUNT left held to the server's lineColumns on the same lines (8a4b); gearBands (G2): each band's lines and count, in hand first then as listed, no group for a type with none there, an unknown band as PACK, stashed lines in STASH whatever the type; a line on you in EQUIPPED in a group of its type, the rest by type, stashed still the STASH, no empty group for an EQUIPPED type whose lines are all stashed (G3); landedIn: a closed band whose count went up, not an open one or one that fell, nothing before the first drawing (G3); foundIn (G4): by name, type, band, place, a column and its words, any case, every word, no group for a type with nothing found, blank as they are; UNIQUE (G5b): which cells, read loosely, blank as nothing, none made by hand or of another type; who and when in words, the GM as the GM; what the item had; the hover; the count; "unique" in FIND +│ │ │ ├── gearTypes.test.ts # The GEAR tab's tables as logic (8a3a): the types read, what fits each kind as the server's check, each line's type and values as the server's lineColumns on the same lines, the tables, values typed, a line's type, values and counts kept on the sheet and on the server, bought one more of; a COUNT left held to the server's lineColumns on the same lines (8a4b); gearBands (G2): each band's lines and count, in hand first then as listed, no group for a type with none there, an unknown band as PACK, stashed lines in STASH whatever the type; a line on you in EQUIPPED in a group of its type, the rest by type, stashed still the STASH, no empty group for an EQUIPPED type whose lines are all stashed (G3); landedIn: a closed band whose count went up, not an open one or one that fell, nothing before the first drawing (G3); foundIn (G4): by name, type, band, place, a column and its words, any case, every word, no group for a type with nothing found, blank as they are; UNIQUE (G5b): which cells, read loosely, blank as nothing, none made by hand or of another type; who and when in words, the GM as the GM; what the item had; the hover; "unique" in FIND │ │ │ ├── rollTotal.test.ts # A roll line's final total: the new and old forms, the tray's own, symbols, a later [ ] or · passed over, the line put back unchanged │ │ │ ├── catalogueItems.test.ts # Items in catalogues (7e3c): how far apart two names are, a line named as an item, one landing in its own rows, near misses by marks or a letter or two, the closest named, nothing without items, the starter file on the gear's shelf or the next │ │ │ ├── levels.test.ts # The table held to the server's, the ranges staying joined, adding and taking one off, typing over, what the boxes show, how they advance, the word @@ -1546,7 +1546,7 @@ CITY_NET/ │ ├── sheet-increases.spec.ts # Ability increases at the table (7d6b2): points spread in ABILITY INCREASE within what it allows, named on the stat's badge, taken off by LEVEL_DOWN; a Feat taken instead, under the feature and on the badge (7d6c2) │ ├── sheet-bonus-ways.spec.ts # The ways a bonus counts at the table (7e1): two +2s each stopping at 20, the cut one named on the badge; an AT LEAST lifts what they leave │ ├── sheet-worn-items.spec.ts # Items at the table (7e3b): WEAR and ATTUNE on GEAR, the ring's +2 CON once attuned and the slot full, a second worn with nothing to press, the GM's ATTUNE ANYWAY and own count, END, taken off still attuned; GIVE.EXE's ITEMS handing the ring to a player, who wears it; TERMINATE_SESSION closing GIVE.EXE at once; no ATTUNED bar until a line needing the slot is on the sheet -│ ├── sheet-item-types.spec.ts # The GEAR tab as a table per type (8a3a): a stick made by hand with its own DAMAGE and GRADE, a line named like the Pistol showing its values faint, RANGE typed over, a rope in GEAR, saved as made, each in its table after a reload; compact lines with ✎ and DONE, and nothing on the GEAR tab scrolling sideways in SHEET.EXE (8a3c1); the Pistol's DAMAGE read on this character under ✎, a bad name flagged, eˣ INSERT (8a3c2); in bands (G2), PACK saying "Nothing here." and things added from the row of + at the top; the Pistol's card opened by a click on its name (G3); the Pistol UNIQUE after the reload, its hover naming the player, 1 UNIQUE; THE ITEM'S on DAMAGE and RANGE, saved a plain Pistol (G5b) +│ ├── sheet-item-types.spec.ts # The GEAR tab as a table per type (8a3a): a stick made by hand with its own DAMAGE and GRADE, a line named like the Pistol showing its values faint, RANGE typed over, a rope in GEAR, saved as made, each in its table after a reload; compact lines with ✎ and DONE, and nothing on the GEAR tab scrolling sideways in SHEET.EXE (8a3c1); the Pistol's DAMAGE read on this character under ✎, a bad name flagged, eˣ INSERT (8a3c2); in bands (G2), PACK saying "Nothing here." and things added from the row of + at the top; the Pistol's card opened by a click on its name (G3); the Pistol UNIQUE after the reload, its hover naming the player, "unique" in FIND finding it; THE ITEM'S on DAMAGE and RANGE, saved a plain Pistol (G5b) │ ├── sheet-gear-bands.spec.ts # The GEAR tab in bands (G2): a Sword, a Draught and a Rope added by hand land in EQUIPPED, USABLE and PACK, counted; the Sword stashed moves to STASH, which opens and says WEAPONS; USABLE closed by its head stays closed on the next visit; the Draught's blank HEALS filled from FILL IN, its card opened at that box (G3); a Cloak of GEAR worn into EQUIPPED and taken off back into PACK, EQUIPPED closed first and lit when the Cloak is worn; FIND 2d4 showing the Draught in a closed USABLE, nothing for lantern, cleared and USABLE closed again (G4) │ ├── sheet-gear-counts.spec.ts # A gear line's COUNT at the table (8a4): the Pistol's AMMO 2 / 6, FIRE spending one, RELOAD asking between Pistol Rounds and AP Rounds and using the AP Rounds up, then full from the Pistol Rounds; the Wand's CHARGES filled by a short rest from the sheet │ ├── sheet-standalone-tab.spec.ts # The sheet in a new tab (8s1a): opened with ⧉, in the theme, WEAR there works and SHEET.EXE says so, a weapon's DAMAGE rolled from it; the roll from the tab opening the main app's dice tray (8s1b); a character being made: CREATING · CONTINUE on the tab opening NEW_CHARACTER.EXE there (8s1c); Cash on the tab opening BANK.EXE in the main window, and with that window closed the tab saying to open it (8s1d); gear added from the row of + at the top of GEAR (G2) diff --git a/e2e/README.md b/e2e/README.md index 6a1f92c5..00dc86ae 100644 --- a/e2e/README.md +++ b/e2e/README.md @@ -205,7 +205,7 @@ kept; the job itself stops at 30 (`timeout-minutes`), for a hang outside the tes | `tests/sheet-ranks.spec.ts` | A rank on the sheet (7f1c1): a player with Level 3 sees Athletics as a picker of UNTRAINED, TRAINED and EXPERT, picks EXPERT, its worth = 7 shows beside it, the formula Climb reading it shows 8, and the server keeps the step 2 with Athletics 7 and Climb 8 | | `tests/sheet-ranks-start.spec.ts` | Ranks making a character (7f1c2): a player in NEW CHARACTER types Grit, finds Lore under RANKS with UP TO TRAINED TO START and EXPERT off, picks TRAINED, and the server keeps the step 1 with Lore worth 2 | | `tests/sheet-worn-items.spec.ts` | Items at the table (7e3b): two GEAR lines named like items get WEAR and ATTUNE; the ring worn does nothing yet, attuned it is WORKING, ATTUNED 1 OF 1, CON 14 → 16; the cloak worn with no slot free says so and can't attune; the GM, on the player's sheet, ATTUNES it ANYWAY (2 OF 1) and gives them 2 of their own; END frees the ring's slot and its +2 goes; the cloak taken off stays attuned and does nothing. A second test: the GM's GIVE.EXE lists the ring under ITEMS with NEEDS ATTUNED and its words, gives it to the player as a stowed gear line, the player is told and WEARS it; TERMINATE_SESSION closes GIVE.EXE while the session is still ending; and (2026-11-22) no ATTUNED bar on GEAR until the Ring's line is there | -| `tests/sheet-item-types.spec.ts` | The GEAR tab as a table per item type (8a3a): a player's sheet with WEAPONS and GEAR tables, each empty with its +; + WEAPON made A stick with DAMAGE 1d4 and GRADE HEAVY; a second line named Pistol showing 2d6 + @might faint, its RANGE typed over to 50 m; + GEAR made Rope at 10 lb; saved as made, each in its table after a reload; since 8a3b the stick's DAMAGE rolled with ROLL, "rolled A stick DAMAGE 1d4" in the dice tray's history; and (8a3c1) as compact lines: a line made by hand opened under ✎, DONE showing its words with ROLL, the Pistol's RANGE read as words after the reload, and no box on the GEAR tab scrolling sideways in SHEET.EXE; and (8a3c2) the Pistol's DAMAGE under ✎ said ON THIS CHARACTER: 2d6 + Might (12): 14 to 24, @strength flagged as not the system's, eˣ INSERT putting in @might; and (G2) in bands: PACK says "Nothing here." with no WEAPONS group before anything is carried, and things are added from the row of + at the top; and (G3) the Pistol's card opened by a click on its name; and (G5a) the Pistol, its RANGE its own, saved with who changed it and when; and (G5b) after the reload the Pistol says UNIQUE, its hover "RANGE 50 m, the item's: 30 m · changed by" the player, with 1 UNIQUE at the top; THE ITEM'S on its DAMAGE and RANGE leaves a plain Pistol, saved so | +| `tests/sheet-item-types.spec.ts` | The GEAR tab as a table per item type (8a3a): a player's sheet with WEAPONS and GEAR tables, each empty with its +; + WEAPON made A stick with DAMAGE 1d4 and GRADE HEAVY; a second line named Pistol showing 2d6 + @might faint, its RANGE typed over to 50 m; + GEAR made Rope at 10 lb; saved as made, each in its table after a reload; since 8a3b the stick's DAMAGE rolled with ROLL, "rolled A stick DAMAGE 1d4" in the dice tray's history; and (8a3c1) as compact lines: a line made by hand opened under ✎, DONE showing its words with ROLL, the Pistol's RANGE read as words after the reload, and no box on the GEAR tab scrolling sideways in SHEET.EXE; and (8a3c2) the Pistol's DAMAGE under ✎ said ON THIS CHARACTER: 2d6 + Might (12): 14 to 24, @strength flagged as not the system's, eˣ INSERT putting in @might; and (G2) in bands: PACK says "Nothing here." with no WEAPONS group before anything is carried, and things are added from the row of + at the top; and (G3) the Pistol's card opened by a click on its name; and (G5a) the Pistol, its RANGE its own, saved with who changed it and when; and (G5b) after the reload the Pistol says UNIQUE, its hover "RANGE 50 m, the item's: 30 m · changed by" the player, "unique" in FIND showing it and not the stick; THE ITEM'S on its DAMAGE and RANGE leaves a plain Pistol, saved so | | `tests/sheet-gear-bands.spec.ts` | The GEAR tab in bands (G2): a game with WEAPONS EQUIPPED, POTIONS USABLE and GEAR unsaid; a player adds a Sword, a Draught and a Rope from the row of + at the top, each in its band and counted (EQUIPPED · 1, USABLE · 1, PACK · 1, STASH · 0 closed), saved as made; the Sword moved to the stash goes to STASH, which opens and says WEAPONS, EQUIPPED left at 0; USABLE closed by its head, and on the next visit USABLE is still closed and PACK open; and (G3) one line a thing: the Draught's HEALS blank, so FILL IN, which opens its card at that box, ready to type; 2d4 typed, DONE, the line says HEALS 2d4 and FILL IN is gone, saved; a Cloak, GEAR, made by hand sits in PACK, WEAR puts it in EQUIPPED (EQUIPPED · 1), taken off it is back in PACK; with EQUIPPED closed, WEAR lights its head (▸ EQUIPPED · 1), opened it is plain again; and (G4) FIND: 2d4 shows the Draught in USABLE, closed, opened while it shows (PACK · 0), lantern says nothing matches, cleared USABLE is closed again | | `tests/sheet-gear-counts.spec.ts` | A gear line's COUNT at the table (8a4): a player's Pistol at AMMO 2 / 6 spends one with FIRE; RELOAD, with Pistol Rounds and AP Rounds both carried, asks which and takes all 3 AP Rounds, their line gone; RELOAD again takes 2 of the Pistol Rounds alone, full, RELOAD held; the Wand's CHARGES, with no RELOAD, filled by a SHORT REST from the sheet | | `tests/sheet-standalone-tab.spec.ts` | The sheet in a new tab is the window (8s1a): a player makes two gear lines in SHEET.EXE, opens the tab with ⧉ (a `.crt-container`, so in the theme), WEARs the boots there and SHEET.EXE says WORKING too, and rolls the club's DAMAGE from the tab, said on it once the dice land; since 8s1b the roll from the tab opens DICE_TRAY.EXE in the main app's window; and (8s1c) a character being made: the flow left, SHEET.EXE says CREATING · CONTINUE, the tab says it too and opens NEW_CHARACTER.EXE on itself; and (8s1d) Cash on the tab opens BANK.EXE in the main window and the tab says so, then with the main window closed the tab says to open it; and (G2) gear added from the row of + at the top of GEAR | diff --git a/e2e/tests/sheet-item-types.spec.ts b/e2e/tests/sheet-item-types.spec.ts index 9072ceef..140efe08 100644 --- a/e2e/tests/sheet-item-types.spec.ts +++ b/e2e/tests/sheet-item-types.spec.ts @@ -89,11 +89,15 @@ test('GEAR as a table per type: a stick made by hand and its DAMAGE rolled, the await expect(weapons.getByText('WEAPONS · 2')).toBeVisible({ timeout: 15_000 }); await expect(gear.getByText('GEAR · 1')).toBeVisible(); await expect(weapons.getByRole('note', { name: 'Item 2 RANGE: 50 m' })).toBeVisible(); - // UNIQUE (G5b): its RANGE its own, so the line says so, with the item's and who changed it when on hover; counted at the top. + // UNIQUE (G5b): its RANGE its own, so the line says so, with the item's and who changed it when on hover; "unique" in FIND finds it. const unique = weapons.getByRole('note', { name: 'Item 2 is unique' }); await expect(unique).toHaveText('UNIQUE'); await expect(unique).toHaveAttribute('title', new RegExp(`RANGE 50 m, the item's: 30 m · changed by ${player.username}, \\d{4}-\\d{2}-\\d{2}`)); - await expect(mine.getByRole('button', { name: '1 UNIQUE', exact: true })).toBeVisible(); + const find = mine.getByRole('searchbox', { name: 'Find in your gear' }); + await find.fill('unique'); + await expect(weapons.getByRole('button', { name: 'Pistol, item 2', exact: true })).toBeVisible(); + await expect(weapons.getByRole('button', { name: 'A stick, item 1', exact: true })).toHaveCount(0); + await find.fill(''); // Compact lines (8a3c1): in SHEET.EXE's width, nothing on the GEAR tab scrolls sideways. // The sheet and any box inside it (the old table scrolled in a box of its own). const sideways = await mine.locator('.sheet-scroll').evaluate((root) => [root, ...root.querySelectorAll('*')] @@ -120,7 +124,6 @@ test('GEAR as a table per type: a stick made by hand and its DAMAGE rolled, the await expect(weapons.getByLabel('Item 2 DAMAGE', { exact: true })).toHaveValue(''); await weapons.getByRole('group', { name: 'Item 2 RANGE is unique' }).getByRole('button', { name: "Item 2 RANGE: the item's" }).click(); await expect(unique).toHaveCount(0); - await expect(mine.getByRole('button', { name: /UNIQUE$/ })).toHaveCount(0); await expect.poll(async () => JSON.parse(String((await sheetOf()).inventory ?? '[]'))[1], { timeout: 15_000 }).toEqual(line('Pistol', { type: 'weapons' })); await context.close(); }); diff --git a/frontend/src/components/GearTypeTables.tsx b/frontend/src/components/GearTypeTables.tsx index 0d85c66a..4b655311 100644 --- a/frontend/src/components/GearTypeTables.tsx +++ b/frontend/src/components/GearTypeTables.tsx @@ -1,7 +1,7 @@ import React, { useEffect, useEffectEvent, useRef, useState } from 'react'; import { CARRY_STATES, type InventoryItem } from '../sheets/inventory'; import type { ItemsShown } from '../sheets/gearItems'; -import { gearTables, gearBands, foundIn, uniqueCells, uniqueTitle, uniqueCount, itemWas, valueText, withLineValue, newLineOf, shownCells, cellWords, countOf, type Cell, type CountAnswer, type CountKind, type TableRow, type TypeShown } from '../sheets/gearTypes'; +import { gearTables, gearBands, foundIn, uniqueCells, uniqueTitle, itemWas, valueText, withLineValue, newLineOf, shownCells, cellWords, countOf, type Cell, type CountAnswer, type CountKind, type TableRow, type TypeShown } from '../sheets/gearTypes'; import { useGearBands } from '../hooks/useGearBands'; import { diceWords, SHAPES, shapeText, insertName, type GearDiceRead } from '../sheets/gearDice'; import { FormulaIcon } from './FormulaIcon'; @@ -18,7 +18,8 @@ import { FormulaIcon } from './FormulaIcon'; // in hand first; STASH, closed to start, whatever the type; a band's head closes it and the sheet remembers. A thing is // made by hand from the row of + buttons at the top; a closed band something lands in pulses, then stays bright until // opened; a line changed from its item says UNIQUE, each column it made its own too, with THE ITEM'S to put it back and -// the item's value and who changed it when, and the count of them at the top lists them in FIND (G5b); FIND at the top, always shown, keeps only the lines it matches, every band open while it has words (G4); +// the item's value and who changed it when, and "unique" in FIND lists them (G5b; no count at the top, the user: FIND +// is enough and saves the room); FIND at the top, always shown, keeps only the lines it matches, every band open while it has words (G4); // a thing worn, attuned or installed is in EQUIPPED whatever its type. One line a thing (G3; the same mockup, decision 3): its name, how many, // the columns it has as words with ROLL, FIRE and RELOAD, where it is carried; a click on it opens the card, every column a // box with NAME, HOW MANY, LOCATION and REMOVE, one card at a time; ✎ at the end of every line opens it too. A line with @@ -333,13 +334,6 @@ export function GearTypeTables({ items, itemsShown, readOnly, write, locked, on, }; return (
- {/* How many lines are their item made unique (G5b): a click lists them in FIND. */} - {uniqueCount(tables) > 0 && ( - - )} {/* The box, and its own × in the theme (the browser's is blue in every theme): Esc clears it too. */} { expect(at(0).queryByRole('group', { name: 'Item 1 DAMAGE is unique' })).toBeNull(); }); - it('the count at the top, which lists them in FIND; none where none are', async () => { + it('"unique" in FIND lists them; no count at the top (the user: FIND is enough)', async () => { show([made, line('Rope'), line('Pistol', { values: { range: '50 m' } })]); - const count = screen.getByRole('button', { name: '2 UNIQUE' }); - expect(count.title).toBe('Lines that differ from their item: click to list them'); - await userEvent.click(count); - expect((screen.getByRole('searchbox', { name: 'Find in your gear' }) as HTMLInputElement).value).toBe('unique'); + expect(screen.queryByRole('button', { name: /UNIQUE$/ })).toBeNull(); + await userEvent.type(screen.getByRole('searchbox', { name: 'Find in your gear' }), 'unique'); expect(screen.getByRole('button', { name: 'Pistol, item 1' })).toBeTruthy(); expect(screen.getByRole('button', { name: 'Pistol, item 3' })).toBeTruthy(); expect(screen.queryByRole('button', { name: 'Rope, item 2' })).toBeNull(); - cleanup(); - show([line('Pistol'), line('Rope')]); - expect(screen.queryByRole('button', { name: /UNIQUE$/ })).toBeNull(); }); }); diff --git a/frontend/src/sheets/__tests__/gearTypes.test.ts b/frontend/src/sheets/__tests__/gearTypes.test.ts index d4321fce..2c4a63a1 100644 --- a/frontend/src/sheets/__tests__/gearTypes.test.ts +++ b/frontend/src/sheets/__tests__/gearTypes.test.ts @@ -1,6 +1,6 @@ import { describe, it, expect } from 'vitest'; import { createRequire } from 'module'; -import { typesOf, fits, itemOfLine, lineColumns, gearTables, valueText, withLineValue, newLineOf, countOf, cellWords, LIMITS, type ColumnShown , gearBands, landedIn, foundIn, uniqueCells, changedWords, itemWas, uniqueTitle, uniqueCount } from '../gearTypes'; +import { typesOf, fits, itemOfLine, lineColumns, gearTables, valueText, withLineValue, newLineOf, countOf, cellWords, LIMITS, type ColumnShown , gearBands, landedIn, foundIn, uniqueCells, changedWords, itemWas, uniqueTitle } from '../gearTypes'; import { normaliseItem, readInventory, type InventoryItem } from '../inventory'; import type { ItemsShown } from '../gearItems'; @@ -295,10 +295,8 @@ describe('UNIQUE on the sheet (G5b)', () => { .toBe("Unique: changed from its item\nDAMAGE 2d8, the item's: 1d8 + @might · changed by kes, 2026-11-20\nRANGE 2 m, the item's: none"); }); - it('how many lines are unique; "unique" in FIND lists them', () => { + it('"unique" in FIND lists them', () => { const lines = [at('Cutlass', { values: { damage: '2d8' } }), at('Cutlass'), at('Rope', { type: 'gear', values: { weight: 1 } })]; - expect(uniqueCount(gearTables(SHOWN, lines))).toBe(1); - expect(uniqueCount(gearTables(SHOWN, [at('Cutlass')]))).toBe(0); const found = foundIn(gearBands(SHOWN, lines), 'unique'); expect(found.flatMap((b) => b.groups.flatMap((g) => g.rows.map((r) => r.index)))).toEqual([0]); }); diff --git a/frontend/src/sheets/gearTypes.ts b/frontend/src/sheets/gearTypes.ts index f8cf77e5..ae3807f8 100644 --- a/frontend/src/sheets/gearTypes.ts +++ b/frontend/src/sheets/gearTypes.ts @@ -176,9 +176,6 @@ export const itemWas = (cell: Cell, line: InventoryItem): string => { export const uniqueTitle = (row: TableRow): string => ['Unique: changed from its item', ...uniqueCells(row.columns).map((c) => `${c.column.label.toUpperCase()} ${valueText(c.own)}, ${itemWas(c, row.line)}`)].join('\n'); -/** How many lines are their item made unique (G5b): at the top of GEAR. */ -export const uniqueCount = (tables: { rows: TableRow[] }[]): number => tables.reduce((n, t) => n + t.rows.filter((r) => uniqueCells(r.columns).length > 0).length, 0); - /** A value as a box shows it. */ export const valueText = (v: Value | undefined): string => (v === undefined ? '' : String(v));