diff --git a/CHANGELOG.md b/CHANGELOG.md index ed7e14b3..d0b414a5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -106,6 +106,7 @@ Format follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### Added +- **SOLD AT on an item type, and + NEW SHOP.** On the builder's ITEMS page, each type now shows the game's shops as buttons, by what this game calls them: tick the kinds of shop that sell its lines, or none to have it only given. Type a name into + NEW SHOP (an Apothecary, a Fence) to make a kind of shop of your game's own, shown dashed and ticked. A type from a preset starts at its shop: WEAPON the Gun Shop, ARMOR the Armorer, CONSUMABLE the Clinic, GEAR the General Store; SPELL is sold nowhere, with a Magic Shop ready to ADD. - **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. diff --git a/README.md b/README.md index 47e61980..1da9f598 100644 --- a/README.md +++ b/README.md @@ -932,7 +932,7 @@ CITY_NET/ │ │ │ ├── ChoicesPage.tsx # CHOICES (7a2b1; approved mockup builder-choices, 2026-10-27): the lists a character picks from down the left; the open list with ONE / MANY, A CHARACTER PICKS (ONE, SEVERAL with how many, ANY), MORE THAN ONCE and LEVELLED, a line saying what the list now means (with @_level when levelled), and its options; the open option with its name, words and an optional requirement, its level name in a levelled list, and its features (FeaturesEditor.tsx). DELETE asks first, saying what goes; a "?" beside every setting. A levelled list's option has a HIT DIE (R1b): NONE, D4 to D20, or OTHER with its sides typed, saying what rolls it. A TABLE TO ROLL ON (7a5b): NONE, d6, 2d6, d20, d100 or the system's own dice, sharing the rolls out evenly; PLAYERS PICK (BY HAND, BY HAND OR ROLL, BY ROLL ONLY); each option's roll, with what is wrong beside it; what an option gives: items as typed, money per currency (7c4e) │ │ │ ├── ItemsPage.tsx # ITEMS (7e2b): SLOTS each character has so many of, and ITEMS, each opening to its name, words, what its features need and its features (the CHOICES form without a level, list or increase); where to sell and give them, CATALOGUES.EXE's DOWNLOAD ITEMS and GIVE.EXE (7e3c); INSTALLS (7e4b): each with its name, what it costs against, ADDS TO IT or TAKES FROM IT, NEVER PAST or NEVER BELOW (a formula box), + INSTALL and ×; an item INSTALLED AS one gets a COST; ITEM TYPES above the items (8a2, ItemTypesSection.tsx), and on an item its TYPE and a field for each of its columns; as three tabs (8aL1; approved mockup items-layout, 2026-11-14), TYPES · SLOTS & INSTALLS · ITEMS in the order a system is set up, slots and installs side by side, one line of words each, the tab and the open item kept while the builder is open; ITEMS as a list grouped by type beside the open item (8aL2), + beside each type making one of it with its name selected, FIND filtering as it is typed into, the open item NAME, TYPE and its columns first, then ITS FEATURES NEED, COST, WORDS and its features; IMPORT, DOWNLOAD EXAMPLE and DOWNLOAD THIS LIST under the list (8aL3b), IMPORT opening in place of the open item; a fourth tab, ENCUMBRANCE (8a5c), and an install's WEIGHS WHILE INSTALLED while it counts; a new item IN SHOPS, and NOT SOLD beside one kept out (8a7a3b1) │ │ │ ├── EncumbranceSection.tsx # ENCUMBRANCE on ITEMS (8a5c): COUNTED BY a NUMBER column IN its unit, CAN CARRY a formula box, BANDS each named and placed by the GM and the word past them, what counts as carried, the names formulas read, STOP COUNTING asked first; under each band and past them WHAT IT MEANS and a CONDITION, NONE first, one gone said (8a5d2) -│ │ │ ├── ItemTypesSection.tsx # ITEM TYPES (8a2; approved mockup item-types, 2026-11-14): a tab for each type, + FROM A PRESET (WEAPON, ARMOR, GEAR, CONSUMABLE, SPELL) and + BLANK; the open type's NAME, ONE and its columns, each a name, a KIND and what the kind has (a unit; a button, the rest that refills it and the items it reloads from; PICK ONE's words), + COLUMN, ×, DELETE TYPE asking; on an item, its TYPE and a field for each column by its kind, DAMAGE and DICE a formula box; the types listed beside the open one (8aL1), the DEFAULT first with MAKE DEFAULT on the others, each with how many items are of it, and ON THE SHEET: the open type's table with its first item as the line; an item's PRICE and IN SHOPS under TYPE, its type's PRICE column shown there once, a price asked for while IN SHOPS (8a7a3b1); ON THE SHEET under ONE: EQUIPPED, USABLE or PACK (G1) +│ │ │ ├── ItemTypesSection.tsx # ITEM TYPES (8a2; approved mockup item-types, 2026-11-14): a tab for each type, + FROM A PRESET (WEAPON, ARMOR, GEAR, CONSUMABLE, SPELL) and + BLANK; the open type's NAME, ONE and its columns, each a name, a KIND and what the kind has (a unit; a button, the rest that refills it and the items it reloads from; PICK ONE's words), + COLUMN, ×, DELETE TYPE asking; on an item, its TYPE and a field for each column by its kind, DAMAGE and DICE a formula box; the types listed beside the open one (8aL1), the DEFAULT first with MAKE DEFAULT on the others, each with how many items are of it, and ON THE SHEET: the open type's table with its first item as the line; an item's PRICE and IN SHOPS under TYPE, its type's PRICE column shown there once, a price asked for while IN SHOPS (8a7a3b1); ON THE SHEET under ONE: EQUIPPED, USABLE or PACK (G1); SOLD AT (8a7b2): the game's shops by their names here as chips, the app's solid and its own dashed, one turned off left out unless ticked; + NEW SHOP by ADD or Enter, a name already a shop ticking it; a SPELL from its preset starting the box as Magic Shop │ │ │ ├── ChoicesImport.tsx # IMPORT on a CHOICES list (choices import 2; approved mockup choices-import, 2026-10-28): over the list and option columns, DOWNLOAD THIS LIST and DOWNLOAD EXAMPLE, a file pasted or uploaded, PREVIEW read by the server, mistakes warned of by line (named at the top as links that select the line, marked in the line numbers beside the text), APPLY into the draft only for the text previewed │ │ │ ├── ItemsImport.tsx # IMPORT on the ITEMS tab (8aL3b; approved mockup items-layout, 2026-11-14): beside the list in place of the open item, a file pasted or uploaded, PREVIEW read by the server, mistakes named by line and marked beside the text, APPLY into the draft only for the text previewed, DOWNLOAD THIS LIST and DOWNLOAD EXAMPLE; its box's grey hint from the system (8a7a5) │ │ │ ├── FormulaIcon.tsx # The formula box's button mark: "math format professional" from Microsoft's Fluent UI System Icons (MIT), picked by the user 2026-10-29, drawn in the text's color so it follows the theme @@ -1060,7 +1060,7 @@ CITY_NET/ │ │ │ ├── GmCreatingLine.test.tsx # The GM's line: nothing for a character never asked, SKIP IT straight through, START OVER asking first, a refusal said only after acting │ │ │ ├── NewCharacterWindow.test.tsx # The ways in as folders, each step's folder and NEXT, BACK, a pick taken back, why the server said no, leaving and finishing, the sheet's CREATING · CONTINUE; a group's own step; a fixed array placed, taken back, NEXT held until each stat has one; ROLL THEM, in order and to arrange, kept; a point buy, as far as the points go; kits picked, put back, one not met off; starting money, said, rolled and typed │ │ │ ├── FeaturesEditor.test.tsx # Features grouped by level in order, tagged, none explained; + FEATURE at the highest level, opened; one open at a time; the limit; a level set on leaving the box or Enter (and a blank one put back); modifiers from the three groups, added and removed; uses on with a count and a rest, the GM's to refill with none, off; rolls given and a roll's change (another roll taking its own first change); a list opened, never its own; where to make what isn't there yet; DELETE asking first; every "?" -│ │ │ ├── ItemsPage.test.tsx # ITEMS (7e2b): a slot named, counted, added and removed (an item needing it back to worn), an item opened, named, worded, its needs, its features without a level, list or increase, + ITEM, DELETE ITEM asking, a gone slot kept, on the rail and in HELP; INSTALLS (7e4b): name, what it costs against (never the token's maximum), which way and its limit, + INSTALL and ×, an item's COST; ITEM TYPES (8a2): GEAR to start, a preset beside it, a name and ONE, each kind's parts, PICK ONE's words typed with commas, a COUNT's rest and reloads, DELETE TYPE asking, none past ten, an item's TYPE and a field of each kind; the tabs (8aL1): in setup order, a line each, the tab and the open item kept and another system starting on TYPES, DEFAULT and MAKE DEFAULT, ON THE SHEET; the list beside the open item (8aL2): grouped by type, the first open, a line's short need, the field order, + beside a type with its name selected, FIND as it is typed into, at the most; ENCUMBRANCE (8a5c): COUNT ENCUMBRANCE starting it, COUNTED BY and its unit, CAN CARRY, bands named and placed and out of order said, STOP COUNTING asked, an install's WEIGHS only while counting; a band's WHAT IT MEANS and CONDITION, and past them, one gone said, a game with none (8a5d2); PRICE and IN SHOPS under TYPE, NOT SOLD, a new item's price asked for (8a7a3b1) +│ │ │ ├── ItemsPage.test.tsx # ITEMS (7e2b): a slot named, counted, added and removed (an item needing it back to worn), an item opened, named, worded, its needs, its features without a level, list or increase, + ITEM, DELETE ITEM asking, a gone slot kept, on the rail and in HELP; INSTALLS (7e4b): name, what it costs against (never the token's maximum), which way and its limit, + INSTALL and ×, an item's COST; ITEM TYPES (8a2): GEAR to start, a preset beside it, a name and ONE, each kind's parts, PICK ONE's words typed with commas, a COUNT's rest and reloads, DELETE TYPE asking, none past ten, an item's TYPE and a field of each kind; the tabs (8aL1): in setup order, a line each, the tab and the open item kept and another system starting on TYPES, DEFAULT and MAKE DEFAULT, ON THE SHEET; the list beside the open item (8aL2): grouped by type, the first open, a line's short need, the field order, + beside a type with its name selected, FIND as it is typed into, at the most; ENCUMBRANCE (8a5c): COUNT ENCUMBRANCE starting it, COUNTED BY and its unit, CAN CARRY, bands named and placed and out of order said, STOP COUNTING asked, an install's WEIGHS only while counting; a band's WHAT IT MEANS and CONDITION, and past them, one gone said, a game with none (8a5d2); PRICE and IN SHOPS under TYPE, NOT SOLD, a new item's price asked for (8a7a3b1); SOLD AT (8a7b2): the game's shops named, one off left out, ticks stored and said; + NEW SHOP by ADD and Enter, dashed and ticked, a name already a shop ticking it; a preset's shop, SPELL's Magic Shop to ADD │ │ │ ├── bonusWays.test.tsx # The ways a bonus counts in the builder (7e1b): ADD or AT LEAST on a modifier, an ADD's STOPS AT, neither on the token's maximum, AT LEAST in words, the "?" │ │ │ ├── PublishPreviewPage.test.tsx # The PUBLISH page on the server's own comparisons: BY CHANGE with each one's value and KEPT, BY CHARACTER with an NPC marked and NOTHING CHANGES, the SAMPLE with no tabs, a version that changes nothing a character sees, problems, and the buttons │ │ │ ├── TableConditionsPanel.test.tsx # The GAME tab's conditions against a fake server running the real checks: standard ones folded, the table's own listed, one added with a drawn or uploaded icon and sent whole with the GM's login, removed only once asked, a refusal said with the typing kept, + CONDITION stopping at 60, and the panel only for the main admin under a built-in game @@ -1249,7 +1249,7 @@ CITY_NET/ │ │ │ ├── systemsLibrary.ts # What MY SYSTEMS says about each system: its badges, version, facts, what an install offers (BRING IT BACK or START FRESH for one deleted here), and the messages after a rename, duplicate, delete or install │ │ │ ├── builderSession.ts # The builder's saving as rules: autosave after a pause, SAVE now, whether leaving needs asking, what PUBLISH says, and its pages (HOUSE RULES between RESTS and TRY IT); ITEMS on the rail, after CHOICES (7e2b); the publish sentence says how many catalogue lines it took out (8a7a4b) │ │ │ ├── setup.ts # SETUP as logic: the health models, advancement, dice and distance it offers, each model's starting shape, and the answers read from and written to a definition -│ │ │ ├── wordsFeatures.ts # WORDS and PARTS as logic: terms and their forms, parts and what turning one off greys, building types, catalogues and currencies written back to a definition; a part's house rule (ONLY WITH), kept when the part is switched +│ │ │ ├── wordsFeatures.ts # WORDS and PARTS as logic: terms and their forms, parts and what turning one off greys, building types, catalogues and currencies written back to a definition; a part's house rule (ONLY WITH), kept when the part is switched; withBuilding keeps a shop's BUYS (8a7b2) │ │ │ ├── dice.ts # The DICE tab as logic (6c2a): a system's own dice and symbols read and written back, three presets (dF, GOOD / GREAT / BAD, a d6 with a word), a die renamed, colored, its faces counted and each face a number and up to six symbols, symbols cancelling as a pair (old partners let go) and counting as another one step at a time (alsoChoices), removed off every face; COPY FROM THE TABLE'S DICE (numbers stay numbers, words become symbols); a face as the log writes it; a symbol's look set (withSymbolLook, a mark always kept for the log) and the pad's drawing a square at a time (withSquare, drawnAt, drawnSquares); more faces on a die numbered 1, 2, 3 carry its numbering on (6c3) │ │ │ ├── rolls.ts # The ROLLS tab as logic: a system's rolls read and written back, a new one from a preset (the server's presets, held equal), ids from first names and kept, a preset's steps swapped in, renamed, ROLLED BY stats, groups and formulas, removed; each step changed (dice kinds up to six, never none, a named kind's effects going with it; the read, dropping a keep count, a success face, cancelling or a die taken away that only the old read used; ADD; a target and rolling under; bands as a table's, the last always catching the rest; the special results each switched on with a default, changed, off, ten at most of a kind, words kept even when empty; the changes added (ids from first names), changed, capped, never doing nothing, removed; what a change can cost); what can roll it and the fields it rolls (the server's own, held equal); its five steps in words (6− · 7–9 · 10+, negatives spelled out); a kind of dice made one of the system's own (6c3: its faces and name come with it), read as COUNT THE SYMBOLS with what is left of a symbol, both in the tab's words by name │ │ │ ├── targetSeen.ts # Who sees a roll's target, the builder's side (6c4h): SHOWN, VERDICT ONLY and GM ONLY with their lines, the system's (SHOWN where it has none) and a roll's own, set or back to the system's, and the examples: the live preview, HELP's STEALTH roll on two trays, what each setting keeps @@ -1290,7 +1290,8 @@ CITY_NET/ │ │ │ ├── houseRules.ts # HOUSE RULES as logic: a system's own house rules (up to 20, a new one starting off), changed keeping their ids, deleted leaving what waited on them always there (no part, section or condition waits on it, a formula loses its alternative), and what waits on a rule with the page GO TO opens; the draft as it would be worked out with one rule on, or as the game would run it with a set of rules on (the server's withHouseRules mirrored, held to it); the rules a running game has on (useHouseRules) and the boxes changed from them; held to the server's checks │ │ │ ├── choices.ts # CHOICES as logic (7a2b1): a system's lists and their options read, made (named to rename, ids free of every option's, feature's and level name's), changed (one pick, not levelled and not again store nothing; several capped) and removed (a list taking with it any feature opening it; an option from its own list only), and the level names formulas read; an option's features (7a2b2) made at a level, changed (blank words, level 1 or any level outside a levelled list, empty lists, no uses and no list store nothing; a level past the highest is the highest) and removed, what each does as tags, and what a feature can name: the stats, formulas and health fields, every rest (the off ones said so), the rolls and their changes. Mirrors backend choices.js, every edit held to its checks. A levelled list's option's die (R1b), kept to 2 to 100 sides and taken away with LEVELLED. A list's table (7a5b): its dice, the rolls shared out evenly, each option's roll, how players pick, and what is wrong with the table in the server's words; taken away, rolls and all, with NONE or EVERYONE HAS IT; an INCREASE kept and said in words (7d6a); the list an increase offers instead (7d6c1); a modifier's way and where it stops, and which field is the token's maximum (7e1b); the names taken shared with items, and a feature kept tidy for an item too (7e2b) │ │ │ ├── items.ts # ITEMS as logic (7e2b): slots and items read and written back, what an item's features need in words, an item's features kept as a pick's but never at a level; installs read and written back (7e4b), kept by every other edit, sharing the slots' names; an item needing one costs 1 to start, 0 to 1000, fractions allowed, none otherwise; INSTALLED AS in what an item needs; the item types and each item's type and values kept by every edit (8a1); a deleted item is reloaded from no longer (8a2); an item's words 1000 characters at most, as the server checks them (8aL3b; it said 2000); an install's weighs (8a5c); an item's own price and in_shops (8a7a3b1) -│ │ │ ├── itemTypes.ts # ITEM TYPES as logic (8a2): GEAR where a system makes none, the presets, types made, named and removed (their items to the first left), columns made, changed (a new kind keeps its own parts, its values gone from the items), removed with their values; an item's type (keeping the values both types have) and values; a rest or item deleted taken off a COUNT; mirrors the server's itemTypes.js; a type made the DEFAULT, moved to the top, the items that said nothing said to be the old default so none changes type (8aL1); an item's PRICE (in its type's PRICE column, else its own) and IN SHOPS, read as the server reads them, its price going with it to another type (8a7a3b1); a type's band on the sheet (BANDS, bandOf; the presets' own; PACK stores nothing, G1) +│ │ │ ├── itemTypes.ts # ITEM TYPES as logic (8a2): GEAR where a system makes none, the presets, types made, named and removed (their items to the first left), columns made, changed (a new kind keeps its own parts, its values gone from the items), removed with their values; an item's type (keeping the values both types have) and values; a rest or item deleted taken off a COUNT; mirrors the server's itemTypes.js; a type made the DEFAULT, moved to the top, the items that said nothing said to be the old default so none changes type (8aL1); an item's PRICE (in its type's PRICE column, else its own) and IN SHOPS, read as the server reads them, its price going with it to another type (8a7a3b1); a type's band on the sheet (BANDS, bandOf; the presets' own; PACK stores nothing, G1); each preset's SOLD AT (WEAPON the Gun Shop, ARMOR the Armorer, CONSUMABLE the Clinic, GEAR unsaid, SPELL none) and PRESET_NEW_SHOP (8a7b2) +│ │ │ ├── gameShops.ts # SOLD AT and the game's own shops as logic (8a7b2): the shops to tick (the app's by their names here, then its own), a type's (the General Store unsaid), ticks kept in the shops' order, + NEW SHOP (id from its name, never one the app has, a name already a shop that one, at most 20), the words under them │ │ │ ├── encumbrance.ts # The builder's ENCUMBRANCE as logic (8a5c; approved mockup item-types, 2026-11-14, decision 7): read and written back tidy, the NUMBER columns it can count with their types, how it starts (WEIGHT, ten times the first stat, LIGHT 50 / ENCUMBERED 100 / OVERLOADED), the bands, and the names formulas read of the gear for INSERT; a band's words and condition, and past them, kept through every edit (8a5d1); blank words and NONE kept as nothing, words cut at 200 (8a5d2) │ │ │ ├── ranks.ts # The builder's ranks as logic (7f1b): lists from four presets or empty, renamed and removed (their stats back to numbers), ranks added, changed, moved and removed (a stat's highest at the start following), a stat's HOLDS and AT START │ │ │ ├── gearItems.ts # Items on the GEAR tab as logic (7e3b): which gear line draws which item (by name, the first carried), what the last save worked out, each line's buttons and words (WEAR, ATTUNE, the GM's ATTUNE ANYWAY, WORKING, why it does nothing), a slot's verb from its name (ATTUNED → ATTUNE), the counters, the GM's own count asked, an item's uses; installed items (7e4c): INSTALL with room, a player's disabled past the limit and why, the GM's INSTALL ANYWAY, INSTALLED · REMOVE, each install's counter (CYBERWARE · STRAIN 2.75 OF 3, or NEVER BELOW), the names installed; the render copy's item types, and each item's type and values (8a3a); countersInUse (2026-11-22): the slots and installs a sheet has a use for, one an item on a line needs or one with something still counted against it @@ -1389,6 +1390,7 @@ CITY_NET/ │ │ │ ├── catalogueSchema.test.ts # An uploaded catalogue's columns derived from each system's own template, so the downloaded example can't drift │ │ │ ├── typedShelves.test.ts # A type's shelf (8a7a2): at the kinds of shop its SOLD AT says, named as the type, where a line lands said; a line bought from it typed, stacked only onto the same thing untouched, exactly as the server places it; sold back from the window, found on its type's shelf, an item kept out of the shops priced at its own (8a7a3c2) │ │ │ ├── shopBuys.test.ts # What a shop BUYS (8a7b1b): ANYTHING on the app's shops and the game's own, every shelf the game has on and each of its types' bought back, not one turned off; a built-in game as ever +│ │ │ ├── gameShops.test.ts # SOLD AT and + NEW SHOP (8a7b2): the shops named as the game names them, ticks in order, a shop made from a name or found by it, blank and past 20 refused, the words, each preset's shop; FEATURES keeping BUYS │ │ │ ├── itemPrice.test.ts # An item's PRICE and IN SHOPS on the ITEMS page (8a7a3b1): in its type's PRICE column or its own, IN SHOPS and a price needed, held to the server's itemPrice and inShops on the same items; changed, and kept on a change of type │ │ │ ├── catalogueTypes.test.ts # A type in a file (8a7a1): its heading and columns, only a custom system's own; EXAMPLE, CURRENT and ITEMS each back through the server's reader with every column; a type's section as gear in the preview │ │ │ ├── catalogueRoundTrip.test.ts # The example the app hands out surviving being handed back to the server's parser @@ -1517,6 +1519,7 @@ CITY_NET/ │ ├── builder-item-price.spec.ts # PRICE and IN SHOPS on ITEMS (8a7a3b1): the Pistol's in its type's PRICE column, once, changed; the Rope given its own; the Ring kept out, NOT SOLD; a new armor's price asked for, then given; saved, no problems │ ├── builder-items-import.spec.ts # Uploading items (8aL3b): DOWNLOAD EXAMPLE made from the system, edited, pasted into IMPORT and PREVIEWed with a mistake named by its line, APPLY, saved as made │ ├── builder-item-types.spec.ts # ITEM TYPES (8a2): WEAPONS from its preset beside GEAR, AMMO refilled by a long rest and reloaded from Pistol Rounds, a GRADE picking LIGHT or HEAVY, and a Pistol filling each column, made by clicks, saved as made, kept after a reload +│ ├── builder-sold-at.spec.ts # SOLD AT (8a7b2): WEAPONS from its preset at the Gun Shop, an Apothecary made by + NEW SHOP and ticked, SPELLS' Magic Shop ADDed, saved as made; that game at the table, a Pistol bought at a Gun Shop │ ├── builder-encumbrance.spec.ts # ENCUMBRANCE on ITEMS (8a5c): counted by GEAR's WEIGHT, CAN CARRY five times Might, the first band renamed and moved, a third added, the word past them changed, CYBERWARE still weighing, saved as made and kept after a reload; ENCUMBERED saying what it means and putting EXHAUSTED on, past them saying theirs (8a5d2) │ ├── builder-condition-modifiers.spec.ts # A condition's modifiers on CONDITIONS (8a5e2): SLOWED made by clicks with the SNAIL icon (8a5i), APPLIED, Speed TIMES 0.5 and Might by a formula, saved as made and kept after a reload │ ├── builder-condition-each-turn.spec.ts # A condition's EACH TURN on CONDITIONS (8a9b): BURNING burning each turn after 3 rounds, POISONED's save rolled by the player, STUNNED ending next turn; saved, nothing to fix, kept after a reload diff --git a/e2e/COVERAGE.md b/e2e/COVERAGE.md index 529d1105..4526dc26 100644 --- a/e2e/COVERAGE.md +++ b/e2e/COVERAGE.md @@ -34,8 +34,8 @@ panel), so a control that looks fine but does nothing is caught for all of them. | GIVE ITEM and shop catalogues | a catalogue typed in, an item given with a note | `shops_give`, `shop_catalogue_*` | `player-journey`, `shop-cart-items` (a catalogue saved while a player is online, bought by them through the cart, 8n1), `shop-cart` (CWN's book: bought and sold back, 8n1), `give-item` (a ring and two ropes given, on the sheet as bought ones are, in GIVEN, 8n2) | **AT THE TABLE** | | Shop catalogues by item type | a section per item type (8a7a1), its columns checked, blanks kept | `shop_catalogue_types`, `catalogueTypes` | `catalogue-types`, `shop-typed-lines` (bought at the General Store and given, landing typed, 8a7a2) | **AT THE TABLE** | | The shops under load | 1000+ lines on a shelf, 200 items, a full cart, a long gear list (8n3); a long shelf drawn 200 rows at a time | `shop_stress`, `ShopWindow` | `shop-stress` | **AT THE TABLE** | -| An item type's SOLD AT | the kinds of shop that sell its lines (8a7a2), the General Store where unsaid; set in the builder in 8a7b | `shop_typed_lines`, `typedShelves` | `shop-typed-lines` (unsaid: the General Store) | **AT THE TABLE** unsaid; a kind of shop picked waits for 8a7b's box | -| The game's own shops, and what a shop BUYS | an Apothecary or a Fence of the game's own (8a7b1a), on or off; a shop's BUYS, WHAT IT SELLS or ANYTHING, every priced thing at the building's BUYBACK rate (8a7b1b) | `system_builder_own_shops`, `system_builder_shop_buys`, `shopBuys`, `ShopWindow` | | **GAP** until the builder sets them: + NEW SHOP in 8a7b2, BUYS and the BUILDING TYPE list in 8a7b3, each with its journey | +| An item type's SOLD AT | the kinds of shop that sell its lines (8a7a2), the General Store where unsaid; ticked in the builder (8a7b2), each preset at its shop | `shop_typed_lines`, `typedShelves`, `gameShops`, `ItemsPage` | `shop-typed-lines` (unsaid: the General Store), `builder-sold-at` (ticked by clicks: a Pistol bought at a Gun Shop) | **AT THE TABLE** | +| The game's own shops, and what a shop BUYS | an Apothecary or a Fence of the game's own (8a7b1a), on or off; a shop's BUYS, WHAT IT SELLS or ANYTHING, every priced thing at the building's BUYBACK rate (8a7b1b) | `system_builder_own_shops`, `gameShops`, `system_builder_shop_buys`, `shopBuys`, `ShopWindow` | `builder-sold-at` (an Apothecary made by + NEW SHOP, saved) | **GAP** at the table until a building can be one: BUYS and the BUILDING TYPE list in 8a7b3, each with its journey | | 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** | diff --git a/e2e/README.md b/e2e/README.md index 93562611..9f119e3d 100644 --- a/e2e/README.md +++ b/e2e/README.md @@ -172,6 +172,7 @@ kept; the job itself stops at 30 (`timeout-minutes`), for a hang outside the tes | `tests/builder-items.spec.ts` | ITEMS (7e2b): + SLOT named ATTUNED with three each; + ITEM named Ring of Constitution, worded, needing WORN AND ATTUNED, with a feature Hardy giving +2 Con that STOPS AT 20, and no level, list or increase on it; saved with no problems as made, and kept after a reload. A second test (7e4b): + INSTALL made CYBERWARE costing against Strain, NEVER PAST @might (read in words), and a Cranial Jack INSTALLED AS CYBERWARE at a COST of 0.25, saved as made and there after a reload; on their tabs since 8aL1, each item made from + beside GEAR since 8aL2 | | `tests/builder-items-import.spec.ts` | Uploading items (8aL3b): on the ITEMS tab, DOWNLOAD EXAMPLE gives a file made from the system (WEAPONS with its DAMAGE and GRADE); edited (a Hand Crossbow named, a Bad Bow with a GRADE the column hasn't), pasted into IMPORT and PREVIEWed: the crossbow new, the bow skipped by its line; APPLY, the crossbow in WEAPONS, saved with no problems Since 8a7a3b2 the example has PRICE and IN SHOPS too, and the crossbow imported from it is priced 25 and IN SHOPS. | | `tests/builder-item-types.spec.ts` | ITEM TYPES (8a2; on their tabs since 8aL1): GEAR said to start on TYPES, where the page opens; WEAPONS from its preset, opened beside it; its AMMO refilled by LONG REST and reloaded from Pistol Rounds; + COLUMN named GRADE, PICK ONE of LIGHT, HEAVY; + ITEM named Pistol, a WEAPON, its DAMAGE, RANGE, AMMO, WEIGHT and GRADE filled; saved with no problems, the types and items as made; after a reload the Pistol a WEAPON and WEAPONS beside GEAR; since 8aL2 the Pistol made from + WEAPON, its name focused to type over, and FIND narrowing the list to the rounds, 1 OF 2 Since G1 the WEAPON preset starts EQUIPPED, checked on its ON THE SHEET buttons and in the saved draft. | +| `tests/builder-sold-at.spec.ts` | SOLD AT and + NEW SHOP on a type (8a7b2). WEAPONS from its preset starts at the Gun Shop, said under the chips; an Apothecary typed into + NEW SHOP and made by Enter is ticked, and the words say shops this game made are dashed; SPELLS from theirs is sold nowhere, Magic Shop filled in, ADDed and ticked. Saved as made (problems none, the shops and each type's SOLD AT). Then that game runs with a priced Pistol: a player paid 1000 buys it at a Gun Shop's WEAPONS shelf, 800 left. | | `tests/builder-encumbrance.spec.ts` | ENCUMBRANCE on the builder's ITEMS page (8a5c): COUNT ENCUMBRANCE starting on GEAR's WEIGHT, CAN CARRY set to five times Might, the first band renamed UNBURDENED up to 40%, a third band HEAVY, the word past them CRUSHED, and the CYBERWARE install still weighing while installed; saved as made, there after a reload; and (8a5d2) ENCUMBERED saying "Speed -10 ft." and putting EXHAUSTED on, past them saying "Speed -20 ft.", kept after a reload | | `tests/builder-condition-modifiers.spec.ts` | A condition's modifiers on the builder's CONDITIONS page (8a5e2): SLOWED made by clicks with the SNAIL icon (8a5i), ITS MODIFIERS APPLIED, Speed TIMES 0.5 and Might less by `@speed / -10`; saved as made, APPLIED, its way and its formula there after a reload | | `tests/builder-condition-each-turn.spec.ts` | A condition's EACH TURN on the builder's CONDITIONS page (8a9b): BURNING made by clicks, ending after 3 rounds, + EACH TURN giving 1d4 damage at the start of its turn onto the token; POISONED a save at the end of its turn, d20 + @con_mod, off on 13, rolled by the player, its line in words saying Con mod; STUNNED ending AT THE END OF ITS NEXT TURN. Saved with nothing to fix, each as made after a reload | diff --git a/e2e/tests/builder-clicks.spec.ts b/e2e/tests/builder-clicks.spec.ts index 561d416c..ce045b3a 100644 --- a/e2e/tests/builder-clicks.spec.ts +++ b/e2e/tests/builder-clicks.spec.ts @@ -148,6 +148,10 @@ test('every control in the builder takes a click, on every page', async ({ page await expect(weapons.getByRole('textbox', { name: 'NEW COLUMN words' })).toBeVisible(); await expect(weapons.getByRole('button', { name: 'MAKE DEFAULT' })).toBeVisible(); await expect(weapons.getByRole('group', { name: 'WEAPONS on the sheet' })).toBeVisible(); + // SOLD AT (8a7b2), with a shop of the game's own made, so a dashed chip is there too. + await weapons.getByRole('textbox', { name: 'New shop name' }).fill('Apothecary'); + await weapons.getByRole('button', { name: 'ADD', exact: true }).click(); + await expect(weapons.getByRole('group', { name: 'WEAPONS sold at' }).getByRole('button', { name: 'Apothecary' })).toHaveAttribute('aria-pressed', 'true'); missed['ITEMS · TYPES'] = await faults(page); // A slot and an install (7e2b, 7e4b), side by side. await itemsTab('SLOTS & INSTALLS').click(); diff --git a/e2e/tests/builder-item-types.spec.ts b/e2e/tests/builder-item-types.spec.ts index 30b6a45d..1308fc83 100644 --- a/e2e/tests/builder-item-types.spec.ts +++ b/e2e/tests/builder-item-types.spec.ts @@ -72,7 +72,8 @@ test('ITEM TYPES: WEAPONS from its preset with AMMO and a GRADE, and a Pistol fi expect(saved.draft.items).toEqual({ types: [ { id: 'gear', label: 'GEAR', one: 'Gear', columns: [{ id: 'weight', label: 'WEIGHT', kind: 'number', unit: 'LB' }, { id: 'price', label: 'PRICE', kind: 'number' }] }, - { id: 'weapons', label: 'WEAPONS', one: 'Weapon', on_sheet: 'equipped', columns: [ + // Sold at the Gun Shop, as its preset suggests (8a7b2). + { id: 'weapons', label: 'WEAPONS', one: 'Weapon', on_sheet: 'equipped', sold_at: ['gun_shop'], columns: [ { id: 'damage', label: 'DAMAGE', kind: 'damage' }, { id: 'range', label: 'RANGE', kind: 'text' }, { id: 'ammo', label: 'AMMO', kind: 'count', button: 'FIRE', refill: 'long_rest', reload: ['rounds'] }, { id: 'weight', label: 'WEIGHT', kind: 'number', unit: 'LB' }, { id: 'price', label: 'PRICE', kind: 'number' }, diff --git a/e2e/tests/builder-sold-at.spec.ts b/e2e/tests/builder-sold-at.spec.ts new file mode 100644 index 00000000..2de7fd57 --- /dev/null +++ b/e2e/tests/builder-sold-at.spec.ts @@ -0,0 +1,94 @@ +import { test, expect } from '@playwright/test'; +import { signInAsGm, signInAsPlayer, openBuilder, builderPage, gmToken, asGm, runningSystem, approvedPlayer } from './helpers'; +import { playerToken, payPlayer } from './shops'; + +// SOLD AT on a type, and + NEW SHOP (8a7b2; approved mockup docs/mockups/types-in-shops.html, section 2). By clicks: WEAPONS +// from its preset, sold at the Gun Shop to start; an Apothecary of the game's own made and ticked too; SPELLS from theirs, +// sold nowhere, its Magic Shop filled in and ADDed. Saved as made. Then that game at the table: a Pistol of WEAPONS bought +// at a Gun Shop. + +test('SOLD AT: WEAPONS at the Gun Shop and a new Apothecary, SPELLS at a Magic Shop, saved; a Pistol bought at a Gun Shop (8a7b2)', async ({ page, browser, request }, info) => { + test.setTimeout(180_000); + const again = info.retry ? ` ${info.retry + 1}` : ''; + const name = `Soldfall${again}`; + const gm = await gmToken(request); + const { id } = await asGm(request, gm, 'post', '/api/systems', { definition: { format: 1, name, core: { health: { model: 'pool' } }, + stats: [{ id: 'abilities', label: 'ABILITIES', stats: [{ id: 'might', label: 'Might' }] }] } }); + await page.setViewportSize({ width: 1280, height: 800 }); + await signInAsGm(page); + await openBuilder(page); + const card = page.getByTestId(/^system-/).filter({ hasText: name.toUpperCase() }); + if (!(await card.getByRole('button', { name: 'OPEN', exact: true }).isVisible())) await card.getByRole('button').first().click(); + await card.getByRole('button', { name: 'OPEN', exact: true }).click(); + await builderPage(page, 'ITEMS'); + + // WEAPONS from its preset: the Gun Shop ticked, said. + const types = page.getByRole('region', { name: 'Item types' }); + const presets = types.getByRole('group', { name: 'Add an item type' }); + await presets.getByRole('button', { name: 'WEAPON', exact: true }).click(); + const weapons = page.getByRole('region', { name: 'WEAPONS type' }); + const soldAt = weapons.getByRole('group', { name: 'WEAPONS sold at' }); + await expect(soldAt.getByRole('button', { name: 'Gun Shop' })).toHaveAttribute('aria-pressed', 'true'); + await expect(soldAt.getByRole('button', { name: 'General Store' })).toHaveAttribute('aria-pressed', 'false'); + await expect(weapons.getByText('Sold at every Gun Shop in this game.')).toBeVisible(); + + // + NEW SHOP: an Apothecary, made by Enter, dashed and ticked. + await weapons.getByRole('textbox', { name: 'New shop name' }).fill('Apothecary'); + await weapons.getByRole('textbox', { name: 'New shop name' }).press('Enter'); + await expect(soldAt.getByRole('button', { name: 'Apothecary' })).toHaveAttribute('aria-pressed', 'true'); + await expect(weapons.getByText('Sold at every Gun Shop, every Apothecary in this game. Dashed: shops this game made.')).toBeVisible(); + + // SPELLS from theirs: sold nowhere, a Magic Shop ready to ADD; ADDed, ticked. + await presets.getByRole('button', { name: 'SPELL', exact: true }).click(); + const spells = page.getByRole('region', { name: 'SPELLS type' }); + await expect(spells.getByText('Sold nowhere: only given, from GIVE.EXE.')).toBeVisible(); + await expect(spells.getByRole('textbox', { name: 'New shop name' })).toHaveValue('Magic Shop'); + await spells.getByRole('button', { name: 'ADD', exact: true }).click(); + await expect(spells.getByRole('group', { name: 'SPELLS sold at' }).getByRole('button', { name: 'Magic Shop' })).toHaveAttribute('aria-pressed', 'true'); + + await expect(page.getByTestId('save-status')).toHaveText(/· SAVED /, { timeout: 15_000 }); + const saved = await asGm(request, gm, 'get', `/api/systems/${id}`); + expect(saved.problems).toEqual([]); + expect(saved.draft.buildings).toEqual({ shops: [{ id: 'apothecary', name: 'Apothecary' }, { id: 'magic_shop', name: 'Magic Shop' }] }); + const soldAtOf = (typeId: string) => saved.draft.items.types.find((t: { id: string }) => t.id === typeId).sold_at; + expect(soldAtOf('weapons')).toEqual(['gun_shop', 'apothecary']); + expect(soldAtOf('spells')).toEqual(['magic_shop']); + expect(saved.draft.items.types.find((t: { id: string }) => t.id === 'gear')).not.toHaveProperty('sold_at'); + + // At the table: that game, a priced Pistol of WEAPONS, a Gun Shop on the map, a player with 1000. + const table = { ...saved.draft, name: `Soldfall Table${again}`, items: { ...saved.draft.items, + list: [{ id: 'pistol', label: 'Pistol', type: 'weapons', values: { damage: '2d6', price: 200 }, in_shops: true }] } }; + await runningSystem(request, gm, table); + const player = { username: `e2e_soldfall${again ? `_${info.retry + 1}` : ''}`, password: 'e2e-player-password' }; + await approvedPlayer(request, gm, player); + await playerToken(request, gm, player.username); + const shop = `SOLDFALL_ARMS${again ? `_${info.retry + 1}` : ''}`; + const made = await asGm(request, gm, 'post', '/api/locations', { name: shop, description: '', shape: 'box', x: 10, y: 0, z: 10, width: 2, height: 2, depth: 2 }); + const typed = await request.patch(`/api/locations/${made.data[0].id}/building-type`, { data: { building_type: 'gun_shop' }, headers: { Authorization: `Bearer ${gm}` } }); + expect(typed.ok(), await typed.text()).toBe(true); + + const context = await browser.newContext({ baseURL: info.project.use.baseURL, viewport: { width: 1280, height: 800 } }); + const mine = await context.newPage(); + 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 expect(mine.getByRole('group', { name: 'Vitals' })).toBeVisible({ timeout: 15_000 }); + await mine.keyboard.press('Escape'); + await page.reload(); + await signInAsGm(page); + await payPlayer(page, player.username, 1000); + + // The Gun Shop's WEAPONS shelf has the Pistol; bought, paid for. + await mine.getByRole('button', { name: 'QUICK_ACCESS', exact: true }).click(); + const list = mine.locator('.quick-access-panel'); + await list.getByText(/DEFINED_STRUCTURES/).click(); + await list.getByText(shop, { exact: true }).click(); + await mine.getByRole('button', { name: 'SHOP', exact: true }).click(); + const window = mine.locator('.win95-window', { has: mine.getByText(`SHOP.EXE · ${shop}`, { exact: true }) }); + await window.getByRole('tab', { name: 'WEAPONS' }).click({ timeout: 15_000 }); + await window.getByRole('button', { name: 'Add Pistol to the cart' }).click(); + await window.getByRole('tab', { name: 'CART' }).click(); + await window.getByRole('button', { name: 'CHECK OUT' }).click(); + await expect(window.getByRole('tabpanel')).toContainText('BALANCE 800cr', { timeout: 15_000 }); + await context.close(); +}); diff --git a/frontend/src/components/ItemTypesSection.tsx b/frontend/src/components/ItemTypesSection.tsx index d0542079..9de52eef 100644 --- a/frontend/src/components/ItemTypesSection.tsx +++ b/frontend/src/components/ItemTypesSection.tsx @@ -3,8 +3,10 @@ import type { Definition, systemsApi } from '../sheets/systemsApi'; import { itemTypes, ownTypes, typeOf, itemValues, withNewType, withType, withoutType, withDefaultType, withNewColumn, withColumn, withoutColumn, withItemType, withItemValue, wordsFrom, KINDS, PRESETS, LIMITS, type ItemColumn, type ItemType, type ColumnKind, - priceColumnOf, itemPriceOf, inShopsOf, priceNeeded, withItemPrice, withInShops, MOST_PRICE, BANDS, bandOf, + priceColumnOf, itemPriceOf, inShopsOf, priceNeeded, withItemPrice, withInShops, MOST_PRICE, BANDS, bandOf, PRESET_NEW_SHOP, } from '../sheets/itemTypes'; +import { shopChoices, soldAtOf, withSoldAtToggled, withNewShop, soldAtWords, ownShopsOf, SHOPS_MOST } from '../sheets/gameShops'; +import { BUILDING_NAME_LIMIT } from '../sheets/wordsFeatures'; import { ToggleSwitch } from './ToggleSwitch'; import { itemList, type Item } from '../sheets/items'; import { restsOf } from '../sheets/rests'; @@ -127,6 +129,49 @@ function OnTheSheet({ definition, type }: Props & { type: ItemType }) { ); } +/** + * SOLD AT (8a7b2; approved mockup docs/mockups/types-in-shops.html, section 2): the game's shops by their names here, each a + * button to tick, the shops the game made dashed; and + NEW SHOP, a name typed and ADDed (or Enter) making one of its own, + * ticked. A name that is already a shop ticks that one. `shopName` is what the box holds, kept by the section so a SPELL + * made from its preset can start it as "Magic Shop". + */ +function SoldAt({ definition, edit, type, shopName, setShopName }: Props & { type: ItemType; shopName: string; setShopName: (name: string) => void }) { + const ticked = soldAtOf(type); + // A shop turned off on FEATURES is left out, unless the type is still sold at it. + const choices = shopChoices(definition).filter((c) => c.on || ticked.includes(c.id)); + const full = ownShopsOf(definition).length >= SHOPS_MOST; + const add = () => { + const made = withNewShop(definition, shopName); + if (!made) return; + edit(ticked.includes(made.id) ? made.definition : withSoldAtToggled(made.definition, type.id, made.id)); + setShopName(''); + }; + return ( + + + {choices.map((c) => { + const on = ticked.includes(c.id); + return ( + + ); + })} + + + setShopName(e.target.value)} onKeyDown={(e) => { if (e.key === 'Enter') { e.preventDefault(); add(); } }} /> + + {full && {SHOPS_MOST} OF {SHOPS_MOST}: a name already a shop still ticks it.} + + {soldAtWords(definition, type)} + + ); +} + /** * ITEM TYPES (8aL1; approved mockup docs/mockups/items-layout.html, 2026-11-14): the types listed, the DEFAULT first, * with the presets and BLANK under them; beside them the open type's name, ONE, columns and how it looks on a sheet. @@ -137,10 +182,15 @@ export function ItemTypesSection({ definition, edit, place = 'items' }: Props & const [openId, setOpenId] = useBuilderPlace(`${place}:type`, null); const [lastKind, setLastKind] = useState(null); const [asking, setAsking] = useState(false); + // What + NEW SHOP holds (8a7b2): a SPELL from its preset starts it as a Magic Shop, ready to ADD. + const [shopName, setShopName] = useState(''); const type = types.find((t) => t.id === openId) ?? types[0]; const isDefault = type.id === types[0].id; const full = types.length >= LIMITS.types; - const add = (preset?: string) => { const made = withNewType(definition, preset); if (made) { edit(made.definition); setOpenId(made.id); setAsking(false); setLastKind(null); } }; + const add = (preset?: string) => { + const made = withNewType(definition, preset); + if (made) { edit(made.definition); setOpenId(made.id); setAsking(false); setLastKind(null); setShopName((preset && PRESET_NEW_SHOP[preset]) || ''); } + }; const shownKind = lastKind ?? type.columns[type.columns.length - 1]?.kind ?? 'number'; const items = itemList(definition); const countOf = (id: string) => items.filter((i) => typeOf(definition, i.type).id === id).length; @@ -157,7 +207,7 @@ export function ItemTypesSection({ definition, edit, place = 'items' }: Props & const on = t.id === type.id; return ( )}

{KINDS.find((k) => k.id === shownKind)?.why}

+
+ SOLD AT + +
@@ -327,7 +381,7 @@ function ItemPrice({ definition, edit, item, id }: Props & { item: Item; id: (pa return ( <> PRICE - { const n = Number(e.target.value); if (!e.target.value.trim()) edit(withItemPrice(definition, item.id, undefined)); else if (Number.isFinite(n) && n >= 0 && n <= MOST_PRICE) edit(withItemPrice(definition, item.id, n)); }} /> IN SHOPS diff --git a/frontend/src/components/__tests__/ItemsPage.test.tsx b/frontend/src/components/__tests__/ItemsPage.test.tsx index 1333959a..1802d8b9 100644 --- a/frontend/src/components/__tests__/ItemsPage.test.tsx +++ b/frontend/src/components/__tests__/ItemsPage.test.tsx @@ -717,3 +717,65 @@ describe('ON THE SHEET on a type (G1)', () => { expect((last().items as unknown as { types: object[] }).types[0]).not.toHaveProperty('on_sheet'); }); }); + +describe('SOLD AT on a type (8a7b2)', () => { + type Saved = { items: { types: { id: string; sold_at?: string[] }[] }; buildings?: { types?: object; shops?: object[] } }; + const GAME = { ...WORN, buildings: { types: { gun_shop: { name: 'Blacksmith' }, garage: { on: false } } }, + items: { types: [{ id: 'gear', label: 'GEAR', columns: [] }], list: [] } } as unknown as Definition; + const says = () => screen.getByText(/^Sold (at|nowhere)/); + const chips = (type = 'GEAR') => within(screen.getByRole('group', { name: `${type} sold at` })); + + it('the game\'s shops by their names here, one turned off left out; unsaid, the General Store; a tick stored, said', async () => { + const last = open(GAME, 'TYPES'); + expect(chips().getAllByRole('button').map((b) => b.textContent)).toEqual(['Ripperdoc', 'Blacksmith', 'Clinic', 'Armorer', 'General Store']); + expect(chips().getByRole('button', { name: 'General Store' }).getAttribute('aria-pressed')).toBe('true'); + expect(says()).toHaveTextContent('Sold at every General Store in this game.'); + await userEvent.click(chips().getByRole('button', { name: 'Blacksmith' })); + expect((last() as unknown as Saved).items.types[0].sold_at).toEqual(['gun_shop', 'general_store']); + expect(says()).toHaveTextContent('Sold at every Blacksmith, every General Store in this game.'); + await userEvent.click(chips().getByRole('button', { name: 'Blacksmith' })); + await userEvent.click(chips().getByRole('button', { name: 'General Store' })); + expect((last() as unknown as Saved).items.types[0].sold_at).toEqual([]); + expect(says()).toHaveTextContent('Sold nowhere: only given, from GIVE.EXE.'); + }); + + it('+ NEW SHOP: made, dashed, ticked, by ADD or Enter; a name already a shop ticks that one', async () => { + const last = open(GAME, 'TYPES'); + const box = screen.getByRole('textbox', { name: 'New shop name' }); + expect(screen.getByRole('button', { name: 'ADD' })).toBeDisabled(); + await userEvent.type(box, ' Apothecary '); + await userEvent.click(screen.getByRole('button', { name: 'ADD' })); + const saved = last() as unknown as Saved; + expect(saved.buildings?.shops).toEqual([{ id: 'apothecary', name: 'Apothecary' }]); + expect(saved.buildings?.types).toEqual({ gun_shop: { name: 'Blacksmith' }, garage: { on: false } }); + expect(saved.items.types[0].sold_at).toEqual(['general_store', 'apothecary']); + expect(chips().getByRole('button', { name: 'Apothecary' }).style.borderStyle).toBe('dashed'); + expect(chips().getByRole('button', { name: 'Apothecary' }).style.outline).toMatch(/dashed/); + expect(chips().getByRole('button', { name: 'Clinic' }).style.borderStyle).toBe('solid'); + expect(box).toHaveValue(''); + expect(says()).toHaveTextContent('Sold at every General Store, every Apothecary in this game. Dashed: shops this game made.'); + // By Enter; and a name that is already one of the game's shops ticks it, making nothing. + await userEvent.type(box, 'blacksmith{Enter}'); + expect((last() as unknown as Saved).items.types[0].sold_at).toEqual(['gun_shop', 'general_store', 'apothecary']); + expect((last() as unknown as Saved).buildings?.shops).toHaveLength(1); + // One already ticked stays ticked. + await userEvent.type(box, 'Apothecary{Enter}'); + expect((last() as unknown as Saved).items.types[0].sold_at).toEqual(['gun_shop', 'general_store', 'apothecary']); + }); + + it('a type from a preset starts at its shop; SPELL at none, a Magic Shop filled in, ready to ADD; another type, an empty box', async () => { + const last = open(GAME, 'TYPES'); + const presets = within(screen.getByRole('group', { name: 'Add an item type' })); + await userEvent.click(presets.getByRole('button', { name: 'WEAPON', exact: true })); + expect(chips('WEAPONS').getByRole('button', { name: 'Blacksmith' }).getAttribute('aria-pressed')).toBe('true'); + await userEvent.click(presets.getByRole('button', { name: 'SPELL', exact: true })); + expect(chips('SPELLS').getAllByRole('button').filter((b) => b.getAttribute('aria-pressed') === 'true')).toEqual([]); + expect(screen.getByRole('textbox', { name: 'New shop name' })).toHaveValue('Magic Shop'); + await userEvent.click(screen.getByRole('button', { name: 'ADD' })); + expect((last() as unknown as Saved).items.types.find((t) => t.id === 'spells')?.sold_at).toEqual(['magic_shop']); + await userEvent.click(presets.getByRole('button', { name: 'SPELL', exact: true })); + await userEvent.click(within(screen.getByRole('group', { name: 'The item types' })).getByRole('button', { name: 'GEAR' })); + expect(screen.getByRole('textbox', { name: 'New shop name' })).toHaveValue(''); + for (const k of ['items.soldAt'] as const) expect(HINTS[k], k).toBeTruthy(); + }); +}); diff --git a/frontend/src/sheets/__tests__/gameShops.test.ts b/frontend/src/sheets/__tests__/gameShops.test.ts new file mode 100644 index 00000000..89ca7186 --- /dev/null +++ b/frontend/src/sheets/__tests__/gameShops.test.ts @@ -0,0 +1,104 @@ +import { describe, it, expect } from 'vitest'; +import type { Definition } from '../systemsApi'; +import { ownShopsOf, shopChoices, soldAtOf, withSoldAtToggled, withNewShop, soldAtWords, SHOPS_MOST, DEFAULT_SOLD_AT } from '../gameShops'; +import { PRESETS, PRESET_NEW_SHOP, withNewType, itemTypes } from '../itemTypes'; +import { withBuilding } from '../wordsFeatures'; + +// SOLD AT and + NEW SHOP (8a7b2; approved mockup docs/mockups/types-in-shops.html, section 2): the game's shops by their +// names here then its own, a type's ticks kept in that order, a shop of its own made from a name, the words under them. + +const def = (more: object = {}) => ({ format: 1, name: 'A', items: { types: [{ id: 'potions', label: 'POTIONS', columns: [] }] }, ...more }) as unknown as Definition; +const potions = (d: Definition) => itemTypes(d)[0]; + +describe('the shops to tick', () => { + it('the app\'s, named as this game names them, on or off; then the game\'s own, well formed only', () => { + const d = def({ buildings: { types: { gun_shop: { name: 'Blacksmith' }, garage: { on: false } }, + shops: [{ id: 'apothecary', name: 'Apothecary' }, { id: 'fence', name: 'Fence', on: false }, { id: 'bar', name: 'Taken' }, { name: 'No id' }, { id: 'nameless' }] } }); + expect(shopChoices(d)).toEqual([ + { id: 'ripperdoc', name: 'Ripperdoc', own: false, on: true }, { id: 'gun_shop', name: 'Blacksmith', own: false, on: true }, + { id: 'clinic', name: 'Clinic', own: false, on: true }, { id: 'garage', name: 'Garage', own: false, on: false }, + { id: 'armorer', name: 'Armorer', own: false, on: true }, { id: 'general_store', name: 'General Store', own: false, on: true }, + { id: 'apothecary', name: 'Apothecary', own: true, on: true }, { id: 'fence', name: 'Fence', own: true, on: false }, + ]); + expect(ownShopsOf(def())).toEqual([]); + }); + + it('a type\'s: what it says, else the General Store', () => { + expect(DEFAULT_SOLD_AT).toEqual(['general_store']); + expect(soldAtOf({ id: 'a', label: 'A', columns: [] })).toEqual(['general_store']); + expect(soldAtOf({ id: 'a', label: 'A', columns: [], sold_at: [] })).toEqual([]); + }); +}); + +describe('ticking one', () => { + it('stored in the order the shops are shown; ticked again, gone; unsaid starts from the General Store', () => { + let d = withSoldAtToggled(def(), 'potions', 'clinic'); + expect(potions(d).sold_at).toEqual(['clinic', 'general_store']); + d = withSoldAtToggled(d, 'potions', 'ripperdoc'); + expect(potions(d).sold_at).toEqual(['ripperdoc', 'clinic', 'general_store']); + d = withSoldAtToggled(d, 'potions', 'clinic'); + expect(potions(d).sold_at).toEqual(['ripperdoc', 'general_store']); + expect(withSoldAtToggled(d, 'wands', 'clinic')).toBe(d); + }); + + it('a shop it is sold at that the game no longer makes stays at the end, to be ticked off', () => { + const d = def({ items: { types: [{ id: 'potions', label: 'POTIONS', columns: [], sold_at: ['gone'] }] } }); + expect(potions(withSoldAtToggled(d, 'potions', 'clinic')).sold_at).toEqual(['clinic', 'gone']); + }); +}); + +describe('+ NEW SHOP', () => { + it('made from its name, tidied, at the end; its id never one the app has', () => { + const made = withNewShop(def(), ' Magic Shop ')!; + expect(made.id).toBe('magic_shop'); + expect(ownShopsOf(made.definition)).toEqual([{ id: 'magic_shop', name: 'Magic Shop' }]); + const bar = withNewShop(made.definition, 'Bar')!; + expect(bar.id).not.toBe('bar'); + expect(ownShopsOf(bar.definition).map((s) => s.name)).toEqual(['Magic Shop', 'Bar']); + }); + + it('a name already a shop, the app\'s by its name here or the game\'s own, any case: that one, nothing made', () => { + const d = def({ buildings: { types: { gun_shop: { name: 'Blacksmith' } }, shops: [{ id: 'fence', name: 'Fence' }] } }); + expect(withNewShop(d, 'blacksmith')).toEqual({ definition: d, id: 'gun_shop' }); + expect(withNewShop(d, 'FENCE')).toEqual({ definition: d, id: 'fence' }); + expect(withNewShop(d, 'General store')).toEqual({ definition: d, id: 'general_store' }); + }); + + it('none from a blank name, nor past the most; a name kept to 40 characters', () => { + expect(withNewShop(def(), ' ')).toBeNull(); + expect(SHOPS_MOST).toBe(20); + const full = def({ buildings: { shops: Array.from({ length: 20 }, (_, n) => ({ id: `shop_${n}`, name: `Shop ${n}` })) } }); + expect(withNewShop(full, 'One more')).toBeNull(); + expect(withNewShop(full, 'Shop 3')).toEqual({ definition: full, id: 'shop_3' }); + expect(ownShopsOf(withNewShop(def(), 'x'.repeat(50))!.definition)[0].name).toHaveLength(40); + }); +}); + +describe('what SOLD AT says', () => { + it('every shop it is sold at by name; dashed explained only where the game made some; sold nowhere', () => { + const d = def({ buildings: { types: { gun_shop: { name: 'Blacksmith' } } } }); + expect(soldAtWords(d, { ...potions(d), sold_at: ['gun_shop', 'general_store'] })).toBe('Sold at every Blacksmith, every General Store in this game.'); + const own = withNewShop(d, 'Fence')!.definition; + expect(soldAtWords(own, { ...potions(own), sold_at: ['fence'] })).toBe('Sold at every Fence in this game. Dashed: shops this game made.'); + expect(soldAtWords(d, { ...potions(d), sold_at: [] })).toBe('Sold nowhere: only given, from GIVE.EXE.'); + }); +}); + +describe('the presets\' shops', () => { + it('WEAPON the Gun Shop, ARMOR the Armorer, GEAR the General Store unsaid, CONSUMABLE the Clinic, SPELL none with a Magic Shop to ADD', () => { + expect(PRESETS.map((p) => `${p.id}:${soldAtOf(p.type).join('+')}`)).toEqual(['weapon:gun_shop', 'armor:armorer', 'gear:general_store', 'consumable:clinic', 'spell:']); + expect(PRESETS.find((p) => p.id === 'gear')!.type).not.toHaveProperty('sold_at'); + expect(PRESET_NEW_SHOP).toEqual({ spell: 'Magic Shop' }); + expect(itemTypes(withNewType(def(), 'weapon')!.definition)[1].sold_at).toEqual(['gun_shop']); + }); +}); + +describe('FEATURES keeps what a shop BUYS (8a7b1b)', () => { + it('renamed or turned off, a shop that buys anything still does; one that buys what it sells stores nothing', () => { + const d = def({ buildings: { types: { general_store: { buys: 'anything' } } } }); + const named = withBuilding(d, 'types', 'general_store', { name: 'Pawn' }); + expect((named as unknown as { buildings: object }).buildings).toEqual({ types: { general_store: { name: 'Pawn', buys: 'anything' } } }); + const back = withBuilding(named, 'types', 'general_store', { buys: 'sells', name: '' }); + expect(back as unknown as object).not.toHaveProperty('buildings'); + }); +}); diff --git a/frontend/src/sheets/builderHelp.ts b/frontend/src/sheets/builderHelp.ts index e16843b3..4cc91fac 100644 --- a/frontend/src/sheets/builderHelp.ts +++ b/frontend/src/sheets/builderHelp.ts @@ -288,6 +288,7 @@ export const HINTS = { 'items.types': 'What kinds of thing your game has, each with columns of its own: WEAPONS with a DAMAGE and AMMO, ARMOR with a DEFENSE. Every system starts with GEAR, a WEIGHT and a PRICE; a sheet shows each type as its own table.', 'items.typeName': 'The type\'s name, as its table on a sheet is headed: WEAPONS.', 'items.one': 'What one of it is called, where the table says one thing: a Weapon.', + 'items.soldAt': 'The kinds of shop that sell its lines, each tick a kind: every building of that kind sells them, at their prices. None ticked, it is sold nowhere and only given. + NEW SHOP makes a kind of shop of this game\'s own, like an Apothecary, shown dashed; a building can then be one.', 'items.onSheet': 'Where its lines sit on the sheet\'s GEAR tab: EQUIPPED (worn or wielded) at the top, USABLE (used up or used often: potions, ammo, kits), or PACK for the rest. Only where it is drawn; what a line does is the same in any.', 'items.column': 'A column of the type\'s table, named as its head reads. Its name can change; what it is underneath stays, so the values filled in keep.', 'items.kind': 'What the column holds: a NUMBER, TEXT, DAMAGE (dice that are damage), DICE (any other roll, like healing), a COUNT spent and refilled, or PICK ONE of the words you list. A new kind clears what items had filled in for it.', diff --git a/frontend/src/sheets/gameShops.ts b/frontend/src/sheets/gameShops.ts new file mode 100644 index 00000000..f892e3bf --- /dev/null +++ b/frontend/src/sheets/gameShops.ts @@ -0,0 +1,86 @@ +// The kinds of shop an item type is SOLD AT, and the game's own kinds of shop (8a7b2; approved mockup +// docs/mockups/types-in-shops.html, section 2, 2026-11-21). The app's six shops by what this game calls them, then the +// shops this game made (an Apothecary, a Fence), which + NEW SHOP adds. Read from the definition and written back; the +// server checks it (backend systemBuilder/buildings.js checkShops, itemTypes.js sold_at). + +import type { Definition } from './systemsApi'; +import { BUILDING_TYPES } from '../data/buildingTypes'; +import { idFor } from './setup'; +import { itemTypes, withType, type ItemType } from './itemTypes'; +import { buildingSetting, BUILDING_NAME_LIMIT } from './wordsFeatures'; + +type Obj = Record; +const isObject = (v: unknown): v is Obj => !!v && typeof v === 'object' && !Array.isArray(v); + +/** The most shops of its own a game makes (buildings.js SHOPS_MOST). */ +export const SHOPS_MOST = 20; +/** A shop's id, as the server takes it (buildings.js SHOP_ID). */ +const SHOP_ID = /^[a-z][a-z0-9_]{0,63}$/; +/** Where a type is sold when it says nothing (itemTypes.js DEFAULT_SOLD_AT). */ +export const DEFAULT_SOLD_AT = ['general_store']; +const APP_SHOPS = BUILDING_TYPES.filter((t) => t.shop); +const APP_IDS = BUILDING_TYPES.map((t) => t.id); + +/** One of the game's own kinds of shop, as stored. */ +export interface OwnShop { id: string; name: string; on?: boolean; buys?: 'sells' | 'anything' } +/** A kind of shop to tick: its id, its name in this game, whether the game made it, and whether it is on. */ +export interface ShopChoice { id: string; name: string; own: boolean; on: boolean } + +const buildingsOf = (def: Definition): Obj => (isObject(def.buildings) ? def.buildings : {}); + +/** The game's own kinds of shop, those well formed, in its order. */ +export const ownShopsOf = (def: Definition): OwnShop[] => { + const list = buildingsOf(def).shops; + return (Array.isArray(list) ? list : []).filter((s): s is OwnShop => isObject(s) && typeof s.id === 'string' && SHOP_ID.test(s.id) + && !APP_IDS.includes(s.id) && typeof s.name === 'string'); +}; + +/** Every kind of shop a type can be sold at: the app's, named as this game names them, then the game's own. */ +export const shopChoices = (def: Definition): ShopChoice[] => [ + ...APP_SHOPS.map((t) => { + const s = buildingSetting(def, 'types', t.id); + return { id: t.id, name: s.name?.trim() || t.label, own: false, on: s.on !== false }; + }), + ...ownShopsOf(def).map((s) => ({ id: s.id, name: s.name.trim() || s.id, own: true, on: s.on !== false })), +]; + +/** The kinds of shop a type is sold at: what it says, else the General Store. */ +export const soldAtOf = (type: ItemType): string[] => (Array.isArray(type.sold_at) ? type.sold_at : DEFAULT_SOLD_AT); + +/** A type sold at a kind of shop, or no longer: the list kept in the order the shops are shown. */ +export const withSoldAtToggled = (def: Definition, typeId: string, shopId: string): Definition => { + const type = itemTypes(def).find((t) => t.id === typeId); + if (!type) return def; + const was = soldAtOf(type); + const ticked = new Set(was.includes(shopId) ? was.filter((id) => id !== shopId) : [...was, shopId]); + const order = shopChoices(def).map((c) => c.id); + return withType(def, typeId, { sold_at: [...order.filter((id) => ticked.has(id)), ...[...ticked].filter((id) => !order.includes(id))] }); +}; + +/** A name as typed: trimmed, its spaces single. */ +const tidy = (name: string) => name.trim().replace(/\s+/g, ' '); + +/** + * + NEW SHOP: a shop of the game's own by this name, at the end of its shops, its id made from its name and fixed after; + * one of this name already (the app's by its name here, or the game's own) is that one, and nothing is made. Null for a + * blank name, or a new one past the most. + */ +export const withNewShop = (def: Definition, name: string): { definition: Definition; id: string } | null => { + const wanted = tidy(name).slice(0, BUILDING_NAME_LIMIT); + if (!wanted) return null; + const known = shopChoices(def).find((c) => c.name.toLowerCase() === wanted.toLowerCase()); + if (known) return { definition: def, id: known.id }; + const own = ownShopsOf(def); + if (own.length >= SHOPS_MOST) return null; + const id = idFor(wanted, [...APP_IDS, ...own.map((s) => s.id)]); + return { definition: { ...def, buildings: { ...buildingsOf(def), shops: [...own, { id, name: wanted }] } }, id }; +}; + +/** What SOLD AT says under its shops: every one it is sold at, by name, or that it is sold nowhere. */ +export const soldAtWords = (def: Definition, type: ItemType): string => { + const choices = shopChoices(def); + const names = soldAtOf(type).map((id) => choices.find((c) => c.id === id)?.name).filter(Boolean); + if (!names.length) return 'Sold nowhere: only given, from GIVE.EXE.'; + const dashed = choices.some((c) => c.own) ? ' Dashed: shops this game made.' : ''; + return `Sold at every ${names.join(', every ')} in this game.${dashed}`; +}; diff --git a/frontend/src/sheets/itemTypes.ts b/frontend/src/sheets/itemTypes.ts index 76a48662..8dd1fe93 100644 --- a/frontend/src/sheets/itemTypes.ts +++ b/frontend/src/sheets/itemTypes.ts @@ -21,6 +21,8 @@ export interface ItemType { id: string; label: string; one?: string; columns: ItemColumn[]; /** Its band on the sheet's GEAR tab (G1): unsaid is PACK. */ on_sheet?: Band; + /** The kinds of shop its lines are sold at (8a7a2; ticked in the builder, 8a7b2): unsaid is the General Store. */ + sold_at?: string[]; } /** Where a type's lines sit on the sheet's GEAR tab (G1; approved mockup sheet-gear-layout.html), as the server checks them. */ @@ -50,20 +52,26 @@ const price: ItemColumn = { id: 'price', label: 'PRICE', kind: 'number' }; /** What a system with no types of its own has, as the server's GEAR. */ export const GEAR: ItemType = { id: 'gear', label: 'GEAR', one: 'Gear', columns: [weight, price] }; -/** The presets a type starts from: its name, one of it, its columns. */ +/** + * The presets a type starts from: its name, one of it, its columns, and the shop it is suggested SOLD AT (8a7b2; approved + * mockup types-in-shops.html): WEAPON the Gun Shop, ARMOR the Armorer, CONSUMABLE the Clinic, GEAR the General Store as + * unsaid. SPELL is sold nowhere, a Magic Shop suggested under + NEW SHOP (PRESET_NEW_SHOP) for a game that sells them. + */ export const PRESETS: { id: string; label: string; type: ItemType }[] = [ { id: 'weapon', label: 'WEAPON', type: { id: 'weapons', label: 'WEAPONS', one: 'Weapon', columns: [ { id: 'damage', label: 'DAMAGE', kind: 'damage' }, { id: 'range', label: 'RANGE', kind: 'text' }, - { id: 'ammo', label: 'AMMO', kind: 'count', button: 'FIRE' }, weight, price], on_sheet: 'equipped' } }, + { id: 'ammo', label: 'AMMO', kind: 'count', button: 'FIRE' }, weight, price], on_sheet: 'equipped', sold_at: ['gun_shop'] } }, { id: 'armor', label: 'ARMOR', type: { id: 'armor', label: 'ARMOR', one: 'Armor', columns: [ - { id: 'defense', label: 'DEFENSE', kind: 'number' }, { id: 'type', label: 'TYPE', kind: 'pick', options: ['LIGHT', 'MEDIUM', 'HEAVY'] }, weight, price], on_sheet: 'equipped' } }, + { id: 'defense', label: 'DEFENSE', kind: 'number' }, { id: 'type', label: 'TYPE', kind: 'pick', options: ['LIGHT', 'MEDIUM', 'HEAVY'] }, weight, price], on_sheet: 'equipped', sold_at: ['armorer'] } }, { id: 'gear', label: 'GEAR', type: GEAR }, { id: 'consumable', label: 'CONSUMABLE', type: { id: 'consumables', label: 'CONSUMABLES', one: 'Consumable', columns: [ - { id: 'uses', label: 'USES', kind: 'count', button: 'USE' }, { id: 'effect', label: 'EFFECT', kind: 'dice' }, weight, price], on_sheet: 'usable' } }, + { id: 'uses', label: 'USES', kind: 'count', button: 'USE' }, { id: 'effect', label: 'EFFECT', kind: 'dice' }, weight, price], on_sheet: 'usable', sold_at: ['clinic'] } }, { id: 'spell', label: 'SPELL', type: { id: 'spells', label: 'SPELLS', one: 'Spell', columns: [ { id: 'level', label: 'LEVEL', kind: 'number' }, { id: 'range', label: 'RANGE', kind: 'text' }, { id: 'damage', label: 'DAMAGE', kind: 'damage' }, - { id: 'charges', label: 'CHARGES', kind: 'count', button: 'CAST', refill: 'long_rest' }], on_sheet: 'usable' } }, + { id: 'charges', label: 'CHARGES', kind: 'count', button: 'CAST', refill: 'long_rest' }], on_sheet: 'usable', sold_at: [] } }, ]; +/** The shop + NEW SHOP is filled in with for a type made from a preset, ready to ADD (8a7b2, answered 3). */ +export const PRESET_NEW_SHOP: Record = { spell: 'Magic Shop' }; const copy = (v: T): T => JSON.parse(JSON.stringify(v)) as T; const itemsPart = (def: Definition): Obj => (isObject(def.items) ? def.items : {}); @@ -124,7 +132,7 @@ export const withNewType = (def: Definition, preset?: string): { definition: Def }; /** A type's name or what one of it is called; its id stays. A blank ONE stores nothing. */ -export const withType = (def: Definition, id: string, patch: { label?: string; one?: string; on_sheet?: Band }): Definition => +export const withType = (def: Definition, id: string, patch: { label?: string; one?: string; on_sheet?: Band; sold_at?: string[] }): Definition => withPart(def, itemTypes(def).map((t) => { if (t.id !== id) return t; const next: ItemType = { ...t, ...patch }; diff --git a/frontend/src/sheets/wordsFeatures.ts b/frontend/src/sheets/wordsFeatures.ts index b4642dfa..9f9e40de 100644 --- a/frontend/src/sheets/wordsFeatures.ts +++ b/frontend/src/sheets/wordsFeatures.ts @@ -149,7 +149,8 @@ export const termPartOff = (def: Definition, row: TermRow): boolean => !!row.par // ─── PARTS: buildings and catalogues ──────────────────────────────────────── export type BuildingKind = 'types' | 'catalogues'; -export interface BuildingSetting { name?: string; on?: boolean; currency?: string } +/** A shop type may also say it BUYS anything (8a7b1b), kept whatever else changes. */ +export interface BuildingSetting { name?: string; on?: boolean; currency?: string; buys?: 'sells' | 'anything' } /** The app's shop types, its other buildings, and its catalogues, with the app's names. */ export const SHOP_TYPES = BUILDING_TYPES.filter((t) => t.shop).map((t) => ({ id: t.id, label: t.label })); @@ -185,6 +186,7 @@ export const withBuilding = (def: Definition, kind: BuildingKind, id: string, pa if (merged.on === false) next.on = false; const main = currencyList(def)[0]?.id; if (kind === 'catalogues' && merged.currency && merged.currency !== main) next.currency = merged.currency; + if (kind === 'types' && merged.buys === 'anything') next.buys = 'anything'; const buildings = { ...section(def, 'buildings') }; const entries = { ...(isObject(buildings[kind]) ? buildings[kind] as Obj : {}) }; if (Object.keys(next).length) entries[id] = next; else delete entries[id];