-- Battle actions: an attack or spell from being declared to its damage -- landing; named attacks for monsters; and how each spell lands (a spell -- attack, or a saving throw). Spells already in campaigns that came from -- the library are marked by name. -- AlterTable ALTER TABLE "monsters" ADD COLUMN "attacks" JSONB NOT NULL DEFAULT '[]'; -- AlterTable ALTER TABLE "spells" ADD COLUMN "attackRoll" BOOLEAN NOT NULL DEFAULT false, ADD COLUMN "halfOnSave" BOOLEAN NOT NULL DEFAULT false, ADD COLUMN "saveAbility" "Ability"; -- CreateTable CREATE TABLE "encounter_actions" ( "id" TEXT NOT NULL, "encounterId" TEXT NOT NULL, "round" INTEGER NOT NULL, "actorParticipantId" TEXT, "actorName" TEXT NOT NULL, "kind" TEXT NOT NULL, "name" TEXT NOT NULL, "detail" JSONB NOT NULL, "targets" JSONB NOT NULL, "damage" JSONB, "status" TEXT NOT NULL DEFAULT 'PENDING', "auto" BOOLEAN NOT NULL DEFAULT false, "hidden" BOOLEAN NOT NULL DEFAULT false, "createdById" TEXT, "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, "appliedAt" TIMESTAMP(3), CONSTRAINT "encounter_actions_pkey" PRIMARY KEY ("id") ); -- CreateIndex CREATE INDEX "encounter_actions_encounterId_status_idx" ON "encounter_actions"("encounterId", "status"); -- AddForeignKey ALTER TABLE "encounter_actions" ADD CONSTRAINT "encounter_actions_encounterId_fkey" FOREIGN KEY ("encounterId") REFERENCES "encounters"("id") ON DELETE CASCADE ON UPDATE CASCADE; -- How the library's spells land, for copies already in campaigns. UPDATE "spells" SET "attackRoll" = true WHERE lower("name") IN ('chill touch', 'eldritch blast', 'fire bolt', 'produce flame', 'ray of frost', 'shocking grasp', 'thorn whip', 'guiding bolt', 'witch bolt', 'scorching ray', 'spiritual weapon', 'contagion'); UPDATE "spells" SET "saveAbility" = 'STR', "halfOnSave" = false WHERE lower("name") IN ('entangle', 'gust of wind'); UPDATE "spells" SET "saveAbility" = 'DEX', "halfOnSave" = true WHERE lower("name") IN ('burning hands', 'flaming sphere', 'call lightning', 'fireball', 'lightning bolt', 'guardian of faith', 'ice storm', 'wall of fire', 'flame strike'); UPDATE "spells" SET "saveAbility" = 'DEX', "halfOnSave" = false WHERE lower("name") IN ('acid splash', 'sacred flame', 'faerie fire', 'web', 'sleet storm'); UPDATE "spells" SET "saveAbility" = 'CON', "halfOnSave" = true WHERE lower("name") IN ('thunderwave', 'moonbeam', 'shatter', 'blight', 'cloudkill', 'cone of cold', 'insect plague'); UPDATE "spells" SET "saveAbility" = 'CON', "halfOnSave" = false WHERE lower("name") IN ('poison spray', 'blindness/deafness', 'levitate', 'stinking cloud'); UPDATE "spells" SET "saveAbility" = 'WIS', "halfOnSave" = true WHERE lower("name") IN ('spirit guardians'); UPDATE "spells" SET "saveAbility" = 'WIS', "halfOnSave" = false WHERE lower("name") IN ('vicious mockery', 'animal friendship', 'charm person', 'command', 'hold person', 'suggestion', 'fear', 'slow', 'confusion', 'polymorph', 'dominate person', 'hold monster'); UPDATE "spells" SET "saveAbility" = 'CHA', "halfOnSave" = false WHERE lower("name") IN ('bane', 'zone of truth', 'banishment');