From e768039b0c3ceba89e42fdf40a1d96f1802106b9 Mon Sep 17 00:00:00 2001 From: Dandaedre Date: Thu, 17 Sep 2026 19:58:36 +0200 Subject: [PATCH] Build and refine Ravenous Roll20 sheet --- .gitignore | 1 + AGENTS.md | 117 ++++++++++++++++++ README.md | 82 ++++++++++++- TASKS.md | 64 ++++++++++ roll20_mod/ravenous_import_name.js | 39 ++++++ scripts/test-worker-container.sh | 10 ++ src/ravenous.css | 117 +++++++++++------- src/ravenous.html | 108 +++++++++++++---- tests/test_build.py | 57 ++++++++- tests/test_mod_import.mjs | 50 ++++++++ tests/test_worker.mjs | 189 +++++++++++++++++++++++++++++ tools/build.py | 132 ++++++++++++++++---- 12 files changed, 871 insertions(+), 95 deletions(-) create mode 100644 AGENTS.md create mode 100644 TASKS.md create mode 100644 roll20_mod/ravenous_import_name.js create mode 100755 scripts/test-worker-container.sh create mode 100644 tests/test_mod_import.mjs create mode 100644 tests/test_worker.mjs diff --git a/.gitignore b/.gitignore index bc4a694..e479401 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ __pycache__/ *.pyc build/ +build-*/ diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..fa7746e --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,117 @@ +# Agent guide: Ravenous Roll20 sheet + +## Purpose and current state + +This repository builds a French Roll20 character sheet for Ravenous from the +`ravenous_typst` rulebook submodule. The sheet is an early working version: +generation and structural tests pass, but its interactions still need validation +in a real Roll20 game. Treat the book data and rules as authoritative; do not +infer a game rule from a field label or an existing formula without checking it. + +## Where to work + +| Path | Role | +| --- | --- | +| `src/ravenous.html` | Hand maintained sheet markup, roll template, and sheet worker JavaScript. `{{...}}` uppercase markers are filled at build time. | +| `src/ravenous.css` | Hand maintained styling template for Roll20's current CSE mode. Theme variables are filled at build time. | +| `src/translation.json`, `src/sheet.json` | Translation metadata and Roll20 manifest. | +| `tools/build.py` | Reads book data, converts a subset of Typst markup, generates skill rows and technique choices, and writes artifacts. | +| `ravenous_typst/` | Git submodule containing the book and source game data. Avoid editing it as part of a sheet-only change. | +| `tests/test_build.py` | Build and generated-output assertions; mostly structural checks. | +| `roll20_mod/ravenous_import_name.js` | Optional Mod proof of concept: create a character from a JSON name. It is installed separately from the sheet. | +| `build/` | Generated output for Roll20. Do not hand edit it; it is currently ignored by Git. | + +The main inputs are `ravenous_typst/data/src/character_sheet.yaml`, +`ravenous_typst/data/src/schools/*.tsv`, `ravenous_typst/data/src/origines/*.yaml`, glossary YAML, and +`ravenous_typst/data/config/build.yaml`. Only school tiers below +`build.max_tier_exclusive` are imported. At the pinned submodule revision the +build reports 141 skills and 275 techniques across 11 schools. + +## Build and verify + +From the repository root, with Python 3.11+ and `uv` available: + +```sh +git submodule update --init --recursive +./scripts/build.sh +uv run python -m unittest discover -s tests -v +node tests/test_worker.mjs +node tests/test_mod_import.mjs +./scripts/build.sh --check +``` + +If `uv` cannot write its default cache in a restricted environment, set +`UV_CACHE_DIR` to a writable temporary directory for these commands. The build +writes `build/ravenous.html`, `ravenous.css`, `translation.json`, `sheet.json`, +and `build-info.json`. `--check` compares those files with freshly generated +content; it does not exercise Roll20 behavior. The tests themselves rebuild +`build/`. The Node tests run the generated worker against a small mock of +Roll20's attribute API. `./scripts/test-worker-container.sh` runs those tests +in a network-isolated Podman container after the build, if Podman is available. +Neither path simulates Roll20's dice parser, browser, or chat. + +Use `./scripts/build.sh --list-themes` to inspect book themes and +`./scripts/build.sh --theme steel --output-dir build-steel` to export a separate +Roll20 bundle. Palettes are read from the submodule's `setup/theme/themes.typ`; +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 +the attack card's **Défendre** and **Subir** actions. + +## How the sheet works + +- Seven tabs cover character statistics, skills, combat, health, consumables, + schools, and powers. Built-in skills, technique choices, and origins are generated from book data; + custom skills, attacks, protections, locations, consumables, effects, and + acquired techniques, and powers are repeating sections. +- Sheet workers calculate characteristic totals, derived statistics, skill + totals, selected damage resistance, and active protection summaries. Most + 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 + 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 + protection. It does not subtract HP or armor integrity from attributes. + Consumables, temporary effects, and techniques display chat cards; they do + not apply costs or mechanical effects automatically. +- Techniques are added one at a time from the generated selector. The importer + translates only the Typst syntax handled by `translate_typst`; inspect newly + imported descriptions when the book data or macros change. +- Origin powers are generated from YAML and added in batches by stage for the + selected origin. Existing imported and custom powers remain if the origin + changes. Source keys prevent duplicate import. + +## Change workflow + +1. Locate the governing rule or source data in the pinned submodule. For sheet + presentation and interaction changes, edit `src/`; for import behavior, + edit `tools/build.py`. Do not edit generated files directly. +2. Preserve existing Roll20 attribute names and repeating section names unless + a migration is planned. Check all related worker events, roll buttons, and + templates when changing a field. +3. Build, run the tests, and run `--check`. Add focused assertions for changed + generation logic, but do not treat string presence as proof of working + 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 + was actually tested and what could not be tested. + +## Known gaps and priorities + +The Python tests confirm artifact shape and selected generated strings. The +Node tests execute worker callbacks against a minimal mock, but do not parse +Roll20 macros or render chat. Follow the concrete smoke test and remaining +work in [TASKS.md](TASKS.md). Verify formulas against the current rulebook, +especially defense and damage edge cases. Document decisions about whether HP, +integrity, technique costs, and temporary effects should remain manual before +automating them. + +The README covers installation, update, and deployment details. Jenkins builds, +tests, archives, and deploys only designated branches; avoid changing its +deployment behavior as part of an ordinary sheet fix. diff --git a/README.md b/README.md index 2acf249..1fa5b0d 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,8 @@ or et sang du livre et fournit : le chat ; - l'ajout individuel des techniques d'école depuis les TSV du livre, avec traduction du balisage Typst et bouton d'activation dans le chat. +- un sélecteur d'origine et l'ajout de ses pouvoirs stade par stade dans un + onglet dédié, avec des lignes libres pour les pouvoirs personnalisés. ## Construction locale @@ -36,9 +38,27 @@ Le script crée `.venv/` et produit dans `build/` : - `build-info.json`, qui indique le nombre d'écoles, techniques et compétences importées ainsi que l'empreinte du contenu. +### Choisir un thème à l'export + +Le thème par défaut est `document.color_scheme` dans +`ravenous_typst/data/config/build.yaml`. Pour voir les thèmes définis dans le +livre puis exporter un autre CSS sans remplacer le build par défaut : + +```sh +./scripts/build.sh --list-themes +./scripts/build.sh --theme steel --output-dir build-steel +./scripts/build.sh --theme steel --output-dir build-steel --check +``` + +Chargez `build-steel/ravenous.css` avec le HTML et la traduction du même dossier +dans Roll20. La feuille et ses cartes de chat utilisent la palette choisie. +Les couleurs viennent de `ravenous_typst/setup/theme/themes.typ` ; `src/ravenous.css` +reste le modèle CSS commun. + La limite des tiers d'école vient directement de `ravenous_typst/data/config/build.yaml` : seuls les tiers strictement inférieurs -à `build.max_tier_exclusive` sont proposés par la feuille. +à `build.max_tier_exclusive` sont proposés par la feuille. Les trigrammes affichés +dans le menu des techniques viennent de `schools.trigrams` dans ce même fichier. Pour vérifier qu'un build versionné correspond aux sources : @@ -46,6 +66,52 @@ Pour vérifier qu'un build versionné correspond aux sources : ./scripts/build.sh --check ``` +Les tests Python vérifient la génération. Des tests Node exécutent aussi le +sheet worker généré avec une simulation minimale des API Roll20 (recalcul, +résistances, protections, techniques et calculs de jets) : + +```sh +uv run python -m unittest discover -s tests -v +node tests/test_worker.mjs +``` + +Si Podman est disponible, le même test Node peut tourner dans un conteneur +isolé, sans accès réseau et avec le dépôt monté en lecture seule. Construisez +d'abord la feuille ; le premier lancement télécharge l'image officielle Node : + +```sh +./scripts/build.sh +./scripts/test-worker-container.sh +``` + +Cette simulation ne reproduit pas le moteur de dés, le navigateur ou le chat de +Roll20. Les interactions doivent aussi être testées dans le Custom Sheet +Sandbox de Roll20. La procédure de vérification est détaillée dans +[`TASKS.md`](TASKS.md). + +## Essai d'import JSON par Mod Roll20 + +Un prototype minimal se trouve dans `roll20_mod/ravenous_import_name.js`. Il +crée un **nouveau personnage avec son nom seulement** ; il ne modifie aucun +personnage existant et n'importe pas encore les autres champs. Le créateur de +la partie doit disposer de l'accès aux Mod scripts de Roll20 (Pro/Elite). + +Dans la page de la partie, ouvrez **Settings → Mod Scripts → New Script**, +collez le contenu du fichier, nommez le script puis cliquez sur **Save Script**. +Dans le chat de cette même partie, en tant que MJ, entrez : + +```text +!ravenous-import-name {"name":"Ariane"} +``` + +Vérifiez qu'un nouveau personnage nommé « Ariane » apparaît dans le journal. +Chaque commande valide crée un personnage supplémentaire. Pour exécuter les +tests locaux de ce prototype : + +```sh +node tests/test_mod_import.mjs +``` + ## Mise à jour depuis le livre ```sh @@ -57,8 +123,12 @@ Les compétences proviennent de `ravenous_typst/data/src/character_sheet.yaml` et les techniques de `ravenous_typst/data/src/schools/*.tsv`. Les transformations sont dans `tools/build.py`; le HTML et le CSS maintenus à la main restent dans `src/`. +Les origines et leurs pouvoirs proviennent de +`ravenous_typst/data/src/origines/*.yaml`. Les spécialités imbriquées (`subskills`) sont également importées ; leur nom -et leur identifiant incluent la compétence parente pour éviter les ambiguïtés. +complet et leur identifiant incluent la compétence parente pour éviter les +ambiguïtés, mais l'affichage les indente sous leur parent et ne répète pas son +nom. Il n'est donc pas nécessaire de recopier les données lors d'une mise à jour du livre. @@ -106,3 +176,11 @@ protection d'une localisation fixe/personnalisée. Pour l'AB, les résistances retirent un point par point et seule la première protection valide de la liste Combat s'applique, sans la Force ; ordonnez donc les protections de haut en bas selon leur ordre d'impact. + +Dans l'onglet **Chasseur**, choisissez l'origine du personnage. Dans l'onglet +**Pouvoirs**, choisissez un stade puis cliquez sur **Ajouter les pouvoirs du +stade**. Tous les pouvoirs de ce stade pour l'origine sélectionnée sont ajoutés. +Une même entrée ne peut être ajoutée qu'une fois. Les lignes sont +modifiables et la section répétable permet d'ajouter des pouvoirs personnalisés. +Changer d'origine ne supprime pas les pouvoirs existants. Les pouvoirs sont +affichables dans le chat mais n'appliquent pas automatiquement leurs effets. diff --git a/TASKS.md b/TASKS.md new file mode 100644 index 0000000..b830e9b --- /dev/null +++ b/TASKS.md @@ -0,0 +1,64 @@ +# Ravenous sheet worklist + +This list tracks the next development steps from [AGENTS.md](AGENTS.md). +Mark an item complete only after its stated check passes. Keep a note of the +Roll20 test date and any failures; local worker tests do not reproduce Roll20's +parser, browser, or chat. + +## Done locally + +- [x] Generate the sheet from the pinned `ravenous_typst` data and run the + Python build tests (`uv run python -m unittest discover -s tests -v`). +- [x] Add local worker tests (`node tests/test_worker.mjs`) for derived values, + resistance and protection summaries, technique import, skill outcomes, + attack follow-up calculations, and damage mitigation. +- [x] Verify generated artifacts with `./scripts/build.sh --check`. +- [x] Add themed exports from the book palette data, with a separate output + directory for alternate CSS and deterministic checks. +- [x] Add a minimal GM-only Roll20 Mod proof of concept that creates one + character from a JSON `name`; test valid and invalid commands locally. +- [x] Add origin powers from the pinned book data stage by stage in an editable + Powers tab, while preserving custom rows and preventing duplicate imports. + +## Next: Roll20 smoke test + +- [ ] Install `roll20_mod/ravenous_import_name.js` as a New Script in a test + game, run `!ravenous-import-name {"name":"Ariane"}` as GM, and confirm a + single new character appears in the journal. Record the date and result. +- [ ] 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. +- [ ] Load one alternate theme (for example `build-steel/`) and inspect the + sheet and chat cards for legibility and contrast in Roll20. +- [ ] 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 + 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 + another stage and a custom power. Change origin and reopen + the sheet. Confirm existing rows persist and selection alone adds no rows. +- [ ] Roll a skill at the threshold boundary and on a natural 1. Check chat + outcome and margin. Try public and secret rolls. +- [ ] 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 + than RMax, multiple checked resistances, one active protection, depleted + integrity, and a fixed location. Confirm DMG and AB against hand calculations. +- [ ] Repeat an attack follow-up after closing and reopening the sheet. Record + whether the attack context survives; the current worker stores it in memory. + +## After smoke test + +- [ ] Fix each observed Roll20 defect with a focused reproduction and a local + test where the behavior can be simulated. Recheck it in the sandbox. +- [ ] Compare derived statistics, defense thresholds, damage, and AB formulas + with the pinned rulebook. Record the rule reference and any intentional + deviation before changing mechanics. +- [ ] Decide whether HP, armor integrity, technique costs, and temporary + effects should be updated automatically. Record the decision before adding + automation or UI controls. +- [ ] Add local worker tests to Jenkins only after confirming Node is installed + on its build agent, or provision a pinned Node runtime there. diff --git a/roll20_mod/ravenous_import_name.js b/roll20_mod/ravenous_import_name.js new file mode 100644 index 0000000..4ec37a6 --- /dev/null +++ b/roll20_mod/ravenous_import_name.js @@ -0,0 +1,39 @@ +/* + * Ravenous name import proof of concept for Roll20 Mod (API). + * Install this file as a New Script in a Pro/Elite game. + * GM chat command: !ravenous-import-name {"name":"Ariane"} + * Creates one new character using the game's selected character sheet. + */ +on('chat:message', function (message) { + var command = '!ravenous-import-name'; + if (message.type !== 'api' || + (message.content !== command && message.content.indexOf(command + ' ') !== 0)) { + return; + } + + if (!playerIsGM(message.playerid)) { + return; + } + + var input = message.content.slice(command.length).trim(); + var data; + try { + data = JSON.parse(input); + } catch (error) { + sendChat('Ravenous Import', '/w gm Invalid JSON. Example: !ravenous-import-name {"name":"Ariane"}'); + return; + } + + if (!data || Array.isArray(data) || typeof data !== 'object' || + typeof data.name !== 'string' || !data.name.trim() || data.name.length > 100) { + sendChat('Ravenous Import', '/w gm Expected an object with a nonempty name of at most 100 characters.'); + return; + } + + var character = createObj('character', { name: data.name.trim() }); + if (!character) { + sendChat('Ravenous Import', '/w gm Roll20 could not create the character.'); + return; + } + sendChat('Ravenous Import', '/w gm Created one character.'); +}); diff --git a/scripts/test-worker-container.sh b/scripts/test-worker-container.sh new file mode 100755 index 0000000..ff69f17 --- /dev/null +++ b/scripts/test-worker-container.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env sh +set -eu + +repo_dir=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd) + +podman run --rm --network none \ + --mount "type=bind,src=$repo_dir,dst=/workspace,ro" \ + -w /workspace \ + docker.io/library/node:20-alpine \ + node tests/test_worker.mjs diff --git a/src/ravenous.css b/src/ravenous.css index 37a5bf8..59fbe8f 100644 --- a/src/ravenous.css +++ b/src/ravenous.css @@ -1,14 +1,15 @@ @import url('https://fonts.googleapis.com/css?family=Cinzel:600,700|Libre+Baskerville:400,400i,700'); -.ravenous-sheet { --ink:#302c26; --muted:#716957; --gold:#9b8050; --dark-gold:#70582f; --paper:#f4ebd8; --light:#fbf9f3; --accent:#ede1c8; --border:#c9bda4; --blood:#7a2424; box-sizing:border-box; max-width:980px; min-width:650px; margin:auto; padding:18px; color:var(--ink); background-color:var(--paper); background-image:radial-gradient(circle at 15% 10%,rgba(155,128,80,.09),transparent 35%),linear-gradient(90deg,rgba(122,36,36,.025) 1px,transparent 1px); background-size:auto,28px 28px; font:13px/1.4 "Libre Baskerville",Georgia,serif; border:1px solid var(--border); } +.ravenous-sheet,.sheet-rolltemplate-ravenous { {{THEME_VARS}} } +.ravenous-sheet { box-sizing:border-box; max-width:980px; min-width:650px; margin:auto; padding:18px; color:var(--ink); background-color:var(--paper); background-image:radial-gradient(circle at 15% 10%,rgba(var(--gold-rgb),.09),transparent 35%),linear-gradient(90deg,rgba(var(--blood-rgb),.025) 1px,transparent 1px); background-size:auto,28px 28px; font:13px/1.4 "Libre Baskerville",Georgia,serif; border:1px solid var(--border); } .ravenous-sheet * { box-sizing:border-box; } -.ravenous-sheet input,.ravenous-sheet select,.ravenous-sheet textarea { width:100%; border:0; border-bottom:1px solid var(--border); border-radius:0; background:rgba(251,249,243,.72); color:var(--ink); font:inherit; padding:4px 6px; box-shadow:none; } -.ravenous-sheet input:focus,.ravenous-sheet select:focus,.ravenous-sheet textarea:focus { outline:2px solid rgba(155,128,80,.35); border-color:var(--dark-gold); } +.ravenous-sheet input,.ravenous-sheet select,.ravenous-sheet textarea { width:100%; border:0; border-bottom:1px solid var(--border); border-radius:0; background:rgba(var(--light-rgb),.72); color:var(--ink); font:inherit; padding:4px 6px; box-shadow:none; } +.ravenous-sheet input:focus,.ravenous-sheet select:focus,.ravenous-sheet textarea:focus { outline:2px solid rgba(var(--gold-rgb),.35); border-color:var(--dark-gold); } .ravenous-sheet input[type=number] { text-align:center; appearance:textfield; -moz-appearance:textfield; } .ravenous-sheet input[type=number]::-webkit-inner-spin-button,.ravenous-sheet input[type=number]::-webkit-outer-spin-button { margin:0; appearance:none; -webkit-appearance:none; } .ravenous-sheet input[type=checkbox] { width:auto; } .ravenous-sheet button { font-family:"Cinzel",Georgia,serif; } -.hero { display:grid; grid-template-columns:70px 1fr 190px; gap:16px; align-items:center; padding:12px 14px; border:1px solid var(--gold); border-left:5px solid var(--blood); background:rgba(251,249,243,.7); } +.hero { display:grid; grid-template-columns:70px 1fr 190px; gap:16px; align-items:center; padding:12px 14px; border:1px solid var(--gold); border-left:5px solid var(--blood); background:rgba(var(--light-rgb),.7); } .sigil { display:grid; place-items:center; width:62px; height:62px; color:var(--paper); background:var(--blood); font:700 34px "Cinzel",serif; transform:rotate(45deg); box-shadow:inset 0 0 0 4px var(--blood),inset 0 0 0 5px var(--gold); } .sigil::first-letter { transform:rotate(-45deg); } .identity>label { color:var(--blood); font:700 12px "Cinzel",serif; letter-spacing:.06em; } @@ -23,22 +24,22 @@ .tabs button { flex:1; padding:8px 5px; border:0; color:var(--muted); background:transparent; font-size:11px; } .tabs button:hover { color:var(--blood); background:var(--accent); } .page { display:none; } -.tab-state[value="core"]~.page-core,.tab-state[value="skills"]~.page-skills,.tab-state[value="combat"]~.page-combat,.tab-state[value="health"]~.page-health,.tab-state[value="consumables"]~.page-consumables,.tab-state[value="classes"]~.page-classes { display:block; } +.tab-state[value="core"]~.page-core,.tab-state[value="skills"]~.page-skills,.tab-state[value="combat"]~.page-combat,.tab-state[value="health"]~.page-health,.tab-state[value="consumables"]~.page-consumables,.tab-state[value="classes"]~.page-classes,.tab-state[value="powers"]~.page-powers { display:block; } .section-title { display:flex; align-items:center; gap:8px; margin:12px 0 8px; color:var(--blood); border-bottom:1px solid var(--gold); } .section-title span { color:var(--gold); } .section-title h2,.section-title h3 { margin:0; color:inherit; font:700 18px/1.8 "Cinzel",Georgia,serif; } .section-title.small h3 { font-size:15px; } .stat-grid { display:grid; grid-template-columns:repeat(4,1fr); gap:9px; } -.stat { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); align-items:end; padding-top:5px; border:1px solid var(--border); background:rgba(251,249,243,.62); } +.stat { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); align-items:end; padding-top:5px; border:1px solid var(--border); background:rgba(var(--light-rgb),.62); } .stat strong { grid-column:1/-1; padding:0 7px 3px; color:var(--blood); font:700 11px "Cinzel",Georgia,serif; text-transform:uppercase; letter-spacing:.04em; } .stat span { padding:0 4px 3px; color:var(--muted); font-size:8px; text-align:center; text-transform:uppercase; letter-spacing:.05em; } .stat input { height:32px; margin:0; padding:4px; font-size:18px; line-height:24px; } .stat input:nth-of-type(2) { background:var(--accent); } -.stat output { display:grid; place-items:center; height:32px; margin:0; color:var(--light); background:var(--blood); font:bold 18px/32px "Cinzel",serif; } +.ravenous-sheet .stat input.stat-total { width:100%; margin:0; color:var(--blood); background:#fff; font:italic bold 18px/24px Georgia,serif; text-align:center; } .legend { text-align:right; color:var(--muted); font-size:10px; } .dashboard { display:grid; grid-template-columns:repeat(3,1fr); gap:8px; margin-top:14px; } -.resource { display:grid; grid-template-columns:minmax(0,1fr) 30px minmax(0,1fr) minmax(0,.8fr); grid-template-rows:47px; gap:4px; align-items:end; min-width:0; padding:5px 8px; background:var(--accent); border-left:3px solid var(--gold); } -.resource label { display:grid; grid-template-rows:14px 28px; align-self:end; min-width:0; } +.resource { display:grid; grid-template-columns:minmax(0,1fr) 30px minmax(0,1fr) minmax(0,.8fr); grid-template-rows:54px; gap:4px; align-items:end; min-width:0; padding:4px 8px; background:var(--accent); border-left:3px solid var(--gold); } +.resource label { display:grid; grid-template-rows:14px 28px; row-gap:3px; align-self:end; min-width:0; margin:0 !important; } .resource input,.resource output { display:block; height:28px; min-height:28px; margin:0; padding:3px 4px; font-size:17px; line-height:22px; text-align:center; } .resource>.resource-separator { display:grid; place-items:center; height:28px; margin:0; color:var(--dark-gold); font:700 9px/28px "Cinzel",Georgia,serif; text-transform:uppercase; } .resource-blood label:last-child { grid-column:3/-1; } @@ -51,14 +52,15 @@ .location-head,.location-row { display:grid; grid-template-columns:minmax(130px,1.5fr) repeat(5,minmax(70px,1fr)); gap:6px; align-items:center; } .location-head { padding:5px 9px; color:var(--muted); font-size:9px; text-align:center; text-transform:uppercase; } .location-grid { border:1px solid var(--border); } -.location-row { padding:7px 9px; background:rgba(251,249,243,.72); } -.location-row:nth-child(even) { background:rgba(237,225,200,.52); } +.location-row { padding:7px 9px; background:rgba(var(--light-rgb),.72); } +.location-row:nth-child(even) { background:rgba(var(--accent-rgb),.52); } .location-row strong { color:var(--blood); font-family:"Cinzel",Georgia,serif; } .location-row input[readonly] { color:var(--blood); background:var(--accent); font-weight:bold; } .custom-location { margin:5px 0; border:1px solid var(--border); } .resistance-title { margin:10px 0 4px; color:var(--dark-gold); font:700 12px "Cinzel",Georgia,serif; } -.resistance-grid { display:grid; grid-template-columns:repeat(4,1fr); gap:7px; } -.resistance-grid label { display:grid; grid-template-columns:1fr 48px; align-items:center; padding:5px 7px; background:var(--light); border-left:3px solid var(--gold); } +.resistance-grid { display:grid; grid-template-columns:repeat(4,1fr); gap:0 7px; } +.resistance-grid label { display:grid; grid-template-columns:1fr 48px; align-items:center; margin:0 !important; padding:2px 7px; background:var(--light); border-left:3px solid var(--gold); line-height:1.2; } +.resistance-grid input { height:24px; padding:2px 4px; } .skill-toolbar,.class-picker,.skill-picker { display:flex; justify-content:space-between; align-items:end; gap:15px; padding:8px; background:var(--accent); } .skill-toolbar label { width:220px; } .skill-picker { margin-top:8px; background:var(--light); border:1px solid var(--border); } @@ -71,58 +73,85 @@ .skill-head { color:var(--muted); font-size:9px; text-transform:uppercase; } .skill-category { margin-top:9px; padding:6px 9px; color:var(--blood); border-bottom:1px solid var(--gold); background:var(--accent); font:700 12px "Cinzel",Georgia,serif; } .skill-category span { margin-right:7px; color:var(--gold); } -.skill-row:nth-of-type(even) { background:rgba(237,225,200,.52); } -.skill-roll,.attack-roll,.combat-card button[type=roll] { display:grid; place-items:center; width:24px; min-width:24px; height:24px; margin:0; padding:0; border:1px solid var(--dark-gold); border-radius:50%; background:var(--blood); color:white; font-size:0; line-height:1; box-shadow:none; appearance:none; } -.skill-roll::before,.attack-roll::before,.combat-card button[type=roll]::before { content:"◆"; color:white; font-size:9px; line-height:1; } -.skill-roll:hover,.skill-roll:focus { border-color:var(--blood); background:var(--dark-gold); outline:2px solid rgba(155,128,80,.3); } +.skill-row:nth-of-type(even) { background:rgba(var(--accent-rgb),.52); } +.skill-roll,.attack-roll,.use-effect,.activate-technique,.combat-card button[type=roll] { display:grid; place-items:center; width:28px; min-width:28px; height:28px; margin:0; padding:0; border:1px solid var(--dark-gold); border-radius:50%; background:var(--blood); color:var(--light); font-size:0; line-height:1; box-shadow:none; appearance:none; } +.ravenous-sheet .skill-roll::before,.ravenous-sheet .attack-roll::before,.ravenous-sheet button[type=roll].use-effect::before,.ravenous-sheet button[type=roll].activate-technique::before,.ravenous-sheet .combat-card button[type=roll]::before { content:"◆" !important; color:var(--light); font:10px/1 Georgia,serif !important; margin:0; } +.skill-roll:hover,.skill-roll:focus,.attack-roll:hover,.attack-roll:focus,.use-effect:hover,.use-effect:focus,.activate-technique:hover,.activate-technique:focus { border-color:var(--blood); background:var(--dark-gold); outline:2px solid rgba(var(--gold-rgb),.3); } .skill-name { font-weight:bold; } +.skill-depth-1 .skill-name { padding-left:20px; } +.skill-depth-2 .skill-name { padding-left:40px; } +.skill-depth-3 .skill-name { padding-left:60px; } .skill-row output,.custom-skill-row output { text-align:center; color:var(--blood); font-weight:bold; } .custom-skill-row { display:grid; grid-template-columns:28px minmax(150px,1fr) 140px 55px 55px 55px; gap:5px; align-items:center; margin:5px 0; } -.combat-card,.consumable-card,.technique-card { display:flex; flex-wrap:wrap; gap:7px; align-items:end; margin:8px 0; padding:9px; border:1px solid var(--border); border-left:4px solid var(--blood); background:rgba(251,249,243,.74); } +.combat-card,.consumable-card,.technique-card { display:flex; flex-wrap:wrap; gap:7px; align-items:end; margin:8px 0; padding:9px; border:1px solid var(--border); border-left:4px solid var(--blood); background:rgba(var(--light-rgb),.74); } .combat-card>.grow,.consumable-card>.grow { flex:1 1 190px; } -.combat-card label { width:75px; } +.combat-card label { display:grid; grid-template-rows:13px 28px; width:75px; min-width:0; align-items:end; } +.combat-card label>input { height:28px; min-height:28px; margin:0; } +.combat-card>label.grow { width:auto; min-width:190px; } .combat-card .attack-followup { display:none; } .combat-card textarea,.consumable-card textarea { flex-basis:100%; } -.attack-thresholds { display:flex; flex-basis:100%; gap:7px; align-items:end; padding:6px 8px; background:var(--accent); border-left:3px solid var(--gold); } -.attack-thresholds>span { flex:1; color:var(--muted); font-size:9px; text-transform:uppercase; } -.attack-thresholds label { width:75px; } -.protection-card .active { width:62px; } -.damage-resistance-grid { display:grid; grid-template-columns:repeat(4,1fr); gap:6px; } -.damage-resistance-grid label { display:flex; align-items:center; gap:6px; padding:7px; background:var(--light); border-left:3px solid var(--gold); } +.attack-card { display:grid; grid-template-columns:28px minmax(150px,1fr) repeat(7,minmax(45px,55px)); gap:7px; } +.attack-card>.attack-roll { align-self:end; } +.attack-card>label,.attack-card>label.grow { width:auto; min-width:0; margin:0 !important; } +.attack-card>textarea,.attack-card>.attack-thresholds { grid-column:1/-1; } +.attack-thresholds { display:flex; flex-basis:100%; gap:7px; align-items:end; padding:4px 8px; background:var(--accent); border-left:3px solid var(--gold); } +.attack-thresholds>span { flex:1; align-self:center; color:var(--muted); font-size:9px; text-transform:uppercase; } +.attack-thresholds label { width:75px; margin:0 !important; } +.protection-card .active { display:flex; flex-direction:column; justify-content:end; width:62px; } +.protection-card .active input { height:28px; min-height:0; margin:0 auto; } +.damage-resistance-grid { display:grid; grid-template-columns:repeat(4,1fr); gap:0 6px; } +.damage-resistance-grid label { display:flex; align-items:center; gap:6px; margin:0 !important; padding:2px 7px; background:var(--light); border-left:3px solid var(--gold); line-height:1.2; } .damage-summary { display:flex; gap:8px; align-items:center; margin-top:8px; padding:8px; background:var(--accent); } .damage-summary span { flex:1; color:var(--muted); font-size:10px; text-transform:uppercase; } .damage-summary output { margin-left:6px; color:var(--blood); font:bold 16px "Cinzel",Georgia,serif; } .damage-summary button { padding:6px 10px; color:white; border:0; background:var(--blood); } .callout { padding:9px 12px; color:var(--muted); background:var(--accent); border-left:3px solid var(--gold); font-style:italic; } -.consumable-card label:not(.active) { width:105px; } +.consumable-card { display:block; } +.consumable-kind { display:grid; grid-template-columns:28px minmax(0,1fr); gap:7px; align-items:center; } +.consumable-kind select { height:32px; min-height:32px; margin:0; } +.consumable-details { display:grid; grid-template-columns:minmax(0,1fr) 60px 105px; gap:7px; align-items:end; margin:7px 0; } +.consumable-details>input { height:28px; min-height:28px; margin:0; } +.consumable-details label { display:grid; grid-template-rows:14px 28px; min-width:0; margin:0 !important; padding:0; align-items:end; } +.consumable-details label input { height:28px; min-height:28px; margin:0; } +.consumable-card textarea { display:block; width:100%; } .active { display:flex; align-items:center; gap:5px; padding:5px; } -.use-effect { width:30px; height:30px; flex:0 0 30px; color:white; border:1px solid var(--dark-gold); border-radius:50%; background:var(--blood); } -.modifier-card { display:flex; flex-wrap:wrap; gap:7px; align-items:end; margin:8px 0; padding:9px; border:1px solid var(--border); border-left:4px solid var(--gold); background:rgba(251,249,243,.74); } +.use-effect { flex:0 0 28px; } +.modifier-card { display:flex; flex-wrap:wrap; gap:7px; align-items:end; margin:8px 0; padding:9px; border:1px solid var(--border); border-left:4px solid var(--gold); background:rgba(var(--light-rgb),.74); } .modifier-card>.grow { flex:1; } -.class-picker label { min-width:240px; flex:1; } -.class-picker button { padding:8px 12px; color:white; border:0; background:var(--blood); } -.technique-message { min-width:150px; color:var(--dark-gold); font-style:italic; } +.class-picker label { display:grid; grid-template-rows:14px 32px; min-width:240px; flex:1; align-items:end; margin:0 !important; padding:0; } +.class-picker select { display:block; height:32px; min-height:32px; margin:0; } +.class-picker button { align-self:end; height:32px; min-height:32px; margin:0; padding:0 12px; color:white; border:0; background:var(--blood); line-height:32px; white-space:nowrap; } +.technique-message { display:flex; align-items:center; align-self:end; min-width:150px; height:32px; margin:0; color:var(--dark-gold); font-style:italic; } .technique-card { display:block; } .tech-title,.tech-meta { display:flex; gap:7px; align-items:end; } -.activate-technique { width:30px; height:30px; flex:0 0 30px; color:white; border:1px solid var(--dark-gold); border-radius:50%; background:var(--blood); } +.activate-technique { flex:0 0 28px; } .tech-title>input { flex:1; color:var(--blood); font-weight:bold; } .tech-title label { width:75px; } .tech-meta { margin:5px 0; } -.tech-meta>input { flex:1; } -.tech-meta label { width:55px; } +.tech-meta label { display:grid; grid-template-rows:14px 28px; flex:0 0 55px; min-width:0; margin:0 !important; padding:0; align-items:end; } +.tech-meta label.grow { flex:1 1 160px; } +.tech-meta input { height:28px; min-height:28px; margin:0; } +.power-message { color:var(--dark-gold); font-style:italic; } +.power-card { margin:8px 0; padding:9px; border:1px solid var(--border); border-left:4px solid var(--blood); background:rgba(var(--light-rgb),.74); } +.power-heading { display:flex; gap:7px; align-items:center; } +.power-heading>input { flex:1; color:var(--blood); font-weight:bold; } +.power-meta { display:flex; gap:7px; margin:7px 0; } +.power-meta label { flex:1; } +.power-meta label:nth-child(2) { flex:0 0 75px; } +.power-card textarea { width:100%; } .repcontrol { margin:6px 0 14px; } .repcontrol_add,.repcontrol_edit { color:var(--dark-gold); border:1px solid var(--gold); background:var(--light); } -.sheet-rolltemplate-ravenous .sheet-template { overflow:hidden; color:#302c26; border:1px solid #9b8050; border-left:5px solid #7a2424; background:#f4ebd8; font:12px/1.4 Georgia,serif; } -.sheet-rolltemplate-ravenous .sheet-template-title { padding:7px 9px; color:#fbf9f3; background:#7a2424; font:bold 15px Georgia,serif; } -.sheet-rolltemplate-ravenous .sheet-template-subtitle { padding:3px 9px; color:#716957; background:#ede1c8; font-style:italic; } +.sheet-rolltemplate-ravenous .sheet-template { overflow:hidden; color:var(--ink); border:1px solid var(--gold); border-left:5px solid var(--blood); background:var(--paper); font:12px/1.4 Georgia,serif; } +.sheet-rolltemplate-ravenous .sheet-template-title { padding:7px 9px; color:var(--light); background:var(--blood); font:bold 15px Georgia,serif; } +.sheet-rolltemplate-ravenous .sheet-template-subtitle { padding:3px 9px; color:var(--muted); background:var(--accent); font-style:italic; } .sheet-rolltemplate-ravenous .sheet-template-result { padding:10px; text-align:center; font-size:20px; } -.sheet-rolltemplate-ravenous .sheet-template-skill-result { padding:9px; color:#7a2424; text-align:center; font:bold 16px Georgia,serif; } -.sheet-rolltemplate-ravenous .sheet-template-row,.sheet-rolltemplate-ravenous .sheet-template-notes { padding:5px 9px; border-top:1px solid #c9bda4; } -.sheet-rolltemplate-ravenous .sheet-template-actions { display:flex; gap:6px; padding:7px 9px; border-top:1px solid #c9bda4; } -.sheet-rolltemplate-ravenous .sheet-template-actions a { flex:1; padding:5px 7px; color:#fbf9f3; border:1px solid #70582f; border-radius:2px; background:#7a2424; font:bold 11px Georgia,serif; text-align:center; text-decoration:none; } -.sheet-rolltemplate-ravenous .sheet-template-calculation { padding:4px 9px 7px; color:#716957; border-top:1px solid #c9bda4; font-size:10px; font-style:italic; } -.sheet-rolltemplate-ravenous .sheet-template-row b { color:#7a2424; } -.sheet-rolltemplate-ravenous .sheet-template-notes { color:#716957; font-style:italic; } +.sheet-rolltemplate-ravenous .sheet-template-skill-result { padding:9px; color:var(--blood); text-align:center; font:bold 16px Georgia,serif; } +.sheet-rolltemplate-ravenous .sheet-template-row,.sheet-rolltemplate-ravenous .sheet-template-notes { padding:5px 9px; border-top:1px solid var(--border); } +.sheet-rolltemplate-ravenous .sheet-template-actions { display:flex; gap:6px; padding:7px 9px; border-top:1px solid var(--border); } +.sheet-rolltemplate-ravenous .sheet-template-actions a { flex:1; padding:5px 7px; color:var(--light); border:1px solid var(--dark-gold); border-radius:2px; background:var(--blood); font:bold 11px Georgia,serif; text-align:center; text-decoration:none; } +.sheet-rolltemplate-ravenous .sheet-template-calculation { padding:4px 9px 7px; color:var(--muted); border-top:1px solid var(--border); font-size:10px; font-style:italic; } +.sheet-rolltemplate-ravenous .sheet-template-row b { color:var(--blood); } +.sheet-rolltemplate-ravenous .sheet-template-notes { color:var(--muted); font-style:italic; } @media (max-width:760px) { .ravenous-sheet { min-width:0; padding:9px; }.hero { grid-template-columns:60px 1fr; }.motto { display:none; }.stat-grid { grid-template-columns:repeat(2,1fr); }.dashboard { grid-template-columns:repeat(2,1fr); }.derived-grid { grid-template-columns:repeat(3,1fr); }.tabs { flex-wrap:wrap; }.tabs button { flex-basis:33%; }.skill-head { display:none; }.skill-row,.custom-skill-row { grid-template-columns:28px 1fr 70px 45px 45px 45px; }.skill-row select,.custom-skill-row select { max-width:70px; }.location-head,.location-row { grid-template-columns:minmax(105px,1.5fr) repeat(5,minmax(54px,1fr)); gap:3px; }.resistance-grid,.damage-resistance-grid { grid-template-columns:repeat(2,1fr); } } diff --git a/src/ravenous.html b/src/ravenous.html index 8361694..b81348c 100644 --- a/src/ravenous.html +++ b/src/ravenous.html @@ -6,7 +6,7 @@
- +
@@ -21,20 +21,21 @@ +
✧

Caractéristiques

-
ForceBaseMod.Total1
-
AgilitéBaseMod.Total1
-
PerceptionBaseMod.Total1
-
IntelligenceBaseMod.Total1
-
VolontéBaseMod.Total1
-
PsyBaseMod.Total1
-
ChanceBaseMod.Total2
-
CharismeBaseMod.Total2
+
ForceBaseMod.Total
+
AgilitéBaseMod.Total
+
PerceptionBaseMod.Total
+
IntelligenceBaseMod.Total
+
VolontéBaseMod.Total
+
PsyBaseMod.Total
+
ChanceBaseMod.Total
+
CharismeBaseMod.Total

valeur + temporaire = finale. Les valeurs dérivées utilisent la valeur permanente.

@@ -106,7 +107,6 @@
❖

Compétences

- Le jet réussit sous caractéristique finale + compétence finale.
CompétenceCaractéristiqueBaseTemp.Total
{{SKILL_ROWS}} @@ -126,12 +126,12 @@
⚔

Attaques

-
+
- + @@ -148,8 +148,8 @@
- - + + @@ -161,21 +161,17 @@
✦

Potions & nourriture

-

Décrivez librement l'effet du consommable puis utilisez le bouton ▶ pour l'annoncer dans le chat.

- - - - - +
+
✧

Effets temporaires

- + @@ -186,16 +182,30 @@
✧

Écoles & techniques

-

Les techniques proposées viennent des TSV Ravenous et respectent la limite de tier du build. Ajoutez uniquement celles acquises par le personnage.

-
-
+
+
+ +
+
✦

Pouvoirs d'origine

+
+

Choisissez d'abord une origine dans l'onglet Chasseur, puis ajoutez les pouvoirs d'un stade entier. Chaque pouvoir de ce stade est ajouté une fois. Pour un pouvoir personnalisé, utilisez le bouton d'ajout de la section ci-dessous.

+ +
+
+ +
+
+ +
+
+
@@ -226,6 +236,7 @@ const CHARACTERISTICS = ["force","agilite","perception","intelligence","volonte","psy","chance","charisme"]; const SKILLS = {{SKILLS_JSON}}; const TECHNIQUES = {{TECHNIQUES_JSON}}; +const ORIGINS = {{ORIGINS_JSON}}; const number = value => Number.parseFloat(value) || 0; const templateText = value => String(value || "").replace(/[{}]/g, ""); const attackRolls = {}; @@ -430,6 +441,20 @@ const recalculateCustomSkills = () => getSectionIDs("customskills", ids => { on("sheet:opened change:force change:agilite change:perception change:intelligence change:volonte change:psy change:chance change:charisme change:stage change:force_manual change:agilite_manual change:perception_manual change:intelligence_manual change:volonte_manual change:psy_manual change:chance_manual change:charisme_manual change:torque_modifier change:speed_modifier change:half_speed_modifier change:run_speed_modifier change:swim_speed_modifier change:fly_speed_modifier change:hp_modifier change:jauge_max_modifier change:fatigue_max_modifier change:toxicite_max_modifier change:satiete_max_modifier change:actions_max_modifier", recalculate); on("sheet:opened change:secret_rolls", () => getAttrs(["secret_rolls"], values => setAttrs({roll_whisper:values.secret_rolls === "1" ? "/w gm " : ""}, {silent:true}))); +on("sheet:opened", () => getSectionIDs("techniques", ids => { + const attrs = ids.flatMap(id => [`repeating_techniques_${id}_source_key`, `repeating_techniques_${id}_school`]); + getAttrs(attrs, values => { + const update = {}; + ids.forEach(id => { + const prefix = `repeating_techniques_${id}_`; + const technique = TECHNIQUES[values[prefix+"source_key"]]; + if (technique && values[prefix+"school"] === technique.school.replaceAll("_", " ")) { + update[prefix+"school"] = technique.school_label; + } + }); + if (Object.keys(update).length) setAttrs(update, {silent:true}); + }); +})); on(`sheet:opened ${DAMAGE_RESISTANCES.flatMap(type => [`change:resist_${type}`,`change:damage_apply_${type}`]).join(" ")}`, recalculateDamageResistances); on("sheet:opened change:repeating_protections change:_reporder_repeating_protections", recalculateProtections); on(`sheet:opened change:repeating_locations ${FIXED_LOCATIONS.flatMap(([,key]) => [`change:${key}_protection`,`change:${key}_armor`]).join(" ")}`, recalculateDamageLocations); @@ -451,7 +476,38 @@ on("clicked:repeating_customskills:roll_customskill", event => { const prefix = event.sourceAttribute.replace(/roll_customskill$/, ""); getAttrs([prefix+"name",prefix+"total"], values => performSkillRoll(values[prefix+"name"] || "Compétence maison", values[prefix+"total"])); }); -["core","skills","combat","health","consumables","classes"].forEach(tab => on(`clicked:tab_${tab}`, () => setAttrs({tab}))); +["core","skills","combat","health","consumables","classes","powers"].forEach(tab => on(`clicked:tab_${tab}`, () => setAttrs({tab}))); +on("change:origin_key", () => getAttrs(["origin_key"], values => { + const origin = ORIGINS[values.origin_key]; + setAttrs({origin:origin ? origin.name : "", power_message:""}); +})); +on("clicked:add_power_stage", () => getAttrs(["origin_key","power_stage_to_add"], values => { + const origin = ORIGINS[values.origin_key]; + if (!origin) return setAttrs({power_message:"Choisissez d'abord une origine."}); + const stage = values.power_stage_to_add; + const powers = origin.powers.filter(power => power.stage === stage); + if (!powers.length) return setAttrs({power_message:"Choisissez un stade disponible."}); + getSectionIDs("powers", ids => { + getAttrs(ids.map(id => `repeating_powers_${id}_source_key`), existing => { + const keys = new Set(ids.map(id => existing[`repeating_powers_${id}_source_key`])); + const update = {}; + let added = 0; + powers.forEach(power => { + if (keys.has(power.key)) return; + const prefix = `repeating_powers_${generateRowID()}_`; + update[prefix+"source_key"] = power.key; + update[prefix+"name"] = power.name; + update[prefix+"origin"] = origin.name; + update[prefix+"stage"] = power.stage; + update[prefix+"type"] = power.type; + update[prefix+"description"] = power.description; + added += 1; + }); + update.power_message = added ? `${added} pouvoir(s) du stade ${stage} ajouté(s).` : `Les pouvoirs du stade ${stage} sont déjà présents.`; + setAttrs(update, {silent:true}); + }); + }); +})); on("clicked:add_technique", () => getAttrs(["technique_to_add"], values => { const key = values.technique_to_add; const technique = TECHNIQUES[key]; if (!technique) return setAttrs({technique_message:"Choisissez une technique."}); @@ -460,7 +516,7 @@ on("clicked:add_technique", () => getAttrs(["technique_to_add"], values => { getAttrs(keys, current => { if (keys.some(attribute => current[attribute] === key)) return setAttrs({technique_message:`${technique.name} est déjà présente.`}); const prefix = `repeating_techniques_${generateRowID()}_`; - setAttrs({[prefix+"source_key"]:key,[prefix+"name"]:technique.name,[prefix+"school"]:technique.school.replaceAll("_", " "),[prefix+"tier"]:technique.tier,[prefix+"level"]:technique.level,[prefix+"type"]:technique.type,[prefix+"blood"]:technique.blood,[prefix+"gauge"]:technique.gauge,[prefix+"other"]:technique.other,[prefix+"effect"]:technique.effect,technique_message:`${technique.name} ajoutée.`}, {silent:true}); + setAttrs({[prefix+"source_key"]:key,[prefix+"name"]:technique.name,[prefix+"school"]:technique.school_label,[prefix+"tier"]:technique.tier,[prefix+"level"]:technique.level,[prefix+"type"]:technique.type,[prefix+"blood"]:technique.blood,[prefix+"gauge"]:technique.gauge,[prefix+"other"]:technique.other,[prefix+"effect"]:technique.effect,technique_message:`${technique.name} ajoutée.`}, {silent:true}); }); }); })); diff --git a/tests/test_build.py b/tests/test_build.py index a96dd6d..6badb86 100644 --- a/tests/test_build.py +++ b/tests/test_build.py @@ -1,5 +1,6 @@ import json import subprocess +import tempfile import unittest from pathlib import Path @@ -27,9 +28,24 @@ class BuildTests(unittest.TestCase): self.assertNotIn("{{SKILL_ROWS}}", sheet) self.assertNotIn("', sheet) - for section in ("customskills", "attacks", "protections", "locations", "consumables", "modifiers", "techniques"): + for section in ("customskills", "attacks", "protections", "locations", "consumables", "modifiers", "techniques", "powers"): self.assertIn(f'class="repeating_{section}"', sheet) + def test_origins_and_powers_are_imported(self): + from tools.build import read_glossary_labels, read_origins + + origins = read_origins(read_glossary_labels()) + self.assertEqual(26, len(origins)) + self.assertEqual("Renouveau", origins["dragon_1"]["powers"][0]["name"]) + self.assertEqual("1", origins["dragon_1"]["powers"][0]["stage"]) + self.assertIn("Cette mort ne vous inflige aucun malus de mort.", origins["dragon_1"]["powers"][0]["description"]) + sheet = (ROOT / "build/ravenous.html").read_text() + self.assertIn('name="attr_origin_key"', sheet) + self.assertIn('name="act_tab_powers"', sheet) + self.assertIn('name="act_add_power_stage"', sheet) + self.assertIn('name="attr_power_stage_to_add"', sheet) + self.assertIn('name="attr_source_key"', sheet) + def test_technique_tier_limit_comes_from_typst_config(self): info = json.loads((ROOT / "build/build-info.json").read_text()) sheet = (ROOT / "build/ravenous.html").read_text() @@ -115,6 +131,17 @@ class BuildTests(unittest.TestCase): self.assertIn("{{details=@{effect}}}", sheet) self.assertNotRegex(technique_data, r"[@#][A-Za-z_]") + def test_school_trigrams_come_from_book_config(self): + from tools.build import read_build_config, read_glossary_labels, read_schools, technique_options + + config = read_build_config() + schools = read_schools(int(config["build"]["max_tier_exclusive"]), read_glossary_labels()) + options, indexed = technique_options(schools, config["schools"]["trigrams"]) + self.assertIn('', options) + self.assertIn('', options) + self.assertEqual("artilleur", indexed["artilleur:0"]["school"]) + self.assertEqual("Artilleur", indexed["artilleur:0"]["school_label"]) + def test_skills_are_categorized_single_roll_checks(self): sheet = (ROOT / "build/ravenous.html").read_text() for category in ("Résistances", "Martial", "Généralistes", "Athlétisme", "Artisanat", "Connaissances", "Langues"): @@ -129,7 +156,7 @@ class BuildTests(unittest.TestCase): self.assertEqual(info["skills"] + 1, sheet.count('class="skill-roll"')) # Includes the custom skill row. def test_nested_specializations_have_distinct_attributes(self): - from tools.build import skills_from_data + from tools.build import skill_rows, skills_from_data skills = skills_from_data({"competences": [{"name": "Martial", "entries": [ {"name": "Parade", "subskills": [{"name": "Expertise", "subskills": [{"name": "Avancée"}]}]}, @@ -138,6 +165,12 @@ class BuildTests(unittest.TestCase): self.assertEqual(["parade", "parade_expertise", "parade_expertise_avancee", "esquive", "esquive_expertise"], [skill["id"] for skill in skills]) self.assertEqual("Parade — Expertise — Avancée", skills[2]["name"]) + self.assertEqual("Avancée", skills[2]["display_name"]) + self.assertEqual(2, skills[2]["depth"]) + rows = skill_rows(skills) + self.assertIn('class="skill-row skill-depth-2"', rows) + self.assertIn('Avancée', rows) + self.assertNotIn('Parade — Expertise', rows) self.assertEqual("force", skills[2]["characteristic"]) self.assertEqual("agilite", skills[4]["characteristic"]) @@ -145,6 +178,7 @@ class BuildTests(unittest.TestCase): sheet = (ROOT / "build/ravenous.html").read_text() self.assertIn('name="attr_armes_d_hast_lance"', sheet) self.assertIn('name="attr_survie_foret"', sheet) + self.assertIn('class="skill-row skill-depth-1"', sheet) def test_current_roll20_css_mode(self): manifest = json.loads((ROOT / "build/sheet.json").read_text()) @@ -159,6 +193,25 @@ class BuildTests(unittest.TestCase): self.assertIn("appearance:textfield", css) self.assertIn('name="attr_sang_max"', (ROOT / "build/ravenous.html").read_text()) + def test_export_can_select_a_book_theme_without_replacing_default(self): + from tools.build import read_theme_palettes + + self.assertIn("steel", read_theme_palettes()) + default_css = (ROOT / "build/ravenous.css").read_text() + with tempfile.TemporaryDirectory() as directory: + command = ["python", "tools/build.py", "--theme", "steel", "--output-dir", directory] + subprocess.run(command, cwd=ROOT, check=True, capture_output=True) + alternate_css = (Path(directory) / "ravenous.css").read_text() + alternate_info = json.loads((Path(directory) / "build-info.json").read_text()) + self.assertIn("--paper:#eef1f3", alternate_css) + self.assertIn("--blood:#526d85", alternate_css) + self.assertIn(".sheet-rolltemplate-ravenous .sheet-template", alternate_css) + self.assertNotIn("{{THEME_VARS}}", alternate_css) + self.assertNotEqual(default_css, alternate_css) + self.assertEqual("steel", alternate_info["theme"]) + subprocess.run(command + ["--check"], cwd=ROOT, check=True, capture_output=True) + self.assertEqual(default_css, (ROOT / "build/ravenous.css").read_text()) + if __name__ == "__main__": unittest.main() diff --git a/tests/test_mod_import.mjs b/tests/test_mod_import.mjs new file mode 100644 index 0000000..e6b72c9 --- /dev/null +++ b/tests/test_mod_import.mjs @@ -0,0 +1,50 @@ +import assert from 'node:assert/strict'; +import { readFileSync } from 'node:fs'; +import { test } from 'node:test'; +import vm from 'node:vm'; + +const script = readFileSync(new URL('../roll20_mod/ravenous_import_name.js', import.meta.url), 'utf8'); + +function mod() { + const created = []; + const chat = []; + let handler; + vm.runInNewContext(script, { + on(event, callback) { + assert.equal(event, 'chat:message'); + handler = callback; + }, + playerIsGM: id => id === 'gm', + createObj(type, fields) { + const value = { type, name: fields.name }; + created.push(value); + return value; + }, + sendChat: (speaker, content) => chat.push({ speaker, content }), + }); + return { created, chat, send: (content, playerid = 'gm', type = 'api') => handler({ content, playerid, type }) }; +} + +test('a GM can create one named character from JSON', () => { + const session = mod(); + session.send('!ravenous-import-name {"name":" Ariane "}'); + assert.deepEqual(session.created, [{ type: 'character', name: 'Ariane' }]); + assert.match(session.chat[0].content, /Created one character/); +}); + +test('unrelated messages and non-GM commands create nothing', () => { + const session = mod(); + session.send('!other {"name":"Ariane"}'); + session.send('!ravenous-import-name {"name":"Ariane"}', 'player'); + session.send('!ravenous-import-name {"name":"Ariane"}', 'gm', 'general'); + assert.equal(session.created.length, 0); +}); + +test('bad JSON and invalid names create nothing', () => { + const session = mod(); + session.send('!ravenous-import-name {bad}'); + session.send('!ravenous-import-name {"name":""}'); + session.send('!ravenous-import-name {"name":42}'); + assert.equal(session.created.length, 0); + assert.equal(session.chat.length, 3); +}); diff --git a/tests/test_worker.mjs b/tests/test_worker.mjs new file mode 100644 index 0000000..4d542f4 --- /dev/null +++ b/tests/test_worker.mjs @@ -0,0 +1,189 @@ +import assert from 'node:assert/strict'; +import { readFileSync } from 'node:fs'; +import { test } from 'node:test'; +import vm from 'node:vm'; + +const sheet = readFileSync(new URL('../build/ravenous.html', import.meta.url), 'utf8'); +const script = sheet.match(/