Shops: central catalog plus GM-curated shops for parties and campaigns #138
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feature/shops"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Implements the shop plan (docs/crafting-harvesting-shop-plan.md §4): one central shop over the whole item catalog, plus GM-curated shops connected to parties and campaigns.
Central shop (virtual)
Synthesized on request over all three item sources - official magic/sourcebook items (enabled-sourcebook gated), mundane SRD gear and homebrew (the 222 Morena items included). Catalog-priced, with a rarity fallback for unpriced items (Common 50 gp .. Mythic 25,000, 10 gp default). Never stored, so it can never go stale.
Custom shops (GM-owned)
shopentity, encounters pattern). Owners,campaigns-permission users,full_controland connected-campaign DMs manage; players see shops connected to their parties/campaigns.{ kind: 'official'|'homebrew', id }ref, with optional price override and optional stock (default unlimited; finite stock decrements and refuses when sold out).Purchase transaction
POST /shops/:id/buy- resolve ref -> price (override -> catalog -> rarity fallback) -> funds check -> gp deduction -> item mapped into the buyer's equipment (magic/rarity/attunement/description carried across) -> stock decrement -> ledger entry (capped at 100). gp only per the agreed v1; buyers need edit access to the character.UI
Validation
tscclean x3.Routing fix en route
The shops router mounts with a
/shopspath prefix - a bare internalrouter.use(requireAuth)intercepted every later-mounted route (including /auth/register). Mount is now path-scoped.Known limitations
One central shop over the whole item catalog, plus GM-owned custom shops connected to campaigns and parties with a curated selection. - Central shop (virtual, never stored): synthesizes a shop view over the official magic/sourcebook items (enabled-sourcebook gated), mundane SRD gear and homebrew items. Catalog-priced; unpriced items fall back by rarity (Common 50 gp .. Mythic 25,000, default 10). - Custom shops: storage-backed CRUD under the 'shop' entity, owned by their creator, manageable by 'campaigns'-permission users and connected-campaign DMs. Listings reference catalog items by a stable { kind, id } ref with optional price override and optional stock (default unlimited; finite stock decrements and refuses when empty). - Purchase transaction: resolve ref -> price -> funds check -> gp deduction -> catalog item mapped into the buyer's equipment (magic, rarity, attunement and description carried across) -> stock decrement -> ledger entry (capped at 100) on custom shops. gp only; buyers need edit access to the character they buy for. - Visibility: players see the central shop plus shops connected to their parties/campaigns; GMs see all. - GM page (/shops, campaigns permission): create/edit shops, connect campaigns/parties, curate listings via dual-catalog search, quick homebrew form that authors an item and lists it in one step. - Player-facing ShopModal from the character sheet Inventory header: shop picker, search, Buy with live gold checks. One routing pitfall fixed en route: the shops router is mounted with a /shops path prefix - a bare internal `router.use(requireAuth)` would otherwise have intercepted every later-mounted route including /auth/register. 15 backend tests: pricing fallback + SRD cost conversion, ref resolution across all three sources, central-shop synthesis, purchase transaction (funds refusal, price overrides, stock decrement to sold-out, ledger), mapping fidelity and visibility rules. Known limitation: mundane SRD equipment rows are name-only stubs upstream, so they price at the 10 gp default until detail enrichment; magic items and homebrew carry real prices.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.