Fix #83: Add more things to the character sheet #86

Merged
Syndria98 merged 1 commits from ai/issue-83 into master 2026-10-15 20:55:58 +00:00
12 changed files with 1047 additions and 34 deletions

View File

@@ -34,10 +34,57 @@ const ActorSchema = new Schema({
max: { type: Number, min: 0, default: 1 }
},
proficiencies: { type: String, default: '' },
// The skills the character is proficient with (Syndria98/dragonroll#83). Dragonroll holds
// whole names; services/actor-foundry.js translates the short keys a Foundry world uses.
skills: {
acrobatics: { type: Boolean, default: false },
animalHandling: { type: Boolean, default: false },
arcana: { type: Boolean, default: false },
athletics: { type: Boolean, default: false },
deception: { type: Boolean, default: false },
history: { type: Boolean, default: false },
insight: { type: Boolean, default: false },
intimidation: { type: Boolean, default: false },
investigation: { type: Boolean, default: false },
medicine: { type: Boolean, default: false },
nature: { type: Boolean, default: false },
perception: { type: Boolean, default: false },
performance: { type: Boolean, default: false },
persuasion: { type: Boolean, default: false },
religion: { type: Boolean, default: false },
sleightOfHand: { type: Boolean, default: false },
stealth: { type: Boolean, default: false },
survival: { type: Boolean, default: false }
},
// Which of the six saving throws the character adds its proficiency bonus to.
savingThrows: {
str: { type: Boolean, default: false },
dex: { type: Boolean, default: false },
con: { type: Boolean, default: false },
int: { type: Boolean, default: false },
wis: { type: Boolean, default: false },
cha: { type: Boolean, default: false }
},
// Tool and language proficiencies: plain names, one per entry. The free-form
// `proficiencies` text keeps whatever else the character is proficient with
// (armour and weapons, say), which has no list of its own.
tools: [{ type: String, trim: true }],
languages: [{ type: String, trim: true }],
// The coins the character holds, in the five D&D denominations.
currency: {
pp: { type: Number, min: 0, default: 0 },
gp: { type: Number, min: 0, default: 0 },
ep: { type: Number, min: 0, default: 0 },
sp: { type: Number, min: 0, default: 0 },
cp: { type: Number, min: 0, default: 0 }
},
inventory: [{
name: { type: String, trim: true, default: '' },
quantity: { type: Number, min: 1, default: 1 },
weight: { type: Number, min: 0, default: 0 }
weight: { type: Number, min: 0, default: 0 },
// The gear's own picture: what a Foundry world sends with the item it stands
// for, shown on the left of the inventory row.
icon: { type: String, default: '' }
}],
traits: { type: String, default: '' },
spells: { type: String, default: '' },

View File

@@ -22,6 +22,13 @@ function barPool(existing, value) {
return { current, max };
}
// The tool and language lists (Syndria98/dragonroll#83): plain names, blank ones and
// repeats dropped.
function textList(value) {
if (!Array.isArray(value)) return [];
return [...new Set(value.map((name) => String(name).trim()).filter(Boolean))];
}
// Folders the campaign's actors are grouped into, in the shape the sidebar groups by
// (the notes, items and maps each keep a tree of their own, see models/Folder.js).
async function actorFolders(campaignId) {
@@ -65,7 +72,10 @@ router.post('/create', async (req, res) => {
router.post('/update', async (req, res) => {
try {
const { id, name, species, className, subclass, level, abilityScores, armorClass, speed, hitPoints, hitDice, proficiencies, inventory, traits, spells, image, folder } = req.body;
const {
id, name, species, className, subclass, level, abilityScores, armorClass, speed, hitPoints, hitDice,
proficiencies, skills, savingThrows, tools, languages, currency, inventory, traits, spells, image, folder
} = req.body;
if (!id) return res.json({ status: 'error', msg: 'errors.missing-data' });
const actor = await Actor.findById(id);
@@ -92,6 +102,14 @@ router.post('/update', async (req, res) => {
if (hitPoints !== undefined) actor.hitPoints = barPool(actor.hitPoints, hitPoints);
if (hitDice !== undefined) actor.hitDice = barPool(actor.hitDice, hitDice);
if (proficiencies !== undefined) actor.proficiencies = proficiencies;
// The lists the sheet toggles and fills in (Syndria98/dragonroll#83): which skills
// and saving throws the character is proficient with, its tools, its languages and
// the coins it carries.
if (skills !== undefined) actor.skills = skills;
if (savingThrows !== undefined) actor.savingThrows = savingThrows;
if (tools !== undefined) actor.tools = textList(tools);
if (languages !== undefined) actor.languages = textList(languages);
if (currency !== undefined) actor.currency = currency;
if (inventory !== undefined) actor.inventory = inventory;
if (traits !== undefined) actor.traits = traits;
if (spells !== undefined) actor.spells = spells;

View File

@@ -23,6 +23,112 @@ function detailsName(value, items) {
return looksLikeFoundryId(text) ? '' : text;
}
// --- Skills, saving throws, tools, languages and coins (Syndria98/dragonroll#83) ---
// The eighteen skills a 5e character has, as the system keys them and as Dragonroll
// names them. The short keys mean nothing outside Foundry, and Dragonroll's sheet holds
// the names it shows a user.
const FOUNDRY_SKILLS = {
acr: 'acrobatics', ani: 'animalHandling', arc: 'arcana', ath: 'athletics', dec: 'deception',
his: 'history', ins: 'insight', itm: 'intimidation', inv: 'investigation', med: 'medicine',
nat: 'nature', prc: 'perception', perf: 'performance', prs: 'persuasion', rel: 'religion',
sle: 'sleightOfHand', stl: 'stealth', sur: 'survival'
};
const ABILITIES = ['str', 'dex', 'con', 'int', 'wis', 'cha'];
const CURRENCIES = ['pp', 'gp', 'ep', 'sp', 'cp'];
// Whether one of the system's proficiency fields says the character has that
// proficiency. The system has held it several ways across its releases — a boolean, a
// number of proficiency steps, a list of proficiency modes ('prof', 'exp'), or one of
// those under `value`, `proficient` or `prof` — and worlds run different releases of
// it. Anything above nothing counts as proficient.
function isProficient(value, depth = 0) {
if (value === undefined || value === null || depth > 3) return false;
if (typeof value === 'boolean') return value;
if (typeof value === 'number') return value > 0;
if (typeof value === 'string') {
const text = value.trim();
if (!text) return false;
const number = Number(text);
return Number.isFinite(number) ? number > 0 : text.toLowerCase() !== 'none';
}
if (Array.isArray(value)) return value.some((entry) => isProficient(entry, depth + 1));
return ['value', 'proficient', 'prof'].some((key) => isProficient(value[key], depth + 1));
}
// A toggled map (skill name or ability → proficient) from whatever the actor lists.
// `null` says the actor says nothing about them at all, which is what keeps a live
// Foundry edit from clearing the toggles the campaign set by hand.
function toggleMap(sources) {
const toggled = {};
for (const [name, value] of Object.entries(sources)) {
if (value !== undefined) toggled[name] = isProficient(value);
}
return Object.keys(toggled).length ? toggled : null;
}
function foundrySkills(system) {
const skills = system.skills && typeof system.skills === 'object' ? system.skills : {};
return toggleMap(Object.fromEntries(Object.entries(FOUNDRY_SKILLS)
.map(([key, name]) => [name, skills[key]])));
}
function foundrySavingThrows(system) {
const saves = system.saves && typeof system.saves === 'object' ? system.saves : {};
return toggleMap(Object.fromEntries(ABILITIES.map((key) => [
key,
system.savingThrows?.[key] ?? system.abilities?.[key]?.save ?? saves[key]
])));
}
// Tools and languages: the module sends the labels its own CONFIG holds, because a
// world's proficiency lists are keys — and, since the third system release, language
// documents — that mean nothing outside Foundry. Without them the keys are the best
// there is to name a proficiency with, and a bare Foundry document id is worse than
// nothing at all. `null` says the actor says nothing about the kind, `[]` that it has
// none of it. Dragonroll names its lists in full; the world keeps its tools under
// `system.traits.tool` and its languages under `system.traits.languages`.
const TRAIT_FIELDS = { tools: 'tool', languages: 'languages' };
function foundryTraitNames(actor, kind) {
const labels = actor.dragonroll?.[kind];
if (Array.isArray(labels)) {
return [...new Set(labels.map((label) => asText(label).trim()).filter(Boolean))];
}
const trait = actor.system?.traits?.[TRAIT_FIELDS[kind] ?? kind];
if (!trait || typeof trait !== 'object') return null;
const names = [
...stringList(trait.value),
...asText(trait.custom).split(',').map((name) => name.trim())
].filter((name) => name && !looksLikeFoundryId(name));
return [...new Set(names)];
}
function foundryCurrency(system) {
const coins = system.currency;
if (!coins || typeof coins !== 'object') return null;
return Object.fromEntries(CURRENCIES.map((key) => [key, Math.max(0, numberOr(coins[key], 0))]));
}
// The character's traits as the world writes them: the free-text details field some
// system releases keep, or its trait items, which are how a monster's traits and a
// character's racial and class features are written. `undefined` says the world holds
// no traits to show.
function foundryTraits(source, items) {
const text = plainText(source.system?.details?.trait);
if (text) return text;
const features = items
.filter((item) => item.type === 'feat' && stringList(item.system?.featType?.value ?? item.system?.featType)
.some((type) => asText(type).toLowerCase().startsWith('tr')))
.map((item) => {
const name = asText(item.name).trim();
const description = plainText(item.system?.description?.value ?? item.system?.description);
return name ? `${name}\n${description}`.trim() : '';
})
.filter(Boolean);
return features.length ? features.join('\n\n') : undefined;
}
function foundryActorToCharacter(foundryActor) {
const system = foundryActor.system || {};
const details = system.details || {};
@@ -43,7 +149,7 @@ function foundryActorToCharacter(foundryActor) {
...stringList(traits.tool?.value)
].join(', ');
return {
const fields = {
name: asText(foundryActor.name).trim(),
type: ['character', 'npc', 'creature'].includes(savedDragonrollType)
? savedDragonrollType
@@ -56,24 +162,45 @@ function foundryActorToCharacter(foundryActor) {
challengeRating: String(details.cr ?? ''),
description: plainText(details.biography?.value || details.biography),
image: asText(foundryActor.img || foundryActor.image),
abilityScores: Object.fromEntries(['str', 'dex', 'con', 'int', 'wis', 'cha'].map((key) => [
abilityScores: Object.fromEntries(ABILITIES.map((key) => [
key,
numberOr(abilities[key]?.value, 10)
])),
armorClass: numberOr(attributes.ac?.value ?? attributes.ac, 10),
speed: numberOr(movement.walk ?? movement.value, 30),
proficiencies: foundryProficiencies || asText(savedDragonrollFields.proficiencies),
traits: asText(savedDragonrollFields.traits),
inventory: items
.filter((item) => !['class', 'subclass', 'background', 'spell'].includes(item.type))
.map((item) => ({
name: asText(item.name).trim(),
quantity: numberOr(item.system?.quantity, 1),
weight: numberOr(item.system?.weight?.value ?? item.system?.weight, 0)
weight: numberOr(item.system?.weight?.value ?? item.system?.weight, 0),
icon: asText(item.img).trim()
}))
.filter((item) => item.name),
spells: items.filter((item) => item.type === 'spell').map((item) => asText(item.name)).filter(Boolean).join('\n')
};
// What the world says about each of these, when it says anything: leaving a field
// out of the character is what keeps a live Foundry edit from clearing what the
// campaign toggled or wrote for it. Traits lead from the world when it has them, the
// way the proficiencies do; the text the module carries back on its flag is what the
// tab shows for an actor the world says nothing about.
const skills = foundrySkills(system);
if (skills) fields.skills = skills;
const savingThrows = foundrySavingThrows(system);
if (savingThrows) fields.savingThrows = savingThrows;
const tools = foundryTraitNames(foundryActor, 'tools');
if (tools) fields.tools = tools;
const languages = foundryTraitNames(foundryActor, 'languages');
if (languages) fields.languages = languages;
const currency = foundryCurrency(system);
if (currency) fields.currency = currency;
const worldTraits = foundryTraits(foundryActor, items);
const campaignTraits = asText(savedDragonrollFields.traits);
if (worldTraits || campaignTraits) fields.traits = worldTraits || campaignTraits;
return fields;
}
module.exports = { foundryActorToCharacter };

View File

@@ -474,9 +474,50 @@ function serializeFoundryActor(actor) {
if (data.img && !/^(https?:|data:|\/\/)/i.test(data.img)) {
data.img = new URL(data.img, window.location.origin).toString();
}
// Tools and languages travel by their names: what the actor holds are proficiency
// keys (and, since the third release of the system, language documents), which mean
// nothing to a sheet outside Foundry.
const names = { tools: foundryTraitNames(actor, "tools"), languages: foundryTraitNames(actor, "languages") };
if (names.tools || names.languages) data.dragonroll = { ...names };
return data;
}
// A proficiency list of `system.traits`: its keys resolved to the labels CONFIG gives
// them, plus whatever the GM typed as a proficiency of their own. `null` for an actor
// that has no such list, an empty array for one that has none of that kind. Dragonroll
// names its lists in full, while the world keeps its tools under `system.traits.tool`
// and its languages under `system.traits.languages`.
const TRAIT_FIELDS = { tools: "tool", languages: "languages" };
function foundryTraitNames(actor, kind) {
if (game.system?.id !== "dnd5e") return null;
const trait = actor.system?.traits?.[TRAIT_FIELDS[kind] ?? kind];
if (!trait || typeof trait !== "object") return null;
const names = (Array.isArray(trait.value) ? trait.value : [])
.map((key) => foundryProficiencyLabel(kind, key))
.filter(Boolean);
for (const custom of String(trait.custom ?? "").split(",")) {
const name = custom.trim();
if (name) names.push(name);
}
return [...new Set(names)];
}
function foundryProficiencyLabel(kind, key) {
if (typeof key !== "string" || !key) return "";
const entry = CONFIG.DND5E?.[kind === "languages" ? "languages" : "tools"]?.[key];
const label = entry?.label ?? entry?.name;
if (label) return String(label);
// A language the world added itself stands as a document of its own rather than in
// the system's config.
const document = kind === "languages" ? game.items?.get?.(key) : null;
if (document?.name) return String(document.name);
// The key beats dropping a proficiency the character really has.
return key;
}
function isSupportedCharacterActor(actor) {
const savedType = actor.getFlag?.(MODULE_ID, "actorType") || actor.flags?.[MODULE_ID]?.actorType;
return ["character", "npc", "creature"].includes(savedType || actor.type);

View File

@@ -24,6 +24,23 @@ const abilityStats = [
{ key: 'int', label: 'INT' }, { key: 'wis', label: 'WIS' }, { key: 'cha', label: 'CHA' }
];
// Les habilitats del 5e. Cada una té un cercle que s'encén quan el personatge hi és
// proficient, i la modificadora que tira és la de la característica que mana.
const skillList = [
{ key: 'acrobatics', ability: 'dex' }, { key: 'animalHandling', ability: 'wis' },
{ key: 'arcana', ability: 'int' }, { key: 'athletics', ability: 'str' },
{ key: 'deception', ability: 'cha' }, { key: 'history', ability: 'int' },
{ key: 'insight', ability: 'wis' }, { key: 'intimidation', ability: 'cha' },
{ key: 'investigation', ability: 'int' }, { key: 'medicine', ability: 'wis' },
{ key: 'nature', ability: 'int' }, { key: 'perception', ability: 'wis' },
{ key: 'performance', ability: 'cha' }, { key: 'persuasion', ability: 'cha' },
{ key: 'religion', ability: 'int' }, { key: 'sleightOfHand', ability: 'dex' },
{ key: 'stealth', ability: 'dex' }, { key: 'survival', ability: 'wis' }
];
// Les cinc monedes que un personatge porta al damunt.
const currencyUnits = ['pp', 'gp', 'ep', 'sp', 'cp'];
// Les pestanyes del lateral dret reparteixen la fitxa: característiques i combat,
// inventari, trets i conjurs. Són pestanyes de marcadors, no una pàgina nova.
const tabs = [
@@ -39,6 +56,17 @@ const activeTab = ref('abilities');
// per sota de 760px el marc les fa estar a dins i el marge deixa de fer falta.
const TAB_RAIL_WIDTH = 150;
// Les eines i els idiomes viatgen com a llista i el formulari els edita com un quadre
// de text: un nom per línia. Les comes també separen, que és com s'escriuen en una frase.
function proficiencyText(value) {
const names = Array.isArray(value) ? value : String(value ?? '').split(/[\n,]/);
return [...new Set(names.map((name) => String(name).trim()).filter(Boolean))].join('\n');
}
function proficiencyList(text) {
return [...new Set(String(text ?? '').split(/[\n,]/).map((name) => String(name).trim()).filter(Boolean))];
}
function normalizeActor(actor) {
return {
name: actor?.name ?? '',
@@ -60,8 +88,17 @@ function normalizeActor(actor) {
max: Number(actor?.hitDice?.max ?? actor?.level ?? 1)
},
proficiencies: actor?.proficiencies ?? '',
// El que el personatge sap fer i el que porta: les habilitats i les tirades de
// salvació són cercles que s'encenen, les eines i els idiomes són noms que el
// formulari edita com un text d'una línia per nom, i la moneda són cinc xifres.
skills: Object.fromEntries(skillList.map(({ key }) => [key, Boolean(actor?.skills?.[key])])),
savingThrows: Object.fromEntries(abilityStats.map(({ key }) => [key, Boolean(actor?.savingThrows?.[key])])),
tools: proficiencyText(actor?.tools),
languages: proficiencyText(actor?.languages),
currency: Object.fromEntries(currencyUnits.map((unit) => [unit, Number(actor?.currency?.[unit] ?? 0) || 0])),
inventory: (actor?.inventory ?? []).map((item) => ({
name: item.name ?? '', quantity: Number(item.quantity ?? 1), weight: Number(item.weight ?? 0)
name: item.name ?? '', quantity: Number(item.quantity ?? 1), weight: Number(item.weight ?? 0),
icon: item.icon ?? ''
})),
traits: actor?.traits ?? '',
spells: actor?.spells ?? '',
@@ -110,17 +147,37 @@ const carryingCapacity = computed(() => form.value.abilityScores.str * 15);
const carriedWeight = computed(() => form.value.inventory.reduce((total, item) => total + (Number(item.quantity) || 0) * (Number(item.weight) || 0), 0));
const carryPercent = computed(() => Math.min(100, carryingCapacity.value ? (carriedWeight.value / carryingCapacity.value) * 100 : 0));
function abilityModifier(score) {
const modifier = Math.floor((Number(score) - 10) / 2);
// `bonus` és el bonificador de proficiència, per a les habilitats i les tirades de
// salvació del personatge que hi està entrenat.
function abilityModifier(score, bonus = 0) {
const modifier = Math.floor((Number(score) - 10) / 2) + (Number(bonus) || 0);
return modifier >= 0 ? `+${modifier}` : String(modifier);
}
const imageUrl = computed(() => {
if (!form.value.image) return '';
return /^(https?:|data:|\/\/)/i.test(form.value.image)
? form.value.image
: `${getBaseUrl()}/public/${form.value.image}`;
});
function skillModifier(skill) {
return abilityModifier(form.value.abilityScores[skill.ability], form.value.skills[skill.key] ? proficiencyBonus.value : 0);
}
function savingThrowModifier(stat) {
return abilityModifier(form.value.abilityScores[stat.key], form.value.savingThrows[stat.key] ? proficiencyBonus.value : 0);
}
// El cercle d'una habilitat o d'una salvació: s'encén i s'apaga, i es desa amb tota la
// fitxa, com la resta del que s'edita.
function toggleProficiency(group, key) {
form.value[group][key] = !form.value[group][key];
}
// Una imatge pot ser una adreça sencera (la que Foundry dona a un objecte, per
// exemple) o un fitxer pujat aquí, que es serveix per `/api/public`.
function resolveImage(image) {
if (!image) return '';
return /^(https?:|data:|\/\/)/i.test(image)
? image
: `${getBaseUrl()}/public/${image}`;
}
const imageUrl = computed(() => resolveImage(form.value.image));
function pickPhoto() {
photoInput.value?.click();
@@ -184,6 +241,9 @@ async function saveSheet() {
const payload = {
id: actorId,
...form.value,
// Les eines i els idiomes van a l'API com a llista, que és com està desats.
tools: proficiencyList(form.value.tools),
languages: proficiencyList(form.value.languages),
inventory: form.value.inventory.filter((item) => item.name.trim())
};
const response = await Server().post('/actor/update', payload);
@@ -337,12 +397,68 @@ async function saveSheet() {
<span class="ability-modifier">{{ abilityModifier(form.abilityScores[stat.key]) }}</span>
</div>
</div>
<!-- Les tirades de salvació van just a sota de les característiques, que
són les que les manen: el cercle diu si el personatge hi està entrenat. -->
<h3>{{ $t('campaigns.character-sheet.saving-throws') }}</h3>
<div class="saving-throw-grid">
<button
v-for="stat in abilityStats"
:key="stat.key"
class="proficiency-row"
type="button"
role="switch"
:aria-checked="form.savingThrows[stat.key]"
:disabled="!editing"
@click="toggleProficiency('savingThrows', stat.key)"
>
<span class="proficiency-dot" :class="{ proficient: form.savingThrows[stat.key] }" aria-hidden="true" />
<span class="proficiency-name">{{ $t(`campaigns.character-sheet.abilities.${stat.key}`) }}</span>
<span class="proficiency-modifier">{{ savingThrowModifier(stat) }}</span>
</button>
</div>
</section>
<section class="sheet-panel skills-panel">
<h2>{{ $t('campaigns.character-sheet.skills') }}</h2>
<div class="skill-grid">
<button
v-for="skill in skillList"
:key="skill.key"
class="proficiency-row"
type="button"
role="switch"
:aria-checked="form.skills[skill.key]"
:disabled="!editing"
@click="toggleProficiency('skills', skill.key)"
>
<span class="proficiency-dot" :class="{ proficient: form.skills[skill.key] }" aria-hidden="true" />
<span class="proficiency-name">{{ $t(`campaigns.character-sheet.skill-names.${skill.key}`) }}</span>
<span class="proficiency-ability">{{ skill.ability.toUpperCase() }}</span>
<span class="proficiency-modifier">{{ skillModifier(skill) }}</span>
</button>
</div>
</section>
<section class="sheet-panel proficiencies-panel">
<h2>{{ $t('campaigns.character-sheet.proficiencies') }}</h2>
<textarea v-if="editing" v-model="form.proficiencies" rows="7" :placeholder="$t('campaigns.character-sheet.proficiencies-placeholder')" />
<p v-else class="sheet-copy">{{ form.proficiencies || $t('campaigns.character-sheet.empty-proficiencies') }}</p>
<!-- Les eines i els idiomes tenen llista pròpia; el text de dalt guarda
el que no en té, com les armadures i les armes. -->
<div class="proficiency-lists">
<div class="proficiency-list">
<h3>{{ $t('campaigns.character-sheet.tools') }}</h3>
<textarea v-if="editing" v-model="form.tools" rows="4" :placeholder="$t('campaigns.character-sheet.tools-placeholder')" />
<p v-else class="sheet-copy">{{ form.tools || $t('campaigns.character-sheet.empty-tools') }}</p>
</div>
<div class="proficiency-list">
<h3>{{ $t('campaigns.character-sheet.languages') }}</h3>
<textarea v-if="editing" v-model="form.languages" rows="4" :placeholder="$t('campaigns.character-sheet.languages-placeholder')" />
<p v-else class="sheet-copy">{{ form.languages || $t('campaigns.character-sheet.empty-languages') }}</p>
</div>
</div>
</section>
</main>
@@ -357,10 +473,21 @@ async function saveSheet() {
<strong>{{ carriedWeight.toFixed(1) }} / {{ carryingCapacity }} lb</strong>
</div>
<div class="weight-track"><div class="weight-fill" :style="{ width: `${carryPercent}%` }" /></div>
<!-- La moneda que el personatge porta a sobre, en les cinc monedes del joc. -->
<h3>{{ $t('campaigns.character-sheet.currency') }}</h3>
<div class="currency-row">
<label v-for="unit in currencyUnits" :key="unit" class="currency-field">
<span>{{ $t(`campaigns.character-sheet.currency-units.${unit}`) }}</span>
<input v-if="editing" v-model.number="form.currency[unit]" type="number" min="0" :aria-label="$t(`campaigns.character-sheet.currency-units.${unit}`)">
<strong v-else>{{ form.currency[unit] }}</strong>
</label>
</div>
<div class="inventory-table-wrap">
<table class="inventory-table">
<thead><tr>
<th>{{ $t('campaigns.character-sheet.item-name') }}</th>
<th><span class="sr-only">{{ $t('campaigns.character-sheet.item-icon') }}</span></th>
<th class="item-name-cell">{{ $t('campaigns.character-sheet.item-name') }}</th>
<th>{{ $t('campaigns.character-sheet.quantity') }}</th>
<th>{{ $t('campaigns.character-sheet.weight-each') }}</th>
<th>{{ $t('campaigns.character-sheet.total-weight') }}</th>
@@ -368,13 +495,17 @@ async function saveSheet() {
</tr></thead>
<tbody>
<tr v-for="(item, index) in form.inventory" :key="index">
<td><input v-if="editing" v-model="item.name" :aria-label="$t('campaigns.character-sheet.item-name')"><span v-else>{{ item.name }}</span></td>
<td class="item-icon-cell">
<img v-if="item.icon" :src="resolveImage(item.icon)" :alt="$t('campaigns.character-sheet.item-icon')">
<span v-else class="item-icon-blank" aria-hidden="true" />
</td>
<td class="item-name-cell"><input v-if="editing" v-model="item.name" :aria-label="$t('campaigns.character-sheet.item-name')"><span v-else>{{ item.name }}</span></td>
<td><input v-if="editing" v-model.number="item.quantity" type="number" min="1" :aria-label="$t('campaigns.character-sheet.quantity')"><span v-else>{{ item.quantity }}</span></td>
<td><input v-if="editing" v-model.number="item.weight" type="number" min="0" step="0.1" :aria-label="$t('campaigns.character-sheet.weight-each')"><span v-else>{{ Number(item.weight).toFixed(1) }} lb</span></td>
<td>{{ ((Number(item.quantity) || 0) * (Number(item.weight) || 0)).toFixed(1) }} lb</td>
<td v-if="editing"><button class="remove-item" type="button" @click="removeInventoryItem(index)">×</button></td>
</tr>
<tr v-if="form.inventory.length === 0"><td :colspan="editing ? 5 : 4" class="empty-inventory">{{ $t('campaigns.character-sheet.empty-inventory') }}</td></tr>
<tr v-if="form.inventory.length === 0"><td :colspan="editing ? 6 : 5" class="empty-inventory">{{ $t('campaigns.character-sheet.empty-inventory') }}</td></tr>
</tbody>
</table>
</div>
@@ -419,7 +550,7 @@ async function saveSheet() {
.sheet-button.primary { background: var(--color-link); color: var(--color-background); border-color: var(--color-link); }
.sheet-button:disabled { opacity: .55; cursor: wait; }
.sheet-button.compact { padding: 5px 9px; font-size: 12px; }
.sheet-grid { display: grid; grid-template-columns: minmax(200px, 34%) minmax(0, 1fr) minmax(0, 1fr); grid-template-rows: auto auto; gap: 11px; align-items: start; }
.sheet-grid { display: grid; grid-template-columns: minmax(200px, 34%) minmax(0, 1fr) minmax(0, 1fr); grid-template-rows: auto auto auto; gap: 11px; align-items: start; }
.sheet-tab-body { display: block; }
/* Pestilletes del marc: arrencen del cantó dret de la finestra, per fora del cos, i queden
fora del contingent que desfila. Per sota de 760px no hi ha lloc fora (vegeu a sota). */
@@ -457,13 +588,27 @@ async function saveSheet() {
tornada — classe d'armadura, velocitat, bonificadors i les barres de cops. */
.character-column { grid-column: 1; grid-row: 1 / -1; display: flex; flex-direction: column; gap: 11px; min-width: 0; }
.abilities-panel { grid-column: 2 / -1; grid-row: 1; }
.proficiencies-panel { grid-column: 2 / -1; grid-row: 2; }
.skills-panel { grid-column: 2 / -1; grid-row: 2; }
.proficiencies-panel { grid-column: 2 / -1; grid-row: 3; }
.ability-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 7px; }
.ability-card { min-height: 83px; padding: 8px 5px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; border: 1px solid var(--color-border); border-radius: 8px; background: var(--color-background-soft); }
.ability-label { font-size: 11px; font-weight: 700; letter-spacing: .08em; opacity: .75; }
.ability-score { font: 25px MrEavesRemake; }
.ability-modifier { min-width: 33px; text-align: center; padding: 2px 5px; border-radius: 999px; background: var(--color-background); font-size: 12px; }
.ability-card input { width: 55px; text-align: center; font-size: 21px; }
/* Les habilitats i les tirades de salvació: el cercle diu si el personatge hi està
entrenat, al costat la característica que mana i la modificadora que tira. */
.saving-throw-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; }
.skill-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px; }
.proficiency-row { display: flex; align-items: center; gap: 6px; min-width: 0; padding: 5px 7px; border: 1px solid var(--color-border); border-radius: 7px; background: var(--color-background-soft); color: var(--color-text); font: inherit; font-size: 12px; text-align: left; cursor: pointer; }
.proficiency-row:hover:not(:disabled) { border-color: var(--color-link); }
.proficiency-row:disabled { cursor: default; }
.proficiency-dot { width: 14px; height: 14px; flex: 0 0 14px; border: 2px solid var(--color-border); border-radius: 50%; }
.proficiency-dot.proficient { border-color: var(--color-link); background: var(--color-link); box-shadow: inset 0 0 0 2px var(--color-background-soft); }
.proficiency-name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.proficiency-ability { font-size: 10px; letter-spacing: .06em; opacity: .6; }
.proficiency-modifier { font-size: 11px; opacity: .8; }
.proficiency-lists { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px; }
.vitals-panel { display: flex; flex-direction: column; gap: 11px; }
.vital-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.vital-stat { min-height: 68px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 6px 4px; border: 1px solid var(--color-border); border-radius: 8px; background: var(--color-background-soft); text-align: center; }
@@ -495,12 +640,23 @@ textarea { resize: vertical; width: 100%; min-height: 88px; font-size: 12px; }
.weight-track { height: 5px; margin-bottom: 10px; overflow: hidden; border-radius: 999px; background: var(--color-background-soft); }
.weight-fill { height: 100%; border-radius: inherit; background: var(--color-link); transition: width .2s ease; }
.inventory-table-wrap { overflow-x: auto; }
/* La moneda que el personatge porta a sobre, en les cinc del joc. */
.currency-row { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 7px; margin-bottom: 11px; }
.currency-field { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 4px; border: 1px solid var(--color-border); border-radius: 8px; background: var(--color-background-soft); text-align: center; }
.currency-field > span { font-size: 10px; letter-spacing: .05em; opacity: .72; }
.currency-field > strong { font: 15px MrEavesRemake; }
.currency-field input { width: 58px; text-align: center; }
.inventory-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.inventory-table th { padding: 6px 7px; text-align: left; font-weight: 600; opacity: .7; }
.inventory-table td { padding: 5px 7px; border-top: 1px solid var(--color-border); }
.inventory-table td input { width: 100%; min-width: 54px; }
.inventory-table td:first-child input { min-width: 100px; }
.inventory-table th:not(:first-child), .inventory-table td:not(:first-child) { text-align: center; }
.inventory-table td.item-name-cell input { min-width: 100px; }
/* La icona de cada objecte obre la filera; el nom continua alineat a l'esquerra i la
quantitat i els pesos van al centre. */
.inventory-table .item-icon-cell { width: 40px; padding-right: 0; }
.item-icon-cell img { display: block; width: 26px; height: 26px; object-fit: contain; border-radius: 5px; }
.item-icon-blank { display: block; width: 26px; height: 26px; border: 1px dashed var(--color-border); border-radius: 5px; opacity: .35; }
.inventory-table th:not(:first-child):not(.item-name-cell), .inventory-table td:not(:first-child):not(.item-name-cell) { text-align: center; }
.empty-inventory { text-align: center !important; opacity: .65; }
.remove-item { width: 24px; height: 24px; border: 0; border-radius: 5px; background: transparent; color: var(--color-text); font-size: 20px; cursor: pointer; }
.remove-item:hover { background: var(--color-button-hover); }
@@ -508,7 +664,7 @@ textarea { resize: vertical; width: 100%; min-height: 88px; font-size: 12px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
@media (max-width: 760px) {
.sheet-grid { grid-template-columns: 1fr; grid-template-rows: none; }
.character-column, .abilities-panel, .proficiencies-panel { grid-column: 1 / -1; grid-row: auto; }
.character-column, .abilities-panel, .skills-panel, .proficiencies-panel { grid-column: 1 / -1; grid-row: auto; }
/* El cantó dret no dona prou per penjar-hi les pestanyes: llavors es queden al marc, per
dins, en una filera sota la barra de la finestra. */
.sheet-tabs { position: static; align-self: stretch; flex-direction: row; flex-wrap: wrap; gap: 4px; padding: 6px 8px 0; }
@@ -519,5 +675,7 @@ textarea { resize: vertical; width: 100%; min-height: 88px; font-size: 12px; }
.sheet-hero { align-items: flex-start; flex-wrap: wrap; }
.sheet-actions { margin-left: auto; }
.ability-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.skill-grid, .saving-throw-grid, .proficiency-lists { grid-template-columns: 1fr; }
.currency-row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
</style>

View File

@@ -14,11 +14,14 @@ Opening an actor opens its **character sheet**, in tabs:
| Tab | What it holds |
| --- | --- |
| Ability Scores | Strength, Dexterity, Constitution, Intelligence, Wisdom, Charisma, and the proficiency bonus |
| Inventory | What it carries: item, quantity and weight each, with the total carried weight added up |
| Ability Scores | Strength, Dexterity, Constitution, Intelligence, Wisdom, Charisma, and the proficiency bonus. Under them the six saving throws and the eighteen skills, each with a circle that stands lit when the character is proficient with it, next to the modifier it rolls. The proficiencies follow: the character's tools, its languages, and whatever else it is proficient with as text |
| Inventory | What it carries: every item with its icon, quantity and weight each, the total carried weight added up, and the coins the character holds |
| Traits | Features, traits and other details, as text |
| Spells | The spells it knows, one per line |
Toggling a skill, a saving throw, or writing a tool or a language is done like everything else on the
sheet: **Edit**, change it, **Save sheet**.
Combat lives above the tabs: armor class, speed, initiative, current and maximum hit points, and hit
dice. The photo at the top of the sheet is what shows up next to the character everywhere else —
including in [Discord](/docs/discord), where players can read the sheet of the character they hold.

View File

@@ -47,7 +47,7 @@ Worth knowing:
| In Foundry | In the campaign |
| --- | --- |
| Character, NPC and creature actors | Actors with the same sheet: abilities, combat stats, proficiencies, traits, spells, carried gear, portrait |
| Character, NPC and creature actors | Actors with the same sheet: abilities, saving throws, skills, combat stats, proficiencies, tools, languages, traits, spells, carried gear with its icons, coins, portrait |
| The world's **item directory** (the items tab) | The campaign's item list, with category, rarity, quantity, weight, properties and description |
| The folders grouping that item directory | Item folders with the same names and nesting |
| A folder's colour | The campaign's folder colour — and the other way round, what you colour in Dragonroll lands on the world's folder |

View File

@@ -120,10 +120,22 @@
"saving": "Desant...", "save": "Desa la fitxa", "save-error": "No s'ha pogut desar aquesta fitxa de personatge.", "photo": "Foto", "upload-photo": "Pujar foto", "change-photo": "Canviar foto", "remove-photo": "Treure foto", "uploading-photo": "Pujant...", "photo-error": "No s'ha pogut pujar aquesta foto.", "ability-scores": "Característiques", "proficiency-bonus": "Bonificador de competència",
"combat": "Combat", "armor-class": "Classe d'armadura", "speed": "Velocitat", "initiative": "Iniciativa",
"hit-points": "Punts de cop", "max-hit-points": "Punts de cop màxims", "hit-dice": "Daus de cop", "max-hit-dice": "Daus de cop màxims", "proficiencies": "Competències",
"proficiencies-placeholder": "Afegeix salvacions, habilitats, armadures, armes, eines i idiomes...", "empty-proficiencies": "No hi ha competències afegides.",
"proficiencies-placeholder": "Afegeix armadures, armes i qualsevol altra competència del personatge...", "empty-proficiencies": "No hi ha competències afegides.",
"saving-throws": "Tirades de salvació", "skills": "Habilitats",
"abilities": { "str": "Força", "dex": "Destresa", "con": "Constitució", "int": "Intel·ligència", "wis": "Saviesa", "cha": "Carisma" },
"skill-names": {
"acrobatics": "Acrobàcies", "animalHandling": "Tracte amb els animals", "arcana": "Arcan", "athletics": "Atletisme",
"deception": "Engany", "history": "Història", "insight": "Penetració", "intimidation": "Intimidació",
"investigation": "Investigació", "medicine": "Medicina", "nature": "Naturalesa", "perception": "Percepció",
"performance": "Actuació", "persuasion": "Persuasió", "religion": "Religió", "sleightOfHand": "Jocs de mans",
"stealth": "Furtivitat", "survival": "Supervivència"
},
"tools": "Eines", "tools-placeholder": "Escriu les eines, una per línia...", "empty-tools": "Cap competència amb eines.",
"languages": "Idiomes", "languages-placeholder": "Escriu els idiomes, un per línia...", "empty-languages": "Cap idioma.",
"traits": "Trets", "traits-placeholder": "Afegeix trets, capacitats i altres detalls...", "empty-traits": "No hi ha trets afegits.",
"spells": "Conjurs", "spells-placeholder": "Escriu els conjurs, un per línia...", "empty-spells": "No hi ha conjurs afegits.",
"inventory": "Inventari", "add-item": "Afegeix un objecte", "carried-weight": "Pes transportat", "item-name": "Objecte",
"quantity": "Quant.", "weight-each": "Unitat (lb)", "total-weight": "Total (lb)", "actions": "Accions", "empty-inventory": "L'inventari és buit."
"quantity": "Quant.", "weight-each": "Unitat (lb)", "total-weight": "Total (lb)", "actions": "Accions", "empty-inventory": "L'inventari és buit.",
"currency": "Monedes", "currency-units": { "pp": "PP", "gp": "GP", "ep": "EP", "sp": "SP", "cp": "CP" }, "item-icon": "Icona"
}
}

View File

@@ -126,10 +126,22 @@
"uploading-photo": "Uploading...", "photo-error": "Unable to upload this photo.", "ability-scores": "Ability Scores", "proficiency-bonus": "Proficiency Bonus",
"combat": "Combat", "armor-class": "Armor Class", "speed": "Speed", "initiative": "Initiative",
"hit-points": "Hit Points", "max-hit-points": "Maximum hit points", "hit-dice": "Hit Dice", "max-hit-dice": "Maximum hit dice", "proficiencies": "Proficiencies",
"proficiencies-placeholder": "Add saving throws, skills, armor, weapons, tools, and languages...", "empty-proficiencies": "No proficiencies added.",
"proficiencies-placeholder": "Add armor, weapons, and anything else the character is proficient with...", "empty-proficiencies": "No proficiencies added.",
"saving-throws": "Saving Throws", "skills": "Skills",
"abilities": { "str": "Strength", "dex": "Dexterity", "con": "Constitution", "int": "Intelligence", "wis": "Wisdom", "cha": "Charisma" },
"skill-names": {
"acrobatics": "Acrobatics", "animalHandling": "Animal Handling", "arcana": "Arcana", "athletics": "Athletics",
"deception": "Deception", "history": "History", "insight": "Insight", "intimidation": "Intimidation",
"investigation": "Investigation", "medicine": "Medicine", "nature": "Nature", "perception": "Perception",
"performance": "Performance", "persuasion": "Persuasion", "religion": "Religion", "sleightOfHand": "Sleight of Hand",
"stealth": "Stealth", "survival": "Survival"
},
"tools": "Tools", "tools-placeholder": "List tools, one per line...", "empty-tools": "No tool proficiencies.",
"languages": "Languages", "languages-placeholder": "List languages, one per line...", "empty-languages": "No languages.",
"traits": "Traits", "traits-placeholder": "Add features, traits, and other character details...", "empty-traits": "No traits added.",
"spells": "Spells", "spells-placeholder": "List spells, one per line...", "empty-spells": "No spells added.",
"inventory": "Inventory", "add-item": "Add item", "carried-weight": "Carried weight", "item-name": "Item",
"quantity": "Qty", "weight-each": "Each (lb)", "total-weight": "Total (lb)", "actions": "Actions", "empty-inventory": "Inventory is empty."
"quantity": "Qty", "weight-each": "Each (lb)", "total-weight": "Total (lb)", "actions": "Actions", "empty-inventory": "Inventory is empty.",
"currency": "Currency", "currency-units": { "pp": "PP", "gp": "GP", "ep": "EP", "sp": "SP", "cp": "CP" }, "item-icon": "Icon"
}
}

View File

@@ -120,10 +120,22 @@
"saving": "Guardando...", "save": "Guardar hoja", "save-error": "No se pudo guardar esta hoja de personaje.", "photo": "Foto", "upload-photo": "Subir foto", "change-photo": "Cambiar foto", "remove-photo": "Quitar foto", "uploading-photo": "Subiendo...", "photo-error": "No se pudo subir esta foto.", "ability-scores": "Características", "proficiency-bonus": "Bonificador por competencia",
"combat": "Combate", "armor-class": "Clase de armadura", "speed": "Velocidad", "initiative": "Iniciativa",
"hit-points": "Puntos de golpe", "max-hit-points": "Puntos de golpe máximos", "hit-dice": "Dados de golpe", "max-hit-dice": "Dados de golpe máximos", "proficiencies": "Competencias",
"proficiencies-placeholder": "Añade salvaciones, habilidades, armaduras, armas, herramientas e idiomas...", "empty-proficiencies": "No hay competencias añadidas.",
"proficiencies-placeholder": "Añade armaduras, armas y cualquier otra competencia del personaje...", "empty-proficiencies": "No hay competencias añadidas.",
"saving-throws": "Tiradas de salvación", "skills": "Habilidades",
"abilities": { "str": "Fuerza", "dex": "Destreza", "con": "Constitución", "int": "Inteligencia", "wis": "Sabiduría", "cha": "Carisma" },
"skill-names": {
"acrobatics": "Acrobacias", "animalHandling": "Trato con animales", "arcana": "Arcano", "athletics": "Atletismo",
"deception": "Engaño", "history": "Historia", "insight": "Perspicacia", "intimidation": "Intimidación",
"investigation": "Investigación", "medicine": "Medicina", "nature": "Naturaleza", "perception": "Percepción",
"performance": "Interpretación", "persuasion": "Persuasión", "religion": "Religión", "sleightOfHand": "Manualidades",
"stealth": "Sigilo", "survival": "Supervivencia"
},
"tools": "Herramientas", "tools-placeholder": "Escribe las herramientas, una por línea...", "empty-tools": "Sin competencias con herramientas.",
"languages": "Idiomas", "languages-placeholder": "Escribe los idiomas, uno por línea...", "empty-languages": "Sin idiomas.",
"traits": "Rasgos", "traits-placeholder": "Añade rasgos, capacidades y otros detalles...", "empty-traits": "No hay rasgos añadidos.",
"spells": "Conjuros", "spells-placeholder": "Escribe los conjuros, uno por línea...", "empty-spells": "No hay conjuros añadidos.",
"inventory": "Inventario", "add-item": "Añadir objeto", "carried-weight": "Peso transportado", "item-name": "Objeto",
"quantity": "Cant.", "weight-each": "Unidad (lb)", "total-weight": "Total (lb)", "actions": "Acciones", "empty-inventory": "El inventario está vacío."
"quantity": "Cant.", "weight-each": "Unidad (lb)", "total-weight": "Total (lb)", "actions": "Acciones", "empty-inventory": "El inventario está vacío.",
"currency": "Monedas", "currency-units": { "pp": "PP", "gp": "GP", "ep": "EP", "sp": "SP", "cp": "CP" }, "item-icon": "Icono"
}
}

View File

@@ -0,0 +1,574 @@
// Tests for Syndria98/dragonroll#83, the things the character sheet did not hold:
// * the eighteen skills down the ability scores tab, each with a circle that stands lit
// when the character is proficient with it, and the six saving throws beside them,
// * proficiencies with tools and with languages,
// * the coins a character carries and the icon of each item it carries,
// * and traits that reach the campaign from the linked Foundry world.
//
// The window is a `.vue` file and the repository root installs no dependencies for it, so
// its template, styles and plain functions are read out of the source the way
// tests/character-sheet-tabs.test.js and tests/character-sheet-portrait-column.test.js
// read them. The Foundry mapper is plain CommonJS and is required for real; the actor
// route runs in a stubbed `require` against fake models, like tests/foundry-force-import.test.js.
// The Foundry module goes into a `node:vm` context with stubbed globals, like
// tests/foundry-sync-toggle.test.js, so what its actor snapshot carries is observable.
//
// Run with `npm test` from the repository root, or `node --test tests/`.
const { test } = require("node:test");
const assert = require("node:assert/strict");
const fs = require("node:fs");
const path = require("node:path");
const vm = require("node:vm");
const read = (...parts) => fs.readFileSync(path.join(__dirname, "..", ...parts), "utf8");
const MODULE_ID = "dragonroll-foundry";
const sheetSource = read("frontend", "app", "components", "windows", "CharacterSheetWindow.vue");
const script = /<script setup>([\s\S]*?)<\/script>/.exec(sheetSource)?.[1] ?? "";
const template = /<template>([\s\S]*)<\/template>/.exec(sheetSource)?.[1] ?? "";
const actorModelSource = read("backend", "src", "models", "Actor.js");
// `fromSource` hands back one top-level declaration as a value, like the other character
// sheet tests do it.
function fromSource(source, pattern, locals = {}) {
const declaration = pattern.exec(source)?.[0];
assert.ok(declaration, `expected ${pattern} in the source`);
const name = /(?:const|function)\s+(\w+)/.exec(declaration)[1];
return new Function(...Object.keys(locals), `${declaration}\n;return ${name};`)(...Object.values(locals));
}
const abilityStats = fromSource(script, /const abilityStats = \[[\s\S]*?\];/);
const skillList = fromSource(script, /const skillList = \[[\s\S]*?\];/);
const currencyUnits = fromSource(script, /const currencyUnits = \[[\s\S]*?\];/);
const proficiencyText = fromSource(script, /function proficiencyText\(value\) \{[\s\S]*?\n\}/);
const proficiencyList = fromSource(script, /function proficiencyList\(text\) \{[\s\S]*?\n\}/);
const normalizeActor = fromSource(script, /function normalizeActor\(actor\) \{[\s\S]*?\n\}/, {
abilityStats, skillList, currencyUnits, proficiencyText
});
const skillKeys = skillList.map(({ key }) => key);
// --- The sheet: skills and saving throws on the ability scores tab -----------------
test("the sheet knows the eighteen skills, each under the ability that manages it", () => {
assert.deepEqual(skillKeys, [
"acrobatics", "animalHandling", "arcana", "athletics", "deception", "history", "insight",
"intimidation", "investigation", "medicine", "nature", "perception", "performance",
"persuasion", "religion", "sleightOfHand", "stealth", "survival"
]);
assert.deepEqual(
skillList.map(({ ability }) => ability),
["dex", "wis", "int", "str", "cha", "int", "wis", "cha", "int", "wis", "int", "wis", "cha", "cha", "int", "dex", "dex", "wis"],
"each skill stands with the ability D&D counts for it"
);
});
test("every skill stands with a circle that toggles whether the character is proficient", () => {
const panel = /<section class="sheet-panel skills-panel">([\s\S]*?)<\/section>/.exec(template)?.[1] ?? "";
assert.match(panel, /campaigns\.character-sheet\.skills/, "the panel is named for the skills");
assert.match(panel, /v-for="skill in skillList"/);
assert.match(panel, /:aria-checked="form\.skills\[skill\.key\]"/, "the circle says what it holds");
assert.match(panel, /@click="toggleProficiency\('skills', skill\.key\)"/);
assert.match(panel, /class="proficiency-dot"/);
assert.match(panel, /\{ proficient: form\.skills\[skill\.key\] \}/, "the circle stands lit for a proficiency");
assert.match(panel, /campaigns\.character-sheet\.skill-names\.\$\{skill\.key\}/, "the skill is called by its name");
assert.match(panel, /\{\{ skillModifier\(skill\) \}\}/, "and it shows the modifier the character rolls with it");
const toggle = /function toggleProficiency\(group, key\) \{[\s\S]*?\n\}/.exec(script)?.[0];
assert.match(toggle, /form\.value\[group\]\[key\] = !form\.value\[group\]\[key\]/, "the circle flips the toggle");
// The toggles belong to an edit in progress, like every other field of the sheet.
assert.match(panel, /:disabled="!editing"/);
});
test("the six saving throws ride with the ability scores", () => {
const abilities = /<section class="sheet-panel abilities-panel">([\s\S]*?)<\/section>/.exec(template)?.[1] ?? "";
assert.match(abilities, /campaigns\.character-sheet\.saving-throws/);
assert.match(abilities, /v-for="stat in abilityStats"/, "one save per ability score");
assert.match(abilities, /:aria-checked="form\.savingThrows\[stat\.key\]"/);
assert.match(abilities, /@click="toggleProficiency\('savingThrows', stat\.key\)"/);
assert.match(abilities, /\{\{ savingThrowModifier\(stat\) \}\}/);
// The ability scores themselves are untouched, and the saves stand under them.
assert.match(abilities, /v-model\.number="form\.abilityScores\[stat\.key\]"/);
assert.ok(
abilities.indexOf("ability-grid") < abilities.indexOf("saving-throw-grid"),
"the saving throws follow the scores they come from"
);
});
test("a skill's form entry starts off, and the world's toggles carry over", () => {
const fresh = normalizeActor({});
assert.deepEqual(fresh.skills.acrobatics, false);
assert.deepEqual(fresh.savingThrows.str, false);
assert.deepEqual(Object.keys(fresh.skills).length, 18, "every skill stands in the form, toggled or not");
assert.deepEqual(Object.keys(fresh.savingThrows).sort(), ["cha", "con", "dex", "int", "str", "wis"]);
const trained = normalizeActor({ skills: { stealth: true }, savingThrows: { con: true } });
assert.equal(trained.skills.stealth, true);
assert.equal(trained.savingThrows.con, true);
});
// --- Tools and languages ----------------------------------------------------------
test("tools and languages have a list of their own under the proficiencies", () => {
const panel = /<section class="sheet-panel proficiencies-panel">([\s\S]*?)<\/section>/.exec(template)?.[1] ?? "";
for (const [key, field] of [["tools", "form.tools"], ["languages", "form.languages"]]) {
assert.match(panel, new RegExp(`campaigns\\.character-sheet\\.${key}`), `the ${key} are named`);
assert.match(panel, new RegExp(`v-model="${field}"`), `the ${key} are edited as text`);
assert.match(panel, new RegExp(`\\{\\{ ${field} \\|\\| \\$t\\('campaigns\\.character-sheet\\.empty-${key}'\\) \\}\\}`));
}
// The free text keeps what has no list of its own, so it no longer asks for these.
const placeholder = /"proficiencies-placeholder": "([^"]+)"/.exec(read("frontend", "i18n", "locales", "en", "campaigns.json"))[1];
assert.doesNotMatch(placeholder, /skills|saving throws|tools|languages/i, "the text field does not ask for what has its own list");
});
test("the tools and languages lists travel as a list and edit as one name per line", () => {
assert.deepEqual(normalizeActor({ tools: ["Thieves tools", "Dice set"] }).tools, "Thieves tools\nDice set");
assert.deepEqual(normalizeActor({ languages: [] }).languages, "");
assert.deepEqual(
normalizeActor({ tools: [" Thieves tools ", "Thieves tools", "", "Dice set"] }).tools,
"Thieves tools\nDice set",
"blanks, spaces and repeats are not kept"
);
assert.deepEqual(proficiencyList("Thieves tools\nDice set"), ["Thieves tools", "Dice set"]);
assert.deepEqual(proficiencyList("Common, Elvish, Common"), ["Common", "Elvish"], "a comma separates too");
assert.deepEqual(proficiencyList(""), []);
assert.deepEqual(proficiencyList(proficiencyText(["Cartographer's supplies"])), ["Cartographer's supplies"]);
});
// --- Currency and item icons on the inventory tab ---------------------------------
test("the inventory shows the coins the character carries", () => {
assert.deepEqual(currencyUnits, ["pp", "gp", "ep", "sp", "cp"]);
const panel = /<main v-show="activeTab === 'inventory'"[\s\S]*?<\/main>/.exec(template)?.[0] ?? "";
assert.match(panel, /campaigns\.character-sheet\.currency/);
assert.match(panel, /v-for="unit in currencyUnits"/);
assert.match(panel, /v-model\.number="form\.currency\[unit\]"/, "each coin can be counted in");
assert.match(panel, /\{\{ form\.currency\[unit\] \}\}/, "and reads back outside of editing");
assert.deepEqual(normalizeActor({}).currency, { pp: 0, gp: 0, ep: 0, sp: 0, cp: 0 });
assert.deepEqual(normalizeActor({ currency: { gp: 12, cp: "40" } }).currency, { pp: 0, gp: 12, ep: 0, sp: 0, cp: 40 });
});
test("every inventory row opens with the item's icon", () => {
const panel = /<main v-show="activeTab === 'inventory'"[\s\S]*?<\/main>/.exec(template)?.[0] ?? "";
const iconCell = /<td class="item-icon-cell">([\s\S]*?)<\/td>/.exec(panel)?.[1] ?? "";
assert.match(iconCell, /v-if="item\.icon"/);
assert.match(iconCell, /:src="resolveImage\(item\.icon\)"/, "a world's own icon and an upload both resolve");
assert.match(iconCell, /item-icon-blank/, "and a row without one leaves the place marked");
// The icon comes first, and the name it stands in front of keeps reading left.
const firstCells = /<tr v-for="\(item, index\) in form\.inventory" :key="index">([\s\S]*?)<\/td>\s*([\s\S]*?)<\/td>/.exec(panel);
assert.match(firstCells[1], /item-icon-cell/);
assert.match(firstCells[2], /item-name-cell/);
const aligns = /\.inventory-table th:not\(:first-child\):not\(\.item-name-cell\)/.exec(sheetSource)?.[0];
assert.ok(aligns, "the name column is let go of the centred columns");
assert.equal(normalizeActor({ inventory: [{ name: "Torch" }] }).inventory[0].icon, "");
assert.equal(
normalizeActor({ inventory: [{ name: "Torch", icon: "http://vtt.test/icons/torch.svg" }] }).inventory[0].icon,
"http://vtt.test/icons/torch.svg"
);
});
// --- The model and the route ------------------------------------------------------
test("the Actor model holds the skills, the saves, the tools, the languages and the coins", () => {
for (const key of skillKeys) {
assert.match(actorModelSource, new RegExp(`${key}: \\{ type: Boolean, default: false \\}`), `${key} is a toggle`);
}
for (const key of ["str", "dex", "con", "int", "wis", "cha"]) {
assert.ok(
new RegExp(`savingThrows: \\{[\\s\\S]*?${key}: \\{ type: Boolean, default: false \\}`).test(actorModelSource),
`the ${key} saving throw stands in the model`
);
}
assert.match(actorModelSource, /tools: \[\{ type: String, trim: true \}\]/);
assert.match(actorModelSource, /languages: \[\{ type: String, trim: true \}\]/);
for (const unit of currencyUnits) {
assert.ok(
new RegExp(`currency: \\{[\\s\\S]*?${unit}: \\{ type: Number, min: 0, default: 0 \\}`).test(actorModelSource),
`${unit} counts among the coins`
);
}
assert.match(actorModelSource, /icon: \{ type: String, default: '' \}/, "a carried item keeps its icon");
});
// The actor update route with every require stubbed, the way
// tests/foundry-force-import.test.js runs the import route.
function loadActorRoute(actor) {
const routes = new Map();
const router = {
get: (route, ...handlers) => routes.set(`GET ${route}`, handlers),
post: (route, ...handlers) => routes.set(`POST ${route}`, handlers),
};
const requireStub = (id) => {
if (id === "express") return { Router: () => router };
if (id === "../services/storage") return { single: () => (req, res, next) => next() };
if (id === "../models/Campaign") {
return { findOne: () => ({ lean: () => Promise.resolve({ _id: "campaign-1" }) }) };
}
if (id === "../models/Actor") return { findById: async () => actor };
if (id === "../models/Folder") return { belongsToSection: async () => true };
if (id === "../models/Map") return { updateMany: async () => ({}) };
throw new Error(`require("${id}") is not stubbed`);
};
const moduleStub = { exports: {} };
vm.compileFunction(read("backend", "src", "routes", "actor.js"), ["require", "module", "exports"])(
requireStub, moduleStub, moduleStub.exports
);
async function update(body, user = { id: "user-1" }) {
const handlers = routes.get("POST /update");
assert.ok(handlers, "POST /update is not mounted");
let payload = null;
await handlers[handlers.length - 1]({ body, user }, { json: (sent) => { payload = sent; } });
return payload;
}
return { update };
}
test("the actor update writes the skills, the saves, the tools, the languages and the coins", async () => {
const actor = { _id: "actor-1", campaign: "campaign-1", save: async () => {} };
const route = loadActorRoute(actor);
const response = await route.update({
id: "actor-1",
skills: { acrobatics: true, stealth: false },
savingThrows: { con: true },
tools: [" Thieves tools ", "Thieves tools", "", "Dice set"],
languages: ["Elvish", "Undercommon"],
currency: { gp: 12, cp: 40 },
inventory: [{ name: "Torch", quantity: 2, weight: 0.5, icon: "icons/torch.svg" }],
});
assert.equal(response.status, "ok");
assert.deepEqual(actor.skills, { acrobatics: true, stealth: false });
assert.deepEqual(actor.savingThrows, { con: true });
assert.deepEqual(actor.tools, ["Thieves tools", "Dice set"], "blanks and repeats are written out of the lists");
assert.deepEqual(actor.languages, ["Elvish", "Undercommon"]);
assert.deepEqual(actor.currency, { gp: 12, cp: 40 });
assert.deepEqual(actor.inventory, [{ name: "Torch", quantity: 2, weight: 0.5, icon: "icons/torch.svg" }]);
});
test("an update that says nothing about them leaves the toggles and lists where they are", async () => {
const actor = {
_id: "actor-1",
campaign: "campaign-1",
skills: { acrobatics: true },
tools: ["Disguise kit"],
currency: { gp: 3 },
save: async () => {},
};
const route = loadActorRoute(actor);
const response = await route.update({ id: "actor-1", name: "Thalia" });
assert.equal(response.status, "ok");
assert.equal(actor.name, "Thalia");
assert.deepEqual(actor.skills, { acrobatics: true });
assert.deepEqual(actor.tools, ["Disguise kit"]);
assert.deepEqual(actor.currency, { gp: 3 });
});
// --- The Foundry world fills them in ---------------------------------------------
const { foundryActorToCharacter } = require(path.join(__dirname, "..", "backend", "src", "services", "actor-foundry.js"));
test("a world's skill and saving throw proficiencies arrive toggled", () => {
const character = foundryActorToCharacter({
name: "Thalia",
system: {
skills: { acr: { value: 1 }, stl: { value: 0 }, prc: { value: 2 }, arc: { value: ["exp"] }, his: { value: [] } },
savingThrows: { str: { value: 1 }, dex: { value: 0 }, con: { prof: { value: 2 } } },
},
});
assert.deepEqual(character.skills, {
acrobatics: true, stealth: false, arcana: true, history: false, perception: true,
});
assert.deepEqual(character.savingThrows, { str: true, dex: false, con: true });
});
test("an older world holding its saves under the abilities is read the same way", () => {
const character = foundryActorToCharacter({
name: "Thalia",
system: { abilities: { str: { save: 0 }, dex: { save: 1 } }, saves: { con: { proficient: true } } },
});
assert.deepEqual(character.savingThrows, { str: false, dex: true, con: true });
});
test("a world that says nothing about skills or saves leaves what the campaign toggled", () => {
const character = foundryActorToCharacter({ name: "Thalia", system: { abilities: { str: { value: 16 } } } });
assert.ok(!("skills" in character), "no skills to report is not the same as none proficient");
assert.ok(!("savingThrows" in character));
assert.ok(!("currency" in character));
assert.ok(!("tools" in character), "and neither are the tool and language lists");
assert.ok(!("languages" in character));
});
test("the tools and languages the module names come over as they are named", () => {
const character = foundryActorToCharacter({
name: "Thalia",
system: { traits: { tool: { value: ["xyz12abc345def67"] }, languages: { value: ["aB3cD9eF1gH2iJ4k"] } } },
dragonroll: { tools: ["Thieves' tools", "Dice set"], languages: ["Elvish", "Deep Speech"] },
});
assert.deepEqual(character.tools, ["Thieves' tools", "Dice set"]);
assert.deepEqual(character.languages, ["Elvish", "Deep Speech"]);
});
test("without the module's names the proficiency keys are read off the actor", () => {
const character = foundryActorToCharacter({
name: "Thalia",
system: {
traits: {
tool: { value: ["thieves", "alchemist"], custom: "Dice set, Playing cards" },
languages: { value: ["common", "aB3cD9eF1gH2iJ4k"], custom: "Thieves' cant" },
},
},
});
assert.deepEqual(character.tools, ["thieves", "alchemist", "Dice set", "Playing cards"]);
assert.deepEqual(
character.languages,
["common", "Thieves' cant"],
"a language the sheet cannot name is dropped rather than shown as a document id"
);
const none = foundryActorToCharacter({ name: "Thalia", system: { traits: { tool: { value: [] } } } });
assert.deepEqual(none.tools, [], "a world with no tool proficiency says so");
assert.ok(!("languages" in none), "and says nothing at all about the ones it does not list");
});
test("the coins of the world are the coins of the campaign", () => {
const character = foundryActorToCharacter({ name: "Thalia", system: { currency: { pp: 1, gp: 25, sp: -3 } } });
assert.deepEqual(character.currency, { pp: 1, gp: 25, ep: 0, sp: 0, cp: 0 }, "and never a debt");
});
test("a carried item brings its own icon", () => {
const character = foundryActorToCharacter({
name: "Thalia",
items: [
{ name: "Longsword", type: "weapon", img: "http://vtt.test/icons/sword.svg", system: { quantity: 1, weight: { value: 3 } } },
{ name: "Rope", type: "equipment", system: { quantity: 2 } },
],
});
assert.deepEqual(character.inventory, [
{ name: "Longsword", quantity: 1, weight: 3, icon: "http://vtt.test/icons/sword.svg" },
{ name: "Rope", quantity: 2, weight: 0, icon: "" },
]);
});
// --- The traits tab syncs --------------------------------------------------------
test("the world's own traits reach the campaign", () => {
const fromText = foundryActorToCharacter({ name: "Thalia", system: { details: { trait: "Spellcaster.<br>Light sleeper." } } });
assert.equal(fromText.traits, "Spellcaster.\nLight sleeper.");
const fromFeatures = foundryActorToCharacter({
name: "Thalia",
system: {},
items: [
{ name: "Darkvision", type: "feat", system: { featType: "trs", description: { value: "<p>See in the dark.</p>" } } },
{ name: "Brave", type: "feat", system: { featType: ["tr"], description: { value: "Advantage on saves." } } },
{ name: "Alert", type: "feat", system: { featType: "feat", description: { value: "Never surprised." } } },
],
});
assert.equal(fromFeatures.traits, "Darkvision\nSee in the dark.\n\nBrave\nAdvantage on saves.");
});
test("the world leads the traits tab, and what the campaign wrote fills in when it has none", () => {
// The module carries whatever the campaign shows for the traits back to the world on
// its flag, and the actor's own traits lead from there: a world keeps its traits in
// step the same way it keeps its proficiencies in step, while a character the world
// says nothing about keeps what the campaign wrote for it.
const fromWorld = foundryActorToCharacter({
name: "Thalia",
system: { details: { trait: "The world's own traits" } },
flags: { [MODULE_ID]: { traits: "What the campaign typed" } },
});
assert.equal(fromWorld.traits, "The world's own traits");
const fromCampaign = foundryActorToCharacter({
name: "Thalia",
system: {},
flags: { [MODULE_ID]: { traits: "What the campaign typed" } },
});
assert.equal(fromCampaign.traits, "What the campaign typed");
});
test("an actor that holds no traits does not clear what the campaign has", () => {
const character = foundryActorToCharacter({ name: "Thalia", system: {}, items: [], flags: {} });
assert.ok(!("traits" in character), "a live edit that knows nothing about traits leaves the tab as it is");
});
// --- The module sends the names a sheet outside Foundry can read -----------------
function makeWorld({ actor, config = {}, worldItems = [] }) {
const state = { hooks: new Map(), requests: [], timers: new Map(), nextTimerId: 1 };
const documents = [actor];
const settingsStore = { autoSync: true, syncToken: "sync-token-1", dragonrollApiUrl: "http://backend.test:5000" };
const sandbox = {
console: { log() {}, info() {}, warn() {}, error() {} },
URL,
CONFIG: config,
window: { location: { origin: "http://vtt.test" } },
ui: { notifications: { info() {}, warn() {}, error() {} } },
Hooks: {
once(name, fn) { state.hooks.set(name, [fn]); },
on(name, fn) { state.hooks.set(name, [...(state.hooks.get(name) || []), fn]); },
},
setTimeout: (fn) => { const id = state.nextTimerId++; state.timers.set(id, { fn }); return id; },
clearTimeout: (id) => state.timers.delete(id),
setInterval: () => 0,
clearInterval: () => {},
fetch: async (url, options = {}) => {
state.requests.push({ href: String(url), body: options.body ? JSON.parse(options.body) : null });
return { ok: true, status: 200, json: async () => ({ status: "ok", actors: [], items: [] }) };
},
Actor: { async create() { return null; } },
Item: { async create() { return null; } },
};
sandbox.game = {
user: { isGM: true },
world: { id: "world-1", title: "Test World" },
system: { id: "dnd5e" },
modules: { get: () => ({}) },
actors: { contents: documents, get: (id) => documents.find((document) => document.id === id) },
items: { contents: worldItems, get: (id) => worldItems.find((document) => document.id === id) },
folders: { contents: [], get: () => null },
settings: {
register(module, key, definition) {
if (!(key in settingsStore)) settingsStore[key] = definition.default;
},
get(module, key) { return settingsStore[key]; },
async set(module, key, value) { settingsStore[key] = value; },
},
};
vm.createContext(sandbox);
vm.runInContext(read("dragonroll-foundry", "scripts", "api.js"), sandbox);
const drain = async () => { await new Promise((resolve) => setImmediate(resolve)); };
state.fire = async (name, ...args) => {
for (const handler of state.hooks.get(name) || []) await handler(...args);
await drain();
};
state.runTimers = async () => {
for (let round = 0; round < 6; round += 1) {
const due = [...state.timers.values()];
state.timers.clear();
for (const timer of due) await timer.fn();
await drain();
}
};
// Only the pushes of an actor count here: the world start sends one, and what an
// actor changed sends the next.
state.actorPushes = () => state.requests
.filter((request) => request.href.includes("foundry/sync/snapshot"))
.map((request) => request.body.actors[0]);
return state;
}
function makeStubActor(id, name, system = {}, items = []) {
return {
id,
name,
type: "character",
documentName: "Actor",
img: "icons/svg/mystery-man.svg",
system,
flags: {},
items: { contents: items },
getFlag(module, key) { return this.flags?.[module]?.[key]; },
async update(data) { return data; },
toObject() { return { _id: this.id, name: this.name, type: this.type, img: this.img, flags: this.flags, system: this.system }; },
};
}
// A world document of its own — a language since the third release of the system —
// plain enough to serialize like any other item of the world.
function makeWorldItem(id, name) {
return {
id,
name,
type: "loot",
documentName: "Item",
parent: null,
folder: null,
flags: {},
system: {},
getFlag() { return undefined; },
toObject() { return { _id: this.id, name: this.name, type: this.type, flags: this.flags, system: this.system }; },
};
}
async function pushAfterEdit(actor, options) {
const world = makeWorld(options);
await world.fire("init");
await world.fire("ready");
await world.runTimers();
await world.fire("updateActor", actor);
await world.runTimers();
return world.actorPushes().at(-1);
}
test("the actor snapshot names the world's tools and languages", async () => {
const actor = makeStubActor("actor-1", "Thalia", {
traits: {
tool: { value: ["thieves"], custom: "Dice set" },
languages: { value: ["common", "lang-1"] },
},
});
const sent = await pushAfterEdit(actor, {
config: {
DND5E: {
tools: { thieves: { label: "Thieves' tools" } },
languages: { common: { name: "Common" } },
},
},
worldItems: [makeWorldItem("lang-1", "Deep Speech")],
});
assert.equal(sent._id, "actor-1", "the actor the world edited is the one that was sent");
assert.deepEqual(sent.dragonroll.tools, ["Thieves' tools", "Dice set"]);
assert.deepEqual(sent.dragonroll.languages, ["Common", "Deep Speech"]);
});
test("an actor listing no tools or languages says nothing about them", async () => {
const actor = makeStubActor("actor-1", "Grunt", { details: { level: 1 } });
const sent = await pushAfterEdit(actor, { config: { DND5E: { tools: { thieves: { label: "Thieves' tools" } } } } });
assert.equal(sent.dragonroll, undefined, "no dragonroll block is what tells the campaign nothing was said");
});
// --- Every locale says it ------------------------------------------------------
test("every locale names the skills, the saving throws, the tools, the languages and the coins", () => {
for (const locale of ["en", "es", "ca"]) {
const sheet = JSON.parse(read("frontend", "i18n", "locales", locale, "campaigns.json"))["character-sheet"];
for (const key of ["skills", "saving-throws", "tools", "languages", "currency", "item-icon"]) {
assert.ok(sheet[key], `${locale} is missing campaigns.character-sheet.${key}`);
}
for (const [group, keys] of [["abilities", ["str", "dex", "con", "int", "wis", "cha"]], ["skill-names", skillKeys], ["currency-units", currencyUnits]]) {
for (const key of keys) {
assert.ok(sheet[group]?.[key], `${locale} is missing campaigns.character-sheet.${group}.${key}`);
}
}
assert.deepEqual(Object.keys(sheet["skill-names"]).sort(), [...skillKeys].sort(), `${locale} names every skill the sheet lists`);
assert.notEqual(sheet["skill-names"].acrobatics, "acrobatics", `${locale} spells the skill out, not its key`);
}
});

View File

@@ -34,7 +34,12 @@ function fromSource(source, pattern, locals = {}) {
}
const abilityStats = fromSource(script, /const abilityStats = \[[\s\S]*?\];/);
const normalizeActor = fromSource(script, /function normalizeActor\(actor\) \{[\s\S]*?\n\}/, { abilityStats });
// #83 put the skills, the saving throws, the tools, the languages and the coins into the
// sheet form, so reading that form out of the source reads their names along with it.
const skillList = fromSource(script, /const skillList = \[[\s\S]*?\];/);
const currencyUnits = fromSource(script, /const currencyUnits = \[[\s\S]*?\];/);
const proficiencyText = fromSource(script, /function proficiencyText\(value\) \{[\s\S]*?\n\}/);
const normalizeActor = fromSource(script, /function normalizeActor\(actor\) \{[\s\S]*?\n\}/, { abilityStats, skillList, currencyUnits, proficiencyText });
const barPercent = fromSource(script, /function barPercent\(current, max\) \{[\s\S]*?\n\}/);
const barPool = fromSource(actorRouteSource, /function barPool\(existing, value\) \{[\s\S]*?\n\}/);
@@ -117,10 +122,14 @@ test("the initiative bonus is the modifier of dexterity", () => {
/const initiativeBonus = computed\(\(\) => abilityModifier\(form\.value\.abilityScores\.dex\)\)/,
"D&D counts initiative as the dexterity modifier while the character carries no extra bonus"
);
const abilityModifier = fromSource(script, /function abilityModifier\(score\) \{[\s\S]*?\n\}/);
// #83 gave the helper an optional proficiency bonus, for the skills and the saving
// throws the character is proficient with; the bare modifier is unchanged.
const abilityModifier = fromSource(script, /function abilityModifier\(score[^{]*\) \{[\s\S]*?\n\}/);
assert.equal(abilityModifier(16), "+3");
assert.equal(abilityModifier(10), "+0", "the sheet writes a flat modifier with its sign, as the ability cards do");
assert.equal(abilityModifier(9), "-1");
assert.equal(abilityModifier(16, 3), "+6", "a proficient skill adds the proficiency bonus to its modifier");
assert.equal(abilityModifier(8, 2), "+1", "and one below 10 counts its own negative modifier first");
});
test("an actor carries its pools, and one without them starts on its level", () => {