From 4c24cd4fbaa7cbaf1204cd07c47f83623295cbb1 Mon Sep 17 00:00:00 2001 From: Developer Date: Sun, 22 Nov 2026 13:03:38 -0600 Subject: [PATCH 1/3] feat: PLAYERS CHANGE GEAR on the GAME tab, and switched off a player's GEAR card shows the columns without changing them, said once; no eX, THE ITEM'S or FILL IN; the GM always may --- CHANGELOG.md | 1 + README.md | 16 ++--- e2e/COVERAGE.md | 1 + e2e/README.md | 1 + e2e/tests/sheet-players-change-gear.spec.ts | 63 +++++++++++++++++++ frontend/src/components/GearTypeTables.tsx | 37 +++++++---- frontend/src/components/InventorySection.tsx | 6 +- frontend/src/components/SheetRenderer.tsx | 6 +- .../__tests__/GearTypeTables.test.tsx | 41 +++++++++++- .../SheetRenderer.playersGear.test.tsx | 47 ++++++++++++++ .../__tests__/tableSwitchesGameTab.test.tsx | 17 +++++ frontend/src/hooks/usePlayerSheet.ts | 6 +- .../sheets/__tests__/tableSwitches.test.ts | 19 +++++- frontend/src/sheets/tableSwitches.ts | 13 +++- 14 files changed, 244 insertions(+), 30 deletions(-) create mode 100644 e2e/tests/sheet-players-change-gear.spec.ts create mode 100644 frontend/src/components/__tests__/SheetRenderer.playersGear.test.tsx diff --git a/CHANGELOG.md b/CHANGELOG.md index 0214459d..b0ee3037 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -106,6 +106,7 @@ Format follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### Added +- **PLAYERS CHANGE GEAR.** A new switch on the GAME tab's house rules, on to start, for systems with their own item types. Switched off, only the GM changes the columns of a player's gear (a weapon's DAMAGE, a potion's HEALS): the player's card shows them but can't change them, and says "ONLY THE GM CHANGES THESE AT THIS TABLE". Players still name, count, move, add and remove their things, and the GM can always change anything. - **UNIQUE on GEAR.** A thing changed from the item it is named after (the Cutlass made 2d8) now says UNIQUE on its line; hover it for the item's own value and who changed it, and when (a player by name, or the GM). In its card, each column made its own says UNIQUE with the item's value beside it and a THE ITEM'S button to put it back. Type unique in FIND to list them. SHEET.EXE and the sheet's own tab are the same. - **FIND on GEAR.** A find box at the top of the sheet's GEAR tab, always there, keeps only the things that match as you type: a name, a type (GUNS), a value (2d6, 30 m) or a column (AMMO), in any case, every word somewhere on the line. Each band counts its matches and opens while you search, so nothing in a closed STASH is missed; clear it with its × or Esc and the bands are as you left them. When nothing matches, it says so. SHEET.EXE and the sheet's own tab are the same. - **GEAR in bands.** The sheet's GEAR tab now sorts what you carry into EQUIPPED, USABLE and PACK, by each item type's ON THE SHEET, with a count on each band and what's in hand first. A fourth band, STASH, holds everything left in the stash whatever its type, and says each one's type; it starts closed. Click a band's head to close or open it, and the sheet remembers. The + buttons for adding a thing by hand sit in one row at the top, and the band it lands in opens. SHEET.EXE and the sheet's own tab are the same. diff --git a/README.md b/README.md index a82e2123..cc7b6797 100644 --- a/README.md +++ b/README.md @@ -797,8 +797,8 @@ 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); tells GEAR's bands which lines are worn, attuned or installed, from what the server worked out (G3); only the slot and install counters something on the sheet uses, 8px apart from FIND on a typed GEAR tab -│ │ │ ├── GearTypeTables.tsx # The GEAR tab as a table per item type (8a3a; approved mockup item-types, 2026-11-14): each type's lines under its own column heads, units said; a line's own value over its item's, shown faint until typed over; + a type's one to add a line of it by hand; name, quantity, where and location as the one list has them; ROLL beside each DAMAGE and DICE (8a3b), read only or not, where the viewer may roll; since 8a3c1 a compact line per thing (name, QTY, WHERE, ✎, ×; only the columns it has as words under it, its item's faint, ROLL beside DAMAGE and DICE, a stashed one's place), ✎ opening every column as a box, one line at a time, a line made by hand opened; under ✎ a DAMAGE or DICE with eˣ (8a3c2): what it reads on this character, a name the system hasn't got flagged, SHAPE and INSERT; a COUNT as "AMMO 4 / 6" with its button (FIRE) and RELOAD beside it (8a4b), held while the server answers, RELOAD FROM asking which carried line where there are several, a refusal said on the line; in bands (G2): EQUIPPED, USABLE and PACK by each type's ON THE SHEET, a group per type with lines, in hand first, and STASH, closed to start, each line's type said; a band's head closes it, remembered; a row of + at the top adds a thing of any type by hand, opening its band; one line a thing (G3): its name, how many, its columns as words with ROLL, FIRE and RELOAD, where it is carried, ✎ at its end (or a click on the line) opening its card (NAME, HOW MANY, every column, LOCATION, DONE, REMOVE), FILL IN where nothing at all is filled in opening the card at its first box, a PICK ONE box as wide as its words; a closed band something lands in (worn, bought, given) pulses three times and stays lit in the theme's own color until opened (G3); FIND at the top, always shown (G4): only the lines it matches, each band counted by its matches and open while it has words, heads readable but not toggling, its own × and Esc to clear, "Nothing on this sheet matches" when nothing does; UNIQUE (G5b): on a line changed from its item, the item's and who changed it when on hover; in the card, beside each column made its own, UNIQUE, THE ITEM'S to put it back and what the item had; "unique" in FIND lists them, with no count at the top +│ │ │ ├── InventorySection.tsx # The inventory table, on every system. Its own file because SheetRenderer is long enough, and generic: which rows carry an extra button, and what pressing it does, is supplied from outside - so a drug offers CONSUME and a skillplug offers LOAD without either knowing about the other A custom system's items (7e3b): the slot counters over it, and WEAR and ATTUNE under a line of an item's name (GearItemLine); an installed item's line locked, named and in place, until REMOVE (7e4c); a custom system with item types gets a table per type instead (8a3a, GearTypeTables.tsx); tells GEAR's bands which lines are worn, attuned or installed, from what the server worked out (G3); only the slot and install counters something on the sheet uses, 8px apart from FIND on a typed GEAR tab; columnsLocked on to GEAR (G6b) +│ │ │ ├── GearTypeTables.tsx # The GEAR tab as a table per item type (8a3a; approved mockup item-types, 2026-11-14): each type's lines under its own column heads, units said; a line's own value over its item's, shown faint until typed over; + a type's one to add a line of it by hand; name, quantity, where and location as the one list has them; ROLL beside each DAMAGE and DICE (8a3b), read only or not, where the viewer may roll; since 8a3c1 a compact line per thing (name, QTY, WHERE, ✎, ×; only the columns it has as words under it, its item's faint, ROLL beside DAMAGE and DICE, a stashed one's place), ✎ opening every column as a box, one line at a time, a line made by hand opened; under ✎ a DAMAGE or DICE with eˣ (8a3c2): what it reads on this character, a name the system hasn't got flagged, SHAPE and INSERT; a COUNT as "AMMO 4 / 6" with its button (FIRE) and RELOAD beside it (8a4b), held while the server answers, RELOAD FROM asking which carried line where there are several, a refusal said on the line; in bands (G2): EQUIPPED, USABLE and PACK by each type's ON THE SHEET, a group per type with lines, in hand first, and STASH, closed to start, each line's type said; a band's head closes it, remembered; a row of + at the top adds a thing of any type by hand, opening its band; one line a thing (G3): its name, how many, its columns as words with ROLL, FIRE and RELOAD, where it is carried, ✎ at its end (or a click on the line) opening its card (NAME, HOW MANY, every column, LOCATION, DONE, REMOVE), FILL IN where nothing at all is filled in opening the card at its first box, a PICK ONE box as wide as its words; a closed band something lands in (worn, bought, given) pulses three times and stays lit in the theme's own color until opened (G3); FIND at the top, always shown (G4): only the lines it matches, each band counted by its matches and open while it has words, heads readable but not toggling, its own × and Esc to clear, "Nothing on this sheet matches" when nothing does; UNIQUE (G5b): on a line changed from its item, the item's and who changed it when on hover; in the card, beside each column made its own, UNIQUE, THE ITEM'S to put it back and what the item had; "unique" in FIND lists them, with no count at the top; PLAYERS CHANGE GEAR off for a player (G6b): the card's columns shown not changed, said once, no eˣ, THE ITEM'S or FILL IN │ │ │ ├── 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) @@ -976,7 +976,7 @@ CITY_NET/ │ │ │ ├── partsShops.test.tsx # Shops under custom systems in the browser: shopsAvailable, every purchase an inventory line, the no_shops refusal and the buy-back rate in the system's word for shops │ │ │ ├── giveItemButtons.test.tsx # GIVE_ITEM in the GAME tab (city and battle map) wherever GIVE ITEM is on, opening GIVE.EXE; SHOP_CATALOGUES for a game with shops or GIVE ITEM, the buy-back rate with shops only │ │ │ ├── partsInitiative.test.tsx # Initiative turned off, in the windows: no tracker window, sidebar button or panel, or INITIATIVE FOLLOWS BUILDING; all as today where the game has initiative -│ │ │ ├── tableSwitchesGameTab.test.tsx # SHOW ENCUMBRANCE, BAND CONDITIONS and APPLY CONDITION MODIFIERS in the GAME tab's HOUSE RULES (8a6b): all three where the system has them, on to start, with what each means; only those it has; as the table has them; switched off and APPLY written to the settings as the GM; CONDITION TURN EFFECTS on to start, switched off and written, offered only where a condition has an EACH TURN (8a9c) +│ │ │ ├── tableSwitchesGameTab.test.tsx # SHOW ENCUMBRANCE, BAND CONDITIONS and APPLY CONDITION MODIFIERS in the GAME tab's HOUSE RULES (8a6b): all three where the system has them, on to start, with what each means; only those it has; as the table has them; switched off and APPLY written to the settings as the GM; CONDITION TURN EFFECTS on to start, switched off and written, offered only where a condition has an EACH TURN (8a9c); PLAYERS CHANGE GEAR on the GAME tab where a system makes its own types, switched off and written (G6b) │ │ │ ├── houseRulesGameTab.test.tsx # A custom game's own house rules in the GAME tab: beside the shared ones with what each means, APPLY sending only those changed as the GM, REVERT, following the game when it changes, a refusal said, none for a built-in game │ │ │ ├── partsCombat.test.tsx # Combat turned off, in the windows: no attack buttons, no defense in the GM's HEALTH or the owner's QUICK ACTIONS (the manual initiative entry stays); all as today where the game has combat │ │ │ ├── partsHealth.test.tsx # Token health turned off, in the windows: no map or stream health, no HIT_POINTS, no MAX HEALTH (no SAVE_STATS with combat off too), no health panel, and a HEALTH folder only for what the GM keeps there; all as today where the game has it @@ -1085,7 +1085,7 @@ CITY_NET/ │ │ │ ├── SheetCyberware.test.tsx # The sheet showing what the chrome does, so a correct effects layer is actually read │ │ │ ├── InventorySection.test.tsx # The inventory table editing one field cleanly, though every keystroke rewrites the whole list │ │ │ ├── GearItemLine.test.tsx # WEAR and ATTUNE on GEAR (7e3b): the counter, an item's line under its own row, what pressing asks, a full slot disabled and why, the GM's ATTUNE ANYWAY and own count, read-only, uses ticking, a refusal said, a system without items unchanged; installs (7e4c): the counter, an installed line locked, REMOVE and INSTALL asked, a player's disabled past the limit, the GM's anyway, amber when full -│ │ │ ├── GearTypeTables.test.tsx # The GEAR tab as a table per type (8a3a): each type's lines and heads, an empty type its heading and + only, an item's values faint until typed over, + a type's one by hand staying in its table, read only, a system without types keeping the one list; ROLL beside DAMAGE sending its line and column, nothing to roll nothing to press, read only still there (8a3b); compact lines (8a3c1): only the columns a line has, ✎ one at a time with "none" where it has none, a hand-made line opened, read only without ✎; a DAMAGE under ✎ read on this character, a bad name flagged, never an older text's words, eˣ SHAPE and INSERT (8a3c2); a COUNT's "4 / 6" with FIRE and RELOAD, held while waiting, none left or full, USE by default, RELOAD FROM asked and CANCEL, a refusal on its line (8a4b); in bands (G2): the four in order and counted, in hand first, STASH closed, a head closing and opening its band remembered, the STASH saying each type, an empty band saying so, a thing made by hand opening its band; one line a thing (G3): a click on the line opening its card but not on ROLL or where it is carried, one card at a time, ✎ opening and closing it (none read only), FILL IN only where nothing is filled in, naming the columns and opening at the first (a DAMAGE too), none where something is or a type has no columns, UNNAMED, a PICK ONE box as wide as its words; a worn Cutlass of a PACK type in EQUIPPED, back in PACK taken off; a closed band lit when the server puts something in it, not on opening the sheet, not an open band, cleared when opened, not when the player opens it by hand; FIND (G4): as you type, counted, every band open, heads not toggling, × and Esc clearing, as left once cleared and nothing lit, a value and a column, nothing found, read only too; the slot and install counters only where something uses them; UNIQUE (G5b): the line's tag and hover, none as the item has it; in the card, what the item had and who changed it, THE ITEM'S putting it back; "unique" in FIND listing them, no count +│ │ │ ├── GearTypeTables.test.tsx # The GEAR tab as a table per type (8a3a): each type's lines and heads, an empty type its heading and + only, an item's values faint until typed over, + a type's one by hand staying in its table, read only, a system without types keeping the one list; ROLL beside DAMAGE sending its line and column, nothing to roll nothing to press, read only still there (8a3b); compact lines (8a3c1): only the columns a line has, ✎ one at a time with "none" where it has none, a hand-made line opened, read only without ✎; a DAMAGE under ✎ read on this character, a bad name flagged, never an older text's words, eˣ SHAPE and INSERT (8a3c2); a COUNT's "4 / 6" with FIRE and RELOAD, held while waiting, none left or full, USE by default, RELOAD FROM asked and CANCEL, a refusal on its line (8a4b); in bands (G2): the four in order and counted, in hand first, STASH closed, a head closing and opening its band remembered, the STASH saying each type, an empty band saying so, a thing made by hand opening its band; one line a thing (G3): a click on the line opening its card but not on ROLL or where it is carried, one card at a time, ✎ opening and closing it (none read only), FILL IN only where nothing is filled in, naming the columns and opening at the first (a DAMAGE too), none where something is or a type has no columns, UNNAMED, a PICK ONE box as wide as its words; a worn Cutlass of a PACK type in EQUIPPED, back in PACK taken off; a closed band lit when the server puts something in it, not on opening the sheet, not an open band, cleared when opened, not when the player opens it by hand; FIND (G4): as you type, counted, every band open, heads not toggling, × and Esc clearing, as left once cleared and nothing lit, a value and a column, nothing found, read only too; the slot and install counters only where something uses them; UNIQUE (G5b): the line's tag and hover, none as the item has it; in the card, what the item had and who changed it, THE ITEM'S putting it back; "unique" in FIND listing them, no count; PLAYERS CHANGE GEAR off (G6b): columns read only and said, no eˣ, THE ITEM'S or FILL IN, name, how many and REMOVE still the player's │ │ │ ├── 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 @@ -1094,6 +1094,7 @@ CITY_NET/ │ │ │ ├── SheetRenderer.encumbrance.test.tsx # The encumbrance line on GEAR and each weapon's CARRY and ENC │ │ │ ├── SheetRenderer.fullwidth.test.tsx # A fullWidth field spanning its section in every layout, so a weapon's mods aren't squeezed into one column │ │ │ ├── SheetRenderer.header.test.tsx # The HP and EXP bars stacking, by fixed widths either side +│ │ │ ├── SheetRenderer.playersGear.test.tsx # PLAYERS CHANGE GEAR from the table to the card (G6b): off, a player's DAMAGE read only and said, the name still theirs; the GM's never locked; on or unsaid as ever │ │ │ ├── SheetRenderer.languages.test.tsx # Adding a language from the list, or typing one the list could never hold │ │ │ ├── SheetRenderer.numbers.test.tsx # Typing a negative number, which a lone minus sign used to wipe to 0 on every sheet │ │ │ ├── SheetRenderer.retired.test.tsx # A retired field shown only while it still holds text, so old notes aren't lost @@ -1175,7 +1176,7 @@ CITY_NET/ │ │ │ ├── useBuilderPlace.ts # Where a GM was on a builder page (8aL1): a tab, what was open, kept by system while the app is open; a reload starts fresh; forgotten between tests │ │ │ ├── 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) +│ │ │ ├── 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); playersChangeGear from the table's settings (G6b) │ │ │ ├── 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 @@ -1258,7 +1259,7 @@ CITY_NET/ │ │ │ ├── rests.ts # RESTS as logic: the standard four and a system's own read from a definition and written back storing only what differs, the count against 12, new and deleted ones (nothing left counting as or ending at a deleted one), what each counts as and loops, what a rest can refill under the health model and the sheet it plays with, refills added, fitted to what they name, changed and removed, and the conditions it wears off set from either side; mirrors the server's rests.js; a deleted rest is taken out of the recovery dice too (R1b); a COUNT a deleted rest refilled refills nothing (8a2) │ │ │ ├── recovery.ts # Recovery dice and how rests are finished as logic (R1b; approved mockup rest-on-sheet): the system's resting read with the server's defaults and written back storing only what differs, the dice turned on as a starting point (a short rest, all back at a long rest, whichever is on), changed and taken away, the rests they are spent at and what each gives back, a deleted rest cleared out, and the options with a die; reads the lists itself, so no import loop with choices.ts and rests.ts. Mirrors the server's recovery.js; SPENDING any time or when the GM opens it (R2a); WHAT PLAYERS GET in the system's own words (R3a); what one rest does with the dice, in words (R3b) │ │ │ ├── turnAsks.ts # A condition's EACH TURN at the tracker as logic (8a9c; approved mockup condition-turn-effects): an NPC's asks for its row, this scene's; WAITING ON KES'S POISONED SAVE; whether BEGIN is offered (where the game acts on turns, not begun, not while everyone rolls again); on the sheet (8a9c2), this token's asks, YOUR SAVE or KES'S SAVE, ROLL SAVE or ROLL -│ │ │ ├── tableSwitches.ts # The GAME tab's encumbrance and condition switches (8a6b; approved mockup carrying-on-sheet): SHOW ENCUMBRANCE, BAND CONDITIONS and APPLY CONDITION MODIFIERS, all on to start, each offered only where the system has what it switches (the render copy's `switches`), with what each does and what off means; whether CARRYING shows at this table; CONDITION TURN EFFECTS where a condition has an EACH TURN (8a9c) +│ │ │ ├── tableSwitches.ts # The GAME tab's encumbrance and condition switches (8a6b; approved mockup carrying-on-sheet): SHOW ENCUMBRANCE, BAND CONDITIONS and APPLY CONDITION MODIFIERS, all on to start, each offered only where the system has what it switches (the render copy's `switches`), with what each does and what off means; whether CARRYING shows at this table; CONDITION TURN EFFECTS where a condition has an EACH TURN (8a9c); PLAYERS CHANGE GEAR (G6b) where a system makes its own item types, and gearByPlayers │ │ │ ├── tokenConditions.ts # A token's conditions in the windows as logic: the column read as the server reads it, what to draw from the game's list (one it no longer has left out), rounds left and modifiers where sent, putting one on or taking one off without resetting another's rounds, and the map's four icons then +N; chipsThatFit, how many of the sheet's chips fit two lines with "+N" in the last place (8a6c) │ │ │ ├── tableConditions.ts # The GAME tab's CONDITIONS as logic: the table's own from the game's list, sent back whole, one added under an id no standard or other one has (name and description trimmed, a blank description not sent), one removed, the limit of 60 counting the standard set │ │ │ ├── tempHp.ts # A token's temporary HP on its sheet: the key the server reads it under beside the linked values, and a linked HP field's current with it added (the HEALTH box draws it in the warning color) @@ -1366,7 +1367,7 @@ CITY_NET/ │ │ │ ├── itemsImport.test.ts # Held to the server's items reader (8aL3b): the example made from the system read back without a mistake, a system with GEAR alone, an install and no slot, the list back unchanged, names that clash going by id; price and in shops written and read back unchanged (8a7a3b2) │ │ │ ├── formulaBox.test.ts # Amounts, uses and requirements in words, by label or as written; the sample line; INSERT's groups and levels; each shape, what it writes and why it can't be used yet; INSERT's GEAR where the gear is read, never in an amount or a refill (8a5c); TIMES, SET TO and AT MOST read and said (8a5e2) │ │ │ ├── turnAsks.test.ts # An NPC's asks for its row (not a player's, another token's or another fight's); WAITING ON each by whose and what, this scene's; BEGIN only where the game acts on turns and not begun, nor while everyone rolls again; a token's asks, YOUR or KES'S SAVE, ROLL SAVE or ROLL (8a9c2) -│ │ │ ├── tableSwitches.test.ts # The GAME tab's switches as logic (8a6b): each only where the system has what it switches, in order, on to start, each saying what off means, none for a built-in game; the keys the server reads; CARRYING shown unless switched off; CONDITION TURN EFFECTS last, where a condition has an EACH TURN (8a9c) +│ │ │ ├── tableSwitches.test.ts # The GAME tab's switches as logic (8a6b): each only where the system has what it switches, in order, on to start, each saying what off means, none for a built-in game; the keys the server reads; CARRYING shown unless switched off; CONDITION TURN EFFECTS last, where a condition has an EACH TURN (8a9c); PLAYERS CHANGE GEAR offered with item types, last, its key pinned; gearByPlayers on unless switched off (G6b) │ │ │ ├── carrying.test.ts # CARRYING as logic (8a6a): read safely, anything odd as nothing; the meter's fill, ticks and color, bands in any order, never under 0 or past 100, none without CAN CARRY; the bands in words; the condition on, off, by name or id, and no token │ │ │ ├── choicesShown.test.ts # Held to the server's own choicesShown and workedOf: the worked-out view read (empty for none or junk); each pick's level, unlocked features and the next; levels added up and said how; what's left, one not met saying what it needs; room; an option gone left out; pips spending and taking back; what a feature does in words; the badge's numbers for a stat and a formula, each bonus named, nothing for a field not shown (7a3b2); the recovery dice read as the server writes them, those not well formed left out, who may spend held to the server's maySpend, and the words (R2b); a condition's change in words, each on its field, whose bonuses the sheet shows (8a5e3) │ │ │ ├── builderHelp.test.tsx # The help held to the builder: the tour down the rail, a topic for every page, every health model and built-in example, every formula function the engine knows with its arguments and an example it reads; the "?" shown on hover and focus, gone after, placed where it fits; each setting's words a sentence filed by its page; a setting's name tied to its field, the "?" outside it; the tour nine steps since CHOICES, each named as the rail names its page, STATS & RULES pointing to HOUSE RULES; a column header named by its word, the "?" inside it @@ -1547,6 +1548,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; no ATTUNED bar until a line needing the slot is on the sheet │ ├── sheet-item-types.spec.ts # The GEAR tab as a table per type (8a3a): a stick made by hand with its own DAMAGE and GRADE, a line named like the Pistol showing its values faint, RANGE typed over, a rope in GEAR, saved as made, each in its table after a reload; compact lines with ✎ and DONE, and nothing on the GEAR tab scrolling sideways in SHEET.EXE (8a3c1); the Pistol's DAMAGE read on this character under ✎, a bad name flagged, eˣ INSERT (8a3c2); in bands (G2), PACK saying "Nothing here." and things added from the row of + at the top; the Pistol's card opened by a click on its name (G3); the Pistol UNIQUE after the reload, its hover naming the player, "unique" in FIND finding it; THE ITEM'S on DAMAGE and RANGE, saved a plain Pistol (G5b) +│ ├── sheet-players-change-gear.spec.ts # PLAYERS CHANGE GEAR (G6): off, the player's Cutlass DAMAGE read only and said; the GM makes it 2d8, the player sees UNIQUE changed by the GM; on again, the player makes it 3d8 │ ├── sheet-gear-bands.spec.ts # The GEAR tab in bands (G2): a Sword, a Draught and a Rope added by hand land in EQUIPPED, USABLE and PACK, counted; the Sword stashed moves to STASH, which opens and says WEAPONS; USABLE closed by its head stays closed on the next visit; the Draught's blank HEALS filled from FILL IN, its card opened at that box (G3); a Cloak of GEAR worn into EQUIPPED and taken off back into PACK, EQUIPPED closed first and lit when the Cloak is worn; FIND 2d4 showing the Draught in a closed USABLE, nothing for lantern, cleared and USABLE closed again (G4) │ ├── sheet-gear-counts.spec.ts # A gear line's COUNT at the table (8a4): the Pistol's AMMO 2 / 6, FIRE spending one, RELOAD asking between Pistol Rounds and AP Rounds and using the AP Rounds up, then full from the Pistol Rounds; the Wand's CHARGES filled by a short rest from the sheet │ ├── sheet-standalone-tab.spec.ts # The sheet in a new tab (8s1a): opened with ⧉, in the theme, WEAR there works and SHEET.EXE says so, a weapon's DAMAGE rolled from it; the roll from the tab opening the main app's dice tray (8s1b); a character being made: CREATING · CONTINUE on the tab opening NEW_CHARACTER.EXE there (8s1c); Cash on the tab opening BANK.EXE in the main window, and with that window closed the tab saying to open it (8s1d); gear added from the row of + at the top of GEAR (G2) diff --git a/e2e/COVERAGE.md b/e2e/COVERAGE.md index eeaaf263..780e362b 100644 --- a/e2e/COVERAGE.md +++ b/e2e/COVERAGE.md @@ -36,6 +36,7 @@ panel), so a control that looks fine but does nothing is caught for all of them. | 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, 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** | +| PLAYERS CHANGE GEAR | the GAME tab's switch, on to start, offered where a system makes its own item types (G6a, G6b): off, a player's gear columns are the GM's | `players_change_gear` setting, `switches.gear`, `uniqueLines.keepColumns`, `GearTypeTables` | `sheet-players-change-gear` (off: DAMAGE read only and said; the GM changes it, UNIQUE by the GM; on: the player changes it) | **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 00dc86ae..93562611 100644 --- a/e2e/README.md +++ b/e2e/README.md @@ -206,6 +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; and (2026-11-22) no ATTUNED bar on GEAR until the Ring's line is there | | `tests/sheet-item-types.spec.ts` | The GEAR tab as a table per item type (8a3a): a player's sheet with WEAPONS and GEAR tables, each empty with its +; + WEAPON made A stick with DAMAGE 1d4 and GRADE HEAVY; a second line named Pistol showing 2d6 + @might faint, its RANGE typed over to 50 m; + GEAR made Rope at 10 lb; saved as made, each in its table after a reload; since 8a3b the stick's DAMAGE rolled with ROLL, "rolled A stick DAMAGE 1d4" in the dice tray's history; and (8a3c1) as compact lines: a line made by hand opened under ✎, DONE showing its words with ROLL, the Pistol's RANGE read as words after the reload, and no box on the GEAR tab scrolling sideways in SHEET.EXE; and (8a3c2) the Pistol's DAMAGE under ✎ said ON THIS CHARACTER: 2d6 + Might (12): 14 to 24, @strength flagged as not the system's, eˣ INSERT putting in @might; and (G2) in bands: PACK says "Nothing here." with no WEAPONS group before anything is carried, and things are added from the row of + at the top; and (G3) the Pistol's card opened by a click on its name; and (G5a) the Pistol, its RANGE its own, saved with who changed it and when; and (G5b) after the reload the Pistol says UNIQUE, its hover "RANGE 50 m, the item's: 30 m · changed by" the player, "unique" in FIND showing it and not the stick; THE ITEM'S on its DAMAGE and RANGE leaves a plain Pistol, saved so | +| `tests/sheet-players-change-gear.spec.ts` | PLAYERS CHANGE GEAR (G6a, G6b): a player names a Cutlass made by hand; the GAME tab's switch off at the table, its card shows DAMAGE read only and "ONLY THE GM CHANGES THESE AT THIS TABLE", the name still theirs; the GM makes it 2d8 on their sheet, and the line says UNIQUE, "changed by the GM"; on again, the player makes it 3d8, saved; the switch put back on whatever happens | | `tests/sheet-gear-bands.spec.ts` | The GEAR tab in bands (G2): a game with WEAPONS EQUIPPED, POTIONS USABLE and GEAR unsaid; a player adds a Sword, a Draught and a Rope from the row of + at the top, each in its band and counted (EQUIPPED · 1, USABLE · 1, PACK · 1, STASH · 0 closed), saved as made; the Sword moved to the stash goes to STASH, which opens and says WEAPONS, EQUIPPED left at 0; USABLE closed by its head, and on the next visit USABLE is still closed and PACK open; and (G3) one line a thing: the Draught's HEALS blank, so FILL IN, which opens its card at that box, ready to type; 2d4 typed, DONE, the line says HEALS 2d4 and FILL IN is gone, saved; a Cloak, GEAR, made by hand sits in PACK, WEAR puts it in EQUIPPED (EQUIPPED · 1), taken off it is back in PACK; with EQUIPPED closed, WEAR lights its head (▸ EQUIPPED · 1), opened it is plain again; and (G4) FIND: 2d4 shows the Draught in USABLE, closed, opened while it shows (PACK · 0), lantern says nothing matches, cleared USABLE is closed again | | `tests/sheet-gear-counts.spec.ts` | A gear line's COUNT at the table (8a4): a player's Pistol at AMMO 2 / 6 spends one with FIRE; RELOAD, with Pistol Rounds and AP Rounds both carried, asks which and takes all 3 AP Rounds, their line gone; RELOAD again takes 2 of the Pistol Rounds alone, full, RELOAD held; the Wand's CHARGES, with no RELOAD, filled by a SHORT REST from the sheet | | `tests/sheet-standalone-tab.spec.ts` | The sheet in a new tab is the window (8s1a): a player makes two gear lines in SHEET.EXE, opens the tab with ⧉ (a `.crt-container`, so in the theme), WEARs the boots there and SHEET.EXE says WORKING too, and rolls the club's DAMAGE from the tab, said on it once the dice land; since 8s1b the roll from the tab opens DICE_TRAY.EXE in the main app's window; and (8s1c) a character being made: the flow left, SHEET.EXE says CREATING · CONTINUE, the tab says it too and opens NEW_CHARACTER.EXE on itself; and (8s1d) Cash on the tab opens BANK.EXE in the main window and the tab says so, then with the main window closed the tab says to open it; and (G2) gear added from the row of + at the top of GEAR | diff --git a/e2e/tests/sheet-players-change-gear.spec.ts b/e2e/tests/sheet-players-change-gear.spec.ts new file mode 100644 index 00000000..f102b3e3 --- /dev/null +++ b/e2e/tests/sheet-players-change-gear.spec.ts @@ -0,0 +1,63 @@ +import { test, expect } from '@playwright/test'; +import { signInAsPlayer, gmToken, asGm, runningSystem, approvedPlayer, sheetTab } from './helpers'; + +// PLAYERS CHANGE GEAR (G6a, G6b; decided 2026-11-20, all A, the user: "the GM can still open, view and change things"): the +// GAME tab's switch off at the table, a player's GEAR card shows the Cutlass's DAMAGE but can't change it, and says so; the +// GM changes it on their sheet, which the player sees as UNIQUE, changed by the GM; on again, the player changes it. +// The table's settings are shared by the tests in a part: switched back on whatever happens. + +test('PLAYERS CHANGE GEAR off: the player\'s DAMAGE shown not changed, the GM changes it, on again the player does (G6)', async ({ browser, request }, info) => { + test.setTimeout(120_000); + const again = info.retry ? `_${info.retry + 1}` : ''; + const gm = await gmToken(request); + await runningSystem(request, gm, { + format: 1, name: `Gearlock${again}`, core: { health: { model: 'pool' } }, + stats: [{ id: 'abilities', label: 'ABILITIES', stats: [{ id: 'might', label: 'Might' }] }], + items: { + types: [{ id: 'weapons', label: 'WEAPONS', one: 'Weapon', on_sheet: 'equipped', columns: [{ id: 'damage', label: 'DAMAGE', kind: 'damage' }] }], + list: [{ id: 'cutlass', label: 'Cutlass', type: 'weapons', values: { damage: '1d8' } }], + }, + }); + const player = { username: `e2e_gearlock${again}`, password: 'e2e-player-password' }; + await approvedPlayer(request, gm, player); + const sheetOf = async () => (await asGm(request, gm, 'get', `/api/sheets/user/${player.username}`)).data; + const setting = (value: string) => asGm(request, gm, 'post', '/api/settings', { key: 'players_change_gear', value }); + + const context = await browser.newContext({ baseURL: info.project.use.baseURL, viewport: { width: 1280, height: 800 } }); + const mine = await context.newPage(); + try { + await signInAsPlayer(mine, player); + await mine.getByRole('button', { name: 'CHARACTER_CONTROLS', exact: true }).click(); + await mine.getByRole('button', { name: 'CHARACTER_SHEET', exact: true }).click(); + await sheetTab(mine, 'GEAR'); + await mine.getByRole('group', { name: 'Add by hand' }).getByRole('button', { name: 'Add a Weapon by hand' }).click(); + await mine.getByLabel('Item 1 name', { exact: true }).fill('Cutlass'); + await expect.poll(async () => JSON.parse(String((await sheetOf()).inventory ?? '[]'))[0]?.name, { timeout: 15_000 }).toBe('Cutlass'); + const card = mine.getByRole('group', { name: 'Item 1 columns' }); + const damage = card.getByLabel('Item 1 DAMAGE', { exact: true }); + await expect(damage).toHaveAttribute('placeholder', '1d8'); + await expect(damage).not.toHaveAttribute('readonly', /.*/); + + // Off: the card shows DAMAGE, can't change it, says so; the name is still theirs. + await setting('0'); + await expect(card.getByRole('note', { name: 'Item 1 columns' })).toHaveText('ONLY THE GM CHANGES THESE AT THIS TABLE', { timeout: 15_000 }); + await expect(damage).toHaveAttribute('readonly', /.*/); + await expect(card.getByLabel('Item 1 name', { exact: true })).not.toHaveAttribute('readonly', /.*/); + + // The GM, on the player's sheet, makes it 2d8: the player sees it UNIQUE, changed by the GM. + await asGm(request, gm, 'put', `/api/sheets/user/${player.username}`, { + fields: { inventory: JSON.stringify([{ name: 'Cutlass', qty: 1, enc: '', bundled: false, carry: 'stowed', location: '', values: { damage: '2d8' } }]) }, + }); + const line = mine.getByTestId('gear-line-0'); + await expect(line.getByRole('note', { name: 'Item 1 is unique' })).toHaveAttribute('title', /DAMAGE 2d8, the item's: 1d8 · changed by the GM, /, { timeout: 15_000 }); + + // On again: the player changes it. + await setting('1'); + await expect(card.getByRole('note', { name: 'Item 1 columns' })).toHaveCount(0, { timeout: 15_000 }); + await damage.fill('3d8'); + await expect.poll(async () => JSON.parse(String((await sheetOf()).inventory ?? '[]'))[0]?.values?.damage, { timeout: 15_000 }).toBe('3d8'); + } finally { + await setting('1'); + await context.close(); + } +}); diff --git a/frontend/src/components/GearTypeTables.tsx b/frontend/src/components/GearTypeTables.tsx index 4b655311..9f7019fb 100644 --- a/frontend/src/components/GearTypeTables.tsx +++ b/frontend/src/components/GearTypeTables.tsx @@ -17,7 +17,7 @@ import { FormulaIcon } from './FormulaIcon'; // docs/mockups/sheet-gear-layout.html, layout A): EQUIPPED, USABLE and PACK by each type's ON THE SHEET, a group per type, // in hand first; STASH, closed to start, whatever the type; a band's head closes it and the sheet remembers. A thing is // made by hand from the row of + buttons at the top; a closed band something lands in pulses, then stays bright until -// opened; a line changed from its item says UNIQUE, each column it made its own too, with THE ITEM'S to put it back and +// opened; PLAYERS CHANGE GEAR off, a player's card shows the columns without changing them (G6b); a line changed from its item says UNIQUE, each column it made its own too, with THE ITEM'S to put it back and // the item's value and who changed it when, and "unique" in FIND lists them (G5b; no count at the top, the user: FIND // is enough and saves the room); FIND at the top, always shown, keeps only the lines it matches, every band open while it has words (G4); // a thing worn, attuned or installed is in EQUIPPED whatever its type. One line a thing (G3; the same mockup, decision 3): its name, how many, @@ -34,6 +34,11 @@ interface Props { write: (next: InventoryItem[]) => void; /** Whether a line is an item installed: kept named and in place. */ locked: (index: number) => boolean; + /** + * PLAYERS CHANGE GEAR off at this table, for a player (G6b; decided 2026-11-20): every column shown in the card but not + * changed, said once; no FILL IN or THE ITEM'S. The name, how many, where and REMOVE still theirs. The server holds it too. + */ + columnsLocked?: 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. */ @@ -84,7 +89,7 @@ function CellBox({ cell, label, readOnly, onType, focus = false }: { cell: Cell; * 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, focus = false }: { cell: Cell; label: string; onType: (typed: string) => void; onRead: (text: string) => Promise; focus?: boolean }) { +function DiceBox({ cell, label, onType, onRead, focus = false, readOnly = false }: { cell: Cell; label: string; onType: (typed: string) => void; onRead: (text: string) => Promise; focus?: boolean; readOnly?: 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); @@ -107,18 +112,19 @@ function DiceBox({ cell, label, onType, onRead, focus = false }: { cell: Cell; l { 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)' } : {}) }} /> - + } {words} {open && ( @@ -148,7 +154,7 @@ function DiceBox({ cell, label, onType, onRead, focus = false }: { cell: Cell; l ); } -export function GearTypeTables({ items, itemsShown, readOnly, write, locked, on, under, onRoll, onReadDice, onCount }: Props) { +export function GearTypeTables({ items, itemsShown, readOnly, columnsLocked = false, 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. @@ -252,7 +258,7 @@ export function GearTypeTables({ items, itemsShown, readOnly, write, locked, on, {stashed && line.location && ( STASHED{line.location} )} - {!readOnly && !editing && nothingFilled && ( + {!readOnly && !columnsLocked && !editing && nothingFilled && ( @@ -295,21 +301,30 @@ export function GearTypeTables({ items, itemsShown, readOnly, write, locked, on, HOW MANY patch(i, { ...line, qty: Math.max(1, Number(e.target.value) || 1) })} style={{ ...input, width: '90px' }} /> + {/* PLAYERS CHANGE GEAR off (G6b): said once, above the columns. */} + {columnsLocked && lc.cells.length > 0 && ( + <> + + ONLY THE GM CHANGES THESE AT THIS TABLE + + )} {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))} />} + ? patch(i, withLineValue(line, cell.column, typed))} onRead={onReadDice} /> + : patch(i, withLineValue(line, cell.column, typed))} />} {/* Made its own (G5b): said, with the item's value, who changed it when, and THE ITEM'S to put it back. */} {cell.unique && ( <> UNIQUE - + {!columnsLocked && ( + + )} {itemWas(cell, line)} diff --git a/frontend/src/components/InventorySection.tsx b/frontend/src/components/InventorySection.tsx index c9ab167e..19404d37 100644 --- a/frontend/src/components/InventorySection.tsx +++ b/frontend/src/components/InventorySection.tsx @@ -79,9 +79,11 @@ interface Props { onReadGearDice?: (text: string) => Promise; /** A line's COUNT spent by its button or reloaded (8a4b). */ onGearCount?: GearCount; + /** PLAYERS CHANGE GEAR off at this table, for a player (G6b): the columns shown but not changed. */ + columnsLocked?: boolean; } -export function InventorySection({ section, data, readOnly, onFieldChange, rowActions, itemsShown, gm = false, onItem, onChoices, refused, onGearRoll, onReadGearDice, onGearCount }: Props) { +export function InventorySection({ section, data, readOnly, onFieldChange, rowActions, itemsShown, gm = false, onItem, onChoices, refused, onGearRoll, onReadGearDice, onGearCount, columnsLocked = false }: Props) { const items = readInventory(data); // A system's items (7e3b): which line draws which, and what the last save worked out. const lineItems = itemLines(itemsShown, items); @@ -139,7 +141,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/SheetRenderer.tsx b/frontend/src/components/SheetRenderer.tsx index f0a5646b..8340a34f 100644 --- a/frontend/src/components/SheetRenderer.tsx +++ b/frontend/src/components/SheetRenderer.tsx @@ -91,6 +91,8 @@ export interface SheetRendererProps { encumbranceEnforced?: boolean; /** CARRYING at the top of GEAR (8a6a): false where the table switched SHOW ENCUMBRANCE off (8a6b). */ carryingShown?: boolean; + /** Players change their gear's columns (G6b): false where the table switched PLAYERS CHANGE GEAR off; the GM always may. */ + playersChangeGear?: boolean; /** A section's header button was pressed. Sections declare the label; what it does is * the surface's business — the renderer has no idea what a window is. */ onSectionAction?: (sectionId: string) => void; @@ -1889,7 +1891,7 @@ function dropEmptyRetired(section: SheetSection, data: SheetData): SheetSection return fields.length === 0 ? null : { ...section, fields }; } -export function SheetRenderer({ onLevelUp, template, data, readOnly = false, onFieldChange, portraitUrl, onPortraitUpload, portraitShadow, onTogglePortraitShadow, onOpenLink, onRoll, onDeathSave, onStabilize, allowFumbleShield = false, xpRate, encumbranceEnforced = false, hiddenTabs, onCastSpell, onRollAbility, onResistDrain, onFieldsChange, onSectionAction, gm = false, onChoices, choicesRefused, onLevel, onRecoverySpend, recoveryOpen, onRestTake, onItem, onGearRoll, onReadGearDice, onGearCount, onSpend, onImprove, vitals, carryingShown = true }: SheetRendererProps) { +export function SheetRenderer({ onLevelUp, template, data, readOnly = false, onFieldChange, portraitUrl, onPortraitUpload, portraitShadow, onTogglePortraitShadow, onOpenLink, onRoll, onDeathSave, onStabilize, allowFumbleShield = false, xpRate, encumbranceEnforced = false, hiddenTabs, onCastSpell, onRollAbility, onResistDrain, onFieldsChange, onSectionAction, gm = false, onChoices, choicesRefused, onLevel, onRecoverySpend, recoveryOpen, onRestTake, onItem, onGearRoll, onReadGearDice, onGearCount, onSpend, onImprove, vitals, carryingShown = true, playersChangeGear = true }: SheetRendererProps) { // The vitals strip's REST ▾ (8s3c): the sheet's own RESTS, where this character has a rest to take from here or the GM // has called one; on the player's own sheet, beside the strip. const restView = vitals && !readOnly && onRestTake && template.resting ? restSection(template.resting, data as Record, gm) : null; @@ -2133,7 +2135,7 @@ export function SheetRenderer({ onLevelUp, template, data, readOnly = false, onF {section.layout === 'spells' && } {section.layout === 'ability_list' && } {section.layout === 'inventory' && } + itemsShown={template.items} gm={gm} columnsLocked={playersChangeGear === false && !gm} onItem={onItem} onGearRoll={onGearRoll} onReadGearDice={onReadGearDice} onGearCount={onGearCount} onChoices={onChoices} refused={choicesRefused} />} {section.layout === 'weapon_stash' && } {section.layout === 'encumbrance' && } {section.layout === 'cyberware' && } diff --git a/frontend/src/components/__tests__/GearTypeTables.test.tsx b/frontend/src/components/__tests__/GearTypeTables.test.tsx index a0a0947d..d8ab14ee 100644 --- a/frontend/src/components/__tests__/GearTypeTables.test.tsx +++ b/frontend/src/components/__tests__/GearTypeTables.test.tsx @@ -39,13 +39,13 @@ const line = (name: string, more = {}) => ({ name, qty: 1, enc: '', bundled: fal 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 } = {}) => { + worked = undefined as object | undefined, columnsLocked = false } = {}) => { const writes: object[][] = []; 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 })); }} />; }; render(); @@ -604,3 +604,40 @@ describe('UNIQUE on the line and in its card (G5b)', () => { expect(screen.queryByRole('button', { name: 'Rope, item 2' })).toBeNull(); }); }); + +describe('PLAYERS CHANGE GEAR off, for a player (G6b)', () => { + const at = (i: number) => within(screen.getByTestId(`gear-line-${i}`)); + const read = async () => ({ ok: true as const, blank: true as const, names: [] }); + + it('the card shows every column without changing it, said once; no eˣ, THE ITEM\'S or FILL IN; name, how many and REMOVE still theirs', async () => { + const made = line('Pistol', { values: { damage: '3d6' } }); + show([made, line('Knife', { type: 'weapons' })], { columnsLocked: true, onReadGearDice: read }); + // Nothing filled in on the Knife, but nothing to fill either. + expect(at(1).queryByRole('button', { name: /^Fill in/ })).toBeNull(); + await userEvent.click(at(0).getByRole('button', { name: 'Edit item 1' })); + const card = within(at(0).getByRole('group', { name: 'Item 1 columns' })); + expect(card.getByRole('note', { name: 'Item 1 columns' }).textContent).toBe('ONLY THE GM CHANGES THESE AT THIS TABLE'); + expect((card.getByLabelText('Item 1 DAMAGE') as HTMLInputElement).readOnly).toBe(true); + expect(card.queryByRole('button', { name: 'Help writing Item 1 DAMAGE' })).toBeNull(); + expect((card.getByLabelText('Item 1 RANGE') as HTMLInputElement).readOnly).toBe(true); + expect((card.getByLabelText('Item 1 GRADE') as HTMLSelectElement).disabled).toBe(true); + // Still UNIQUE, with what the item had; nothing to put it back with. + expect(card.getByRole('group', { name: 'Item 1 DAMAGE is unique' })).toBeTruthy(); + expect(card.queryByRole('button', { name: "Item 1 DAMAGE: the item's" })).toBeNull(); + expect((card.getByLabelText('Item 1 name') as HTMLInputElement).readOnly).toBe(false); + expect((card.getByLabelText('Item 1 quantity') as HTMLInputElement).readOnly).toBe(false); + expect(card.getByRole('button', { name: 'Remove item 1' })).toBeTruthy(); + }); + + it('on: none of that; a type with no columns says nothing either', async () => { + show([line('Pistol')], { onReadGearDice: read }); + await userEvent.click(at(0).getByRole('button', { name: 'Edit item 1' })); + expect(at(0).queryByRole('note', { name: 'Item 1 columns' })).toBeNull(); + expect(at(0).getByRole('button', { name: 'Help writing Item 1 DAMAGE' })).toBeTruthy(); + cleanup(); + const bare: ItemsShown = { slots: [], list: [], types: [{ id: 'gear', label: 'GEAR', one: 'Gear', columns: [] }] }; + show([line('Rope', { type: 'gear' })], { items: bare, columnsLocked: true }); + await userEvent.click(at(0).getByRole('button', { name: 'Edit item 1' })); + expect(at(0).queryByRole('note', { name: 'Item 1 columns' })).toBeNull(); + }); +}); diff --git a/frontend/src/components/__tests__/SheetRenderer.playersGear.test.tsx b/frontend/src/components/__tests__/SheetRenderer.playersGear.test.tsx new file mode 100644 index 00000000..1b7609ef --- /dev/null +++ b/frontend/src/components/__tests__/SheetRenderer.playersGear.test.tsx @@ -0,0 +1,47 @@ +import { describe, it, expect, afterEach } from 'vitest'; +import { render, screen, cleanup, fireEvent, within } from '@testing-library/react'; +import { SheetRenderer } from '../SheetRenderer'; + +/** + * PLAYERS CHANGE GEAR on the sheet (G6b; decided 2026-11-20, all A, the user: "the GM can still open, view and change + * things"): switched off at the table, a player's GEAR card shows every column but changes none; the GM's never locks. + */ + +afterEach(cleanup); + +const template = { + id: 'sys_x', name: 'Blades', tabs: ['GEAR'], + items: { + slots: [], list: [{ id: 'cutlass', label: 'Cutlass', needs: 'carried', features: [], type: 'weapons', values: { damage: '1d8' } }], + types: [{ id: 'weapons', label: 'WEAPONS', one: 'Weapon', columns: [{ id: 'damage', label: 'DAMAGE', kind: 'damage' }] }], + }, + sections: [{ id: 'inventory', label: 'INVENTORY', layout: 'inventory', tab: 'GEAR', fields: [] }], +} as never; +const data = { inventory: JSON.stringify([{ name: 'Cutlass', qty: 1, enc: '', bundled: false, carry: 'stowed', location: '' }]) }; + +const opened = (extra: object) => { + render( {}} data={data as never} {...extra} />); + fireEvent.click(screen.getByRole('button', { name: 'Edit item 1' })); + return within(screen.getByRole('group', { name: 'Item 1 columns' })); +}; + +describe('PLAYERS CHANGE GEAR, from the table to the card', () => { + it('off, for a player: DAMAGE shown, not changed, said; the name still theirs', () => { + const card = opened({ playersChangeGear: false }); + expect((card.getByLabelText('Item 1 DAMAGE') as HTMLInputElement).readOnly).toBe(true); + expect(card.getByRole('note', { name: 'Item 1 columns' }).textContent).toBe('ONLY THE GM CHANGES THESE AT THIS TABLE'); + expect((card.getByLabelText('Item 1 name') as HTMLInputElement).readOnly).toBe(false); + }); + + it('off, for the GM: as ever', () => { + const card = opened({ playersChangeGear: false, gm: true }); + expect((card.getByLabelText('Item 1 DAMAGE') as HTMLInputElement).readOnly).toBe(false); + expect(card.queryByRole('note', { name: 'Item 1 columns' })).toBeNull(); + }); + + it('on, or not said: as ever', () => { + expect((opened({ playersChangeGear: true }).getByLabelText('Item 1 DAMAGE') as HTMLInputElement).readOnly).toBe(false); + cleanup(); + expect((opened({}).getByLabelText('Item 1 DAMAGE') as HTMLInputElement).readOnly).toBe(false); + }); +}); diff --git a/frontend/src/components/__tests__/tableSwitchesGameTab.test.tsx b/frontend/src/components/__tests__/tableSwitchesGameTab.test.tsx index 372018b0..ba89d961 100644 --- a/frontend/src/components/__tests__/tableSwitchesGameTab.test.tsx +++ b/frontend/src/components/__tests__/tableSwitchesGameTab.test.tsx @@ -117,4 +117,21 @@ describe('the GAME tab\'s encumbrance and condition switches', () => { await screen.findByRole('checkbox', { name: /^SHOW ENCUMBRANCE/ }); expect(box(/^CONDITION TURN EFFECTS/)).toBeNull(); }); + + it('PLAYERS CHANGE GEAR (G6b): where the system makes its own item types, on to start; switched off and APPLY, written', async () => { + packs({ encumbrance: false, band_conditions: false, applied_conditions: false, gear: true }); + await openRules(); + const gear = await screen.findByRole('checkbox', { name: /^PLAYERS CHANGE GEAR/ }); + expect((gear as HTMLInputElement).checked).toBe(true); + expect(gear.closest('label')!.getAttribute('title')).toMatch(/Off: only the GM changes them/); + await userEvent.click(gear); + await userEvent.click(screen.getByRole('button', { name: 'APPLY' })); + await screen.findByText('HOUSE RULES APPLIED'); + expect(posted.filter((p) => p.key === 'players_change_gear')).toEqual([{ key: 'players_change_gear', value: '0', auth: 'Bearer admintoken' }]); + cleanup(); + packs({ encumbrance: true, band_conditions: false, applied_conditions: false, gear: false }); + await openRules(); + await screen.findByRole('checkbox', { name: /^SHOW ENCUMBRANCE/ }); + expect(box(/^PLAYERS CHANGE GEAR/)).toBeNull(); + }); }); diff --git a/frontend/src/hooks/usePlayerSheet.ts b/frontend/src/hooks/usePlayerSheet.ts index 214805cb..aaf3012b 100644 --- a/frontend/src/hooks/usePlayerSheet.ts +++ b/frontend/src/hooks/usePlayerSheet.ts @@ -3,7 +3,7 @@ import { useState, useEffect, useRef, useCallback } from 'react'; import { getTemplate, getMaxPairs, hiddenTabsFor, type CharacterSheet, type SheetFieldValue } from '../sheets'; import { SLOW_ADVANCEMENT_RULE } from '../sheets/cwnAdvancement'; import { ENCUMBRANCE_RULE } from '../sheets/cwnEncumbrance'; -import { carryingShown } from '../sheets/tableSwitches'; +import { carryingShown, gearByPlayers } from '../sheets/tableSwitches'; import { OVERDRAFT_RULE } from '../data/shopRules'; import { isOpen } from '../sheets/restCalls'; import { INVENTORY_FIELD } from '../sheets/inventory'; @@ -248,6 +248,8 @@ export function usePlayerSheet( // CARRYING on GEAR, unless the table switched SHOW ENCUMBRANCE off (8a6b). const showCarrying = carryingShown(ruleSettings); + // Players change their gear's columns, unless the table switched PLAYERS CHANGE GEAR off (G6b). + const playersChangeGear = gearByPlayers(ruleSettings); // Whether the GM has spending recovery dice open (R2b), read with the house rules. const recoveryOpen = isOpen(ruleSettings); @@ -259,7 +261,7 @@ export function usePlayerSheet( /** Every play prop a surface hands SheetRenderer: both spread it whole (8s1a). */ const sheetProps = { - ...actions, choicesRefused, recoveryOpen, allowFumbleShield, xpRate, encumbranceEnforced, hiddenTabs, vitals, carryingShown: showCarrying, + ...actions, choicesRefused, recoveryOpen, allowFumbleShield, xpRate, encumbranceEnforced, hiddenTabs, vitals, carryingShown: showCarrying, playersChangeGear, } satisfies Partial; return { diff --git a/frontend/src/sheets/__tests__/tableSwitches.test.ts b/frontend/src/sheets/__tests__/tableSwitches.test.ts index 4cbcbce4..d5cc7c47 100644 --- a/frontend/src/sheets/__tests__/tableSwitches.test.ts +++ b/frontend/src/sheets/__tests__/tableSwitches.test.ts @@ -1,5 +1,5 @@ import { describe, it, expect } from 'vitest'; -import { switchRules, carryingShown, SHOW_ENCUMBRANCE, BAND_CONDITIONS, APPLY_CONDITION_MODIFIERS, CONDITION_TURN_EFFECTS } from '../tableSwitches'; +import { switchRules, carryingShown, gearByPlayers, SHOW_ENCUMBRANCE, BAND_CONDITIONS, APPLY_CONDITION_MODIFIERS, CONDITION_TURN_EFFECTS, PLAYERS_CHANGE_GEAR } from '../tableSwitches'; // The GAME tab's encumbrance and condition switches (8a6b; approved mockup docs/mockups/carrying-on-sheet.html). @@ -14,6 +14,10 @@ describe('switchRules', () => { expect(switchRules({ encumbrance: true, band_conditions: false, applied_conditions: false, turn_effects: true }).map((r) => [r.settingKey, r.label, r.defaultOn])) .toEqual([[SHOW_ENCUMBRANCE, 'SHOW ENCUMBRANCE', true], [CONDITION_TURN_EFFECTS, 'CONDITION TURN EFFECTS', true]]); expect(switchRules({ encumbrance: false, band_conditions: false, applied_conditions: false, turn_effects: false })).toEqual([]); + // PLAYERS CHANGE GEAR (G6b), last: where the system makes its own item types. + expect(switchRules({ encumbrance: true, band_conditions: false, applied_conditions: false, gear: true }).map((r) => [r.settingKey, r.label, r.defaultOn])) + .toEqual([[SHOW_ENCUMBRANCE, 'SHOW ENCUMBRANCE', true], [PLAYERS_CHANGE_GEAR, 'PLAYERS CHANGE GEAR', true]]); + expect(switchRules({ encumbrance: false, band_conditions: false, applied_conditions: false, gear: false })).toEqual([]); }); it('none for a built-in game or a system not loaded yet', () => { expect(switchRules(null)).toEqual([]); @@ -21,11 +25,11 @@ describe('switchRules', () => { expect(switchRules({ encumbrance: false, band_conditions: false, applied_conditions: false })).toEqual([]); }); it('each says what it does, and what off means', () => { - for (const r of switchRules({ encumbrance: true, band_conditions: true, applied_conditions: true, turn_effects: true })) expect(r.title, r.label).toMatch(/Off: /); + for (const r of switchRules({ encumbrance: true, band_conditions: true, applied_conditions: true, turn_effects: true, gear: true })) expect(r.title, r.label).toMatch(/Off: /); }); it('the keys the server reads (backend sheets/bandConditions.js BAND_SETTING, conditionsOnSheet.js CONDITIONS_SETTING, tokens/turnEffects.js TURN_EFFECTS_SETTING)', () => { // Pinned here as words: those modules load the server's own, which a frontend test may not (crossBoundaryImports). - expect([BAND_CONDITIONS, APPLY_CONDITION_MODIFIERS, CONDITION_TURN_EFFECTS]).toEqual(['band_conditions', 'apply_condition_modifiers', 'condition_turn_effects']); + expect([BAND_CONDITIONS, APPLY_CONDITION_MODIFIERS, CONDITION_TURN_EFFECTS, PLAYERS_CHANGE_GEAR]).toEqual(['band_conditions', 'apply_condition_modifiers', 'condition_turn_effects', 'players_change_gear']); }); }); @@ -37,3 +41,12 @@ describe('carryingShown', () => { expect(carryingShown([{ key: SHOW_ENCUMBRANCE, value: '0' }])).toBe(false); }); }); + +describe('gearByPlayers (G6b)', () => { + it('on unless the table switched PLAYERS CHANGE GEAR off', () => { + expect(gearByPlayers([])).toBe(true); + expect(gearByPlayers([{ key: PLAYERS_CHANGE_GEAR, value: '1' }])).toBe(true); + expect(gearByPlayers([{ key: 'show_encumbrance', value: '0' }])).toBe(true); + expect(gearByPlayers([{ key: PLAYERS_CHANGE_GEAR, value: '0' }])).toBe(false); + }); +}); diff --git a/frontend/src/sheets/tableSwitches.ts b/frontend/src/sheets/tableSwitches.ts index 56bea9f2..7fbd0e67 100644 --- a/frontend/src/sheets/tableSwitches.ts +++ b/frontend/src/sheets/tableSwitches.ts @@ -13,9 +13,11 @@ export const BAND_CONDITIONS = 'band_conditions'; export const APPLY_CONDITION_MODIFIERS = 'apply_condition_modifiers'; /** A condition's EACH TURN rolled on NEXT and BEGIN (backend TURN_EFFECTS_SETTING): '0' leaves them to the GM. */ export const CONDITION_TURN_EFFECTS = 'condition_turn_effects'; +/** Players changing their gear lines' columns (G6; backend uniqueLines.js PLAYERS_GEAR_SETTING): '0' leaves them to the GM. */ +export const PLAYERS_CHANGE_GEAR = 'players_change_gear'; /** What a system has for each switch to switch. */ -export interface TableSwitches { encumbrance: boolean; band_conditions: boolean; applied_conditions: boolean; turn_effects?: boolean } +export interface TableSwitches { encumbrance: boolean; band_conditions: boolean; applied_conditions: boolean; turn_effects?: boolean; gear?: boolean } export interface SwitchRule { settingKey: string; label: string; title: string; defaultOn: true } @@ -37,8 +39,17 @@ export const switchRules = (has: TableSwitches | null | undefined): SwitchRule[] settingKey: CONDITION_TURN_EFFECTS, label: 'CONDITION TURN EFFECTS', defaultOn: true as const, title: 'Each condition\'s EACH TURN is rolled on NEXT and BEGIN, burning, healing or a save, said in the log. Off: nothing is rolled on turns; the conditions stay on the tokens as reminders and the GM rolls by hand. One that ends at the end of its next turn still comes off.', }] : []), + // PLAYERS CHANGE GEAR (G6; decided 2026-11-20): where the system makes its own item types. + ...(has?.gear ? [{ + settingKey: PLAYERS_CHANGE_GEAR, label: 'PLAYERS CHANGE GEAR', defaultOn: true as const, + title: 'Players change the columns of their own gear, a weapon\'s DAMAGE or a potion\'s HEALS, each change marked UNIQUE. Off: only the GM changes them; players still name, count, move and add their things.', + }] : []), ]; +/** Whether players change their gear's columns at this table (G6b), from its settings: on unless switched off. */ +export const gearByPlayers = (settings: { key: string; value: string }[]): boolean => + settings.find((s) => s.key === PLAYERS_CHANGE_GEAR)?.value !== '0'; + /** Whether CARRYING shows at this table, from its settings: on unless switched off. */ export const carryingShown = (settings: { key: string; value: string }[]): boolean => settings.find((s) => s.key === SHOW_ENCUMBRANCE)?.value !== '0'; From b89edd823f0e7cb03d0e86244faba78e2ecd51f9 Mon Sep 17 00:00:00 2001 From: Developer Date: Sun, 22 Nov 2026 13:56:04 -0600 Subject: [PATCH 2/3] feat: gift notices in one box, each going 5 seconds after it came, held while hovered or focused, x closing them all; journeys look for the notice before the save --- CHANGELOG.md | 1 + README.md | 4 +- e2e/tests/sheet-new-character.spec.ts | 5 +- e2e/tests/sheet-worn-items.spec.ts | 5 +- frontend/src/components/GiftNotices.tsx | 48 ++++++++++------- .../__tests__/giveFromToken.test.tsx | 52 ++++++++++++++++--- 6 files changed, 81 insertions(+), 34 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b0ee3037..92f4258a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -802,6 +802,7 @@ Format follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### Changed +- **"THE GM GAVE YOU" notices in one box, gone after 5 seconds.** Gifts now share one box, newest first, instead of stacking a box each, and each goes 5 seconds after it arrives. Hover over the box (or tab into it) to keep it while you read; ✕ closes them all. - **Slot and install counters only where they are used.** On GEAR, a counter like ATTUNED 0 OF 3 or CYBERWARE · STRAIN 0 OF 2 shows only once something on that sheet needs it, worn, carried or stashed, or while anything is still counted against it. A character with no cyberware no longer sees STRAIN 0 OF 0. - **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. diff --git a/README.md b/README.md index cc7b6797..c3161f73 100644 --- a/README.md +++ b/README.md @@ -805,7 +805,7 @@ CITY_NET/ │ │ │ ├── GiveItemWindow.tsx # GIVE.EXE, the GM handing out items free, on the shop's terminal layout: the item being given in the corner; ITEMS (catalogue tabs, a search, each item's worth), TO (HOW MANY, every player character online or not and the map's NPCs, where it would land on each or why not, a note) and GIVEN (the game's last gifts, blinking after a GIVE); GIVE along the bottom. Opened from a token's GIVE_ITEM, that character is ticked. One question to the server at a time, and a preview for a number since changed is dropped; a system's kits beside the items, what is in each said (7c4c) │ │ │ ├── AccelerationNotice.tsx # HARDWARE ACCELERATION IS OFF: a small notice for the GM and players, only when the browser says it draws in software (never a guess), with the steps for their browser (utils/hardwareAccel.ts); DISMISS turns SYSTEM_INFO's WARN ME switch off for good in that browser; not over the system builder, never in an automated browser unless asked │ │ │ ├── MapSlowHelp.tsx # MAP SLOW? in SYSTEM_INFO, for the GM and players: the steps to turn hardware acceleration on in their browser, opened when wanted, and the WARN ME IF HARDWARE ACCELERATION IS OFF switch the notice follows, kept in the browser's local storage -│ │ │ ├── GiftNotices.tsx # What a player sees when the GM gives them something: "THE GM GAVE YOU HEAVY PISTOL x2" in the game's own word for the GM, the note, and that it's already on their sheet; sent to their screens alone, each kept until closed, the newest three +│ │ │ ├── GiftNotices.tsx # What a player sees when the GM gives them something: "THE GM GAVE YOU HEAVY PISTOL x2" in the game's own word for the GM, the note, and that it's already on their sheet; sent to their screens alone, each kept until closed, the newest three; one box, each gift a row, newest first, each going 5 seconds after it came, held while the pointer or focus is on it, ✕ closing them all (2026-11-22) │ │ │ ├── GraphAddPalette.tsx # + ADD's search on the graph view: what can be added, searched as typed, arrow keys and Enter, Escape; what comes later greyed with when │ │ │ ├── GraphProblems.tsx # PROBLEMS in the graph view's bottom left corner: errors (✕) and warnings (!) counted, opened to the list in players' names; one on the map a click to its node, one on another page to PROBLEMS │ │ │ ├── GraphPanel.tsx # The graph view's node panel: the node clicked, with the very controls FORMS has (statsRulesFields): a stats group and the modifiers its table gives, a formula's name, text, INSERT, value and alternative, ON THE WAY IN (its diamonds' numbers), REMOVE, a table's rows and TRY IT; a house rule with GO TO HOUSE RULES; a note written (to 1000 characters), pinned to a node or to nothing and removed, its panel named by what it is pinned to; a formula's MAP GROUP (none, one of the map's own, or a new one); a map group's own panel, from its title bar: its name, its formulas each taken out with ×, LINE UP (stacked in one column, a cell apart), UNGROUP; a roll's panel the ROLLS tab's five steps and TEST ROLL (6b4a); ×, Escape or a click on the map closes it. A list of choices says what it gives and goes to CHOICES (7a5c) @@ -1068,7 +1068,7 @@ CITY_NET/ │ │ │ ├── GraphView.test.tsx # Every node as tall as the model plans; a list with SCORE, MOD and MOD VIA; a formula's inputs by name, where from, BEST, its text in names and = its value; a sheet field, a name no sheet has, a missing table, the engine's own; a mistake inside the node; folding to one line; zoom, FIT, AUTO-LAYOUT asking first; the status line; an example locked but zoomable; + ADD → ROLL from a preset, its node and panel open │ │ │ ├── GiveItemWindow.test.tsx # GIVE.EXE against a fake server: the layout, ITEMS narrowed by catalogue and name, TO previewing everyone and the map's NPCs (Stowed only in CWN, a stale preview dropped, online by any case), HOW MANY, ticking, GIVE with the note and how it went, GIVEN updated and blinking, and refusals; kits listed, narrowed and picked │ │ │ ├── HelpPage.test.tsx # The topics in their groups opening on GETTING STARTED, the one picked with all its words, GO TO a page (waiting for a system), FORMULAS' table held to the engine's list, EXAMPLES looked at or only described, and START THE TOUR only with a tour -│ │ │ ├── giveFromToken.test.tsx # GIVE_ITEM on a token: the GM's, on a player's character or an NPC with a sheet here, opening GIVE.EXE with that character ticked (added to the ticks if it's already open); the player's notice, newest three, each until closed, in the game's word for the GM +│ │ │ ├── giveFromToken.test.tsx # GIVE_ITEM on a token: the GM's, on a player's character or an NPC with a sheet here, opening GIVE.EXE with that character ticked (added to the ticks if it's already open); the player's notice, newest three, each until closed, in the game's word for the GM; the notice as one box of rows, ✕ closing all, each going after 5 seconds and held while hovered, its timers stopped when it goes │ │ │ ├── TryItPage.test.tsx # The made-up character and its formulas, SAVE AS THE SAMPLE (absent with nowhere to save), RESET, health on a pretend token under each model, both maximums, and an NPC rolled from a tier; a "?" beside the health, what others see, the level and the rules; RULES switching a formula's alternative and a hidden section, never the draft, SAVE AS THE SAMPLE still writing the draft itself │ │ │ ├── ToggleSwitch.test.tsx # Named by its label or, with the words elsewhere, by name; the label part of the button; what it becomes when clicked; the knob across and lit when on; the color it is given; nothing while disabled; a button's own attributes passed through but never its role or state; a click seen first (the graph keeps it off the map) │ │ │ ├── ControlledNpcSheetWindow.test.tsx # A friendly NPC's sheet read-only for the player it was given to, fetched with their own login, rolling as the NPC diff --git a/e2e/tests/sheet-new-character.spec.ts b/e2e/tests/sheet-new-character.spec.ts index b1315923..ac6001d9 100644 --- a/e2e/tests/sheet-new-character.spec.ts +++ b/e2e/tests/sheet-new-character.spec.ts @@ -482,10 +482,9 @@ test('a kit the GM gives: listed in GIVE, ticked, landing on the sheet with the await expect(who.getByText('4 items, in the inventory')).toBeVisible({ timeout: 15_000 }); await who.getByRole('checkbox', { name: 'Wren' }).check(); await page.getByRole('button', { name: 'GIVE 1 × ROOK TO 1' }).click(); - await expect.poll(async () => JSON.parse((await stored()).inventory ?? '[]').map((i: { name: string; qty: number }) => [i.name, i.qty]), { timeout: 15_000 }).toEqual([['Old sword', 1], ['Candles', 3]]); - - // The player is told, and it is on their sheet without a reload. + // The player is told (looked for first: the notice goes after 5 seconds), and it is on their sheet without a reload. await expect(theirs.getByText('THE GM GAVE YOU ROOK ×1: Old sword, 3x Candles')).toBeVisible({ timeout: 15_000 }); + await expect.poll(async () => JSON.parse((await stored()).inventory ?? '[]').map((i: { name: string; qty: number }) => [i.name, i.qty]), { timeout: 15_000 }).toEqual([['Old sword', 1], ['Candles', 3]]); await sheetTab(theirs, 'GEAR'); await expect(theirs.locator('[value="Candles"]')).toHaveCount(1, { timeout: 15_000 }); await theirs.context().close(); diff --git a/e2e/tests/sheet-worn-items.spec.ts b/e2e/tests/sheet-worn-items.spec.ts index e55cbdc0..b91e9d58 100644 --- a/e2e/tests/sheet-worn-items.spec.ts +++ b/e2e/tests/sheet-worn-items.spec.ts @@ -135,10 +135,9 @@ test('GIVE.EXE hands out a system\'s item from ITEMS: a stowed line of its name, await expect(who.getByText('an inventory line')).toBeVisible({ timeout: 15_000 }); await who.getByRole('checkbox', { name: 'Wren' }).check(); await give.getByRole('button', { name: 'GIVE 1 × RING OF MIGHT TO 1' }).click(); - await expect.poll(async () => JSON.parse((await sheetOf()).inventory ?? '[]').map((i: { name: string; carry: string }) => [i.name, i.carry]), { timeout: 15_000 }).toEqual([['Ring of Might', 'stowed']]); - - // The player is told, and it is that item: WEAR it there and then. + // The player is told (looked for first: the notice goes after 5 seconds), and it is that item: WEAR it there and then. await expect(mine.getByText('THE GM GAVE YOU RING OF MIGHT ×1: NEEDS ATTUNED · A heavy iron band.')).toBeVisible({ timeout: 15_000 }); + await expect.poll(async () => JSON.parse((await sheetOf()).inventory ?? '[]').map((i: { name: string; carry: string }) => [i.name, i.carry]), { timeout: 15_000 }).toEqual([['Ring of Might', 'stowed']]); await sheetTab(mine, 'GEAR'); const ring = mine.getByTestId('gear-item-ring'); await ring.getByRole('button', { name: 'WEAR Ring of Might' }).click(); diff --git a/frontend/src/components/GiftNotices.tsx b/frontend/src/components/GiftNotices.tsx index 6f80f1d4..4ea3e9a0 100644 --- a/frontend/src/components/GiftNotices.tsx +++ b/frontend/src/components/GiftNotices.tsx @@ -1,4 +1,4 @@ -import React, { useEffect, useState } from 'react'; +import React, { useEffect, useRef, useState } from 'react'; import { createPortal } from 'react-dom'; import { themeRoot } from '../utils/themeRoot'; import { useWords } from '../sheets/words'; @@ -7,11 +7,18 @@ import { noticeText, type AskSocket, type ReceivedNotice } from '../sheets/giveI // What a player sees when the GM gives them something (4g4c; approved mockup // docs/mockups/give-item.html, 2026-10-12): "THE GM GAVE YOU HEAVY PISTOL ×1", with the GM's note. // Only the player given it is sent 'itemReceived' (backend sockets/index.js, to their screens alone), -// so a gift can be a secret. It is already on their sheet; this says so. Each stays until closed, -// so a player away from the keys still sees it; the last few are kept. +// so a gift can be a secret. It is already on their sheet; this says so. +// +// One box, each gift a row in it, newest first (the user, 2026-11-22: separate boxes "stack and look bad"); each row goes +// 5 seconds after it came ("can we have these time out after 5 seconds?"), held while the pointer or focus is on the box, +// so a player reading one doesn't lose it; ✕ closes them all. -/** How many notices stay up at once, newest first. */ +/** How many gifts the box lists at once, newest first. */ export const NOTICES_KEPT = 3; +/** How long each gift is said before it goes, in ms. */ +export const NOTICE_MS = 5000; +/** How often a gift held on the screen looks again whether it may go. */ +const HELD_RECHECK_MS = 500; interface Props { socket: Pick | null; @@ -22,38 +29,43 @@ interface Props { export function GiftNotices({ socket, system }: Props) { const word = useWords(system); const [notices, setNotices] = useState<(ReceivedNotice & { n: number })[]>([]); + // The pointer or focus on the box: what is being read isn't taken away. + const held = useRef(false); useEffect(() => { if (!socket) return; let count = 0; + const timers = new Set>(); + const later = (fn: () => void, ms: number) => { const t = setTimeout(() => { timers.delete(t); fn(); }, ms); timers.add(t); }; const heard = (notice: ReceivedNotice) => { count += 1; const n = count; setNotices((prev) => [{ ...notice, n }, ...prev].slice(0, NOTICES_KEPT)); + const go = () => { if (held.current) later(go, HELD_RECHECK_MS); else setNotices((prev) => prev.filter((x) => x.n !== n)); }; + later(go, NOTICE_MS); }; socket.on('itemReceived', heard); - return () => { socket.off('itemReceived', heard); }; + return () => { socket.off('itemReceived', heard); timers.forEach(clearTimeout); }; }, [socket]); if (!notices.length) return null; - const dismiss = (n: number) => setNotices((prev) => prev.filter((x) => x.n !== n)); return createPortal( -
- {notices.map((g) => ( -
-
+
{ held.current = true; }} onMouseLeave={() => { held.current = false; }} + onFocus={() => { held.current = true; }} onBlur={() => { held.current = false; }} + style={{ position: 'fixed', top: 70, left: '50%', transform: 'translateX(-50%)', zIndex: 3000, width: 'min(420px, calc(100vw - 32px))', + fontFamily: 'monospace', fontSize: 11, letterSpacing: 1, padding: '8px 10px', background: 'var(--black)', + border: '1px solid var(--warning)', color: 'var(--warning)', display: 'flex', gap: 8, alignItems: 'flex-start' }}> +
+ {notices.map((g, i) => ( +
0 ? { borderTop: '1px dashed var(--dark-green)', paddingTop: 6 } : {}) }}> {noticeText(g, word('gm', 'short', 'GM'))} {g.note && “{g.note}”} - It's on your sheet.
- -
- ))} + ))} + {notices.length > 1 ? "They're on your sheet." : "It's on your sheet."} +
+
, themeRoot(), ); diff --git a/frontend/src/components/__tests__/giveFromToken.test.tsx b/frontend/src/components/__tests__/giveFromToken.test.tsx index ea0c21d8..ec3131ce 100644 --- a/frontend/src/components/__tests__/giveFromToken.test.tsx +++ b/frontend/src/components/__tests__/giveFromToken.test.tsx @@ -1,10 +1,10 @@ import React from 'react'; import { describe, it, expect, vi, afterEach } from 'vitest'; -import { render, screen, cleanup, act, within } from '@testing-library/react'; +import { render, screen, cleanup, act, within, fireEvent } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import { buildTokenActions, tokenActionKeys, type TokenActionContext, type TokenViewer } from '../tokenActions'; -import { GiftNotices, NOTICES_KEPT } from '../GiftNotices'; +import { GiftNotices, NOTICES_KEPT, NOTICE_MS } from '../GiftNotices'; import { GiveItemWindow } from '../GiveItemWindow'; import { registerCustomTemplate, clearCustomTemplates, type CustomRender } from '../../sheets/customTemplates'; import type { AskSocket, ReceivedNotice } from '../../sheets/giveItems'; @@ -116,22 +116,58 @@ describe('the player\'s notice', () => { expect(screen.queryByTestId('gift-notices')).toBeNull(); s.send(pistol); expect(screen.getByRole('status').textContent).toBe('THE GM GAVE YOU HEAVY PISTOL ×2“For the job tonight.”It\'s on your sheet.✕'); + // A second: in the same box, newest first, not a box of its own (2026-11-22: "they stack and look bad"). s.send({ ...pistol, item: 'Rope', qty: 1, note: '' }); - expect(screen.getAllByRole('status')[0].textContent).toBe('THE GM GAVE YOU ROPE ×1It\'s on your sheet.✕'); + expect(screen.getAllByRole('status')).toHaveLength(1); + expect(screen.getAllByRole('listitem').map((r) => r.textContent)).toEqual(['THE GM GAVE YOU ROPE ×1', 'THE GM GAVE YOU HEAVY PISTOL ×2“For the job tonight.”']); + expect(screen.getByRole('status').textContent).toContain("They're on your sheet."); }); - it('keeps the newest few, each until closed', async () => { + it('lists the newest few; ✕ closes them all', async () => { const s = fakeSocket(); render(); for (let i = 1; i <= NOTICES_KEPT + 1; i += 1) s.send({ ...pistol, item: `Thing ${i}`, note: '' }); expect(NOTICES_KEPT).toBe(3); - expect(screen.getAllByRole('status').map((n) => n.textContent?.split(' ×')[0])).toEqual(['THE GM GAVE YOU THING 4', 'THE GM GAVE YOU THING 3', 'THE GM GAVE YOU THING 2']); - await userEvent.click(within(screen.getAllByRole('status')[1]).getByRole('button', { name: 'Dismiss' })); - expect(screen.getAllByRole('status').map((n) => n.textContent?.split(' ×')[0])).toEqual(['THE GM GAVE YOU THING 4', 'THE GM GAVE YOU THING 2']); - for (const n of screen.getAllByRole('status')) await userEvent.click(within(n).getByRole('button', { name: 'Dismiss' })); + expect(screen.getAllByRole('listitem').map((n) => n.textContent?.split(' ×')[0])).toEqual(['THE GM GAVE YOU THING 4', 'THE GM GAVE YOU THING 3', 'THE GM GAVE YOU THING 2']); + await userEvent.click(screen.getByRole('button', { name: 'Dismiss' })); expect(screen.queryByTestId('gift-notices')).toBeNull(); }); + it('each goes 5 seconds after it came, held while the pointer is on the box', () => { + vi.useFakeTimers(); + try { + const s = fakeSocket(); + render(); + expect(NOTICE_MS).toBe(5000); + s.send({ ...pistol, item: 'First', note: '' }); + act(() => { vi.advanceTimersByTime(3000); }); + s.send({ ...pistol, item: 'Second', note: '' }); + act(() => { vi.advanceTimersByTime(1999); }); + expect(screen.getAllByRole('listitem')).toHaveLength(2); + // The first's 5 seconds: it goes, the second stays. + act(() => { vi.advanceTimersByTime(1); }); + expect(screen.getAllByRole('listitem').map((n) => n.textContent?.split(' ×')[0])).toEqual(['THE GM GAVE YOU SECOND']); + // Held while read: past its 5 seconds it stays; let go, it goes. + fireEvent.mouseEnter(screen.getByTestId('gift-notices')); + act(() => { vi.advanceTimersByTime(10_000); }); + expect(screen.getAllByRole('listitem')).toHaveLength(1); + fireEvent.mouseLeave(screen.getByTestId('gift-notices')); + act(() => { vi.advanceTimersByTime(500); }); + expect(screen.queryByTestId('gift-notices')).toBeNull(); + } finally { vi.useRealTimers(); } + }); + + it('stops its timers when it goes', () => { + vi.useFakeTimers(); + try { + const s = fakeSocket(); + const { unmount } = render(); + s.send(pistol); + unmount(); + expect(vi.getTimerCount()).toBe(0); + } finally { vi.useRealTimers(); } + }); + it('says the game\'s own word for the GM', () => { registerCustomTemplate({ id: 'sys_aaaaaaaaaaaaaaaa', name: 'Hearth', parts: {}, derived: [], sheet: { sections: [] }, words: { gm: { singular: 'Keeper', plural: 'Keepers', short: 'Keeper' } } } as unknown as CustomRender); From c72c472a6056713d8fa8477811ff520787243e10 Mon Sep 17 00:00:00 2001 From: Developer Date: Sun, 22 Nov 2026 14:03:21 -0600 Subject: [PATCH 3/3] feat: gift notices fade in, and fade out before they go, the box with its last; none where motion is turned down --- CHANGELOG.md | 2 +- README.md | 2 +- frontend/src/App.css | 19 +++++++++++++++++ frontend/src/components/GiftNotices.tsx | 21 ++++++++++++++----- .../__tests__/giveFromToken.test.tsx | 14 ++++++++++--- 5 files changed, 48 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 92f4258a..0da2f523 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -802,7 +802,7 @@ Format follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### Changed -- **"THE GM GAVE YOU" notices in one box, gone after 5 seconds.** Gifts now share one box, newest first, instead of stacking a box each, and each goes 5 seconds after it arrives. Hover over the box (or tab into it) to keep it while you read; ✕ closes them all. +- **"THE GM GAVE YOU" notices in one box, gone after 5 seconds.** Gifts now share one box, newest first, instead of stacking a box each, and each fades away 5 seconds after it arrives. Hover over the box (or tab into it) to keep it while you read; ✕ closes them all. - **Slot and install counters only where they are used.** On GEAR, a counter like ATTUNED 0 OF 3 or CYBERWARE · STRAIN 0 OF 2 shows only once something on that sheet needs it, worn, carried or stashed, or while anything is still counted against it. A character with no cyberware no longer sees STRAIN 0 OF 0. - **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. diff --git a/README.md b/README.md index c3161f73..7c68071e 100644 --- a/README.md +++ b/README.md @@ -805,7 +805,7 @@ CITY_NET/ │ │ │ ├── GiveItemWindow.tsx # GIVE.EXE, the GM handing out items free, on the shop's terminal layout: the item being given in the corner; ITEMS (catalogue tabs, a search, each item's worth), TO (HOW MANY, every player character online or not and the map's NPCs, where it would land on each or why not, a note) and GIVEN (the game's last gifts, blinking after a GIVE); GIVE along the bottom. Opened from a token's GIVE_ITEM, that character is ticked. One question to the server at a time, and a preview for a number since changed is dropped; a system's kits beside the items, what is in each said (7c4c) │ │ │ ├── AccelerationNotice.tsx # HARDWARE ACCELERATION IS OFF: a small notice for the GM and players, only when the browser says it draws in software (never a guess), with the steps for their browser (utils/hardwareAccel.ts); DISMISS turns SYSTEM_INFO's WARN ME switch off for good in that browser; not over the system builder, never in an automated browser unless asked │ │ │ ├── MapSlowHelp.tsx # MAP SLOW? in SYSTEM_INFO, for the GM and players: the steps to turn hardware acceleration on in their browser, opened when wanted, and the WARN ME IF HARDWARE ACCELERATION IS OFF switch the notice follows, kept in the browser's local storage -│ │ │ ├── GiftNotices.tsx # What a player sees when the GM gives them something: "THE GM GAVE YOU HEAVY PISTOL x2" in the game's own word for the GM, the note, and that it's already on their sheet; sent to their screens alone, each kept until closed, the newest three; one box, each gift a row, newest first, each going 5 seconds after it came, held while the pointer or focus is on it, ✕ closing them all (2026-11-22) +│ │ │ ├── GiftNotices.tsx # What a player sees when the GM gives them something: "THE GM GAVE YOU HEAVY PISTOL x2" in the game's own word for the GM, the note, and that it's already on their sheet; sent to their screens alone, each kept until closed, the newest three; one box, each gift a row, newest first, each fading in, and out 5 seconds after it came (none where motion is turned down), held while the pointer or focus is on it, ✕ closing them all at once (2026-11-22) │ │ │ ├── GraphAddPalette.tsx # + ADD's search on the graph view: what can be added, searched as typed, arrow keys and Enter, Escape; what comes later greyed with when │ │ │ ├── GraphProblems.tsx # PROBLEMS in the graph view's bottom left corner: errors (✕) and warnings (!) counted, opened to the list in players' names; one on the map a click to its node, one on another page to PROBLEMS │ │ │ ├── GraphPanel.tsx # The graph view's node panel: the node clicked, with the very controls FORMS has (statsRulesFields): a stats group and the modifiers its table gives, a formula's name, text, INSERT, value and alternative, ON THE WAY IN (its diamonds' numbers), REMOVE, a table's rows and TRY IT; a house rule with GO TO HOUSE RULES; a note written (to 1000 characters), pinned to a node or to nothing and removed, its panel named by what it is pinned to; a formula's MAP GROUP (none, one of the map's own, or a new one); a map group's own panel, from its title bar: its name, its formulas each taken out with ×, LINE UP (stacked in one column, a cell apart), UNGROUP; a roll's panel the ROLLS tab's five steps and TEST ROLL (6b4a); ×, Escape or a click on the map closes it. A list of choices says what it gives and goes to CHOICES (7a5c) diff --git a/frontend/src/App.css b/frontend/src/App.css index 4307c646..71a62118 100644 --- a/frontend/src/App.css +++ b/frontend/src/App.css @@ -1371,6 +1371,25 @@ button.choice-off:disabled { .gear-band-news { animation: none; } } +/* The GM's gifts (GiftNotices.tsx): each row fades in, and out over FADE_MS before it goes; the box with its last. */ +@keyframes gift-fade-in { + from { opacity: 0; transform: translateY(-4px); } + to { opacity: 1; transform: none; } +} + +.gift-row, .gift-box { + animation: gift-fade-in 200ms ease-out; + transition: opacity 400ms ease-in; +} + +.gift-row.leaving, .gift-box.leaving { + opacity: 0; +} + +@media (prefers-reduced-motion: reduce) { + .gift-row, .gift-box { animation: none; transition: none; } +} + /* FIND on GEAR (G4) has its own × in the theme; the browser's is blue whatever the theme. */ .gear-find::-webkit-search-cancel-button { -webkit-appearance: none; diff --git a/frontend/src/components/GiftNotices.tsx b/frontend/src/components/GiftNotices.tsx index 4ea3e9a0..08b3a2bc 100644 --- a/frontend/src/components/GiftNotices.tsx +++ b/frontend/src/components/GiftNotices.tsx @@ -11,7 +11,9 @@ import { noticeText, type AskSocket, type ReceivedNotice } from '../sheets/giveI // // One box, each gift a row in it, newest first (the user, 2026-11-22: separate boxes "stack and look bad"); each row goes // 5 seconds after it came ("can we have these time out after 5 seconds?"), held while the pointer or focus is on the box, -// so a player reading one doesn't lose it; ✕ closes them all. +// so a player reading one doesn't lose it; ✕ closes them all. A row fades in, and fades out before it goes (the user: it +// "blinks out of existence"), the box with its last; ✕ is at once, the player's own choice. No fades where motion is +// turned down (App.css). /** How many gifts the box lists at once, newest first. */ export const NOTICES_KEPT = 3; @@ -19,6 +21,8 @@ export const NOTICES_KEPT = 3; export const NOTICE_MS = 5000; /** How often a gift held on the screen looks again whether it may go. */ const HELD_RECHECK_MS = 500; +/** How long a gift takes to fade out before it goes, in ms (the fade in App.css .gift-row.leaving). */ +export const FADE_MS = 400; interface Props { socket: Pick | null; @@ -28,7 +32,7 @@ interface Props { export function GiftNotices({ socket, system }: Props) { const word = useWords(system); - const [notices, setNotices] = useState<(ReceivedNotice & { n: number })[]>([]); + const [notices, setNotices] = useState<(ReceivedNotice & { n: number; leaving?: true })[]>([]); // The pointer or focus on the box: what is being read isn't taken away. const held = useRef(false); @@ -41,7 +45,12 @@ export function GiftNotices({ socket, system }: Props) { count += 1; const n = count; setNotices((prev) => [{ ...notice, n }, ...prev].slice(0, NOTICES_KEPT)); - const go = () => { if (held.current) later(go, HELD_RECHECK_MS); else setNotices((prev) => prev.filter((x) => x.n !== n)); }; + // Its time up: faded out, then gone. + const go = () => { + if (held.current) { later(go, HELD_RECHECK_MS); return; } + setNotices((prev) => prev.map((x) => (x.n === n ? { ...x, leaving: true as const } : x))); + later(() => setNotices((prev) => prev.filter((x) => x.n !== n)), FADE_MS); + }; later(go, NOTICE_MS); }; socket.on('itemReceived', heard); @@ -49,16 +58,18 @@ export function GiftNotices({ socket, system }: Props) { }, [socket]); if (!notices.length) return null; + // The last going: the box fades with it. + const allLeaving = notices.every((g) => g.leaving); return createPortal( -
{ held.current = true; }} onMouseLeave={() => { held.current = false; }} +
{ held.current = true; }} onMouseLeave={() => { held.current = false; }} onFocus={() => { held.current = true; }} onBlur={() => { held.current = false; }} style={{ position: 'fixed', top: 70, left: '50%', transform: 'translateX(-50%)', zIndex: 3000, width: 'min(420px, calc(100vw - 32px))', fontFamily: 'monospace', fontSize: 11, letterSpacing: 1, padding: '8px 10px', background: 'var(--black)', border: '1px solid var(--warning)', color: 'var(--warning)', display: 'flex', gap: 8, alignItems: 'flex-start' }}>
{notices.map((g, i) => ( -
0 ? { borderTop: '1px dashed var(--dark-green)', paddingTop: 6 } : {}) }}> +
0 ? { borderTop: '1px dashed var(--dark-green)', paddingTop: 6 } : {}) }}> {noticeText(g, word('gm', 'short', 'GM'))} {g.note && “{g.note}”}
diff --git a/frontend/src/components/__tests__/giveFromToken.test.tsx b/frontend/src/components/__tests__/giveFromToken.test.tsx index ec3131ce..a8ce87cd 100644 --- a/frontend/src/components/__tests__/giveFromToken.test.tsx +++ b/frontend/src/components/__tests__/giveFromToken.test.tsx @@ -4,7 +4,7 @@ import { render, screen, cleanup, act, within, fireEvent } from '@testing-librar import userEvent from '@testing-library/user-event'; import { buildTokenActions, tokenActionKeys, type TokenActionContext, type TokenViewer } from '../tokenActions'; -import { GiftNotices, NOTICES_KEPT, NOTICE_MS } from '../GiftNotices'; +import { GiftNotices, NOTICES_KEPT, NOTICE_MS, FADE_MS } from '../GiftNotices'; import { GiveItemWindow } from '../GiveItemWindow'; import { registerCustomTemplate, clearCustomTemplates, type CustomRender } from '../../sheets/customTemplates'; import type { AskSocket, ReceivedNotice } from '../../sheets/giveItems'; @@ -144,15 +144,23 @@ describe('the player\'s notice', () => { s.send({ ...pistol, item: 'Second', note: '' }); act(() => { vi.advanceTimersByTime(1999); }); expect(screen.getAllByRole('listitem')).toHaveLength(2); - // The first's 5 seconds: it goes, the second stays. + // The first's 5 seconds: it fades out, then goes; the second stays, the box with it. act(() => { vi.advanceTimersByTime(1); }); + expect(screen.getAllByRole('listitem').map((n) => n.className)).toEqual(['gift-row', 'gift-row leaving']); + expect(screen.getByTestId('gift-notices').className).toBe('gift-box'); + expect(FADE_MS).toBe(400); + act(() => { vi.advanceTimersByTime(FADE_MS); }); expect(screen.getAllByRole('listitem').map((n) => n.textContent?.split(' ×')[0])).toEqual(['THE GM GAVE YOU SECOND']); // Held while read: past its 5 seconds it stays; let go, it goes. fireEvent.mouseEnter(screen.getByTestId('gift-notices')); act(() => { vi.advanceTimersByTime(10_000); }); expect(screen.getAllByRole('listitem')).toHaveLength(1); fireEvent.mouseLeave(screen.getByTestId('gift-notices')); - act(() => { vi.advanceTimersByTime(500); }); + // Looked at again each half second while held (here at 15.5 s, the clock at 15.4): let go, it fades. + act(() => { vi.advanceTimersByTime(100); }); + // The last going: the box fades with it, then is gone. + expect(screen.getByTestId('gift-notices').className).toBe('gift-box leaving'); + act(() => { vi.advanceTimersByTime(FADE_MS); }); expect(screen.queryByTestId('gift-notices')).toBeNull(); } finally { vi.useRealTimers(); } });