Fix Roll20 worker compatibility and combat targeting
Roll20 Sheet Build Successful The Ravenous Roll20 sheet was generated and validated successfully.
Ravenous/ravenous_roll20/pipeline/head This commit looks good Details

This commit is contained in:
Dandaedre 2026-09-17 22:48:56 +02:00
parent ebc428a74e
commit d4b629bfae
Signed by: Dandaedre
GPG Key ID: 440C6592E8A26D99
8 changed files with 83 additions and 44 deletions

View File

@ -64,7 +64,7 @@ the default is selected by `data/config/build.yaml`.
For a Roll20 test, copy the generated HTML, CSS, and translation JSON into a
custom sheet or sheet sandbox. Use current CSE mode with Legacy Sanitization
disabled. The editor preview is insufficient for sheet workers and repeating
sections. Test with two characters and a selected defender token when checking
sections. Test with two characters and a targeted defender token when checking
the attack card's **Défendre** and **Subir** actions.
## How the sheet works
@ -78,7 +78,7 @@ the attack card's **Défendre** and **Subir** actions.
persistent values are Roll20 attributes. Keep attribute names and generated
option values stable when possible because existing characters store them.
- Skill and attack rolls use the `ravenous` roll template and `startRoll` /
`finishRoll`. Attack follow-ups use the selected defender token. The attack
`finishRoll`. Attack follow-ups prompt for a defender token. The attack
result cache (`attackRolls`) lives only in worker memory, so test follow-up
behavior after reopening a sheet as well as immediately after rolling.
- **Subir** displays calculated DMG and AB after checked resistances and
@ -108,7 +108,7 @@ the attack card's **Défendre** and **Subir** actions.
Roll20 interaction.
4. For interactive changes, manually exercise the affected flow in Roll20:
open and reopen the sheet, change inputs, add and reorder repeating rows,
roll from chat, and check results on a selected defender token. Record what
roll from chat, and check results on a targeted defender token. Record what
was actually tested and what could not be tested.
## Known gaps and priorities

View File

@ -218,19 +218,20 @@ prévisualisation intégrée de Roll20 ne simule pas complètement les sheet
workers ni les sections répétables : validez les imports et les jets dans le
bac à sable de feuille ou dans une partie de test.
Pour utiliser **Défendre** depuis la carte d'une attaque, sélectionnez d'abord
le token du défenseur. La macro utilise alors sa compétence d'Esquive ou de
Pour utiliser **Défendre** ou **Subir** depuis la carte d'une attaque, cliquez
le token du défenseur lorsque Roll20 affiche le ciblage « Défenseur ».
La macro utilise alors sa compétence d'Esquive ou de
Parade et son modificateur temporaire, sans ajouter la caractéristique associée.
Le bouton **Jets secrets** dans l'en-tête envoie les jets du personnage
uniquement au maître de jeu. Les actions Défendre et Subir suivent le réglage
du token défenseur sélectionné.
du token défenseur ciblé.
Avant d'utiliser **Subir** depuis une attaque, cochez dans l'onglet Santé les
résistances applicables et, dans l'onglet Combat, les protections couvrant la
localisation. Les résistances cochées se cumulent et retirent chacune deux DMG
par point. Une protection cochée ne compte que si son intégrité est supérieure
à zéro ; le calcul retire alors sa Protection ainsi que la Force finale du
défenseur sélectionné.
défenseur ciblé.
Le menu Protection de **Subir** permet d'utiliser les protections cochées ou la
protection d'une localisation fixe/personnalisée. Pour l'AB, les résistances

View File

@ -35,37 +35,53 @@ parser, browser, or chat.
monster and check each mapped row and any worker recalculations. **2026-09-17:**
user reports this workflow completed successfully in Roll20;
`local_exports/character.json` is the local saved export and is excluded from Git.
- [ ] Load `build/ravenous.html`, `build/ravenous.css`, and
- [x] Load `build/ravenous.html`, `build/ravenous.css`, and
`build/translation.json` into a Custom Sheet Sandbox with Legacy Sanitization
disabled. Record the date, browser, and any console or worker errors.
**2026-09-17 attempt:** user supplied a Firefox console log (browser inferred
from Firefox-specific messages). It shows `Starting up WEB WORKER`, CSP
warnings for inline scripts/event handlers, Sentry CDN CORS/integrity errors,
and `Uncaught SyntaxError: missing ] after element list` in `vtt.bundle`.
The log does not confirm the Legacy Sanitization setting or whether the sheet
itself loaded and its workers ran; the syntax error needs a reproduction.
**Follow-up, 2026-09-17:** user confirms all Legacy Sanitization is disabled.
A new Firefox log reports `SyntaxError: "" string literal contains an unescaped
line break` from `sheetsandbox.bundle.js` after sheet worker startup. The
generated worker parses and passes local Node tests. Generated data was split
into shorter source lines (the longest is now under 3.5 KB instead of 128 KB)
as a compatibility attempt. **Final retest, 2026-09-17:** user reports the
sheet now works with Legacy Sanitization disabled. The supplied console log
shows sheet worker startup and no worker syntax error; only VTT startup,
a CSP frame notice, and a layout warning remain.
- [x] Load one alternate theme (for example `build-steel/`) and inspect the
sheet and chat cards for legibility and contrast in Roll20. **2026-09-17:**
user reports that the themes work perfectly.
- [ ] Create an attacker and defender, plus a token representing the defender.
Open both sheets; switch every tab; add, edit, delete, and reorder a repeating
row. Reopen each sheet and confirm values persist.
- [ ] Change base and temporary characteristics, stage, a skill rank, and a
row. Reopen each sheet and confirm values persist. **2026-09-17:** user reports
values appear to persist; repeating row reorder still needs explicit confirmation.
- [x] Change base and temporary characteristics, stage, a skill rank, and a
custom skill. Confirm the displayed totals update and that derived stats use
the permanent characteristic as intended.
- [ ] Add one technique, attempt to add it again, and activate its chat card.
Check that text is readable and free of raw Typst markup.
- [ ] Select an origin, add one stage of powers, try adding it again, then add
the permanent characteristic as intended. **2026-09-17:** user reports
calculations done in Roll20.
- [x] Add one technique, attempt to add it again, and activate its chat card.
Check that text is readable and free of raw Typst markup. **2026-09-17:**
user reports techniques work in Roll20.
- [x] Select an origin, add one stage of powers, try adding it again, then add
another stage and a custom power. Change origin and reopen
the sheet. Confirm existing rows persist and selection alone adds no rows.
**2026-09-17:** user reports powers work in Roll20.
- [ ] Roll a skill at the threshold boundary and on a natural 1. Check chat
outcome and margin. Try public and secret rolls.
outcome and margin. Try public and secret rolls. **2026-09-17:** user reports
rolls generally work but CF was marked one above the die maximum. The worker
now marks the maximum face as critical failure; retest in Roll20.
- [ ] Roll an attack, use its **Défendre** chat button with the defender token
selected, then use **Dégâts** and **Subir**. Test zero successes, more successes
targeted when prompted, then use **Dégâts** and **Subir**. Test zero successes, more successes
than RMax, multiple checked resistances, one active protection, depleted
integrity, and a fixed location. Confirm DMG and AB against hand calculations.
**2026-09-17:** user reports repeated missing-selected-token warnings when
clicking without a token. The worker now requests one named target; retest.
- [ ] Repeat an attack follow-up after closing and reopening the sheet. Record
whether the attack context survives; the current worker stores it in memory.
**2026-09-17:** user believes it works; verify damage values after reopening.
## After smoke test
@ -76,8 +92,8 @@ parser, browser, or chat.
deviation before changing mechanics.
- [x] Decide whether HP should update automatically. **2026-09-17:** user
decided to keep HP updates manual for now.
- [ ] Decide whether armor integrity, technique costs, and temporary effects
should update automatically. Record each decision before adding automation
or UI controls.
- [x] Decide whether armor integrity, technique costs, and temporary effects
should update automatically. **2026-09-17:** user wants all these updates
manual for now.
- [ ] Add local worker tests to Jenkins only after confirming Node is installed
on its build agent, or provision a pinned Node runtime there.

View File

@ -17,7 +17,6 @@
.identity-grid { display:grid; grid-template-columns:2fr 2fr 1fr; gap:8px; margin-top:6px; }
.identity-grid label,.ravenous-sheet label { color:var(--muted); font-size:10px; text-transform:uppercase; letter-spacing:.05em; }
.motto { color:var(--dark-gold); font-style:italic; text-align:center; }
.motto>span { display:block; }
.secret-rolls { display:flex; justify-content:center; align-items:center; gap:6px; margin-top:7px; color:var(--blood)!important; font-style:normal; }
.secret-rolls input { margin:0; }
.tabs { display:flex; margin:14px 0; border-bottom:2px solid var(--gold); }

View File

@ -11,7 +11,7 @@
<label>Stade<input type="number" name="attr_stage" value="1" min="0"></label>
</div>
</div>
<div class="motto"><span>La chasse laisse des marques.</span><label class="secret-rolls">Jets secrets<input type="checkbox" name="attr_secret_rolls" value="1"></label></div>
<div class="motto"><label class="secret-rolls">Jets secrets<input type="checkbox" name="attr_secret_rolls" value="1"></label></div>
</header>
<nav class="tabs" aria-label="Sections de la feuille">
@ -303,12 +303,12 @@ const recalculateDamageLocations = () => getSectionIDs("locations", ids => {
const performSkillRoll = (title, threshold) => getAttrs(["character_name","skill_die","roll_whisper"], values => {
const die = Math.max(1, Math.floor(number(values.skill_die) || 10));
const target = Math.floor(number(threshold));
const expression = `1d${die}cs1cf${die + 1}`;
const expression = `1d${die}cs1cf${die}`;
const command = `${values.roll_whisper || ""}&{template:ravenous} {{title=${templateText(title)}}} {{subtitle=${templateText(values.character_name)}}} {{skillcheck=1}} {{roll=[[${expression}]]}} {{threshold=[[${target}]]}} {{margin=[[0]]}} {{outcome=[[0]]}}`;
startRoll(command, results => {
const rolled = results.results.roll.result;
const margin = target - rolled;
const outcome = rolled === 1 ? "Réussite critique" : rolled < target ? "Réussite" : "Échec";
const outcome = rolled === 1 ? "Réussite critique" : rolled === die ? "Échec critique" : rolled < target ? "Réussite" : "Échec";
finishRoll(results.rollId, {margin, outcome});
});
});
@ -333,11 +333,11 @@ on("clicked:repeating_attacks:defend", event => {
const dodgeThreshold = number(values[prefix+"dodge_threshold"]);
const parryThreshold = number(values[prefix+"parry_threshold"]);
const repositionTarget = number(values[prefix+"reposition_threshold"]);
const defenseQuery = `?{Défense|Esquive (${dodgeThreshold} + @{selected|esquive} + @{selected|esquive_temp}),@{selected|esquive}+@{selected|esquive_temp}+${dodgeThreshold}|Parade (${parryThreshold} + @{selected|parade} + @{selected|parade_temp}),@{selected|parade}+@{selected|parade_temp}+${parryThreshold}|Repositionnement (${repositionTarget}),${repositionTarget}}`;
const defenseQuery = `?{Défense|Esquive (${dodgeThreshold} + @{target|Défenseur|esquive} + @{target|Défenseur|esquive_temp}),@{target|Défenseur|esquive}+@{target|Défenseur|esquive_temp}+${dodgeThreshold}|Parade (${parryThreshold} + @{target|Défenseur|parade} + @{target|Défenseur|parade_temp}),@{target|Défenseur|parade}+@{target|Défenseur|parade_temp}+${parryThreshold}|Repositionnement (${repositionTarget}),${repositionTarget}}`;
const attack = attackRolls[event.originalRollId];
const damageFields = attack ? ` {{damagecalc=1}} {{finalsuccesses=[[0]]}} {{damage=[[0]]}} {{breakdamage=${attack.breakDamage}}}` : "";
const command = `&{template:ravenous} {{title=Défense · ${templateText(values[prefix+"name"] || "Attaque")}}} {{subtitle=@{selected|character_name}}} {{defense=1}} {{defense_successes=[[0]]}} {{pool=[[?{Nombre de dés|1}]]d10}} {{threshold=[[${defenseQuery}+?{Bonus|0}]]}} {{defense_roll=[[?{Nombre de dés|1}d10<${defenseQuery}+?{Bonus|0}]]}}${damageFields}`;
startRoll(`@{selected|roll_whisper}${command}`, results => {
const command = `&{template:ravenous} {{title=Défense · ${templateText(values[prefix+"name"] || "Attaque")}}} {{subtitle=@{target|Défenseur|character_name}}} {{defense=1}} {{defense_successes=[[0]]}} {{pool=[[?{Nombre de dés|1}]]d10}} {{threshold=[[${defenseQuery}+?{Bonus|0}]]}} {{defense_roll=[[?{Nombre de dés|1}d10<${defenseQuery}+?{Bonus|0}]]}}${damageFields}`;
startRoll(`@{target|Défenseur|roll_whisper}${command}`, results => {
const defenseSuccesses = results.results.defense_roll.result;
const computed = {defense_successes: defenseSuccesses};
if (attack) {
@ -366,8 +366,8 @@ on("clicked:repeating_attacks:damage", event => {
on("clicked:repeating_attacks:take_damage", event => {
const prefix = event.sourceAttribute.replace(/take_damage$/, "");
getAttrs([prefix+"name",prefix+"base_damage",prefix+"damage_per_success",prefix+"break_damage",prefix+"rmax"], values => {
const command = `&{template:ravenous} {{title=Subir · ${templateText(values[prefix+"name"] || "Attaque")}}} {{subtitle=@{selected|character_name}}} {{damagecalc=1}} {{damagebreakdown=1}} {{abcalc=1}} {{remaining=[[?{Succès restants|1}]]}} {{selected_resistance=[[@{selected|damage_resistance_total}]]}} {{location_protection=[[@{selected|damage_location_query}]]}} {{finalsuccesses=[[0]]}} {{incoming_damage=[[0]]}} {{resistance_reduction=[[0]]}} {{protection_reduction=[[0]]}} {{damage=[[0]]}} {{incoming_break=[[0]]}} {{break_resistance=[[0]]}} {{break_protection=[[0]]}} {{break_damage=[[0]]}}`;
startRoll(`@{selected|roll_whisper}${command}`, results => {
const command = `&{template:ravenous} {{title=Subir · ${templateText(values[prefix+"name"] || "Attaque")}}} {{subtitle=@{target|Défenseur|character_name}}} {{damagecalc=1}} {{damagebreakdown=1}} {{abcalc=1}} {{remaining=[[?{Succès restants|1}]]}} {{selected_resistance=[[@{target|Défenseur|damage_resistance_total}]]}} {{location_protection=[[@{target|Défenseur|damage_location_query}]]}} {{finalsuccesses=[[0]]}} {{incoming_damage=[[0]]}} {{resistance_reduction=[[0]]}} {{protection_reduction=[[0]]}} {{damage=[[0]]}} {{incoming_break=[[0]]}} {{break_resistance=[[0]]}} {{break_protection=[[0]]}} {{break_damage=[[0]]}}`;
startRoll(`@{target|Défenseur|roll_whisper}${command}`, results => {
const remaining = Math.max(0, Math.floor(results.results.remaining.result));
const finalSuccesses = Math.min(remaining, Math.max(0, Math.floor(number(values[prefix+"rmax"]))));
const incoming = finalSuccesses > 0 ? number(values[prefix+"base_damage"]) + (finalSuccesses - 1) * number(values[prefix+"damage_per_success"]) : 0;

View File

@ -101,12 +101,12 @@ class BuildTests(unittest.TestCase):
self.assertIn("{{defense_successes=[[0]]}}", sheet)
self.assertIn("attackRolls[event.originalRollId]", sheet)
self.assertIn("?{Succès restants|1}", sheet)
self.assertIn("@{selected|esquive}+@{selected|esquive_temp}", sheet)
self.assertIn("@{selected|parade}+@{selected|parade_temp}", sheet)
self.assertNotIn("@{selected|esquive_total}", sheet)
self.assertNotIn("@{selected|parade_total}", sheet)
self.assertIn("{{subtitle=@{selected|character_name}}}", sheet)
self.assertIn("Esquive (${dodgeThreshold} + @{selected|esquive} + @{selected|esquive_temp})", sheet)
self.assertIn("@{target|Défenseur|esquive}+@{target|Défenseur|esquive_temp}", sheet)
self.assertIn("@{target|Défenseur|parade}+@{target|Défenseur|parade_temp}", sheet)
self.assertNotIn("@{target|Défenseur|esquive_total}", sheet)
self.assertNotIn("@{target|Défenseur|parade_total}", sheet)
self.assertIn("{{subtitle=@{target|Défenseur|character_name}}}", sheet)
self.assertIn("Esquive (${dodgeThreshold} + @{target|Défenseur|esquive} + @{target|Défenseur|esquive_temp})", sheet)
self.assertIn('d10<${number(get("threshold")) + number(get("temp"))}', sheet)
self.assertIn("d10<${defenseQuery}+?{Bonus|0}", sheet)
self.assertIn('name="act_take_damage"', sheet)
@ -117,7 +117,7 @@ class BuildTests(unittest.TestCase):
self.assertIn("{{computed::resistance_reduction}} (resist) − {{computed::protection_reduction}} (armor)", sheet)
self.assertIn('name="attr_secret_rolls"', sheet)
self.assertIn('values.secret_rolls === "1" ? "/w gm " : ""', sheet)
self.assertIn("@{selected|roll_whisper}", sheet)
self.assertIn("@{target|Défenseur|roll_whisper}", sheet)
self.assertIn("active_first_protection", sheet)
self.assertIn("damage_location_query", sheet)
self.assertIn("repeating_locations_${id}_name", sheet)
@ -131,6 +131,11 @@ class BuildTests(unittest.TestCase):
self.assertIn("{{details=@{effect}}}", sheet)
self.assertNotRegex(technique_data, r"[@#][A-Za-z_]")
def test_generated_worker_data_has_bounded_line_lengths(self):
sheet = (ROOT / "build/ravenous.html").read_text()
worker = sheet.split('<script type="text/worker">', 1)[1].split('</script>', 1)[0]
self.assertLess(max(map(len, worker.splitlines())), 12000)
def test_school_trigrams_come_from_book_config(self):
from tools.build import read_build_config, read_glossary_labels, read_schools, technique_options

View File

@ -6,6 +6,7 @@ import vm from 'node:vm';
const sheet = readFileSync(new URL('../build/ravenous.html', import.meta.url), 'utf8');
const script = sheet.match(/<script type="text\/worker">([\s\S]*?)<\/script>/)?.[1];
assert.ok(script, 'generated sheet worker exists; run ./scripts/build.sh first');
const generatedData = name => JSON.parse(sheet.match(new RegExp(`const ${name} = ([\\s\\S]*?);\\n`))?.[1]);
function worker(initial = {}) {
const attrs = { ...initial };
@ -83,9 +84,7 @@ test('selected resistances and live protections update mitigation', () => {
});
test('technique selector adds one row and rejects a duplicate', () => {
const match = sheet.match(/const TECHNIQUES = (\{[^\n]+\});/);
assert.ok(match);
const [key, technique] = Object.entries(JSON.parse(match[1]))[0];
const [key, technique] = Object.entries(generatedData('TECHNIQUES'))[0];
const { attrs, fire } = worker({ technique_to_add: key });
fire('clicked:add_technique');
assert.equal(attrs.repeating_techniques_newrow_name, technique.name);
@ -117,6 +116,11 @@ test('skill roll reports a critical success and a threshold failure', () => {
sheetWorker.queueRoll('failure', { roll: 5 });
sheetWorker.fire('clicked:skill_parade');
assert.equal(sheetWorker.rolls[1].computed.outcome, 'Échec');
sheetWorker.attrs.skill_die = '4';
sheetWorker.queueRoll('critical-failure', { roll: 4 });
sheetWorker.fire('clicked:skill_parade');
assert.match(sheetWorker.rolls[2].command, /1d4cs1cf4/);
assert.equal(sheetWorker.rolls[2].computed.outcome, 'Échec critique');
});
test('attack and defense cap remaining successes at RMax', () => {
@ -135,6 +139,8 @@ test('attack and defense cap remaining successes at RMax', () => {
});
assert.equal(sheetWorker.rolls[1].computed.finalsuccesses, 2);
assert.equal(sheetWorker.rolls[1].computed.damage, 6);
assert.match(sheetWorker.rolls[1].command, /@\{target\|Défenseur\|character_name\}/);
assert.doesNotMatch(sheetWorker.rolls[1].command, /@\{selected\|/);
});
test('Subir reports damage and armor break after selected mitigation', () => {
@ -147,6 +153,8 @@ test('Subir reports damage and armor break after selected mitigation', () => {
// Roll20 resolves the defender's attribute references and query before the callback.
sheetWorker.queueRoll('damage1', { remaining: 2, selected_resistance: 1, location_protection: 70004 });
sheetWorker.fire('clicked:repeating_attacks:take_damage', { sourceAttribute: prefix + 'take_damage' });
assert.match(sheetWorker.rolls[0].command, /@\{target\|Défenseur\|damage_resistance_total\}/);
assert.doesNotMatch(sheetWorker.rolls[0].command, /@\{selected\|/);
assert.equal(sheetWorker.rolls[0].computed.incoming_damage, 10);
assert.equal(sheetWorker.rolls[0].computed.resistance_reduction, 2);
assert.equal(sheetWorker.rolls[0].computed.protection_reduction, 7);
@ -155,7 +163,7 @@ test('Subir reports damage and armor break after selected mitigation', () => {
});
test('origin stage picker adds its powers once and preserves custom rows', () => {
const origins = JSON.parse(sheet.match(/const ORIGINS = (\{[^\n]+\});/)[1]);
const origins = generatedData('ORIGINS');
const stagePowers = origins.dragon_1.powers.filter(power => power.stage === '1');
const sheetWorker = worker({
origin_key: 'dragon_1',

View File

@ -275,6 +275,16 @@ def technique_options(schools: dict[str, list[dict[str, str]]], trigrams: dict[s
return "".join(options), indexed
def javascript_data(value: dict | list) -> str:
"""Put generated entries on separate lines for the Roll20 sheet editor."""
if isinstance(value, dict):
entries = (f"{json.dumps(key, ensure_ascii=False)}:{json.dumps(item, ensure_ascii=False, separators=(',', ':'))}"
for key, item in value.items())
return "{\n" + ",\n".join(entries).replace("</", "<\\/") + "\n}"
entries = (json.dumps(item, ensure_ascii=False, separators=(',', ':')) for item in value)
return "[\n" + ",\n".join(entries).replace("</", "<\\/") + "\n]"
CHARACTERISTICS = ["force", "agilite", "perception", "intelligence", "volonte", "psy", "chance", "charisme"]
@ -340,9 +350,9 @@ def main() -> None:
"TARGET_OPTIONS": target_options(skills),
"TARGET_OPTIONS_EMPTY": target_options(skills, include_empty=True),
"SKILL_TARGET_OPTIONS_EMPTY": skill_target_options(skills),
"TECHNIQUES_JSON": json.dumps(techniques, ensure_ascii=False, separators=(",", ":")).replace("</", "<\\/"),
"ORIGINS_JSON": json.dumps(origins, ensure_ascii=False, separators=(",", ":")).replace("</", "<\\/"),
"SKILLS_JSON": json.dumps(skills, ensure_ascii=False, separators=(",", ":")),
"TECHNIQUES_JSON": javascript_data(techniques),
"ORIGINS_JSON": javascript_data(origins),
"SKILLS_JSON": javascript_data(skills),
}),
"ravenous.css": render((TEMPLATES / "ravenous.css").read_text(encoding="utf-8"),
{"THEME_VARS": theme_variables(palettes[theme])}),