V1.27.0: battles that run themselves: track, targets, hit or miss, saves, auto-rolls

- Turn-order track: names coloured by PC, NPC or monster, this round, a flag
  where it ends, and the next round
- Target by clicking a name on the track, the card, or keys 1-9; whoever is
  on turn and every target show what they have in hand
- Attacks and spells are declared, rolled and applied: type or roll the d20
  and the app says hit, miss or critical; a save spell asks each target for
  its save against the caster's DC; the DM overrules anything and applies
- Critical damage by the campaign's rule; a spell spends its slot; a
  concentration save is called for
- Auto-rolled monster and NPC attacks: aimed (weighted), rolled, and offered
  to the DM to accept, edit or discard; hidden from players until accepted
- Monsters can have named attacks and multiattacks; spells say how they land
- A "What now" line tells the DM (and each player) what the scene waits on

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-12 09:14:04 +02:00
co-authored by Claude Opus 5.5
parent 8811f14732
commit 9b3637576d
29 changed files with 2693 additions and 38 deletions
+50
View File
@@ -656,6 +656,13 @@ model Spell {
// Brings back the dead: a character who can cast it may revive a dead ally
// on their turn in a battle (encounters.routes.js).
revives Boolean @default(false)
// How it lands in a battle (game/combat.js). attackRoll: the caster rolls a
// spell attack against AC. saveAbility: each target saves against the
// caster's spell DC with this ability, taking half on a success when
// halfOnSave. Neither: it simply takes effect.
attackRoll Boolean @default(false)
saveAbility Ability?
halfOnSave Boolean @default(false)
campaign Campaign @relation(fields: [campaignId], references: [id], onDelete: Cascade)
known CharacterSpell[]
@@ -699,6 +706,11 @@ model Monster {
challengeRating String?
specialTrait String?
notes String?
// Named attacks, for a monster with more than the one above: a list of
// { name, attackBonus, damageDice, damageType?, count? }. `count` is how
// many times it is made each turn (a multiattack). Empty: the single
// attackBonus/damageDice above is its attack.
attacks Json @default("[]")
campaign Campaign @relation(fields: [campaignId], references: [id], onDelete: Cascade)
encounterAppearances EncounterParticipant[]
@@ -769,11 +781,49 @@ model Encounter {
participants EncounterParticipant[]
rewards EncounterReward[]
wares SaleOffer[]
actions EncounterAction[]
@@index([campaignId])
@@map("encounters")
}
// An attack or a spell in a battle, from the moment it is declared to the
// moment its damage lands (game/combat.js). A player declares their own on
// their turn; the DM declares anyone's; and with the campaign's auto-roll
// settings the server declares a monster's or NPC's, already rolled. While
// PENDING it gathers what it needs (a d20 against each target's AC, or each
// target's saving throw, and the damage); the DM then applies it, changed as
// they see fit, or discards it. `hidden` keeps it from the players until it
// is applied.
model EncounterAction {
id String @id @default(cuid())
encounterId String
round Int
actorParticipantId String?
actorName String
kind String // ATTACK (a d20 against AC) | SAVE (targets save against a DC) | AUTO (it just lands)
name String // "Longsword", "Fireball", "Bite"
// What it rolls with: { attackBonus?, saveAbility?, saveDC?, halfOnSave?,
// damageDice?, damageBonus, damageType?, characterId?, slotLevel? }.
detail Json
// One entry per target: { participantId, name, kind, ac, penalty, saveBonus,
// d20, outcome (set by the DM to overrule the dice), damage (likewise) }.
targets Json
// The damage once rolled or entered: { total, dice?, modifier?, crit? }.
damage Json?
status String @default("PENDING") // PENDING | APPLIED | DISCARDED
auto Boolean @default(false) // declared and rolled by the server
hidden Boolean @default(false)
createdById String?
createdAt DateTime @default(now())
appliedAt DateTime?
encounter Encounter @relation(fields: [encounterId], references: [id], onDelete: Cascade)
@@index([encounterId, status])
@@map("encounter_actions")
}
// Loot the DM lines up for an encounter and later hands to a character. Until
// it is awarded it is the DM's secret; awarding it is what actually changes
// the character (gold ledger entry, or the weapon/item added to what they hold).