From c7c0150d4804946708e1542cd7187436f0ea4d01 Mon Sep 17 00:00:00 2001 From: Developer Date: Sat, 21 Nov 2026 21:44:00 -0600 Subject: [PATCH 1/4] feat: one line a thing on GEAR, its name, how many, its columns as words and where it is carried, a click opening its card with NAME, HOW MANY, every column, LOCATION and REMOVE; FILL IN where a column is blank, opening the card at that box; a PICK ONE box as wide as its words --- CHANGELOG.md | 1 + README.md | 8 +- e2e/COVERAGE.md | 2 +- e2e/README.md | 4 +- e2e/tests/sheet-gear-bands.spec.ts | 15 +- e2e/tests/sheet-item-types.spec.ts | 3 +- frontend/src/components/GearTypeTables.tsx | 239 +++++++++--------- .../__tests__/GearTypeTables.test.tsx | 108 ++++++-- 8 files changed, 241 insertions(+), 139 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 338d730f..32641522 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -799,6 +799,7 @@ Format follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### Changed +- **One line a thing on GEAR.** Each thing on the sheet's GEAR tab is now a single line: its name, how many, its values with ROLL, FIRE and RELOAD beside them, and where it is carried, still changed with one click. Click the line or its name to open its card, with NAME, HOW MANY, every column, LOCATION, DONE and REMOVE; one card is open at a time. A line with a blank column shows a dashed FILL IN, which opens the card at that box, ready to type. A pick-one box such as GRADE is now as wide as its words, not the whole card. SHEET.EXE and the sheet's own tab are the same. - **Long shop shelves stay quick.** A shelf with hundreds of lines now shows 200 at a time, with more as you scroll down, or press SHOW MORE. A line says how many there are, and filtering and sorting still cover every line. Typing in the filter no longer waits for the list to redraw. On a 1000-line shelf, sorting went from about 0.4 s to 0.15 s, and opening it from 0.6 s to 0.26 s. Saving a big catalogue is about five times faster. - **The initiative tracker for a GM running several fights.** The tracker window now opens beside the INITIATIVE menu instead of on top of it, so ACTIVE COMBATS stays in view and the GM can jump from fight to fight with the tracker open. The menu's ACTIVE COMBATS, each COMBAT #n and the scene name on the tracker were drawn in the theme's border colour and could hardly be read in any theme; they now use its text colour. Jumping to a fight whose building has lost its battle map says NO_BATTLE_MAP_FOR_THAT_SCENE instead of doing nothing. Whose turn it is is also announced to screen readers. All found by new browser journeys: one fight with two players from START to END, two fights at once with the GM jumping between them, and one fight spread over two scenes. - **The tracker counts ROUNDs in Generic and custom systems.** Its counter read TURN 3, though it counts laps of the whole order, which are rounds; Cities Without Number and Cyberpunk RED already said ROUND. It now says ROUND 3, a custom system's own word for a round where it renamed one (the WORDS page's ROUND, apart from its TURN), and Shadowrun still counts PASSes. diff --git a/README.md b/README.md index c2fd1816..af007951 100644 --- a/README.md +++ b/README.md @@ -796,7 +796,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) -│ │ │ ├── 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 +│ │ │ ├── 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, a click opening its card (NAME, HOW MANY, every column, LOCATION, DONE, REMOVE), FILL IN where a column is blank opening the card at that box, a PICK ONE box as wide as its words │ │ │ ├── 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) @@ -1083,7 +1083,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 +│ │ │ ├── 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, FILL IN naming the blank columns and opening at the first (a DAMAGE too), none where nothing is blank, UNNAMED, a PICK ONE box as wide as its words │ │ │ ├── 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 @@ -1544,8 +1544,8 @@ 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 -│ ├── 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 -│ ├── 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 +│ ├── 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-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) │ ├── 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) │ ├── sheet-vitals.spec.ts # The vitals strip (8s3b): DAMAGE in SHEET.EXE and HEAL on the ⧉ tab moving the token and both sheets; the HP bar opening HEALTH in place on the tab; a condition put on in SHEET.EXE shown on the tab and taken off there, and a long rest taken from the tab's REST ▾ (8s3c); two tracks: STUN picked, damage past its maximum spilling into PHYSICAL, said (8s3d1); the GM taking damage off a player from the box in their view of the sheet, the player's SHEET.EXE following (8s3d2) diff --git a/e2e/COVERAGE.md b/e2e/COVERAGE.md index 9894aff1..39f86132 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 | +| 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 column blank on the line and its item (G3): FILL IN, opening the card at that box (`sheet-gear-bands`, the Draught's HEALS) | | 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 cdbf8856..bdcad0eb 100644 --- a/e2e/README.md +++ b/e2e/README.md @@ -205,8 +205,8 @@ 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 | -| `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 | -| `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 | +| `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 | +| `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 | | `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 | | `tests/sheet-vitals.spec.ts` | The vitals strip (8s3b): a player with a token takes 5 with DAMAGE in SHEET.EXE (the token and the bar at 15/20), opens the ⧉ tab and HEALs 3 there (18/20 on the token, the tab and SHEET.EXE), then clicks the tab's HP bar and HEALTH's own panel opens in place; and (8s3c) PRONE put on under the box in SHEET.EXE, shown on the tab as a chip and taken off there, then REST ▾ on the tab taking a LONG REST, asked first, the stat it refills set; the box's HIT POINTS ▾ wholly under the numbers with the slash centered over it, and the conditions list as wide as the box; and CWN in SHEET.EXE: MELEE AC and RANGED AC shown, no two of HEAL, DAMAGE, STIM, HIT POINTS, + CONDITION, the AC and REST overlapping, and every button's words inside it; the AC centered between + CONDITION and REST; and (8s3d1) a two-track system: STUN MAX set on the sheet, STUN picked above the box, 6 damage filling it with 2 spilling into PHYSICAL (18/20 on the token), STUN FULL · 2 SPILLED INTO PHYSICAL said; and (8s3d2) the GM opens a player's sheet (GLOBAL_CHAT, VIEW_PLAYER_INFO, OPEN_SHEET) and takes 5 with the box there: the token at 15, the GM's box and the player's own SHEET.EXE saying 15. Since 8a6c the chip is clicked open, as wide as the box, and taken off with TAKE OFF | diff --git a/e2e/tests/sheet-gear-bands.spec.ts b/e2e/tests/sheet-gear-bands.spec.ts index 45c9ddc0..fb52e23e 100644 --- a/e2e/tests/sheet-gear-bands.spec.ts +++ b/e2e/tests/sheet-gear-bands.spec.ts @@ -52,14 +52,25 @@ test('GEAR in bands: EQUIPPED, USABLE, PACK by type, a sword stashed into the ST // The sword to the stash: into the STASH band, opened to show it, its type said. await band('EQUIPPED').getByLabel('Item 1 carried', { exact: true }).selectOption('stash'); await expect(head('STASH')).toHaveText('▾ STASH · 1'); - await expect(band('STASH').getByLabel('Item 1 name', { exact: true })).toHaveValue('Sword'); + await expect(band('STASH').getByRole('button', { name: 'Sword, item 1', exact: true })).toBeVisible(); await expect(band('STASH').getByText('WEAPONS', { exact: true })).toBeVisible(); await expect(head('EQUIPPED')).toHaveText('▾ EQUIPPED · 0'); + // One line a thing (G3): the Draught's HEALS is blank, so FILL IN, which opens its card at that box, ready to type. + const draught = mine.getByTestId('gear-line-1'); + await expect(draught.getByRole('group', { name: 'Item 2 columns' })).toHaveCount(0); + await draught.getByRole('button', { name: 'Fill in item 2: HEALS', exact: true }).click(); + await expect(draught.getByLabel('Item 2 HEALS', { exact: true })).toBeFocused(); + await mine.keyboard.type('2d4'); + await draught.getByRole('button', { name: 'DONE', exact: true }).click(); + await expect(draught.getByRole('note', { name: 'Item 2 HEALS: 2d4' })).toBeVisible(); + await expect(draught.getByRole('button', { name: /^Fill in/ })).toHaveCount(0); + await expect.poll(async () => JSON.parse(String((await sheetOf()).inventory ?? '[]'))[1]?.values, { timeout: 15_000 }).toEqual({ heals: '2d4' }); + // USABLE closed by its head; still closed after a reload. await head('USABLE').click(); await expect(head('USABLE')).toHaveAttribute('aria-expanded', 'false'); - await expect(band('USABLE').getByLabel('Item 2 name', { exact: true })).toHaveCount(0); + await expect(band('USABLE').getByRole('button', { name: 'Draught, item 2', exact: true })).toHaveCount(0); await expect.poll(async () => JSON.parse(String((await sheetOf()).inventory ?? '[]'))[0]?.carry, { timeout: 15_000 }).toBe('stash'); // A fresh visit, signed in again: which bands are closed is kept in this browser. await signInAsPlayer(mine, player); diff --git a/e2e/tests/sheet-item-types.spec.ts b/e2e/tests/sheet-item-types.spec.ts index 55dc3227..bab20d40 100644 --- a/e2e/tests/sheet-item-types.spec.ts +++ b/e2e/tests/sheet-item-types.spec.ts @@ -96,7 +96,8 @@ test('GEAR as a table per type: a stick made by hand and its DAMAGE rolled, the // Its DAMAGE under ✎ (8a3c2): what it reads on this character, as ROLL reads it (Might 12); a name the system hasn't // got, said as typed rather than skipped at the roll. - await weapons.getByRole('button', { name: 'Edit item 2' }).click(); + // Its card opened by a click on its name (G3). + await weapons.getByRole('button', { name: 'Pistol, item 2', exact: true }).click(); const reads = weapons.getByRole('status', { name: 'Item 2 DAMAGE on this character' }); await expect(reads).toHaveText('ON THIS CHARACTER: 2d6 + Might (12): 14 to 24', { timeout: 15_000 }); await weapons.getByLabel('Item 2 DAMAGE', { exact: true }).fill('1d6 + @strength'); diff --git a/frontend/src/components/GearTypeTables.tsx b/frontend/src/components/GearTypeTables.tsx index bc64e3db..d4871bd6 100644 --- a/frontend/src/components/GearTypeTables.tsx +++ b/frontend/src/components/GearTypeTables.tsx @@ -16,7 +16,10 @@ import { FormulaIcon } from './FormulaIcon'; // the server, which asks which carried line to reload from when there are several. The lines in bands (G2; approved mockup // 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. +// made by hand from the row of + buttons at the top. 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. A column blank on the line and its item says FILL IN, +// which opens the card at that box. A PICK ONE box is as wide as its words. interface Props { items: InventoryItem[]; @@ -47,12 +50,13 @@ const small: React.CSSProperties = { fontSize: '0.55rem', letterSpacing: '1px', const smallButton: React.CSSProperties = { fontSize: '0.5rem', padding: '0 5px', letterSpacing: '1px', flexShrink: 0 }; /** A column's box under ✎: the line's own value, its item's faint where it has none, "none" where neither. */ -function CellBox({ cell, label, readOnly, onType }: { cell: Cell; label: string; readOnly: boolean; onType: (typed: string) => void }) { +function CellBox({ cell, label, readOnly, onType, focus = false }: { cell: Cell; label: string; readOnly: boolean; onType: (typed: string) => void; focus?: boolean }) { const { column } = cell; const given = cell.given !== undefined ? valueText(cell.given) : 'none'; if (column.kind === 'pick') { return ( - onType(e.target.value)}> {(column.options ?? []).map((w) => )} @@ -61,7 +65,7 @@ function CellBox({ cell, label, readOnly, onType }: { cell: Cell; label: string; const number = column.kind === 'number' || column.kind === 'count'; return ( onType(e.target.value)} + value={valueText(cell.own)} placeholder={given} readOnly={readOnly} autoFocus={focus} onChange={(e) => onType(e.target.value)} style={{ ...input, ...(number ? { width: '90px' } : {}) }} /> ); } @@ -72,7 +76,7 @@ function CellBox({ cell, label, readOnly, onType }: { cell: Cell; label: string; * ROLL would, or what is wrong with it; and eˣ, as the builder's formula box has it: SHAPE writes a common one, INSERT * puts in one of the system's names. */ -function DiceBox({ cell, label, onType, onRead }: { cell: Cell; label: string; onType: (typed: string) => void; onRead: (text: string) => Promise }) { +function DiceBox({ cell, label, onType, onRead, focus = false }: { cell: Cell; label: string; onType: (typed: string) => void; onRead: (text: string) => Promise; focus?: boolean }) { const [open, setOpen] = useState(false); // What the server said, kept with the text it was said of: an answer for older text is never shown. const [read, setRead] = useState<{ text: string; result: GearDiceRead | null } | null>(null); @@ -95,7 +99,7 @@ function DiceBox({ cell, label, onType, onRead }: { cell: Cell; label: string; o { onType(e.target.value); cursor.current = e.target.selectionStart ?? e.target.value.length; }} onSelect={(e) => { cursor.current = (e.target as HTMLInputElement).selectionStart ?? 0; }} style={{ ...input, flex: 1, ...(bad ? { borderColor: 'var(--danger)' } : {}) }} /> @@ -139,6 +143,8 @@ function DiceBox({ cell, label, onType, onRead }: { cell: Cell; label: string; o export function GearTypeTables({ items, itemsShown, readOnly, write, locked, under, onRoll, onReadDice, onCount }: Props) { // The one line open under ✎, by its place in the inventory. const [open, setOpen] = useState(null); + // The box the open card starts at: a column's id from FILL IN, 'name' for a line made by hand, else none. + const [focusAt, setFocusAt] = useState(null); // A COUNT's RELOAD asking which carried line to take from, or what the server said no with, on the line that asked. const [asked, setAsked] = useState<{ index: number; column: string; label: string; from: { line: number; name: string; qty: number }[] } | null>(null); const [said, setSaid] = useState<{ index: number; text: string } | null>(null); @@ -168,118 +174,125 @@ export function GearTypeTables({ items, itemsShown, readOnly, write, locked, und const bands = gearBands(itemsShown, items); const { shut, toggle, openBand } = useGearBands(); const bandOfType = (type: TypeShown) => (type.on_sheet === 'equipped' || type.on_sheet === 'usable' ? type.on_sheet : 'pack'); - /** One line as the sheet has drawn it since 8a3c1, by its place; `tagged`, in the STASH, says its type. */ + /** One line a thing (G3), by its place; a click opens its card. `tagged`, in the STASH, says its type. */ const lineView = ({ index: i, line, columns: lc }: TableRow, type: TypeShown, tagged = false) => { - const cells = shownCells(lc); - const editing = open === i; - const stashed = line.carry === 'stash'; - const lockedTitle = locked(i) ? 'Installed: REMOVE it first' : undefined; + const cells = shownCells(lc); + // Blank on the line and its item alike: FILL IN, opening the card at the first. + const blank = lc.cells.filter((c) => c.own === undefined && c.given === undefined); + const editing = open === i; + const stashed = line.carry === 'stash'; + const lockedTitle = locked(i) ? 'Installed: REMOVE it first' : undefined; + const name = line.name.trim() || 'UNNAMED'; + const openAt = (at: string | null) => { setOpen(editing && at === null ? null : i); setFocusAt(at); }; + return ( +
+ {/* In the STASH, whatever its type: the type said, so GUNS and WEAPONS still read apart. */} + {tagged && {type.label.toUpperCase()}} + {/* The line: a click anywhere on it but its buttons and box opens or closes the card. */} +
{ if (!readOnly && !(e.target as HTMLElement).closest('button, input, select, a')) openAt(null); }} + style={{ display: 'flex', flexWrap: 'wrap', gap: '2px 12px', alignItems: 'center', fontSize: '0.7rem', minWidth: 0, cursor: readOnly ? 'default' : 'pointer' }}> + {readOnly + ? {name} + : } + {line.qty > 1 && ×{line.qty}} + {/* 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}`; + const rolls = (cell.column.kind === 'damage' || cell.column.kind === 'dice') && onRoll; + // A COUNT (8a4b; decision 6 of the gear mockup): "AMMO 4 / 6", its button and RELOAD beside it, like ROLL. + const left = cell.column.kind === 'count' && onCount ? countOf(line, cell) : null; + const word = cell.column.label.toUpperCase(); + const button = (cell.column.button || 'USE').toUpperCase(); + const reload = cell.column.reload ?? []; return ( -
- {/* In the STASH, whatever its type: the type said, so GUNS and WEAPONS still read apart. */} - {tagged && {type.label.toUpperCase()}} -
- patch(i, { ...line, name: e.target.value })} style={input} /> - patch(i, { ...line, qty: Math.max(1, Number(e.target.value) || 1) })} style={{ ...input, textAlign: 'center' }} /> - - {!readOnly && ( - - )} - {!readOnly && ( - - )} -
- {/* Only the columns it has, as words: its item's faint, ROLL beside a DAMAGE or DICE (8a3b); kept over the boxes - while ✎ is open, as the mockup draws it. */} - {(cells.length > 0 || stashed) && ( -
- {cells.map((cell) => { - const label = `Item ${i + 1} ${cell.column.label}`; - const rolls = (cell.column.kind === 'damage' || cell.column.kind === 'dice') && onRoll; - // A COUNT (8a4b; decision 6 of the gear mockup): "AMMO 4 / 6", its button and RELOAD beside it, like ROLL. - const left = cell.column.kind === 'count' && onCount ? countOf(line, cell) : null; - const word = cell.column.label.toUpperCase(); - const button = (cell.column.button || 'USE').toUpperCase(); - const reload = cell.column.reload ?? []; - return ( - - {word} - {cellWords(cell, line)} - {rolls && ( - - )} - {left && ( - - )} - {left && reload.length > 0 && ( - - )} - - ); - })} - {/* Where a stashed thing is, as words (its box is under ✎). */} - {stashed && line.location && ( - STASHED{line.location} - )} -
- )} - {/* RELOAD with more than one kind carried (Pistol Rounds, AP Rounds): which, asked on the line. */} - {asked && asked.index === i && ( -
- RELOAD {asked.label} FROM - {asked.from.map((s) => ( - - ))} - -
- )} - {said && said.index === i && ( - {said.text} + + {word} + {cellWords(cell, line)} + {rolls && ( + )} - {!editing && !readOnly && cells.length === 0 && type.columns.length > 0 && ( - NOTHING FILLED IN · ✎ TO FILL IT + {left && ( + )} - {/* ✎: every column as a box, its item's value faint until typed over, "none" where it has none. */} - {editing && ( -
- {lc.cells.map((cell) => ( - - {/* Beside its box's top, not halfway down a DAMAGE with its words and eˣ open under it. */} - {cell.column.label.toUpperCase()}{cell.column.kind === 'number' && cell.column.unit ? ` (${cell.column.unit})` : ''} - {(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))} />} - - ))} - LOCATION - patch(i, { ...line, location: e.target.value })} style={input} /> - - - - or ✎ again; opening another line closes this one - -
+ {left && reload.length > 0 && ( + )} - {under(i)} -
+ ); + })} + {/* Where a stashed thing is, as words (its box is in the card). */} + {stashed && line.location && ( + STASHED{line.location} + )} + {!readOnly && !editing && blank.length > 0 && ( + + )} + {/* Where it is carried, one click to change, as a tag at the end of the line. */} + +
+ {/* RELOAD with more than one kind carried (Pistol Rounds, AP Rounds): which, asked on the line. */} + {asked && asked.index === i && ( +
+ RELOAD {asked.label} FROM + {asked.from.map((s) => ( + + ))} + +
+ )} + {said && said.index === i && ( + {said.text} + )} + {/* The card: NAME and HOW MANY, every column as a box, its item's value faint until typed over, "none" where it has + none; LOCATION; DONE and REMOVE. */} + {editing && ( +
+ NAME + patch(i, { ...line, name: e.target.value })} style={input} /> + HOW MANY + patch(i, { ...line, qty: Math.max(1, Number(e.target.value) || 1) })} style={{ ...input, width: '90px' }} /> + {lc.cells.map((cell) => ( + + {/* Beside its box's top, not halfway down a DAMAGE with its words and eˣ open under it. */} + {cell.column.label.toUpperCase()}{cell.column.kind === 'number' && cell.column.unit ? ` (${cell.column.unit})` : ''} + {(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))} />} + + ))} + LOCATION + patch(i, { ...line, location: e.target.value })} style={input} /> + + + + or click the line again + + +
+ )} + {under(i)} +
+ ); }; return (
@@ -288,7 +301,7 @@ export function GearTypeTables({ items, itemsShown, readOnly, write, locked, und
{tables.map(({ type }) => ( + onClick={() => { write([...items, newLineOf(type)]); setOpen(items.length); setFocusAt('name'); openBand(bandOfType(type)); }}>+ {type.one.toUpperCase()} ))}
)} diff --git a/frontend/src/components/__tests__/GearTypeTables.test.tsx b/frontend/src/components/__tests__/GearTypeTables.test.tsx index 4f59ab99..c849d514 100644 --- a/frontend/src/components/__tests__/GearTypeTables.test.tsx +++ b/frontend/src/components/__tests__/GearTypeTables.test.tsx @@ -47,19 +47,23 @@ const show = (lines: object[], { readOnly = false, items = ITEMS as ItemsShown | return () => writes[writes.length - 1] as Record[]; }; const table = (name: string) => within(screen.getByRole('region', { name: `${name} gear` })); +/** A line's name, the button opening its card (G3): "Pistol, item 2". */ +const named = (i: number) => new RegExp(`, item ${i}$`); describe('a compact line per thing, by type', () => { const note = (name: string, label: string) => table(name).queryByRole('note', { name: new RegExp(`^${label}: `) }); - const edit = (name: string, i: number) => userEvent.click(table(name).getByRole('button', { name: `Edit item ${i}` })); + // Its card opened by a click on its name (G3). + const edit = (name: string, i: number) => userEvent.click(table(name).getByRole('button', { name: named(i) })); it('each type\'s lines under its heading; on a line only the columns it has, as words, its item\'s faint, units said', () => { show([line('Rope'), line('Pistol'), line('A stick', { type: 'weapons', values: { damage: '1d4' } })]); expect(table('WEAPONS').getByText('WEAPONS · 3')).toBeTruthy(); - expect((table('WEAPONS').getByLabelText('Item 2 name') as HTMLInputElement).value).toBe('Pistol'); + expect(table('WEAPONS').getByRole('button', { name: 'Pistol, item 2' })).toBeTruthy(); // Rope is no item of the system: the first type... which is WEAPONS; it has no columns at all. - expect((table('WEAPONS').getByLabelText('Item 1 name') as HTMLInputElement).value).toBe('Rope'); + expect(table('WEAPONS').getByRole('button', { name: 'Rope, item 1' })).toBeTruthy(); expect(within(screen.getByTestId('gear-line-0')).queryAllByRole('note').filter((n) => /^Item [0-9]+ /.test(n.getAttribute('aria-label') ?? ''))).toHaveLength(0); - expect(within(screen.getByTestId('gear-line-0')).getByText('NOTHING FILLED IN · ✎ TO FILL IT')).toBeTruthy(); + // Every column blank: FILL IN says which (G3). + expect(within(screen.getByTestId('gear-line-0')).getByRole('button', { name: 'Fill in item 1: DAMAGE, RANGE, AMMO, WEIGHT, CHARGES, GRADE' })).toBeTruthy(); // The Pistol: its item's DAMAGE, RANGE, AMMO, WEIGHT with its unit, GRADE. expect(within(screen.getByTestId('gear-line-1')).getAllByRole('note').map((n) => n.getAttribute('aria-label')).filter((l) => /^Item [0-9]+ /.test(l ?? ''))) .toEqual(['Item 2 DAMAGE: 2d6', 'Item 2 RANGE: 30 m', 'Item 2 AMMO: 6 / 6', 'Item 2 WEIGHT: 2 LB', 'Item 2 GRADE: LIGHT']); @@ -77,7 +81,7 @@ describe('a compact line per thing, by type', () => { it('✎ opens every column as a box, its item\'s faint, "none" where it has none; typed, the line\'s own; blank, the item\'s again', async () => { const last = show([line('Pistol'), line('A stick', { type: 'weapons', values: { damage: '1d4' } })]); await edit('WEAPONS', 1); - expect(table('WEAPONS').getByRole('button', { name: 'Edit item 1' }).getAttribute('aria-pressed')).toBe('true'); + expect(table('WEAPONS').getByRole('button', { name: 'Pistol, item 1' }).getAttribute('aria-expanded')).toBe('true'); // Its words stay over the boxes, as the mockup draws it. expect(note('WEAPONS', 'Item 1 RANGE')).toBeTruthy(); const range = table('WEAPONS').getByLabelText('Item 1 RANGE') as HTMLInputElement; @@ -96,7 +100,7 @@ describe('a compact line per thing, by type', () => { expect(table('WEAPONS').queryByLabelText('Item 1 RANGE')).toBeNull(); expect((table('WEAPONS').getByLabelText('Item 2 RANGE') as HTMLInputElement).placeholder).toBe('none'); expect((table('WEAPONS').getByLabelText('Item 2 GRADE') as HTMLSelectElement).options[0].textContent).toBe('none'); - // DONE closes it, as ✎ again does. + // DONE closes it, as a click on the line again does. await userEvent.click(table('WEAPONS').getByRole('button', { name: 'DONE' })); expect(table('WEAPONS').queryByLabelText('Item 2 RANGE')).toBeNull(); await edit('WEAPONS', 2); @@ -110,6 +114,8 @@ describe('a compact line per thing, by type', () => { await userEvent.click(within(screen.getByRole('group', { name: 'Add by hand' })).getByRole('button', { name: 'Add a Gear by hand' })); expect(last()[1]).toEqual(line('', { type: 'gear' })); expect(table('GEAR').getByLabelText('Item 2 WEIGHT')).toBeTruthy(); + // Its NAME box ready to type in (G3). + expect(document.activeElement).toBe(table('GEAR').getByLabelText('Item 2 name')); fireEvent.change(table('GEAR').getByLabelText('Item 2 name'), { target: { value: 'Pistol' } }); // Named like the pistol, it is still GEAR: what was made by hand stays where it was made. expect((table('GEAR').getByLabelText('Item 2 name') as HTMLInputElement).value).toBe('Pistol'); @@ -123,19 +129,23 @@ describe('a compact line per thing, by type', () => { await userEvent.click(stashed.getByRole('button', { name: 'DONE' })); expect(within(screen.getByTestId('gear-line-1')).getByText('the van')).toBeTruthy(); expect(within(screen.getByTestId('gear-line-1')).getByText('STASHED')).toBeTruthy(); + // REMOVE is in the card (G3). + await userEvent.click(within(screen.getByTestId('gear-line-1')).getByRole('button', { name: 'Pistol, item 2' })); await userEvent.click(within(screen.getByTestId('gear-line-1')).getByRole('button', { name: 'Remove item 2' })); expect(last()).toHaveLength(1); }); - it('read only: the words and nothing to change, no ✎, + or ×', () => { + it('read only: the words and nothing to change, no card to open, no + or REMOVE', () => { // A Rope, with nothing filled in: said only where it could be filled. show([line('Pistol'), line('Rope')], { readOnly: true }); - expect((table('WEAPONS').getByLabelText('Item 1 name') as HTMLInputElement).readOnly).toBe(true); + expect(within(screen.getByTestId('gear-line-0')).getByText('Pistol')).toBeTruthy(); + expect(screen.queryByRole('button', { name: /, item \d+$/ })).toBeNull(); + expect((table('WEAPONS').getByLabelText('Item 1 carried') as HTMLSelectElement).disabled).toBe(true); expect(note('WEAPONS', 'Item 1 RANGE')).toBeTruthy(); expect(screen.queryByRole('button', { name: /^Edit item/ })).toBeNull(); expect(screen.queryByRole('button', { name: /by hand/ })).toBeNull(); expect(screen.queryByRole('button', { name: /Remove item/ })).toBeNull(); - expect(screen.queryByText('NOTHING FILLED IN · ✎ TO FILL IT')).toBeNull(); + expect(screen.queryByRole('button', { name: /^Fill in/ })).toBeNull(); }); it('ROLL beside each DAMAGE (8a3b): its line and column sent; none where there is no DAMAGE; read only, still there', async () => { @@ -180,7 +190,7 @@ describe('a DAMAGE or DICE under ✎ (8a3c2)', () => { it('says what it reads on this character, its item\'s while it has none of its own; a name the system hasn\'t got, flagged', async () => { const { asked, read } = reader(); const last = show([line('Pistol', { values: { damage: '1d8 + @might_mod' } })], { onReadGearDice: read }); - await userEvent.click(table('WEAPONS').getByRole('button', { name: 'Edit item 1' })); + await userEvent.click(table('WEAPONS').getByRole('button', { name: named(1) })); const words = () => table('WEAPONS').getByRole('status', { name: 'Item 1 DAMAGE on this character' }); await waitFor(() => expect(words().textContent).toBe('ON THIS CHARACTER: 1d8 + Might mod (2): 3 to 10')); fireEvent.change(table('WEAPONS').getByLabelText('Item 1 DAMAGE'), { target: { value: '1d6 + @strength' } }); @@ -198,7 +208,7 @@ describe('a DAMAGE or DICE under ✎ (8a3c2)', () => { it('eˣ: SHAPE writes one, INSERT puts a name in; a DICE column too; without a reader, the plain box', async () => { const { read } = reader(); const last = show([line('Pistol')], { onReadGearDice: read }); - await userEvent.click(table('WEAPONS').getByRole('button', { name: 'Edit item 1' })); + await userEvent.click(table('WEAPONS').getByRole('button', { name: named(1) })); expect(table('WEAPONS').queryByRole('group', { name: 'Help writing Item 1 DAMAGE' })).toBeNull(); await userEvent.click(table('WEAPONS').getByRole('button', { name: 'Help writing Item 1 DAMAGE' })); const help = within(table('WEAPONS').getByRole('group', { name: 'Help writing Item 1 DAMAGE' })); @@ -212,7 +222,7 @@ describe('a DAMAGE or DICE under ✎ (8a3c2)', () => { expect(last()[0].values).toMatchObject({ damage: '1d6 + @might_mod' }); cleanup(); show([line('Pistol')]); - await userEvent.click(table('WEAPONS').getByRole('button', { name: 'Edit item 1' })); + await userEvent.click(table('WEAPONS').getByRole('button', { name: named(1) })); expect(table('WEAPONS').queryByRole('button', { name: 'Help writing Item 1 DAMAGE' })).toBeNull(); expect(table('WEAPONS').getByLabelText('Item 1 DAMAGE')).toBeTruthy(); }); @@ -321,11 +331,11 @@ describe('in bands (G2)', () => { it('EQUIPPED, USABLE, PACK and STASH in order, each counted; a type\'s lines in its band, in hand first; STASH closed', () => { show([typed('Rope', 'gear'), typed('Sword', 'weapons'), typed('Pistol', 'weapons', { carry: 'readied' }), typed('Draught', 'potions'), typed('Spare Sword', 'weapons', { carry: 'stash' })], { items: BANDED }); expect(screen.getAllByRole('button', { name: /^[▸▾] [A-Z]+ · \d+$/ }).map((b) => b.textContent)).toEqual(['▾ EQUIPPED · 2', '▾ USABLE · 1', '▾ PACK · 1', '▸ STASH · 1']); - expect(within(band('EQUIPPED')).getAllByLabelText(/^Item \d+ name$/).map((i) => (i as HTMLInputElement).value)).toEqual(['Pistol', 'Sword']); + expect(within(band('EQUIPPED')).getAllByRole('button', { name: /, item \d+$/ }).map((b) => b.textContent)).toEqual(['Pistol', 'Sword']); expect(within(band('USABLE')).getByRole('region', { name: 'POTIONS gear' })).toBeTruthy(); expect(within(band('PACK')).getByRole('region', { name: 'GEAR gear' })).toBeTruthy(); expect(head('STASH').getAttribute('aria-expanded')).toBe('false'); - expect(within(band('STASH')).queryByLabelText(/name$/)).toBeNull(); + expect(within(band('STASH')).queryByRole('button', { name: /, item \d+$/ })).toBeNull(); }); it('a head closes and opens its band, remembered; the STASH says each line\'s type; an empty band says so', async () => { @@ -333,10 +343,10 @@ describe('in bands (G2)', () => { await userEvent.click(head('STASH')); expect(head('STASH').getAttribute('aria-expanded')).toBe('true'); expect(within(band('STASH')).getByText('WEAPONS')).toBeTruthy(); - expect((within(band('STASH')).getByLabelText('Item 2 name') as HTMLInputElement).value).toBe('Spare Sword'); + expect(within(band('STASH')).getByRole('button', { name: 'Spare Sword, item 2' })).toBeTruthy(); expect(within(band('USABLE')).getByText('Nothing here.')).toBeTruthy(); await userEvent.click(head('EQUIPPED')); - expect(within(band('EQUIPPED')).queryByLabelText('Item 1 name')).toBeNull(); + expect(within(band('EQUIPPED')).queryByRole('button', { name: 'Sword, item 1' })).toBeNull(); // Shown again, as left. cleanup(); show([typed('Sword', 'weapons'), typed('Spare Sword', 'weapons', { carry: 'stash' })], { items: BANDED }); @@ -352,3 +362,69 @@ describe('in bands (G2)', () => { expect(within(band('EQUIPPED')).getByLabelText('Item 2 name')).toBeTruthy(); }); }); + +describe('one line a thing, its card on a click (G3)', () => { + const at = (i: number) => within(screen.getByTestId(`gear-line-${i}`)); + + it('a click on the line opens its card: NAME, HOW MANY, every column, LOCATION, REMOVE; its own buttons and where it is carried don\'t', async () => { + const rolled: number[] = []; + show([line('Pistol', { qty: 2 }), line('A stick', { type: 'weapons', values: { damage: '1d4' } })], { onGearRoll: (l) => rolled.push(l) }); + // On the line: its name, how many where more than one, its columns as words, where it is carried; no boxes. + expect(at(0).getByText('×2')).toBeTruthy(); + expect(at(1).queryByText(/^×/)).toBeNull(); + expect(at(0).queryByLabelText('Item 1 name')).toBeNull(); + expect(at(0).queryByRole('button', { name: 'Remove item 1' })).toBeNull(); + // ROLL and the carried box do their own thing. + await userEvent.click(at(0).getByRole('button', { name: 'Roll Item 1 DAMAGE' })); + fireEvent.click(at(0).getByLabelText('Item 1 carried')); + expect(rolled).toEqual([0]); + expect(at(0).queryByRole('group', { name: 'Item 1 columns' })).toBeNull(); + // Anywhere else on the line opens it. + await userEvent.click(at(0).getByText('30 m')); + const card = within(at(0).getByRole('group', { name: 'Item 1 columns' })); + expect([...card.getAllByRole('textbox'), ...card.getAllByRole('spinbutton'), ...card.getAllByRole('combobox')].map((b) => b.getAttribute('aria-label'))) + .toEqual(['Item 1 name', 'Item 1 DAMAGE', 'Item 1 RANGE', 'Item 1 location', 'Item 1 quantity', 'Item 1 AMMO', 'Item 1 WEIGHT', 'Item 1 CHARGES', 'Item 1 GRADE']); + expect((card.getByLabelText('Item 1 quantity') as HTMLInputElement).value).toBe('2'); + expect(card.getByRole('button', { name: 'Remove item 1' })).toBeTruthy(); + // Another line's opens it and closes this one; its name again closes it. + await userEvent.click(at(1).getByRole('button', { name: 'A stick, item 2' })); + expect(at(0).queryByRole('group', { name: 'Item 1 columns' })).toBeNull(); + expect(at(1).getByRole('group', { name: 'Item 2 columns' })).toBeTruthy(); + await userEvent.click(at(1).getByRole('button', { name: 'A stick, item 2' })); + expect(at(1).queryByRole('group', { name: 'Item 2 columns' })).toBeNull(); + }); + + it('FILL IN names the blank columns and opens the card at the first, its box ready; none where nothing is blank, or while open', async () => { + const items: ItemsShown = { ...ITEMS, list: [...ITEMS.list, { id: 'rope', label: 'Rope', needs: 'carried', features: [], type: 'gear', values: { weight: 5 } }] }; + show([line('Pistol'), line('Rope', { type: 'gear' }), line('', { type: 'gear' })], { items }); + // The Pistol's item has every column but CHARGES. + const fill = at(0).getByRole('button', { name: 'Fill in item 1: CHARGES' }); + expect(fill.title).toBe('Blank: CHARGES'); + // The Rope's item has its WEIGHT: nothing blank. + expect(at(1).queryByRole('button', { name: /^Fill in/ })).toBeNull(); + // A line with no name says so. + expect(at(2).getByRole('button', { name: 'UNNAMED, item 3' })).toBeTruthy(); + await userEvent.click(fill); + expect(document.activeElement).toBe(at(0).getByLabelText('Item 1 CHARGES')); + expect(at(0).queryByRole('button', { name: /^Fill in/ })).toBeNull(); + // A line's own value fills it. + await userEvent.click(at(2).getByRole('button', { name: 'Fill in item 3: WEIGHT' })); + fireEvent.change(at(2).getByLabelText('Item 3 WEIGHT'), { target: { value: '1' } }); + await userEvent.click(at(2).getByRole('button', { name: 'DONE' })); + expect(at(2).queryByRole('button', { name: /^Fill in/ })).toBeNull(); + }); + + it('FILL IN at a blank DAMAGE, read as dice: that box ready to type', async () => { + show([line('Knife', { type: 'weapons' })], { onReadGearDice: async () => ({ ok: true, blank: true, names: [] }) }); + await userEvent.click(at(0).getByRole('button', { name: /^Fill in item 1: DAMAGE/ })); + expect(document.activeElement).toBe(at(0).getByLabelText('Item 1 DAMAGE')); + }); + + it('a PICK ONE box as wide as its words, a number box 90 wide', async () => { + show([line('Pistol')]); + await userEvent.click(screen.getByRole('button', { name: named(1) })); + expect((screen.getByLabelText('Item 1 GRADE') as HTMLSelectElement).style.width).toBe('auto'); + expect((screen.getByLabelText('Item 1 WEIGHT') as HTMLInputElement).style.width).toBe('90px'); + expect((screen.getByLabelText('Item 1 RANGE') as HTMLInputElement).style.width).toBe('100%'); + }); +}); From db5973e1a30938fb56b01b678510f2d525a6cccb Mon Sep 17 00:00:00 2001 From: Developer Date: Sat, 21 Nov 2026 22:14:47 -0600 Subject: [PATCH 2/4] feat: a thing worn, attuned or installed sits in EQUIPPED on GEAR whatever its type's band, back in its type's band when taken off --- CHANGELOG.md | 2 +- README.md | 10 +++---- e2e/COVERAGE.md | 2 +- e2e/README.md | 2 +- e2e/tests/sheet-gear-bands.spec.ts | 13 ++++++++- frontend/src/components/GearTypeTables.tsx | 8 +++--- frontend/src/components/InventorySection.tsx | 7 ++++- .../__tests__/GearTypeTables.test.tsx | 18 +++++++++++-- .../src/sheets/__tests__/gearTypes.test.ts | 27 +++++++++++++++++++ frontend/src/sheets/gearTypes.ts | 20 ++++++++++---- 10 files changed, 89 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 32641522..65411782 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -799,7 +799,7 @@ Format follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### Changed -- **One line a thing on GEAR.** Each thing on the sheet's GEAR tab is now a single line: its name, how many, its values with ROLL, FIRE and RELOAD beside them, and where it is carried, still changed with one click. Click the line or its name to open its card, with NAME, HOW MANY, every column, LOCATION, DONE and REMOVE; one card is open at a time. A line with a blank column shows a dashed FILL IN, which opens the card at that box, ready to type. A pick-one box such as GRADE is now as wide as its words, not the whole card. SHEET.EXE and the sheet's own tab are the same. +- **One line a thing on GEAR.** Each thing on the sheet's GEAR tab is now a single line: its name, how many, its values with ROLL, FIRE and RELOAD beside them, and where it is carried, still changed with one click. Click the line or its name to open its card, with NAME, HOW MANY, every column, LOCATION, DONE and REMOVE; one card is open at a time. A line with a blank column shows a dashed FILL IN, which opens the card at that box, ready to type. A pick-one box such as GRADE is now as wide as its words, not the whole card. Anything worn, attuned or installed now sits in EQUIPPED, whatever band its type is in, and goes back when taken off. SHEET.EXE and the sheet's own tab are the same. - **Long shop shelves stay quick.** A shelf with hundreds of lines now shows 200 at a time, with more as you scroll down, or press SHOW MORE. A line says how many there are, and filtering and sorting still cover every line. Typing in the filter no longer waits for the list to redraw. On a 1000-line shelf, sorting went from about 0.4 s to 0.15 s, and opening it from 0.6 s to 0.26 s. Saving a big catalogue is about five times faster. - **The initiative tracker for a GM running several fights.** The tracker window now opens beside the INITIATIVE menu instead of on top of it, so ACTIVE COMBATS stays in view and the GM can jump from fight to fight with the tracker open. The menu's ACTIVE COMBATS, each COMBAT #n and the scene name on the tracker were drawn in the theme's border colour and could hardly be read in any theme; they now use its text colour. Jumping to a fight whose building has lost its battle map says NO_BATTLE_MAP_FOR_THAT_SCENE instead of doing nothing. Whose turn it is is also announced to screen readers. All found by new browser journeys: one fight with two players from START to END, two fights at once with the GM jumping between them, and one fight spread over two scenes. - **The tracker counts ROUNDs in Generic and custom systems.** Its counter read TURN 3, though it counts laps of the whole order, which are rounds; Cities Without Number and Cyberpunk RED already said ROUND. It now says ROUND 3, a custom system's own word for a round where it renamed one (the WORDS page's ROUND, apart from its TURN), and Shadowrun still counts PASSes. diff --git a/README.md b/README.md index af007951..e65861b2 100644 --- a/README.md +++ b/README.md @@ -795,7 +795,7 @@ CITY_NET/ │ │ │ ├── AdminPanel.tsx # GM dashboard — CITY / EXPORT / GAME / PLAYERS tabs (GAME has GIVE_ITEM beside PAY_PLAYERS, and SHOP_CATALOGUES wherever there are shops or GIVE ITEM); CITY_GENERATOR delegates to cityGen/ and exposes LAYOUT, DRAG_RECT/DRAW_AREA bounds, OVERPASS_DENSITY, WATER, PARK_PONDS, an optional SEED and REGENERATE; CUSTOM type integrates into NEXT_STYLE cycle using cross-map custom_structure_library; data-driven HouseRulesPanel for CP:R, CWN, and SR6; SR6 Edge replenishment (reset all / give 1 to player); a built-in game's own CONDITIONS for the main admin (TableConditionsPanel); a custom game's RESTS for the GM and editors (GameRestsPanel), with the NPCs on the map being viewed; a custom game's own house rules beside the shared ones in HOUSE RULES, one APPLY for all, following the game when it changes. The GAME tab's RESTS and BANK are folders of its own (R2b, GameFolder.tsx), RESTS out of TTRPG_SYSTEM, a line before what the GM hands out; AWARD_EXPERIENCE where XP is spent (7f2c2); AdminPanel itself only picks the battle map's panel or the city's (CityAdminPanel), two components so their hooks never mix; HOUSE RULES offers a custom system's SHOW ENCUMBRANCE, BAND CONDITIONS and APPLY CONDITION MODIFIERS where it has what each switches (8a6b) │ │ │ ├── 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) +│ │ │ ├── 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) │ │ │ ├── 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, a click opening its card (NAME, HOW MANY, every column, LOCATION, DONE, REMOVE), FILL IN where a column is blank opening the card at that box, a PICK ONE box as wide as its words │ │ │ ├── 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 @@ -1083,7 +1083,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, FILL IN naming the blank columns and opening at the first (a DAMAGE too), none where nothing is blank, UNNAMED, a PICK ONE box as wide as its words +│ │ │ ├── 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, FILL IN naming the blank columns and opening at the first (a DAMAGE too), none where nothing is blank, UNNAMED, a PICK ONE box as wide as its words; a worn Cutlass of a PACK type in EQUIPPED, back in PACK taken off │ │ │ ├── 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 @@ -1289,7 +1289,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) -│ │ │ ├── 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 +│ │ │ ├── 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) │ │ │ ├── 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) @@ -1343,7 +1343,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 -│ │ │ ├── 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 +│ │ │ ├── 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) │ │ │ ├── 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 @@ -1545,7 +1545,7 @@ CITY_NET/ │ ├── 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 │ ├── 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-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) +│ ├── 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 │ ├── 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) │ ├── sheet-vitals.spec.ts # The vitals strip (8s3b): DAMAGE in SHEET.EXE and HEAL on the ⧉ tab moving the token and both sheets; the HP bar opening HEALTH in place on the tab; a condition put on in SHEET.EXE shown on the tab and taken off there, and a long rest taken from the tab's REST ▾ (8s3c); two tracks: STUN picked, damage past its maximum spilling into PHYSICAL, said (8s3d1); the GM taking damage off a player from the box in their view of the sheet, the player's SHEET.EXE following (8s3d2) diff --git a/e2e/COVERAGE.md b/e2e/COVERAGE.md index 39f86132..dc15e107 100644 --- a/e2e/COVERAGE.md +++ b/e2e/COVERAGE.md @@ -35,7 +35,7 @@ panel), so a control that looks fine but does nothing is caught for all of them. | Shop catalogues by item type | a section per item type (8a7a1), its columns checked, blanks kept | `shop_catalogue_types`, `catalogueTypes` | `catalogue-types`, `shop-typed-lines` (bought at the General Store and given, landing typed, 8a7a2) | **AT THE TABLE** | | The shops under load | 1000+ lines on a shelf, 200 items, a full cart, a long gear list (8n3); a long shelf drawn 200 rows at a time | `shop_stress`, `ShopWindow` | `shop-stress` | **AT THE TABLE** | | An item type's SOLD AT | the kinds of shop that sell its lines (8a7a2), the General Store where unsaid; set in the builder in 8a7b | `shop_typed_lines`, `typedShelves` | `shop-typed-lines` (unsaid: the General Store) | **AT THE TABLE** unsaid; a kind of shop picked waits for 8a7b's box | -| An item type's ON THE SHEET band | EQUIPPED, USABLE or PACK (G1), PACK where unsaid; the sheet's GEAR tab in those bands plus STASH, closed to start, a band's head closing it, remembered (G2) | `system_builder_item_types`, `itemTypes`, `ItemsPage`, `gearBands`, `GearTypeTables` | `builder-item-types` (the WEAPON preset EQUIPPED), `sheet-gear-bands` (a Sword, a Draught and a Rope in EQUIPPED, USABLE and PACK; the Sword stashed into STASH; USABLE kept closed) | **AT THE TABLE** | +| An item type's ON THE SHEET band | EQUIPPED, USABLE or PACK (G1), PACK where unsaid; the sheet's GEAR tab in those bands plus STASH, closed to start, a band's head closing it, remembered (G2); a thing worn, attuned or installed in EQUIPPED whatever its type (G3) | `system_builder_item_types`, `itemTypes`, `ItemsPage`, `gearBands`, `GearTypeTables` | `builder-item-types` (the WEAPON preset EQUIPPED), `sheet-gear-bands` (a Sword, a Draught and a Rope in EQUIPPED, USABLE and PACK; the Sword stashed into STASH; USABLE kept closed; a Cloak of GEAR worn into EQUIPPED, taken off back into PACK) | **AT THE TABLE** | | An item's PRICE and IN SHOPS | priced and IN SHOPS, it sells itself at its type's shops (8a7a3a); off, never sold, not even from a file, but bought back at its price by a shop of its type (8a7a3c2); a type's PRICE column read as its price; set on ITEMS under TYPE, NOT SOLD in the list, a new item's price asked for (8a7a3b1); in the ITEMS import and downloads, price and in shops columns (8a7a3b2) | `shop_items_on_sale`, `itemPrice`, `ItemsPage`, `system_builder_items_import`, `itemsImport` | `shop-items-on-sale` (a type's PRICE column; a ring turned off; sold back from the window at 50%), `builder-item-price` (set by clicks), `builder-items-import` (imported priced and IN SHOPS) | **AT THE TABLE** | | A catalogue file held against the game's items | an exact copy of an item left out, an item kept out of the shops left out, one of an item's name overruling it, ALSO ON SALE FROM ITEMS (8a7a3c1) | `shop_items_on_sale`, `CatalogueWindow` | `catalogue-and-items` | **AT THE TABLE** | | ADD NEW LINES TO ITEMS | a catalogue's new lines made items in the draft (8a7a4a), off to start; on PUBLISH the lines now exactly an item leave the file (8a7a4b) | `catalogue_into_items`, `CatalogueWindow`, `catalogueItems`, `BuilderScreen` | `catalogue-and-items` (the Hand Cannon into the draft, then out of the file once published) | **AT THE TABLE** | diff --git a/e2e/README.md b/e2e/README.md index bdcad0eb..1be4ff55 100644 --- a/e2e/README.md +++ b/e2e/README.md @@ -206,7 +206,7 @@ kept; the job itself stops at 30 (`timeout-minutes`), for a hang outside the tes | `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 | | `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 | -| `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 | +| `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 | | `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 | | `tests/sheet-vitals.spec.ts` | The vitals strip (8s3b): a player with a token takes 5 with DAMAGE in SHEET.EXE (the token and the bar at 15/20), opens the ⧉ tab and HEALs 3 there (18/20 on the token, the tab and SHEET.EXE), then clicks the tab's HP bar and HEALTH's own panel opens in place; and (8s3c) PRONE put on under the box in SHEET.EXE, shown on the tab as a chip and taken off there, then REST ▾ on the tab taking a LONG REST, asked first, the stat it refills set; the box's HIT POINTS ▾ wholly under the numbers with the slash centered over it, and the conditions list as wide as the box; and CWN in SHEET.EXE: MELEE AC and RANGED AC shown, no two of HEAL, DAMAGE, STIM, HIT POINTS, + CONDITION, the AC and REST overlapping, and every button's words inside it; the AC centered between + CONDITION and REST; and (8s3d1) a two-track system: STUN MAX set on the sheet, STUN picked above the box, 6 damage filling it with 2 spilling into PHYSICAL (18/20 on the token), STUN FULL · 2 SPILLED INTO PHYSICAL said; and (8s3d2) the GM opens a player's sheet (GLOBAL_CHAT, VIEW_PLAYER_INFO, OPEN_SHEET) and takes 5 with the box there: the token at 15, the GM's box and the player's own SHEET.EXE saying 15. Since 8a6c the chip is clicked open, as wide as the box, and taken off with TAKE OFF | diff --git a/e2e/tests/sheet-gear-bands.spec.ts b/e2e/tests/sheet-gear-bands.spec.ts index fb52e23e..97e6f6a6 100644 --- a/e2e/tests/sheet-gear-bands.spec.ts +++ b/e2e/tests/sheet-gear-bands.spec.ts @@ -18,7 +18,8 @@ test('GEAR in bands: EQUIPPED, USABLE, PACK by type, a sword stashed into the ST { id: 'weapons', label: 'WEAPONS', one: 'Weapon', on_sheet: 'equipped', columns: [{ id: 'damage', label: 'DAMAGE', kind: 'damage' }] }, { id: 'potions', label: 'POTIONS', one: 'Potion', on_sheet: 'usable', columns: [{ id: 'heals', label: 'HEALS', kind: 'dice' }] }, ], - list: [], + // A GEAR thing to wear (G3): worn, it is on you, so EQUIPPED though GEAR is PACK. + list: [{ id: 'cloak', label: 'Cloak', type: 'gear', needs: 'worn', features: [] }], }, }); const player = { username: `e2e_bandhold${again}`, password: 'e2e-player-password' }; @@ -79,5 +80,15 @@ test('GEAR in bands: EQUIPPED, USABLE, PACK by type, a sword stashed into the ST await sheetTab(mine, 'GEAR'); await expect(head('USABLE')).toHaveAttribute('aria-expanded', 'false'); await expect(head('PACK')).toHaveAttribute('aria-expanded', 'true'); + + // A Cloak, GEAR, in PACK; worn, EQUIPPED; taken off, PACK again (G3: "my Cutlass is worn, should it be in EQUIPPED?"). + await add.getByRole('button', { name: 'Add a Gear by hand' }).click(); + await mine.getByLabel('Item 4 name', { exact: true }).fill('Cloak'); + await expect(band('PACK').getByRole('button', { name: 'Cloak, item 4', exact: true })).toBeVisible(); + await mine.getByTestId('gear-item-cloak').getByRole('button', { name: 'WEAR Cloak', exact: true }).click(); + await expect(band('EQUIPPED').getByRole('button', { name: 'Cloak, item 4', exact: true })).toBeVisible({ timeout: 15_000 }); + await expect(head('EQUIPPED')).toHaveText('▾ EQUIPPED · 1'); + await mine.getByTestId('gear-item-cloak').getByRole('button', { name: /^WORN/ }).click(); + await expect(band('PACK').getByRole('button', { name: 'Cloak, item 4', exact: true })).toBeVisible({ timeout: 15_000 }); await context.close(); }); diff --git a/frontend/src/components/GearTypeTables.tsx b/frontend/src/components/GearTypeTables.tsx index d4871bd6..2409aef9 100644 --- a/frontend/src/components/GearTypeTables.tsx +++ b/frontend/src/components/GearTypeTables.tsx @@ -16,7 +16,7 @@ import { FormulaIcon } from './FormulaIcon'; // the server, which asks which carried line to reload from when there are several. The lines in bands (G2; approved mockup // 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. One line a thing (G3; the same mockup, decision 3): its name, how many, +// made by hand from the row of + buttons at the top; 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. A column blank on the line and its item says FILL IN, // which opens the card at that box. A PICK ONE box is as wide as its words. @@ -28,6 +28,8 @@ interface Props { write: (next: InventoryItem[]) => void; /** Whether a line is an item installed: kept named and in place. */ locked: (index: number) => boolean; + /** Whether a line is an item worn, attuned or installed: on you, so in EQUIPPED whatever its type's band. */ + on?: (index: number) => boolean; /** What goes under a line: an item's WEAR, ATTUNE and uses. */ under: (index: number) => React.ReactNode; /** A DAMAGE or DICE rolled into the log (8a3b), where the viewer may roll: read only or not, as a stat's ROLL. */ @@ -140,7 +142,7 @@ function DiceBox({ cell, label, onType, onRead, focus = false }: { cell: Cell; l ); } -export function GearTypeTables({ items, itemsShown, readOnly, write, locked, under, onRoll, onReadDice, onCount }: Props) { +export function GearTypeTables({ items, itemsShown, readOnly, write, locked, on, under, onRoll, onReadDice, onCount }: Props) { // The one line open under ✎, by its place in the inventory. const [open, setOpen] = useState(null); // The box the open card starts at: a column's id from FILL IN, 'name' for a line made by hand, else none. @@ -171,7 +173,7 @@ export function GearTypeTables({ items, itemsShown, readOnly, write, locked, und else if (!answer.ok) setSaid({ index, text: answer.error }); }); }; - const bands = gearBands(itemsShown, items); + const bands = gearBands(itemsShown, items, on); const { shut, toggle, openBand } = useGearBands(); const bandOfType = (type: TypeShown) => (type.on_sheet === 'equipped' || type.on_sheet === 'usable' ? type.on_sheet : 'pack'); /** One line a thing (G3), by its place; a click opens its card. `tagged`, in the STASH, says its type. */ diff --git a/frontend/src/components/InventorySection.tsx b/frontend/src/components/InventorySection.tsx index 78fdf0c8..6ad1516e 100644 --- a/frontend/src/components/InventorySection.tsx +++ b/frontend/src/components/InventorySection.tsx @@ -91,6 +91,11 @@ export function InventorySection({ section, data, readOnly, onFieldChange, rowAc const installs = installCounters(itemsShown, worked); /** Whether a line is an item installed (7e4c): kept as it is, named and in place, until REMOVE. */ const locked = (i: number) => lineItems.has(i) && !!worked.items.find((w) => w.id === lineItems.get(i)!.id)?.installed; + /** Whether a line is an item worn, attuned or installed: on you, so EQUIPPED on GEAR's bands (G3). */ + const onYou = (i: number) => { + const w = lineItems.has(i) ? worked.items.find((x) => x.id === lineItems.get(i)!.id) : undefined; + return !!(w && (w.worn || w.attuned || w.installed)); + }; // Encumbrance is Cities Without Number's. A system with no carrying rule gets the table // without the column, rather than a rule invented for it. const showEnc = section.inventoryEnc === true; @@ -131,7 +136,7 @@ export function InventorySection({ section, data, readOnly, onFieldChange, rowAc time somebody picks up a rope. */}
{typed && itemsShown ? ( - underLine(i)} onRoll={onGearRoll} onReadDice={onReadGearDice} onCount={onGearCount} /> + underLine(i)} onRoll={onGearRoll} onReadDice={onReadGearDice} onCount={onGearCount} /> ) : (
ITEM
diff --git a/frontend/src/components/__tests__/GearTypeTables.test.tsx b/frontend/src/components/__tests__/GearTypeTables.test.tsx index c849d514..d79e740a 100644 --- a/frontend/src/components/__tests__/GearTypeTables.test.tsx +++ b/frontend/src/components/__tests__/GearTypeTables.test.tsx @@ -36,10 +36,12 @@ const ITEMS: ItemsShown = { const line = (name: string, more = {}) => ({ name, qty: 1, enc: '', bundled: false, carry: 'stowed', location: '', ...more }); const show = (lines: object[], { readOnly = false, items = ITEMS as ItemsShown | undefined, onGearRoll = undefined as ((line: number, column: string) => void) | undefined, - onReadGearDice = undefined as ((text: string) => Promise) | undefined, onGearCount = undefined as GearCount | undefined } = {}) => { + onReadGearDice = undefined as ((text: string) => Promise) | undefined, onGearCount = undefined as GearCount | undefined, + worked = undefined as object | undefined } = {}) => { const writes: object[][] = []; const Harness = () => { - const [data, setData] = useState>({ inventory: JSON.stringify(lines) }); + // `worked`: what the server worked out of the items (_worked), which are worn. + const [data, setData] = useState>({ inventory: JSON.stringify(lines), ...(worked ? { _worked: worked } : {}) }); return { writes.push(JSON.parse(v as string)); setData((d) => ({ ...d, [id]: v })); }} />; }; @@ -354,6 +356,18 @@ describe('in bands (G2)', () => { expect(head('STASH').getAttribute('aria-expanded')).toBe('true'); }); + it('a thing worn is EQUIPPED though its type is PACK (G3): the Cutlass, as the user found it', () => { + const items: ItemsShown = { ...BANDED, list: [{ id: 'cutlass', label: 'Cutlass', needs: 'worn', features: [], type: 'gear', values: {} }] }; + show([typed('Cutlass', 'gear'), typed('Rope', 'gear')], { items, worked: { items: [{ id: 'cutlass', needs: 'worn', worn: true }] } }); + expect(within(band('EQUIPPED')).getByRole('button', { name: 'Cutlass, item 1' })).toBeTruthy(); + expect(within(band('PACK')).getByRole('button', { name: 'Rope, item 2' })).toBeTruthy(); + expect(head('EQUIPPED').textContent).toBe('▾ EQUIPPED · 1'); + cleanup(); + // Taken off: back in its type's band. + show([typed('Cutlass', 'gear'), typed('Rope', 'gear')], { items, worked: { items: [{ id: 'cutlass', needs: 'worn' }] } }); + expect(within(band('PACK')).getByRole('button', { name: 'Cutlass, item 1' })).toBeTruthy(); + }); + it('a thing made by hand opens its band if closed', async () => { show([typed('Sword', 'weapons')], { items: BANDED }); await userEvent.click(head('EQUIPPED')); diff --git a/frontend/src/sheets/__tests__/gearTypes.test.ts b/frontend/src/sheets/__tests__/gearTypes.test.ts index a36f63e4..d388514a 100644 --- a/frontend/src/sheets/__tests__/gearTypes.test.ts +++ b/frontend/src/sheets/__tests__/gearTypes.test.ts @@ -188,3 +188,30 @@ describe('the GEAR tab\'s bands (G2)', () => { expect(bands[3].loose.map(({ type, row }) => [type.id, row.line.name, row.index])).toEqual([['potions', 'Old Map', 4]]); }); }); + +describe('a line on you is EQUIPPED (G3)', () => { + const SHOWN = { + slots: [], list: [], + types: [ + { id: 'weapons', label: 'WEAPONS', one: 'Weapon', columns: [] }, + { id: 'armor', label: 'ARMOR', one: 'Armor', on_sheet: 'equipped', columns: [] }, + { id: 'potions', label: 'POTIONS', one: 'Potion', on_sheet: 'usable', columns: [] }, + { id: 'shields', label: 'SHIELDS', one: 'Shield', on_sheet: 'equipped', columns: [] }, + ], + } as never; + const at = (name: string, type: string, carry = 'stowed') => ({ name, qty: 1, enc: '', bundled: false, carry, location: '', type }) as never; + + it('worn, attuned or installed: EQUIPPED whatever its type\'s band, in a group of its type, in hand first; the rest where their type is; stashed, the STASH', () => { + const lines = [at('Cutlass', 'weapons'), at('Knife', 'weapons'), at('Leather', 'armor'), at('Charm', 'potions', 'readied'), at('Old Ring', 'potions', 'stash'), at('Dagger', 'weapons', 'readied'), at('Old Shield', 'shields', 'stash')]; + const bands = gearBands(SHOWN, lines, (i) => [0, 3, 4, 5].includes(i)); + const names = (b: number) => bands[b].groups.map((g) => [g.type.id, g.rows.map((r) => r.line.name)]); + expect(names(0)).toEqual([['weapons', ['Dagger', 'Cutlass']], ['armor', ['Leather']], ['potions', ['Charm']]]); + expect(names(1)).toEqual([]); + expect(names(2)).toEqual([['weapons', ['Knife']]]); + // SHIELDS are EQUIPPED, their one line in the stash: no empty SHIELDS group. + expect(bands[3].loose.map(({ row }) => row.line.name)).toEqual(['Old Ring', 'Old Shield']); + expect(bands.map((b) => b.count)).toEqual([4, 0, 1, 2]); + // Told nothing, as before: by type alone. + expect(gearBands(SHOWN, lines).map((b) => b.count)).toEqual([1, 1, 3, 2]); + }); +}); diff --git a/frontend/src/sheets/gearTypes.ts b/frontend/src/sheets/gearTypes.ts index 4f208050..cf486700 100644 --- a/frontend/src/sheets/gearTypes.ts +++ b/frontend/src/sheets/gearTypes.ts @@ -89,21 +89,31 @@ export const gearTables = (shown: ItemsShown | null | undefined, lines: Inventor /** * The GEAR tab's bands (G2; approved mockup docs/mockups/sheet-gear-layout.html, layout A, 2026-11-20): EQUIPPED, USABLE and * PACK, each type's lines in its type's band (its ON THE SHEET, G1; PACK where unsaid), in hand first; and STASH, every line - * left in the stash whatever its type. Within a band, a group per type that has lines. + * left in the stash whatever its type. Within a band, a group per type that has lines. A line worn, attuned or installed + * (`on`, by its place) is on you, so EQUIPPED whatever its type's band (the user, 2026-11-22: "my Cutlass is worn, should it + * be in EQUIPPED?"); in the stash it is still the STASH's. */ export type GearBand = 'equipped' | 'usable' | 'pack' | 'stash'; export const GEAR_BANDS: { id: GearBand; label: string }[] = [ { id: 'equipped', label: 'EQUIPPED' }, { id: 'usable', label: 'USABLE' }, { id: 'pack', label: 'PACK' }, { id: 'stash', label: 'STASH' }, ]; export interface BandShown { band: GearBand; label: string; count: number; groups: { type: TypeShown; rows: TableRow[] }[]; loose: { type: TypeShown; row: TableRow }[] } -export const gearBands = (shown: ItemsShown | null | undefined, lines: InventoryItem[]): BandShown[] => { +export const gearBands = (shown: ItemsShown | null | undefined, lines: InventoryItem[], on: (index: number) => boolean = () => false): BandShown[] => { const bands: BandShown[] = GEAR_BANDS.map((b) => ({ band: b.id, label: b.label, count: 0, groups: [], loose: [] })); const at = (id: GearBand) => bands.find((b) => b.band === id)!; const inHand = (r: TableRow) => (r.line.carry === 'readied' ? 0 : 1); + const inOrder = (rows: TableRow[]) => rows.map((r, n) => ({ r, n })).sort((a, b) => inHand(a.r) - inHand(b.r) || a.n - b.n).map(({ r }) => r); for (const { type, rows } of gearTables(shown, lines)) { - const here = rows.filter((r) => r.line.carry !== 'stash').map((r, n) => ({ r, n })).sort((a, b) => inHand(a.r) - inHand(b.r) || a.n - b.n).map(({ r }) => r); - const band = at(type.on_sheet === 'equipped' || type.on_sheet === 'usable' ? type.on_sheet : 'pack'); - if (here.length) band.groups.push({ type, rows: here }); + const home: GearBand = type.on_sheet === 'equipped' || type.on_sheet === 'usable' ? type.on_sheet : 'pack'; + const here = rows.filter((r) => r.line.carry !== 'stash'); + // Its type's band, and EQUIPPED for what is on you: a group each, in the system's order of types. + const worn = here.filter((r) => on(r.index)); + const rest = here.filter((r) => !on(r.index)); + if (home === 'equipped') { if (here.length) at('equipped').groups.push({ type, rows: inOrder(here) }); } + else { + if (worn.length) at('equipped').groups.push({ type, rows: inOrder(worn) }); + if (rest.length) at(home).groups.push({ type, rows: inOrder(rest) }); + } for (const row of rows.filter((r) => r.line.carry === 'stash')) at('stash').loose.push({ type, row }); } for (const b of bands) b.count = b.groups.reduce((n, g) => n + g.rows.length, 0) + b.loose.length; From 1ea856ea44ab12c3dbc224cb000bb4e3d0b88e34 Mon Sep 17 00:00:00 2001 From: Developer Date: Sat, 21 Nov 2026 22:26:51 -0600 Subject: [PATCH 3/4] =?UTF-8?q?feat:=20a=20=E2=9C=8E=20at=20the=20end=20of?= =?UTF-8?q?=20every=20gear=20line=20opening=20its=20card;=20FILL=20IN=20on?= =?UTF-8?q?ly=20where=20nothing=20at=20all=20is=20filled=20in,=20a=20blank?= =?UTF-8?q?=20beside=20others=20filled=20being=20one=20that=20doesn't=20ap?= =?UTF-8?q?ply?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 2 +- README.md | 4 +-- e2e/COVERAGE.md | 2 +- frontend/src/components/GearTypeTables.tsx | 20 +++++++---- .../__tests__/GearTypeTables.test.tsx | 33 +++++++++++++++---- 5 files changed, 44 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 65411782..dbeda12a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -799,7 +799,7 @@ Format follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### Changed -- **One line a thing on GEAR.** Each thing on the sheet's GEAR tab is now a single line: its name, how many, its values with ROLL, FIRE and RELOAD beside them, and where it is carried, still changed with one click. Click the line or its name to open its card, with NAME, HOW MANY, every column, LOCATION, DONE and REMOVE; one card is open at a time. A line with a blank column shows a dashed FILL IN, which opens the card at that box, ready to type. A pick-one box such as GRADE is now as wide as its words, not the whole card. Anything worn, attuned or installed now sits in EQUIPPED, whatever band its type is in, and goes back when taken off. SHEET.EXE and the sheet's own tab are the same. +- **One line a thing on GEAR.** Each thing on the sheet's GEAR tab is now a single line: its name, how many, its values with ROLL, FIRE and RELOAD beside them, and where it is carried, still changed with one click. The ✎ at the end of each line opens its card (a click on the line does too), with NAME, HOW MANY, every column, LOCATION, DONE and REMOVE; one card is open at a time. A line with nothing filled in at all shows a dashed FILL IN, which opens the card at its first box, ready to type; a column left blank beside others means it doesn't apply, so it says nothing. A pick-one box such as GRADE is now as wide as its words, not the whole card. Anything worn, attuned or installed now sits in EQUIPPED, whatever band its type is in, and goes back when taken off. SHEET.EXE and the sheet's own tab are the same. - **Long shop shelves stay quick.** A shelf with hundreds of lines now shows 200 at a time, with more as you scroll down, or press SHOW MORE. A line says how many there are, and filtering and sorting still cover every line. Typing in the filter no longer waits for the list to redraw. On a 1000-line shelf, sorting went from about 0.4 s to 0.15 s, and opening it from 0.6 s to 0.26 s. Saving a big catalogue is about five times faster. - **The initiative tracker for a GM running several fights.** The tracker window now opens beside the INITIATIVE menu instead of on top of it, so ACTIVE COMBATS stays in view and the GM can jump from fight to fight with the tracker open. The menu's ACTIVE COMBATS, each COMBAT #n and the scene name on the tracker were drawn in the theme's border colour and could hardly be read in any theme; they now use its text colour. Jumping to a fight whose building has lost its battle map says NO_BATTLE_MAP_FOR_THAT_SCENE instead of doing nothing. Whose turn it is is also announced to screen readers. All found by new browser journeys: one fight with two players from START to END, two fights at once with the GM jumping between them, and one fight spread over two scenes. - **The tracker counts ROUNDs in Generic and custom systems.** Its counter read TURN 3, though it counts laps of the whole order, which are rounds; Cities Without Number and Cyberpunk RED already said ROUND. It now says ROUND 3, a custom system's own word for a round where it renamed one (the WORDS page's ROUND, apart from its TURN), and Shadowrun still counts PASSes. diff --git a/README.md b/README.md index e65861b2..adf89aaf 100644 --- a/README.md +++ b/README.md @@ -796,7 +796,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) -│ │ │ ├── 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, a click opening its card (NAME, HOW MANY, every column, LOCATION, DONE, REMOVE), FILL IN where a column is blank opening the card at that box, a PICK ONE box as wide as its words +│ │ │ ├── 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 │ │ │ ├── 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) @@ -1083,7 +1083,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, FILL IN naming the blank columns and opening at the first (a DAMAGE too), none where nothing is blank, UNNAMED, a PICK ONE box as wide as its words; a worn Cutlass of a PACK type in EQUIPPED, back in PACK taken off +│ │ │ ├── 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 │ │ │ ├── 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 diff --git a/e2e/COVERAGE.md b/e2e/COVERAGE.md index dc15e107..45e6d6a7 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 column blank on the line and its item (G3): FILL IN, opening the card at that box (`sheet-gear-bands`, the Draught's HEALS) | +| 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 | 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/frontend/src/components/GearTypeTables.tsx b/frontend/src/components/GearTypeTables.tsx index 2409aef9..cb9a7036 100644 --- a/frontend/src/components/GearTypeTables.tsx +++ b/frontend/src/components/GearTypeTables.tsx @@ -18,8 +18,10 @@ 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 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. A column blank on the line and its item says FILL IN, -// which opens the card at that box. A PICK ONE box is as wide as its words. +// 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 +// nothing filled in at all, on it or its item, says FILL IN, which opens the card at its first box: a column blank beside +// others filled is one that doesn't apply (8a3c1), so says nothing (the user, 2026-11-22). A PICK ONE box is as wide as its +// words. interface Props { items: InventoryItem[]; @@ -179,8 +181,9 @@ export function GearTypeTables({ items, itemsShown, readOnly, write, locked, on, /** One line a thing (G3), by its place; a click opens its card. `tagged`, in the STASH, says its type. */ const lineView = ({ index: i, line, columns: lc }: TableRow, type: TypeShown, tagged = false) => { const cells = shownCells(lc); - // Blank on the line and its item alike: FILL IN, opening the card at the first. + // Blank on the line and its item alike. Only every column blank is FILL IN: one blank beside others filled doesn't apply. 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 stashed = line.carry === 'stash'; const lockedTitle = locked(i) ? 'Installed: REMOVE it first' : undefined; @@ -233,16 +236,21 @@ export function GearTypeTables({ items, itemsShown, readOnly, write, locked, on, {stashed && line.location && ( STASHED{line.location} )} - {!readOnly && !editing && blank.length > 0 && ( + {!readOnly && !editing && nothingFilled && ( )} + {/* ✎: the card, as a click on the line opens it, for whoever doesn't think to click a name. */} + {!readOnly && ( + + )} {/* Where it is carried, one click to change, as a tag at the end of the line. */}
@@ -286,7 +294,7 @@ export function GearTypeTables({ items, itemsShown, readOnly, write, locked, on, - or click the line again + or ✎ again diff --git a/frontend/src/components/__tests__/GearTypeTables.test.tsx b/frontend/src/components/__tests__/GearTypeTables.test.tsx index d79e740a..44eb4950 100644 --- a/frontend/src/components/__tests__/GearTypeTables.test.tsx +++ b/frontend/src/components/__tests__/GearTypeTables.test.tsx @@ -335,6 +335,8 @@ describe('in bands (G2)', () => { expect(screen.getAllByRole('button', { name: /^[▸▾] [A-Z]+ · \d+$/ }).map((b) => b.textContent)).toEqual(['▾ EQUIPPED · 2', '▾ USABLE · 1', '▾ PACK · 1', '▸ STASH · 1']); expect(within(band('EQUIPPED')).getAllByRole('button', { name: /, item \d+$/ }).map((b) => b.textContent)).toEqual(['Pistol', 'Sword']); expect(within(band('USABLE')).getByRole('region', { name: 'POTIONS gear' })).toBeTruthy(); + // POTIONS has no columns: nothing to fill in, so no FILL IN (G3). + expect(within(band('USABLE')).queryByRole('button', { name: /^Fill in/ })).toBeNull(); expect(within(band('PACK')).getByRole('region', { name: 'GEAR gear' })).toBeTruthy(); expect(head('STASH').getAttribute('aria-expanded')).toBe('false'); expect(within(band('STASH')).queryByRole('button', { name: /, item \d+$/ })).toBeNull(); @@ -408,19 +410,21 @@ describe('one line a thing, its card on a click (G3)', () => { expect(at(1).queryByRole('group', { name: 'Item 2 columns' })).toBeNull(); }); - it('FILL IN names the blank columns and opens the card at the first, its box ready; none where nothing is blank, or while open', async () => { + it('FILL IN only where nothing is filled in, naming the columns, opening the card at the first, its box ready; none while open', async () => { const items: ItemsShown = { ...ITEMS, list: [...ITEMS.list, { id: 'rope', label: 'Rope', needs: 'carried', features: [], type: 'gear', values: { weight: 5 } }] }; - show([line('Pistol'), line('Rope', { type: 'gear' }), line('', { type: 'gear' })], { items }); - // The Pistol's item has every column but CHARGES. - const fill = at(0).getByRole('button', { name: 'Fill in item 1: CHARGES' }); - expect(fill.title).toBe('Blank: CHARGES'); + show([line('Pistol'), line('Rope', { type: 'gear' }), line('', { type: 'gear' }), line('Knife', { type: 'weapons' })], { items }); + // The Pistol's item has every column but CHARGES: a blank beside others filled doesn't apply, so no FILL IN (2026-11-22). + expect(at(0).queryByRole('button', { name: /^Fill in/ })).toBeNull(); // The Rope's item has its WEIGHT: nothing blank. expect(at(1).queryByRole('button', { name: /^Fill in/ })).toBeNull(); // A line with no name says so. expect(at(2).getByRole('button', { name: 'UNNAMED, item 3' })).toBeTruthy(); + // A Knife made by hand, nothing filled in. + const fill = at(3).getByRole('button', { name: 'Fill in item 4: DAMAGE, RANGE, AMMO, WEIGHT, CHARGES, GRADE' }); + expect(fill.title).toBe('Blank: DAMAGE, RANGE, AMMO, WEIGHT, CHARGES, GRADE'); await userEvent.click(fill); - expect(document.activeElement).toBe(at(0).getByLabelText('Item 1 CHARGES')); - expect(at(0).queryByRole('button', { name: /^Fill in/ })).toBeNull(); + expect(document.activeElement).toBe(at(3).getByLabelText('Item 4 DAMAGE')); + expect(at(3).queryByRole('button', { name: /^Fill in/ })).toBeNull(); // A line's own value fills it. await userEvent.click(at(2).getByRole('button', { name: 'Fill in item 3: WEIGHT' })); fireEvent.change(at(2).getByLabelText('Item 3 WEIGHT'), { target: { value: '1' } }); @@ -434,6 +438,21 @@ describe('one line a thing, its card on a click (G3)', () => { expect(document.activeElement).toBe(at(0).getByLabelText('Item 1 DAMAGE')); }); + it('✎ at the end of every line opens its card and closes it, as the line does; none read only', async () => { + show([line('Pistol'), line('Rope', { type: 'gear' })]); + const pencil = at(0).getByRole('button', { name: 'Edit item 1' }); + expect(pencil.textContent).toBe('✎'); + expect(at(1).getByRole('button', { name: 'Edit item 2' })).toBeTruthy(); + await userEvent.click(pencil); + expect(pencil.getAttribute('aria-expanded')).toBe('true'); + expect(at(0).getByRole('group', { name: 'Item 1 columns' })).toBeTruthy(); + await userEvent.click(pencil); + expect(at(0).queryByRole('group', { name: 'Item 1 columns' })).toBeNull(); + cleanup(); + show([line('Pistol')], { readOnly: true }); + expect(screen.queryByRole('button', { name: /^Edit item/ })).toBeNull(); + }); + it('a PICK ONE box as wide as its words, a number box 90 wide', async () => { show([line('Pistol')]); await userEvent.click(screen.getByRole('button', { name: named(1) })); From a4827e9129d5a3165e96018d903bf78894b58c4b Mon Sep 17 00:00:00 2001 From: Developer Date: Sat, 21 Nov 2026 23:15:34 -0600 Subject: [PATCH 4/4] feat: a closed GEAR band something lands in (worn, bought, given) pulses three times and stays lit in the theme's own color until opened; no pulse with reduced motion --- CHANGELOG.md | 2 +- README.md | 12 +++---- e2e/COVERAGE.md | 2 +- e2e/README.md | 2 +- e2e/tests/sheet-gear-bands.spec.ts | 9 ++++-- frontend/src/App.css | 16 ++++++++++ frontend/src/components/GearTypeTables.tsx | 13 +++++--- .../__tests__/GearTypeTables.test.tsx | 31 ++++++++++++++++++- frontend/src/hooks/useGearBands.ts | 19 ++++++++++-- .../src/sheets/__tests__/gearTypes.test.ts | 11 ++++++- frontend/src/sheets/gearTypes.ts | 8 +++++ 11 files changed, 105 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dbeda12a..2d16e222 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -799,7 +799,7 @@ Format follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### Changed -- **One line a thing on GEAR.** Each thing on the sheet's GEAR tab is now a single line: its name, how many, its values with ROLL, FIRE and RELOAD beside them, and where it is carried, still changed with one click. The ✎ at the end of each line opens its card (a click on the line does too), with NAME, HOW MANY, every column, LOCATION, DONE and REMOVE; one card is open at a time. A line with nothing filled in at all shows a dashed FILL IN, which opens the card at its first box, ready to type; a column left blank beside others means it doesn't apply, so it says nothing. A pick-one box such as GRADE is now as wide as its words, not the whole card. Anything worn, attuned or installed now sits in EQUIPPED, whatever band its type is in, and goes back when taken off. SHEET.EXE and the sheet's own tab are the same. +- **One line a thing on GEAR.** Each thing on the sheet's GEAR tab is now a single line: its name, how many, its values with ROLL, FIRE and RELOAD beside them, and where it is carried, still changed with one click. The ✎ at the end of each line opens its card (a click on the line does too), with NAME, HOW MANY, every column, LOCATION, DONE and REMOVE; one card is open at a time. A line with nothing filled in at all shows a dashed FILL IN, which opens the card at its first box, ready to type; a column left blank beside others means it doesn't apply, so it says nothing. A pick-one box such as GRADE is now as wide as its words, not the whole card. Anything worn, attuned or installed now sits in EQUIPPED, whatever band its type is in, and goes back when taken off. When something lands in a closed band (worn, bought or given), its header pulses briefly and stays lit until you open it; with reduced motion turned on, it is only lit. SHEET.EXE and the sheet's own tab are the same. - **Long shop shelves stay quick.** A shelf with hundreds of lines now shows 200 at a time, with more as you scroll down, or press SHOW MORE. A line says how many there are, and filtering and sorting still cover every line. Typing in the filter no longer waits for the list to redraw. On a 1000-line shelf, sorting went from about 0.4 s to 0.15 s, and opening it from 0.6 s to 0.26 s. Saving a big catalogue is about five times faster. - **The initiative tracker for a GM running several fights.** The tracker window now opens beside the INITIATIVE menu instead of on top of it, so ACTIVE COMBATS stays in view and the GM can jump from fight to fight with the tracker open. The menu's ACTIVE COMBATS, each COMBAT #n and the scene name on the tracker were drawn in the theme's border colour and could hardly be read in any theme; they now use its text colour. Jumping to a fight whose building has lost its battle map says NO_BATTLE_MAP_FOR_THAT_SCENE instead of doing nothing. Whose turn it is is also announced to screen readers. All found by new browser journeys: one fight with two players from START to END, two fights at once with the GM jumping between them, and one fight spread over two scenes. - **The tracker counts ROUNDs in Generic and custom systems.** Its counter read TURN 3, though it counts laps of the whole order, which are rounds; Cities Without Number and Cyberpunk RED already said ROUND. It now says ROUND 3, a custom system's own word for a round where it renamed one (the WORDS page's ROUND, apart from its TURN), and Shadowrun still counts PASSes. diff --git a/README.md b/README.md index adf89aaf..feb6534f 100644 --- a/README.md +++ b/README.md @@ -796,7 +796,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) -│ │ │ ├── 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 +│ │ │ ├── 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) │ │ │ ├── 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) @@ -1083,7 +1083,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 +│ │ │ ├── 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 │ │ │ ├── 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 @@ -1174,7 +1174,7 @@ CITY_NET/ │ │ │ ├── useFormulaReads.ts # Many formulas read by the server at once (formula box 3): one request a moment after typing stops, twenty to a request, empty ones never asked, an answer kept only for the text it was for, nothing read with an api without the call │ │ │ ├── usePreviewValues.ts # A draft's formulas worked out by the server for its sample character a moment after editing stops, and with each house rule an alternative follows on: FORMULAS and the graph view show the same values; the graph view asks with the house rules TRY ON THE MAP has on │ │ │ ├── usePlayerSheet.ts # Shared sheet state, debounced saves, house-rule flags, action emitters (roll/deathSave/stabilize/castSpell); used by CharacterSheetWindow and SheetPage; onGearRoll (8a3b); sheetProps (8s1a): every play prop both sheet surfaces hand the sheet, Phase 7's choices, levels, items, spending, improving and rests with what the server refused and whether recovery is open; the vitals strip's props (8s3b), with the sign-in each surface passes; onGearCount (8a4b), FIRE and RELOAD by countAction, a gear edit still waiting sent first so it never lands after the count; SHOW ENCUMBRANCE read with the house rules, CARRYING hidden where it is off (8a6b) -│ │ │ ├── useGearBands.ts # Which of the GEAR tab's bands are closed (G2), kept in this browser: STASH closed to start, a head toggling its band, a band opened when a line lands in it +│ │ │ ├── useGearBands.ts # Which of the GEAR tab's bands are closed (G2), kept in this browser: STASH closed to start, a head toggling its band, a band opened when a line lands in it; and which closed bands something has landed in since (G3), cleared when opened │ │ │ └── __tests__/ │ │ │ ├── useApi.test.ts # Fetch helper unit tests │ │ │ ├── useMapData.test.ts # The location list asks anonymously until the GM signs in, then with their token, and again without after sign-out @@ -1289,7 +1289,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) -│ │ │ ├── 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) +│ │ │ ├── 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) │ │ │ ├── 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) @@ -1343,7 +1343,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 -│ │ │ ├── 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) +│ │ │ ├── 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) │ │ │ ├── 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 @@ -1545,7 +1545,7 @@ CITY_NET/ │ ├── 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 │ ├── 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-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 +│ ├── 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 │ ├── 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) │ ├── sheet-vitals.spec.ts # The vitals strip (8s3b): DAMAGE in SHEET.EXE and HEAL on the ⧉ tab moving the token and both sheets; the HP bar opening HEALTH in place on the tab; a condition put on in SHEET.EXE shown on the tab and taken off there, and a long rest taken from the tab's REST ▾ (8s3c); two tracks: STUN picked, damage past its maximum spilling into PHYSICAL, said (8s3d1); the GM taking damage off a player from the box in their view of the sheet, the player's SHEET.EXE following (8s3d2) diff --git a/e2e/COVERAGE.md b/e2e/COVERAGE.md index 45e6d6a7..1b11a1e6 100644 --- a/e2e/COVERAGE.md +++ b/e2e/COVERAGE.md @@ -35,7 +35,7 @@ panel), so a control that looks fine but does nothing is caught for all of them. | Shop catalogues by item type | a section per item type (8a7a1), its columns checked, blanks kept | `shop_catalogue_types`, `catalogueTypes` | `catalogue-types`, `shop-typed-lines` (bought at the General Store and given, landing typed, 8a7a2) | **AT THE TABLE** | | The shops under load | 1000+ lines on a shelf, 200 items, a full cart, a long gear list (8n3); a long shelf drawn 200 rows at a time | `shop_stress`, `ShopWindow` | `shop-stress` | **AT THE TABLE** | | An item type's SOLD AT | the kinds of shop that sell its lines (8a7a2), the General Store where unsaid; set in the builder in 8a7b | `shop_typed_lines`, `typedShelves` | `shop-typed-lines` (unsaid: the General Store) | **AT THE TABLE** unsaid; a kind of shop picked waits for 8a7b's box | -| An item type's ON THE SHEET band | EQUIPPED, USABLE or PACK (G1), PACK where unsaid; the sheet's GEAR tab in those bands plus STASH, closed to start, a band's head closing it, remembered (G2); a thing worn, attuned or installed in EQUIPPED whatever its type (G3) | `system_builder_item_types`, `itemTypes`, `ItemsPage`, `gearBands`, `GearTypeTables` | `builder-item-types` (the WEAPON preset EQUIPPED), `sheet-gear-bands` (a Sword, a Draught and a Rope in EQUIPPED, USABLE and PACK; the Sword stashed into STASH; USABLE kept closed; a Cloak of GEAR worn into EQUIPPED, taken off back into PACK) | **AT THE TABLE** | +| An item type's ON THE SHEET band | EQUIPPED, USABLE or PACK (G1), PACK where unsaid; the sheet's GEAR tab in those bands plus STASH, closed to start, a band's head closing it, remembered (G2); a thing worn, attuned or installed in EQUIPPED whatever its type, a closed band something lands in lit until opened (G3) | `system_builder_item_types`, `itemTypes`, `ItemsPage`, `gearBands`, `GearTypeTables` | `builder-item-types` (the WEAPON preset EQUIPPED), `sheet-gear-bands` (a Sword, a Draught and a Rope in EQUIPPED, USABLE and PACK; the Sword stashed into STASH; USABLE kept closed; a Cloak of GEAR worn into a closed EQUIPPED, its head lit, taken off back into PACK) | **AT THE TABLE** | | An item's PRICE and IN SHOPS | priced and IN SHOPS, it sells itself at its type's shops (8a7a3a); off, never sold, not even from a file, but bought back at its price by a shop of its type (8a7a3c2); a type's PRICE column read as its price; set on ITEMS under TYPE, NOT SOLD in the list, a new item's price asked for (8a7a3b1); in the ITEMS import and downloads, price and in shops columns (8a7a3b2) | `shop_items_on_sale`, `itemPrice`, `ItemsPage`, `system_builder_items_import`, `itemsImport` | `shop-items-on-sale` (a type's PRICE column; a ring turned off; sold back from the window at 50%), `builder-item-price` (set by clicks), `builder-items-import` (imported priced and IN SHOPS) | **AT THE TABLE** | | A catalogue file held against the game's items | an exact copy of an item left out, an item kept out of the shops left out, one of an item's name overruling it, ALSO ON SALE FROM ITEMS (8a7a3c1) | `shop_items_on_sale`, `CatalogueWindow` | `catalogue-and-items` | **AT THE TABLE** | | ADD NEW LINES TO ITEMS | a catalogue's new lines made items in the draft (8a7a4a), off to start; on PUBLISH the lines now exactly an item leave the file (8a7a4b) | `catalogue_into_items`, `CatalogueWindow`, `catalogueItems`, `BuilderScreen` | `catalogue-and-items` (the Hand Cannon into the draft, then out of the file once published) | **AT THE TABLE** | diff --git a/e2e/README.md b/e2e/README.md index 1be4ff55..5bdeadfb 100644 --- a/e2e/README.md +++ b/e2e/README.md @@ -206,7 +206,7 @@ kept; the job itself stops at 30 (`timeout-minutes`), for a hang outside the tes | `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 | | `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 | -| `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 | +| `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 | | `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 | | `tests/sheet-vitals.spec.ts` | The vitals strip (8s3b): a player with a token takes 5 with DAMAGE in SHEET.EXE (the token and the bar at 15/20), opens the ⧉ tab and HEALs 3 there (18/20 on the token, the tab and SHEET.EXE), then clicks the tab's HP bar and HEALTH's own panel opens in place; and (8s3c) PRONE put on under the box in SHEET.EXE, shown on the tab as a chip and taken off there, then REST ▾ on the tab taking a LONG REST, asked first, the stat it refills set; the box's HIT POINTS ▾ wholly under the numbers with the slash centered over it, and the conditions list as wide as the box; and CWN in SHEET.EXE: MELEE AC and RANGED AC shown, no two of HEAL, DAMAGE, STIM, HIT POINTS, + CONDITION, the AC and REST overlapping, and every button's words inside it; the AC centered between + CONDITION and REST; and (8s3d1) a two-track system: STUN MAX set on the sheet, STUN picked above the box, 6 damage filling it with 2 spilling into PHYSICAL (18/20 on the token), STUN FULL · 2 SPILLED INTO PHYSICAL said; and (8s3d2) the GM opens a player's sheet (GLOBAL_CHAT, VIEW_PLAYER_INFO, OPEN_SHEET) and takes 5 with the box there: the token at 15, the GM's box and the player's own SHEET.EXE saying 15. Since 8a6c the chip is clicked open, as wide as the box, and taken off with TAKE OFF | diff --git a/e2e/tests/sheet-gear-bands.spec.ts b/e2e/tests/sheet-gear-bands.spec.ts index 97e6f6a6..b0436dee 100644 --- a/e2e/tests/sheet-gear-bands.spec.ts +++ b/e2e/tests/sheet-gear-bands.spec.ts @@ -85,9 +85,14 @@ test('GEAR in bands: EQUIPPED, USABLE, PACK by type, a sword stashed into the ST await add.getByRole('button', { name: 'Add a Gear by hand' }).click(); await mine.getByLabel('Item 4 name', { exact: true }).fill('Cloak'); await expect(band('PACK').getByRole('button', { name: 'Cloak, item 4', exact: true })).toBeVisible(); + // EQUIPPED closed, the Cloak worn: its head lights up with the count (G3), and opened shows it. + await head('EQUIPPED').click(); await mine.getByTestId('gear-item-cloak').getByRole('button', { name: 'WEAR Cloak', exact: true }).click(); - await expect(band('EQUIPPED').getByRole('button', { name: 'Cloak, item 4', exact: true })).toBeVisible({ timeout: 15_000 }); - await expect(head('EQUIPPED')).toHaveText('▾ EQUIPPED · 1'); + await expect(head('EQUIPPED')).toHaveText('▸ EQUIPPED · 1', { timeout: 15_000 }); + await expect(head('EQUIPPED')).toHaveClass('gear-band-news'); + await head('EQUIPPED').click(); + await expect(head('EQUIPPED')).not.toHaveClass('gear-band-news'); + await expect(band('EQUIPPED').getByRole('button', { name: 'Cloak, item 4', exact: true })).toBeVisible(); await mine.getByTestId('gear-item-cloak').getByRole('button', { name: /^WORN/ }).click(); await expect(band('PACK').getByRole('button', { name: 'Cloak, item 4', exact: true })).toBeVisible({ timeout: 15_000 }); await context.close(); diff --git a/frontend/src/App.css b/frontend/src/App.css index 00ca96e7..ef12836f 100644 --- a/frontend/src/App.css +++ b/frontend/src/App.css @@ -1355,6 +1355,22 @@ button.choice-off:disabled { 50% { color: #ff6666; text-shadow: 0 0 8px #ff6666; } } +/* A closed GEAR band something just landed in (G3): three pulses in a second and a half, never a lasting blink, then + lit (a tint of the theme's own color, set on the head) until opened. None where motion is turned down. */ +@keyframes gear-band-news { + 0%, 100% { opacity: 1; } + 50% { opacity: 0.3; } +} + +.gear-band-news { + text-shadow: 0 0 6px var(--green); + animation: gear-band-news 0.5s ease-in-out 3; +} + +@media (prefers-reduced-motion: reduce) { + .gear-band-news { animation: none; } +} + .login-panel h1 { letter-spacing: 10px; margin-bottom: 5px; diff --git a/frontend/src/components/GearTypeTables.tsx b/frontend/src/components/GearTypeTables.tsx index cb9a7036..1decbf55 100644 --- a/frontend/src/components/GearTypeTables.tsx +++ b/frontend/src/components/GearTypeTables.tsx @@ -16,7 +16,8 @@ import { FormulaIcon } from './FormulaIcon'; // the server, which asks which carried line to reload from when there are several. The lines in bands (G2; approved mockup // 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 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, +// made by hand from the row of + buttons at the top; a closed band something lands in pulses, then stays bright until +// opened; 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 // nothing filled in at all, on it or its item, says FILL IN, which opens the card at its first box: a column blank beside @@ -176,7 +177,7 @@ export function GearTypeTables({ items, itemsShown, readOnly, write, locked, on, }); }; const bands = gearBands(itemsShown, items, on); - const { shut, toggle, openBand } = useGearBands(); + const { shut, toggle, openBand, news } = useGearBands(Object.fromEntries(bands.map((b) => [b.band, b.count]))); const bandOfType = (type: TypeShown) => (type.on_sheet === 'equipped' || type.on_sheet === 'usable' ? type.on_sheet : 'pack'); /** One line a thing (G3), by its place; a click opens its card. `tagged`, in the STASH, says its type. */ const lineView = ({ index: i, line, columns: lc }: TableRow, type: TypeShown, tagged = false) => { @@ -317,10 +318,14 @@ export function GearTypeTables({ items, itemsShown, readOnly, write, locked, on, )} {bands.map((b) => { const closed = shut.has(b.band); + // Something landed in it while closed (G3): a short pulse, then bright until opened (opening clears it). + const fresh = news.has(b.band); return (
- {!closed && (b.count === 0 diff --git a/frontend/src/components/__tests__/GearTypeTables.test.tsx b/frontend/src/components/__tests__/GearTypeTables.test.tsx index 44eb4950..b4948295 100644 --- a/frontend/src/components/__tests__/GearTypeTables.test.tsx +++ b/frontend/src/components/__tests__/GearTypeTables.test.tsx @@ -1,6 +1,6 @@ import React, { useState } from 'react'; import { describe, it, expect, afterEach } from 'vitest'; -import { render, screen, fireEvent, within, cleanup, waitFor } from '@testing-library/react'; +import { render, screen, fireEvent, within, cleanup, waitFor, act } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import { InventorySection } from '../InventorySection'; import type { SheetSection } from '../../sheets/types'; @@ -35,6 +35,8 @@ const ITEMS: ItemsShown = { }; const line = (name: string, more = {}) => ({ name, qty: 1, enc: '', bundled: false, carry: 'stowed', location: '', ...more }); +/** What the server sends next, from outside the sheet (a WEAR, a gift): set on the sheet shown. */ +const outside: { set: (more: Record) => void } = { set: () => {} }; const show = (lines: object[], { readOnly = false, items = ITEMS as ItemsShown | undefined, onGearRoll = undefined as ((line: number, column: string) => void) | undefined, onReadGearDice = undefined as ((text: string) => Promise) | undefined, onGearCount = undefined as GearCount | undefined, worked = undefined as object | undefined } = {}) => { @@ -42,6 +44,7 @@ const show = (lines: object[], { readOnly = false, items = ITEMS as ItemsShown | const Harness = () => { // `worked`: what the server worked out of the items (_worked), which are worn. const [data, setData] = useState>({ inventory: JSON.stringify(lines), ...(worked ? { _worked: worked } : {}) }); + outside.set = (more) => setData((d) => ({ ...d, ...more })); return { writes.push(JSON.parse(v as string)); setData((d) => ({ ...d, [id]: v })); }} />; }; @@ -370,12 +373,38 @@ describe('in bands (G2)', () => { expect(within(band('PACK')).getByRole('button', { name: 'Cutlass, item 1' })).toBeTruthy(); }); + it('something landing in a closed band: its head bright with a pulse until opened; not on opening the sheet, not in an open band', async () => { + const items: ItemsShown = { ...BANDED, list: [{ id: 'cutlass', label: 'Cutlass', needs: 'worn', features: [], type: 'gear', values: {} }] }; + show([typed('Cutlass', 'gear'), typed('Rope', 'gear'), typed('Old Map', 'gear', { carry: 'stash' })], { items }); + // Opening the sheet: STASH closed with a line in it, nothing new. + expect(head('STASH').className).toBe(''); + await userEvent.click(head('EQUIPPED')); + // The Cutlass worn, by the server: EQUIPPED is closed, so it says so. + act(() => outside.set({ _worked: { items: [{ id: 'cutlass', needs: 'worn', worn: true }] } })); + expect(head('EQUIPPED').textContent).toBe('▸ EQUIPPED · 1'); + expect(head('EQUIPPED').className).toBe('gear-band-news'); + expect(head('EQUIPPED').title).toBe('Something new landed here: open to see'); + // Lit after the pulse, a tint of the theme's own color behind it. + expect(head('EQUIPPED').style.background).toContain('var(--green) 20%'); + expect(head('PACK').style.background).toBe('none'); + // PACK, open, lost one: nothing. + expect(head('PACK').className).toBe(''); + // Opened: seen; closed again, nothing new. + await userEvent.click(head('EQUIPPED')); + expect(head('EQUIPPED').className).toBe(''); + await userEvent.click(head('EQUIPPED')); + expect(head('EQUIPPED').className).toBe(''); + expect(head('EQUIPPED').title).toBe('Open'); + }); + it('a thing made by hand opens its band if closed', async () => { show([typed('Sword', 'weapons')], { items: BANDED }); await userEvent.click(head('EQUIPPED')); await userEvent.click(within(screen.getByRole('group', { name: 'Add by hand' })).getByRole('button', { name: 'Add a Weapon by hand' })); expect(head('EQUIPPED').getAttribute('aria-expanded')).toBe('true'); expect(within(band('EQUIPPED')).getByLabelText('Item 2 name')).toBeTruthy(); + // Opened by the player's own hand: nothing to catch the eye. + expect(head('EQUIPPED').className).toBe(''); }); }); diff --git a/frontend/src/hooks/useGearBands.ts b/frontend/src/hooks/useGearBands.ts index 2ceedf77..a8d4e3c8 100644 --- a/frontend/src/hooks/useGearBands.ts +++ b/frontend/src/hooks/useGearBands.ts @@ -1,8 +1,9 @@ import { useState } from 'react'; -import type { GearBand } from '../sheets/gearTypes'; +import { GEAR_BANDS, landedIn, type GearBand } from '../sheets/gearTypes'; // Which of the GEAR tab's bands are closed (G2; approved mockup sheet-gear-layout.html: "a band's head closes it, and the // sheet remembers. The STASH closed to start."). Kept in this browser, for this viewer: where it can't be, STASH closed. +// And which closed bands something has landed in since (G3): their heads pulse and stay bright until opened. const KEY = 'city.gearBandsShut'; const START: GearBand[] = ['stash']; @@ -14,15 +15,27 @@ const read = (): Set => { } catch { return new Set(START); } }; -export const useGearBands = () => { +/** `counts`: each band's count as drawn now, to see what landed where. */ +export const useGearBands = (counts: Partial> | null = null) => { const [shut, setShut] = useState>(read); + const [news, setNews] = useState>(() => new Set()); + const [before, setBefore] = useState(counts); + // Counts changed since the last drawing: a closed band that went up has news. Worked out while drawing, as React has + // state that follows what it is given, so the head is bright in the same frame the number goes up. + if (counts && GEAR_BANDS.some((b) => (counts[b.id] ?? 0) !== (before?.[b.id] ?? 0))) { + setBefore(counts); + const landed = landedIn(before, counts, shut); + if (landed.length) setNews(new Set([...news, ...landed])); + } const keep = (next: Set) => { setShut(next); + // Opened: seen. + setNews((n) => new Set([...n].filter((b) => next.has(b)))); try { localStorage.setItem(KEY, JSON.stringify([...next])); } catch { /* not kept: still closed or open for now */ } }; /** Its head clicked: closed if open, open if closed. */ const toggle = (band: GearBand) => { const next = new Set(shut); if (next.has(band)) next.delete(band); else next.add(band); keep(next); }; /** Opened, if closed: a line made by hand is shown where it lands. */ const openBand = (band: GearBand) => { if (shut.has(band)) { const next = new Set(shut); next.delete(band); keep(next); } }; - return { shut, toggle, openBand }; + return { shut, toggle, openBand, news }; }; diff --git a/frontend/src/sheets/__tests__/gearTypes.test.ts b/frontend/src/sheets/__tests__/gearTypes.test.ts index d388514a..4810c80e 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 } from '../gearTypes'; +import { typesOf, fits, itemOfLine, lineColumns, gearTables, valueText, withLineValue, newLineOf, countOf, cellWords, LIMITS, type ColumnShown , gearBands, landedIn } from '../gearTypes'; import { normaliseItem, readInventory, type InventoryItem } from '../inventory'; import type { ItemsShown } from '../gearItems'; @@ -215,3 +215,12 @@ describe('a line on you is EQUIPPED (G3)', () => { expect(gearBands(SHOWN, lines).map((b) => b.count)).toEqual([1, 1, 3, 2]); }); }); + +describe('what landed in a closed band (G3)', () => { + it('a closed band whose count went up; not an open one, not one that fell or held; nothing before the first drawing', () => { + const shut = new Set(['equipped', 'usable', 'stash'] as const); + expect(landedIn({ equipped: 0, usable: 1, pack: 2, stash: 0 }, { equipped: 1, usable: 1, pack: 3, stash: 1 }, shut as never)).toEqual(['equipped', 'stash']); + expect(landedIn({ equipped: 2, usable: 1, pack: 0, stash: 0 }, { equipped: 1, usable: 0, pack: 0, stash: 0 }, shut as never)).toEqual([]); + expect(landedIn(null, { equipped: 1, usable: 1, pack: 1, stash: 1 }, shut as never)).toEqual([]); + }); +}); diff --git a/frontend/src/sheets/gearTypes.ts b/frontend/src/sheets/gearTypes.ts index cf486700..1f442833 100644 --- a/frontend/src/sheets/gearTypes.ts +++ b/frontend/src/sheets/gearTypes.ts @@ -120,6 +120,14 @@ export const gearBands = (shown: ItemsShown | null | undefined, lines: Inventory return bands; }; +/** + * The closed bands something landed in between two drawings (G3; the user, 2026-11-22: the header's number tells people + * there are things in it; a closed one a thing was just put into, worn or bought, should catch the eye): a closed band whose + * count went up. Nothing before the first drawing, so opening the sheet says nothing new. + */ +export const landedIn = (before: Partial> | null, after: Partial>, shut: Set): GearBand[] => + before ? GEAR_BANDS.map((b) => b.id).filter((id) => shut.has(id) && (after[id] ?? 0) > (before[id] ?? 0)) : []; + /** A value as a box shows it. */ export const valueText = (v: Value | undefined): string => (v === undefined ? '' : String(v));