V1.1.0: gear levels, encounter overhaul, guided builder, trading, docs
Characters - Builder: pick-then-Next on every step with live preview, Back button, plain-language help throughout, and "Suggest for me" for ability scores - Motivation is picked from a list; new steps for special abilities, background and appearance, all composed from fixed lists and DM-only to edit afterwards - Copy a character to another campaign - Characters can give gold, weapons, items and spells to each other - Money tracker: gold only changes through a logged ledger - Fixes: level/XP/location are DM-only, HP stays within 0..max, physical dice ability rolls, every die is rolled once Gear - DM-managed item pool; weapons, items and spells are handed out by the DM - Starting-option flag per pool entry - Gear levels 1-9 per held copy with a damage ladder, growth rate and starting level; spells gated by spell level with a fixed damage value - Spell library carries default damage; damage is picked from a list Encounters - Battle and NPC quest modes, turn tracking, scene description, DM notes - NPCs, richer combatant cards, conditions from a list - Rewards (gold, weapons, items) lined up and awarded, with gold splitting - Character HP is shared between the sheet and the encounter - Monster stat blocks and NPC secrets are never sent to players Other - Dice roller on every page - Docs for characters, weapons, spells, items, encounters, monsters and NPCs, with full lists generated from the data (npm run docs:lists) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+95
@@ -0,0 +1,95 @@
|
||||
-- AlterTable: starting-option flags. Existing pool entries keep the previous
|
||||
-- behaviour (everything was offered at character creation); new ones opt in.
|
||||
ALTER TABLE "weapons" ADD COLUMN "isStartingOption" BOOLEAN NOT NULL DEFAULT false;
|
||||
ALTER TABLE "spells" ADD COLUMN "isStartingOption" BOOLEAN NOT NULL DEFAULT false;
|
||||
UPDATE "weapons" SET "isStartingOption" = true;
|
||||
UPDATE "spells" SET "isStartingOption" = true;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "items" (
|
||||
"id" TEXT NOT NULL,
|
||||
"campaignId" TEXT NOT NULL,
|
||||
"name" TEXT NOT NULL,
|
||||
"description" TEXT,
|
||||
"isStartingOption" BOOLEAN NOT NULL DEFAULT false,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
|
||||
CONSTRAINT "items_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- Move free-text inventory into the campaign item pool: one pool item per
|
||||
-- distinct name (case-insensitive) per campaign, then point each row at it.
|
||||
INSERT INTO "items" ("id", "campaignId", "name", "description")
|
||||
SELECT DISTINCT ON (c."campaignId", lower(i."name"))
|
||||
'itm_' || md5(c."campaignId" || ':' || lower(i."name")),
|
||||
c."campaignId", i."name", i."description"
|
||||
FROM "inventory_items" i
|
||||
JOIN "characters" c ON c."id" = i."characterId"
|
||||
ORDER BY c."campaignId", lower(i."name"), i."id";
|
||||
|
||||
ALTER TABLE "inventory_items" ADD COLUMN "itemId" TEXT;
|
||||
|
||||
UPDATE "inventory_items" i
|
||||
SET "itemId" = 'itm_' || md5(c."campaignId" || ':' || lower(i."name"))
|
||||
FROM "characters" c
|
||||
WHERE c."id" = i."characterId";
|
||||
|
||||
-- A character that held the same item on several rows keeps one, with the
|
||||
-- quantities summed.
|
||||
UPDATE "inventory_items" keep
|
||||
SET "quantity" = agg.total, "equipped" = agg.any_equipped
|
||||
FROM (
|
||||
SELECT "characterId", "itemId", min("id") AS keep_id, sum("quantity")::int AS total, bool_or("equipped") AS any_equipped
|
||||
FROM "inventory_items"
|
||||
GROUP BY "characterId", "itemId"
|
||||
) agg
|
||||
WHERE keep."id" = agg.keep_id;
|
||||
|
||||
DELETE FROM "inventory_items" d
|
||||
USING (
|
||||
SELECT "characterId", "itemId", min("id") AS keep_id
|
||||
FROM "inventory_items"
|
||||
GROUP BY "characterId", "itemId"
|
||||
) agg
|
||||
WHERE d."characterId" = agg."characterId" AND d."itemId" = agg."itemId" AND d."id" <> agg.keep_id;
|
||||
|
||||
ALTER TABLE "inventory_items" ALTER COLUMN "itemId" SET NOT NULL;
|
||||
ALTER TABLE "inventory_items" DROP COLUMN "name";
|
||||
ALTER TABLE "inventory_items" DROP COLUMN "description";
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "gold_transactions" (
|
||||
"id" TEXT NOT NULL,
|
||||
"characterId" TEXT NOT NULL,
|
||||
"amount" INTEGER NOT NULL,
|
||||
"balanceAfter" INTEGER NOT NULL,
|
||||
"reason" TEXT,
|
||||
"createdById" TEXT,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
|
||||
CONSTRAINT "gold_transactions_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- Give characters that already hold gold an opening ledger entry.
|
||||
INSERT INTO "gold_transactions" ("id", "characterId", "amount", "balanceAfter", "reason")
|
||||
SELECT 'gtx_' || md5("id"), "id", "gold", "gold", 'Opening balance'
|
||||
FROM "characters"
|
||||
WHERE "gold" > 0;
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "inventory_items_characterId_itemId_key" ON "inventory_items"("characterId", "itemId");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "gold_transactions_characterId_createdAt_idx" ON "gold_transactions"("characterId", "createdAt");
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "items" ADD CONSTRAINT "items_campaignId_fkey" FOREIGN KEY ("campaignId") REFERENCES "campaigns"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "inventory_items" ADD CONSTRAINT "inventory_items_itemId_fkey" FOREIGN KEY ("itemId") REFERENCES "items"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "gold_transactions" ADD CONSTRAINT "gold_transactions_characterId_fkey" FOREIGN KEY ("characterId") REFERENCES "characters"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "gold_transactions" ADD CONSTRAINT "gold_transactions_createdById_fkey" FOREIGN KEY ("createdById") REFERENCES "users"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
@@ -0,0 +1,21 @@
|
||||
-- AlterTable: how many ladder rungs a weapon climbs per level (1 standard, 2 powerful, 3 legendary)
|
||||
ALTER TABLE "weapons" ADD COLUMN "damageScaling" INTEGER NOT NULL DEFAULT 1;
|
||||
|
||||
-- AlterTable: the level of the copy a character holds
|
||||
ALTER TABLE "character_weapons" ADD COLUMN "level" INTEGER NOT NULL DEFAULT 1;
|
||||
|
||||
-- AlterTable: items can optionally carry dice (damage, healing, ...) that scale the same way
|
||||
ALTER TABLE "items" ADD COLUMN "damageDice" TEXT,
|
||||
ADD COLUMN "damageScaling" INTEGER NOT NULL DEFAULT 1;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "inventory_items" ADD COLUMN "level" INTEGER NOT NULL DEFAULT 1;
|
||||
|
||||
-- AlterTable: spells get a fixed damage value; their classic level is the requirement
|
||||
ALTER TABLE "spells" ADD COLUMN "damageDice" TEXT;
|
||||
|
||||
-- A spell above its holder's level can no longer be prepared.
|
||||
UPDATE "character_spells" cs
|
||||
SET "prepared" = false
|
||||
FROM "spells" s, "characters" c
|
||||
WHERE s."id" = cs."spellId" AND c."id" = cs."characterId" AND s."level" > c."level";
|
||||
@@ -0,0 +1,7 @@
|
||||
-- AlterTable: the level a weapon or item starts at (its dice are the damage at this level)
|
||||
ALTER TABLE "weapons" ADD COLUMN "minLevel" INTEGER NOT NULL DEFAULT 1;
|
||||
ALTER TABLE "items" ADD COLUMN "minLevel" INTEGER NOT NULL DEFAULT 1;
|
||||
|
||||
-- Gear levels now stop at 9.
|
||||
UPDATE "character_weapons" SET "level" = 9 WHERE "level" > 9;
|
||||
UPDATE "inventory_items" SET "level" = 9 WHERE "level" > 9;
|
||||
@@ -0,0 +1,69 @@
|
||||
-- CreateEnum
|
||||
CREATE TYPE "EncounterMode" AS ENUM ('BATTLE', 'QUEST');
|
||||
|
||||
-- CreateEnum
|
||||
CREATE TYPE "NpcDisposition" AS ENUM ('FRIENDLY', 'NEUTRAL', 'HOSTILE');
|
||||
|
||||
-- CreateEnum
|
||||
CREATE TYPE "RewardType" AS ENUM ('GOLD', 'WEAPON', 'ITEM');
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "encounter_participants" ADD COLUMN "npcId" TEXT;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "encounters" ADD COLUMN "activeParticipantId" TEXT,
|
||||
ADD COLUMN "description" TEXT,
|
||||
ADD COLUMN "dmNotes" TEXT,
|
||||
ADD COLUMN "mode" "EncounterMode" NOT NULL DEFAULT 'BATTLE';
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "npcs" (
|
||||
"id" TEXT NOT NULL,
|
||||
"campaignId" TEXT NOT NULL,
|
||||
"name" TEXT NOT NULL,
|
||||
"role" TEXT,
|
||||
"disposition" "NpcDisposition" NOT NULL DEFAULT 'NEUTRAL',
|
||||
"description" TEXT,
|
||||
"dmNotes" TEXT,
|
||||
"ac" INTEGER,
|
||||
"maxHp" INTEGER,
|
||||
"attackBonus" INTEGER,
|
||||
"damageDice" TEXT,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
|
||||
CONSTRAINT "npcs_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "encounter_rewards" (
|
||||
"id" TEXT NOT NULL,
|
||||
"encounterId" TEXT NOT NULL,
|
||||
"type" "RewardType" NOT NULL,
|
||||
"gold" INTEGER,
|
||||
"weaponId" TEXT,
|
||||
"itemId" TEXT,
|
||||
"quantity" INTEGER NOT NULL DEFAULT 1,
|
||||
"level" INTEGER NOT NULL DEFAULT 1,
|
||||
"note" TEXT,
|
||||
"awardedTo" TEXT,
|
||||
"awardedAt" TIMESTAMP(3),
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
|
||||
CONSTRAINT "encounter_rewards_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "npcs" ADD CONSTRAINT "npcs_campaignId_fkey" FOREIGN KEY ("campaignId") REFERENCES "campaigns"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "encounter_rewards" ADD CONSTRAINT "encounter_rewards_encounterId_fkey" FOREIGN KEY ("encounterId") REFERENCES "encounters"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "encounter_rewards" ADD CONSTRAINT "encounter_rewards_weaponId_fkey" FOREIGN KEY ("weaponId") REFERENCES "weapons"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "encounter_rewards" ADD CONSTRAINT "encounter_rewards_itemId_fkey" FOREIGN KEY ("itemId") REFERENCES "items"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "encounter_participants" ADD CONSTRAINT "encounter_participants_npcId_fkey" FOREIGN KEY ("npcId") REFERENCES "npcs"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
-- AlterEnum: three story steps between skills and equipment
|
||||
ALTER TYPE "BuildStage" ADD VALUE 'CHOOSING_ABILITIES' BEFORE 'CHOOSING_EQUIPMENT';
|
||||
ALTER TYPE "BuildStage" ADD VALUE 'CHOOSING_BACKGROUND' BEFORE 'CHOOSING_EQUIPMENT';
|
||||
ALTER TYPE "BuildStage" ADD VALUE 'CHOOSING_APPEARANCE' BEFORE 'CHOOSING_EQUIPMENT';
|
||||
Reference in New Issue
Block a user