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
+23 -1
View File
@@ -1,6 +1,6 @@
import { ABILITY_ORDER } from './previewCalc';
import { formatMoney } from './format';
import type { Monster, Npc } from '../api/types';
import type { Ability, Monster, Npc } from '../api/types';
// One thing in a campaign's lists that opens in a pop-out.
export type EntryKind = 'weapon' | 'item' | 'spell' | 'monster' | 'npc';
@@ -33,3 +33,25 @@ export function matchesSearch(query: string, ...fields: (string | number | null
const text = fields.filter((f) => f !== null && f !== undefined).join(' ').toLowerCase();
return words.every((word) => text.includes(word));
}
// How a spell lands in a battle, as one choice: it just takes effect, the
// caster rolls a spell attack, or each target makes a save with an ability
// (taking half damage on a success, or none). `landingValue` and
// `landingFrom` turn it into the value of a select and back.
export interface SpellLanding {
attackRoll: boolean;
saveAbility: Ability | null;
halfOnSave: boolean;
}
export function landingValue(spell: SpellLanding): string {
if (spell.attackRoll) return 'ATTACK';
return spell.saveAbility ? `${spell.saveAbility}:${spell.halfOnSave ? 'HALF' : 'NONE'}` : '';
}
export function landingFrom(value: string): SpellLanding {
if (value === 'ATTACK') return { attackRoll: true, saveAbility: null, halfOnSave: false };
if (!value) return { attackRoll: false, saveAbility: null, halfOnSave: false };
const [ability, half] = value.split(':');
return { attackRoll: false, saveAbility: ability as Ability, halfOnSave: half === 'HALF' };
}