Build and refine Ravenous Roll20 sheet
This commit is contained in:
parent
1f56c02995
commit
e768039b0c
|
|
@ -2,3 +2,4 @@
|
|||
__pycache__/
|
||||
*.pyc
|
||||
build/
|
||||
build-*/
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
82
README.md
82
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.
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -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.');
|
||||
});
|
||||
|
|
@ -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
|
||||
117
src/ravenous.css
117
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); } }
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
<div class="identity">
|
||||
<label>Chasseur<input type="text" name="attr_character_name" placeholder="Nom du chasseur"></label>
|
||||
<div class="identity-grid">
|
||||
<label>Origine<input type="text" name="attr_origin"></label>
|
||||
<label>Origine<select name="attr_origin_key"><option value="">Choisir une origine…</option>{{ORIGIN_OPTIONS}}</select><input type="hidden" name="attr_origin"></label>
|
||||
<label>Joueur<input type="text" name="attr_player_name"></label>
|
||||
<label>Stade<input type="number" name="attr_stage" value="1" min="0"></label>
|
||||
</div>
|
||||
|
|
@ -21,20 +21,21 @@
|
|||
<button type="action" name="act_tab_health">Santé & résistances</button>
|
||||
<button type="action" name="act_tab_consumables">Cuisine & alchimie</button>
|
||||
<button type="action" name="act_tab_classes">Écoles</button>
|
||||
<button type="action" name="act_tab_powers">Pouvoirs</button>
|
||||
</nav>
|
||||
<input type="hidden" class="tab-state" name="attr_tab" value="core">
|
||||
|
||||
<section class="page page-core">
|
||||
<div class="section-title"><span>✧</span><h2>Caractéristiques</h2></div>
|
||||
<div class="stat-grid">
|
||||
<div class="stat"><strong>Force</strong><span>Base</span><span>Mod.</span><span>Total</span><input aria-label="Force de base" type="number" name="attr_force" value="1"><input aria-label="Modificateur temporaire de Force" type="number" name="attr_force_manual" value="0"><output name="attr_force_total">1</output></div>
|
||||
<div class="stat"><strong>Agilité</strong><span>Base</span><span>Mod.</span><span>Total</span><input aria-label="Agilité de base" type="number" name="attr_agilite" value="1"><input aria-label="Modificateur temporaire d'Agilité" type="number" name="attr_agilite_manual" value="0"><output name="attr_agilite_total">1</output></div>
|
||||
<div class="stat"><strong>Perception</strong><span>Base</span><span>Mod.</span><span>Total</span><input aria-label="Perception de base" type="number" name="attr_perception" value="1"><input aria-label="Modificateur temporaire de Perception" type="number" name="attr_perception_manual" value="0"><output name="attr_perception_total">1</output></div>
|
||||
<div class="stat"><strong>Intelligence</strong><span>Base</span><span>Mod.</span><span>Total</span><input aria-label="Intelligence de base" type="number" name="attr_intelligence" value="1"><input aria-label="Modificateur temporaire d'Intelligence" type="number" name="attr_intelligence_manual" value="0"><output name="attr_intelligence_total">1</output></div>
|
||||
<div class="stat"><strong>Volonté</strong><span>Base</span><span>Mod.</span><span>Total</span><input aria-label="Volonté de base" type="number" name="attr_volonte" value="1"><input aria-label="Modificateur temporaire de Volonté" type="number" name="attr_volonte_manual" value="0"><output name="attr_volonte_total">1</output></div>
|
||||
<div class="stat"><strong>Psy</strong><span>Base</span><span>Mod.</span><span>Total</span><input aria-label="Psy de base" type="number" name="attr_psy" value="1"><input aria-label="Modificateur temporaire de Psy" type="number" name="attr_psy_manual" value="0"><output name="attr_psy_total">1</output></div>
|
||||
<div class="stat"><strong>Chance</strong><span>Base</span><span>Mod.</span><span>Total</span><input aria-label="Chance de base" type="number" name="attr_chance" value="2"><input aria-label="Modificateur temporaire de Chance" type="number" name="attr_chance_manual" value="0"><output name="attr_chance_total">2</output></div>
|
||||
<div class="stat"><strong>Charisme</strong><span>Base</span><span>Mod.</span><span>Total</span><input aria-label="Charisme de base" type="number" name="attr_charisme" value="2"><input aria-label="Modificateur temporaire de Charisme" type="number" name="attr_charisme_manual" value="0"><output name="attr_charisme_total">2</output></div>
|
||||
<div class="stat"><strong>Force</strong><span>Base</span><span>Mod.</span><span>Total</span><input aria-label="Force de base" type="number" name="attr_force" value="1"><input aria-label="Modificateur temporaire de Force" type="number" name="attr_force_manual" value="0"><input class="stat-total" aria-label="Force totale" type="text" name="attr_force_total" value="1" readonly></div>
|
||||
<div class="stat"><strong>Agilité</strong><span>Base</span><span>Mod.</span><span>Total</span><input aria-label="Agilité de base" type="number" name="attr_agilite" value="1"><input aria-label="Modificateur temporaire d'Agilité" type="number" name="attr_agilite_manual" value="0"><input class="stat-total" aria-label="Agilité totale" type="text" name="attr_agilite_total" value="1" readonly></div>
|
||||
<div class="stat"><strong>Perception</strong><span>Base</span><span>Mod.</span><span>Total</span><input aria-label="Perception de base" type="number" name="attr_perception" value="1"><input aria-label="Modificateur temporaire de Perception" type="number" name="attr_perception_manual" value="0"><input class="stat-total" aria-label="Perception totale" type="text" name="attr_perception_total" value="1" readonly></div>
|
||||
<div class="stat"><strong>Intelligence</strong><span>Base</span><span>Mod.</span><span>Total</span><input aria-label="Intelligence de base" type="number" name="attr_intelligence" value="1"><input aria-label="Modificateur temporaire d'Intelligence" type="number" name="attr_intelligence_manual" value="0"><input class="stat-total" aria-label="Intelligence totale" type="text" name="attr_intelligence_total" value="1" readonly></div>
|
||||
<div class="stat"><strong>Volonté</strong><span>Base</span><span>Mod.</span><span>Total</span><input aria-label="Volonté de base" type="number" name="attr_volonte" value="1"><input aria-label="Modificateur temporaire de Volonté" type="number" name="attr_volonte_manual" value="0"><input class="stat-total" aria-label="Volonté totale" type="text" name="attr_volonte_total" value="1" readonly></div>
|
||||
<div class="stat"><strong>Psy</strong><span>Base</span><span>Mod.</span><span>Total</span><input aria-label="Psy de base" type="number" name="attr_psy" value="1"><input aria-label="Modificateur temporaire de Psy" type="number" name="attr_psy_manual" value="0"><input class="stat-total" aria-label="Psy totale" type="text" name="attr_psy_total" value="1" readonly></div>
|
||||
<div class="stat"><strong>Chance</strong><span>Base</span><span>Mod.</span><span>Total</span><input aria-label="Chance de base" type="number" name="attr_chance" value="2"><input aria-label="Modificateur temporaire de Chance" type="number" name="attr_chance_manual" value="0"><input class="stat-total" aria-label="Chance totale" type="text" name="attr_chance_total" value="2" readonly></div>
|
||||
<div class="stat"><strong>Charisme</strong><span>Base</span><span>Mod.</span><span>Total</span><input aria-label="Charisme de base" type="number" name="attr_charisme" value="2"><input aria-label="Modificateur temporaire de Charisme" type="number" name="attr_charisme_manual" value="0"><input class="stat-total" aria-label="Charisme total" type="text" name="attr_charisme_total" value="2" readonly></div>
|
||||
</div>
|
||||
<p class="legend"><span>valeur</span> + <span>temporaire</span> = <span>finale</span>. Les valeurs dérivées utilisent la valeur permanente.</p>
|
||||
|
||||
|
|
@ -106,7 +107,6 @@
|
|||
<div class="section-title"><span>❖</span><h2>Compétences</h2></div>
|
||||
<div class="skill-toolbar">
|
||||
<label>Dé de difficulté<select name="attr_skill_die"><option value="4">d4 · trivial</option><option value="6">d6 · simple</option><option value="8">d8 · ordinaire</option><option value="10" selected>d10 · modéré</option><option value="12">d12 · complexe</option><option value="20">d20 · avancé</option><option value="30">d30</option><option value="100">d100 · cauchemardesque</option><option value="1000">d1000 · impossible</option></select></label>
|
||||
<span>Le jet réussit sous caractéristique finale + compétence finale.</span>
|
||||
</div>
|
||||
<div class="skill-head"><span></span><span>Compétence</span><span>Caractéristique</span><span>Base</span><span>Temp.</span><span>Total</span></div>
|
||||
{{SKILL_ROWS}}
|
||||
|
|
@ -126,12 +126,12 @@
|
|||
<section class="page page-combat">
|
||||
<div class="section-title"><span>⚔</span><h2>Attaques</h2></div>
|
||||
<fieldset class="repeating_attacks">
|
||||
<div class="combat-card">
|
||||
<div class="combat-card attack-card">
|
||||
<button class="attack-roll" type="action" name="act_attack" title="Effectuer cette attaque" aria-label="Effectuer cette attaque"></button>
|
||||
<button class="attack-followup" type="action" name="act_defend" aria-label="Défendre contre cette attaque"></button>
|
||||
<button class="attack-followup" type="action" name="act_damage" aria-label="Calculer les dégâts de cette attaque"></button>
|
||||
<button class="attack-followup" type="action" name="act_take_damage" aria-label="Appliquer les réductions du défenseur"></button>
|
||||
<input class="grow" type="text" name="attr_name" placeholder="Arme / attaque">
|
||||
<label class="grow">Attaque<input type="text" name="attr_name" placeholder="Arme / attaque"></label>
|
||||
<label>Dés<input type="number" name="attr_dice" value="1" min="0"></label>
|
||||
<label>Seuil<input type="number" name="attr_threshold" value="6"></label>
|
||||
<label>Temp.<input type="number" name="attr_temp" value="0"></label>
|
||||
|
|
@ -148,8 +148,8 @@
|
|||
<fieldset class="repeating_protections">
|
||||
<div class="combat-card protection-card">
|
||||
<label class="active">Active<input type="checkbox" name="attr_active" value="1"></label>
|
||||
<input class="grow" type="text" name="attr_name" placeholder="Armure, bouclier, protection naturelle…">
|
||||
<label>Protection<input type="number" name="attr_protection" value="0" min="0"></label>
|
||||
<label class="grow">Protection<input type="text" name="attr_name" placeholder="Armure, bouclier, protection naturelle…"></label>
|
||||
<label title="Valeur de protection">Prot.<input type="number" name="attr_protection" value="0" min="0"></label>
|
||||
<label>Int.<input type="number" name="attr_integrity" value="0" min="0"></label>
|
||||
<label>Int. max<input type="number" name="attr_integrity_max" value="0" min="0"></label>
|
||||
<label>Parade<input type="number" name="attr_parry" value="0"></label>
|
||||
|
|
@ -161,21 +161,17 @@
|
|||
|
||||
<section class="page page-consumables">
|
||||
<div class="section-title"><span>✦</span><h2>Potions & nourriture</h2></div>
|
||||
<p class="callout">Décrivez librement l'effet du consommable puis utilisez le bouton ▶ pour l'annoncer dans le chat.</p>
|
||||
<fieldset class="repeating_consumables">
|
||||
<div class="consumable-card">
|
||||
<button class="use-effect" type="roll" name="roll_use" title="Utiliser dans le chat" value="@{roll_whisper}&{template:ravenous} {{title=@{name}}} {{subtitle=@{kind} · @{character_name}}} {{duration=@{duration}}} {{details=@{description}}}">▶</button>
|
||||
<select name="attr_kind"><option value="Nourriture">Nourriture</option><option value="Potion">Potion</option><option value="Autre">Autre</option></select>
|
||||
<input class="grow" type="text" name="attr_name" placeholder="Nom du consommable">
|
||||
<label>Qté<input type="number" name="attr_quantity" value="1" min="0"></label>
|
||||
<label>Durée<input type="text" name="attr_duration" placeholder="3 tours"></label>
|
||||
<div class="consumable-kind"><button class="use-effect" type="roll" name="roll_use" title="Utiliser dans le chat" aria-label="Utiliser dans le chat" value="@{roll_whisper}&{template:ravenous} {{title=@{name}}} {{subtitle=@{kind} · @{character_name}}} {{duration=@{duration}}} {{details=@{description}}}"></button><select name="attr_kind"><option value="Nourriture">Nourriture</option><option value="Potion">Potion</option><option value="Autre">Autre</option></select></div>
|
||||
<div class="consumable-details"><input type="text" name="attr_name" placeholder="Nom du consommable"><label>Qté<input type="number" name="attr_quantity" value="1" min="0"></label><label>Durée<input type="text" name="attr_duration" placeholder="3 tours"></label></div>
|
||||
<textarea name="attr_description" placeholder="Effet, toxicité, recette, notes…"></textarea>
|
||||
</div>
|
||||
</fieldset>
|
||||
<div class="section-title small"><span>✧</span><h3>Effets temporaires</h3></div>
|
||||
<fieldset class="repeating_modifiers">
|
||||
<div class="modifier-card">
|
||||
<button class="use-effect" type="roll" name="roll_use" title="Afficher dans le chat" value="@{roll_whisper}&{template:ravenous} {{title=@{name}}} {{subtitle=Effet temporaire · @{character_name}}} {{duration=@{duration}}} {{details=@{description}}}">▶</button>
|
||||
<button class="use-effect" type="roll" name="roll_use" title="Afficher dans le chat" aria-label="Afficher dans le chat" value="@{roll_whisper}&{template:ravenous} {{title=@{name}}} {{subtitle=Effet temporaire · @{character_name}}} {{duration=@{duration}}} {{details=@{description}}}"></button>
|
||||
<input class="grow" type="text" name="attr_name" placeholder="Bénédiction, blessure, terrain…">
|
||||
<input type="text" name="attr_duration" placeholder="Durée / fin">
|
||||
<textarea name="attr_description" placeholder="Effet et conditions…"></textarea>
|
||||
|
|
@ -186,16 +182,30 @@
|
|||
<section class="page page-classes">
|
||||
<div class="section-title"><span>✧</span><h2>Écoles & techniques</h2></div>
|
||||
<div class="class-picker"><label>Technique<select name="attr_technique_to_add"><option value="">Choisir une technique…</option>{{TECHNIQUE_OPTIONS}}</select></label><button type="action" name="act_add_technique">Ajouter cette technique</button><span class="technique-message" name="attr_technique_message"></span></div>
|
||||
<p class="callout">Les techniques proposées viennent des TSV Ravenous et respectent la limite de tier du build. Ajoutez uniquement celles acquises par le personnage.</p>
|
||||
<fieldset class="repeating_techniques">
|
||||
<div class="technique-card">
|
||||
<input type="hidden" name="attr_source_key">
|
||||
<div class="tech-title"><button class="activate-technique" type="roll" name="roll_activate" title="Activer dans le chat" value="@{roll_whisper}&{template:ravenous} {{title=@{name}}} {{subtitle=@{school} · Tier @{tier} · @{type}}} {{cost=Sang @{blood} · Jauge @{gauge} · @{other}}} {{details=@{effect}}}">▶</button><input type="text" name="attr_name"><label>Acquise<input type="checkbox" name="attr_owned" value="1"></label></div>
|
||||
<div class="tech-meta"><input type="text" name="attr_school"><label>Tier<input type="text" name="attr_tier"></label><label>Niv.<input type="text" name="attr_level"></label><label>Sang<input type="text" name="attr_blood"></label><label>Jauge<input type="text" name="attr_gauge"></label><label>Autre<input type="text" name="attr_other"></label><input type="text" name="attr_type"></div>
|
||||
<div class="tech-title"><button class="activate-technique" type="roll" name="roll_activate" title="Activer dans le chat" aria-label="Activer dans le chat" value="@{roll_whisper}&{template:ravenous} {{title=@{name}}} {{subtitle=@{school} · Tier @{tier} · @{type}}} {{cost=Sang @{blood} · Jauge @{gauge} · @{other}}} {{details=@{effect}}}"></button><input type="text" name="attr_name"><label>Acquise<input type="checkbox" name="attr_owned" value="1"></label></div>
|
||||
<div class="tech-meta"><label class="grow school-field">École<input type="text" name="attr_school"></label><label>Tier<input type="text" name="attr_tier"></label><label>Niv.<input type="text" name="attr_level"></label><label>Sang<input type="text" name="attr_blood"></label><label>Jauge<input type="text" name="attr_gauge"></label><label>Autre<input type="text" name="attr_other"></label><label class="grow">Type<input type="text" name="attr_type"></label></div>
|
||||
<textarea name="attr_effect" rows="3"></textarea>
|
||||
</div>
|
||||
</fieldset>
|
||||
</section>
|
||||
|
||||
<section class="page page-powers">
|
||||
<div class="section-title"><span>✦</span><h2>Pouvoirs d'origine</h2></div>
|
||||
<div class="class-picker"><label>Stade<select name="attr_power_stage_to_add"><option value="">Choisir un stade…</option>{{POWER_STAGE_OPTIONS}}</select></label><button type="action" name="act_add_power_stage">Ajouter les pouvoirs du stade</button></div>
|
||||
<p class="callout">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.</p>
|
||||
<span class="power-message" name="attr_power_message"></span>
|
||||
<fieldset class="repeating_powers">
|
||||
<div class="power-card">
|
||||
<input type="hidden" name="attr_source_key">
|
||||
<div class="power-heading"><button class="use-effect" type="roll" name="roll_activate" title="Afficher dans le chat" aria-label="Afficher dans le chat" value="@{roll_whisper}&{template:ravenous} {{title=@{name}}} {{subtitle=@{origin} · Stade @{stage} · @{type}}} {{details=@{description}}}"></button><input type="text" name="attr_name" placeholder="Nom du pouvoir"></div>
|
||||
<div class="power-meta"><label>Origine<input type="text" name="attr_origin"></label><label>Stade<input type="number" name="attr_stage" value="1" min="0"></label><label>Type<input type="text" name="attr_type" placeholder="named, passive…"></label></div>
|
||||
<textarea name="attr_description" rows="4" placeholder="Description du pouvoir"></textarea>
|
||||
</div>
|
||||
</fieldset>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<rolltemplate class="sheet-rolltemplate-ravenous">
|
||||
|
|
@ -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});
|
||||
});
|
||||
});
|
||||
}));
|
||||
|
|
|
|||
|
|
@ -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("<body", sheet.lower())
|
||||
self.assertIn('<script type="text/worker">', 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('<optgroup label="ART · Artilleur">', options)
|
||||
self.assertIn('<option value="artilleur:0">ART · T1 · Jauge du Dragon 1</option>', 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('<span class="skill-name">Avancée</span>', rows)
|
||||
self.assertNotIn('<span class="skill-name">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()
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
});
|
||||
|
|
@ -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(/<script type="text\/worker">([\s\S]*?)<\/script>/)?.[1];
|
||||
assert.ok(script, 'generated sheet worker exists; run ./scripts/build.sh first');
|
||||
|
||||
function worker(initial = {}) {
|
||||
const attrs = { ...initial };
|
||||
const handlers = new Map();
|
||||
const rolls = [];
|
||||
const queuedRolls = [];
|
||||
let nextRow = 0;
|
||||
const context = {
|
||||
on(events, callback) {
|
||||
for (const event of events.split(/\s+/)) {
|
||||
if (!handlers.has(event)) handlers.set(event, []);
|
||||
handlers.get(event).push(callback);
|
||||
}
|
||||
},
|
||||
getAttrs(names, callback) {
|
||||
callback(Object.fromEntries(names.map(name => [name, attrs[name]])));
|
||||
},
|
||||
setAttrs(values, options, callback) {
|
||||
Object.assign(attrs, values);
|
||||
(typeof options === 'function' ? options : callback)?.();
|
||||
},
|
||||
getSectionIDs(section, callback) {
|
||||
const prefix = `repeating_${section}_`;
|
||||
callback([...new Set(Object.keys(attrs).filter(key => key.startsWith(prefix))
|
||||
.map(key => key.slice(prefix.length).split('_')[0]))]);
|
||||
},
|
||||
generateRowID: () => nextRow++ === 0 ? 'newrow' : `row${nextRow}`,
|
||||
startRoll(command, callback) {
|
||||
const queued = queuedRolls.shift();
|
||||
assert.ok(queued, `No scripted result for ${command}`);
|
||||
const roll = { command, rollId: queued.rollId, computed: undefined };
|
||||
rolls.push(roll);
|
||||
callback({ rollId: roll.rollId, results: Object.fromEntries(
|
||||
Object.entries(queued.results).map(([name, result]) => [name, { result }])) });
|
||||
},
|
||||
finishRoll(rollId, computed) {
|
||||
const roll = rolls.find(item => item.rollId === rollId);
|
||||
assert.ok(roll);
|
||||
roll.computed = computed;
|
||||
},
|
||||
};
|
||||
vm.runInNewContext(script, context, { filename: 'ravenous-worker.js' });
|
||||
const fire = (event, payload = {}) => {
|
||||
for (const callback of handlers.get(event) || []) callback(payload);
|
||||
};
|
||||
const queueRoll = (rollId, results) => queuedRolls.push({ rollId, results });
|
||||
return { attrs, fire, queueRoll, rolls };
|
||||
}
|
||||
|
||||
test('opening the sheet recalculates base and temporary values', () => {
|
||||
const { attrs, fire } = worker({ force: '3', force_manual: '2', agilite: '4', volonte: '2', stage: '3' });
|
||||
fire('sheet:opened');
|
||||
assert.equal(attrs.force_total, 5);
|
||||
assert.equal(attrs.torque, 15); // Derived from permanent Force.
|
||||
assert.equal(attrs.hp_limbs_max, 7);
|
||||
assert.equal(attrs.hp_torso_max, 9);
|
||||
assert.equal(attrs.toxicite_max, 11);
|
||||
assert.equal(attrs.parade_total, 5); // Default Parade characteristic is Force.
|
||||
});
|
||||
|
||||
test('selected resistances and live protections update mitigation', () => {
|
||||
const { attrs, fire } = worker({
|
||||
force: '3', resist_fire: '2', damage_apply_fire: '1',
|
||||
resist_slash: '1', damage_apply_slash: '1',
|
||||
repeating_protections_a_active: '1', repeating_protections_a_integrity: '2', repeating_protections_a_protection: '4',
|
||||
repeating_protections_b_active: '1', repeating_protections_b_integrity: '0', repeating_protections_b_protection: '9',
|
||||
});
|
||||
fire('sheet:opened');
|
||||
assert.equal(attrs.damage_resistance_total, 3);
|
||||
assert.equal(attrs.active_protection_total, 4);
|
||||
assert.equal(attrs.active_first_protection, 4);
|
||||
assert.equal(attrs.active_mitigation_total, 7);
|
||||
fire('clicked:clear_damage_resistances');
|
||||
assert.equal(attrs.damage_resistance_total, 0);
|
||||
});
|
||||
|
||||
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 { attrs, fire } = worker({ technique_to_add: key });
|
||||
fire('clicked:add_technique');
|
||||
assert.equal(attrs.repeating_techniques_newrow_name, technique.name);
|
||||
assert.equal(attrs.repeating_techniques_newrow_school, technique.school_label);
|
||||
assert.equal(attrs.repeating_techniques_newrow_source_key, key);
|
||||
fire('clicked:add_technique');
|
||||
assert.match(attrs.technique_message, /déjà présente/);
|
||||
});
|
||||
|
||||
test('opening the sheet capitalizes old imported school names without changing edits', () => {
|
||||
const sheetWorker = worker({
|
||||
repeating_techniques_old_source_key: 'artilleur:0',
|
||||
repeating_techniques_old_school: 'artilleur',
|
||||
repeating_techniques_edited_source_key: 'artilleur:1',
|
||||
repeating_techniques_edited_school: 'École maison',
|
||||
});
|
||||
sheetWorker.fire('sheet:opened');
|
||||
assert.equal(sheetWorker.attrs.repeating_techniques_old_school, 'Artilleur');
|
||||
assert.equal(sheetWorker.attrs.repeating_techniques_edited_school, 'École maison');
|
||||
});
|
||||
|
||||
test('skill roll reports a critical success and a threshold failure', () => {
|
||||
const sheetWorker = worker({ force: '3', parade: '2', skill_die: '10', character_name: 'Test' });
|
||||
sheetWorker.fire('sheet:opened');
|
||||
sheetWorker.queueRoll('critical', { roll: 1 });
|
||||
sheetWorker.fire('clicked:skill_parade');
|
||||
assert.equal(sheetWorker.rolls[0].computed.outcome, 'Réussite critique');
|
||||
assert.equal(sheetWorker.rolls[0].computed.margin, 4);
|
||||
sheetWorker.queueRoll('failure', { roll: 5 });
|
||||
sheetWorker.fire('clicked:skill_parade');
|
||||
assert.equal(sheetWorker.rolls[1].computed.outcome, 'Échec');
|
||||
});
|
||||
|
||||
test('attack and defense cap remaining successes at RMax', () => {
|
||||
const prefix = 'repeating_attacks_a_';
|
||||
const sheetWorker = worker({
|
||||
[prefix + 'name']: 'Test', [prefix + 'dice']: '5', [prefix + 'threshold']: '6',
|
||||
[prefix + 'base_damage']: '4', [prefix + 'damage_per_success']: '2',
|
||||
[prefix + 'break_damage']: '3', [prefix + 'rmax']: '2',
|
||||
});
|
||||
sheetWorker.queueRoll('attack1', { attack_roll: 4 });
|
||||
sheetWorker.fire('clicked:repeating_attacks:attack', { sourceAttribute: prefix + 'attack' });
|
||||
assert.equal(sheetWorker.rolls[0].computed.attack_successes, 4);
|
||||
sheetWorker.queueRoll('defense1', { defense_roll: 1 });
|
||||
sheetWorker.fire('clicked:repeating_attacks:defend', {
|
||||
sourceAttribute: prefix + 'defend', originalRollId: 'attack1',
|
||||
});
|
||||
assert.equal(sheetWorker.rolls[1].computed.finalsuccesses, 2);
|
||||
assert.equal(sheetWorker.rolls[1].computed.damage, 6);
|
||||
});
|
||||
|
||||
test('Subir reports damage and armor break after selected mitigation', () => {
|
||||
const prefix = 'repeating_attacks_a_';
|
||||
const sheetWorker = worker({
|
||||
[prefix + 'name']: 'Test', [prefix + 'base_damage']: '8',
|
||||
[prefix + 'damage_per_success']: '2', [prefix + 'break_damage']: '6',
|
||||
[prefix + 'rmax']: '3',
|
||||
});
|
||||
// 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.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);
|
||||
assert.equal(sheetWorker.rolls[0].computed.damage, 1);
|
||||
assert.equal(sheetWorker.rolls[0].computed.break_damage, 1);
|
||||
});
|
||||
|
||||
test('origin stage picker adds its powers once and preserves custom rows', () => {
|
||||
const origins = JSON.parse(sheet.match(/const ORIGINS = (\{[^\n]+\});/)[1]);
|
||||
const stagePowers = origins.dragon_1.powers.filter(power => power.stage === '1');
|
||||
const sheetWorker = worker({
|
||||
origin_key: 'dragon_1',
|
||||
power_stage_to_add: '1',
|
||||
repeating_powers_custom_name: 'Pouvoir maison',
|
||||
repeating_powers_custom_description: 'Texte libre',
|
||||
});
|
||||
sheetWorker.fire('change:origin_key');
|
||||
let keys = Object.keys(sheetWorker.attrs).filter(key => key.startsWith('repeating_powers_') && key.endsWith('_source_key'));
|
||||
assert.equal(keys.length, 0);
|
||||
assert.equal(sheetWorker.attrs.origin, 'Ür-Dragon, Maître des Cieux');
|
||||
assert.equal(sheetWorker.attrs.repeating_powers_custom_name, 'Pouvoir maison');
|
||||
sheetWorker.fire('clicked:add_power_stage');
|
||||
keys = Object.keys(sheetWorker.attrs).filter(key => key.startsWith('repeating_powers_') && key.endsWith('_source_key'));
|
||||
assert.equal(keys.length, stagePowers.length);
|
||||
const firstKey = keys[0].replace(/_source_key$/, '');
|
||||
assert.ok(sheetWorker.attrs[firstKey + '_name']);
|
||||
assert.ok(sheetWorker.attrs[firstKey + '_stage']);
|
||||
sheetWorker.fire('clicked:add_power_stage');
|
||||
assert.match(sheetWorker.attrs.power_message, /déjà présents/);
|
||||
assert.equal(Object.keys(sheetWorker.attrs).filter(key => key.startsWith('repeating_powers_') && key.endsWith('_source_key')).length, stagePowers.length);
|
||||
sheetWorker.attrs.power_stage_to_add = '2';
|
||||
sheetWorker.fire('clicked:add_power_stage');
|
||||
assert.equal(Object.keys(sheetWorker.attrs).filter(key => key.startsWith('repeating_powers_') && key.endsWith('_source_key')).length,
|
||||
stagePowers.length + origins.dragon_1.powers.filter(power => power.stage === '2').length);
|
||||
sheetWorker.attrs.origin_key = 'dragon_2';
|
||||
sheetWorker.fire('change:origin_key');
|
||||
assert.equal(sheetWorker.attrs.repeating_powers_custom_name, 'Pouvoir maison');
|
||||
assert.equal(Object.keys(sheetWorker.attrs).filter(key => key.startsWith('repeating_powers_') && key.endsWith('_source_key')).length,
|
||||
stagePowers.length + origins.dragon_1.powers.filter(power => power.stage === '2').length);
|
||||
});
|
||||
132
tools/build.py
132
tools/build.py
|
|
@ -9,7 +9,6 @@ import hashlib
|
|||
import html
|
||||
import json
|
||||
import re
|
||||
import shutil
|
||||
from pathlib import Path
|
||||
|
||||
import yaml
|
||||
|
|
@ -19,6 +18,12 @@ DATA = ROOT / "ravenous_typst" / "data" / "src"
|
|||
TEMPLATES = ROOT / "src"
|
||||
BUILD = ROOT / "build"
|
||||
BUILD_CONFIG = ROOT / "ravenous_typst" / "data" / "config" / "build.yaml"
|
||||
THEMES_SOURCE = ROOT / "ravenous_typst" / "setup" / "theme" / "themes.typ"
|
||||
THEME_COLORS = {
|
||||
"ink": "ink", "muted": "muted-ink", "gold": "gold", "dark-gold": "dark-gold",
|
||||
"paper": "parchment", "light": "parchment-light", "accent": "parchment-accent",
|
||||
"border": "border", "blood": "blood",
|
||||
}
|
||||
|
||||
|
||||
def slug(value: str) -> str:
|
||||
|
|
@ -139,11 +144,77 @@ def read_schools(max_tier_exclusive: int, glossary: dict[str, str]) -> dict[str,
|
|||
return schools
|
||||
|
||||
|
||||
def read_origins(glossary: dict[str, str]) -> dict[str, dict]:
|
||||
descriptions = {}
|
||||
for path in sorted((DATA / "glossaries").glob("*.yaml")):
|
||||
for entry in yaml.safe_load(path.read_text(encoding="utf-8")) or []:
|
||||
if isinstance(entry, dict) and isinstance(entry.get("description"), str):
|
||||
descriptions[entry["key"]] = entry["description"]
|
||||
|
||||
def power_text(value: str) -> str:
|
||||
value = re.sub(r'#reference\(<[^>]+>,\s*fallback:\s*\[([^]]+)\]\)',
|
||||
lambda match: f"voir {match.group(1)}", value)
|
||||
value = re.sub(r'#gls-definition\("([^"]+)"\)',
|
||||
lambda match: descriptions.get(match.group(1), glossary.get(match.group(1), match.group(1))), value)
|
||||
value = re.sub(r"#spend\[([^]]*)]", r"Dépensez \1 —", value)
|
||||
value = re.sub(r"#mecaniquejeu\[([^]]*)]", r"\1", value)
|
||||
value = value.replace("#death-without-penalty", "Cette mort ne vous inflige aucun malus de mort.")
|
||||
return translate_typst(value, glossary)
|
||||
|
||||
origins = {}
|
||||
for path in sorted((DATA / "origines").glob("*.yaml")):
|
||||
data = yaml.safe_load(path.read_text(encoding="utf-8"))
|
||||
powers = []
|
||||
for stage in data.get("stades", []):
|
||||
for index, ability in enumerate(stage.get("abilities", [])):
|
||||
powers.append({
|
||||
"key": f"{path.stem}:{stage['number']}:{index}",
|
||||
"stage": str(stage["number"]),
|
||||
"type": ability["type"],
|
||||
"name": power_text(ability.get("name", "Passif")),
|
||||
"description": power_text(ability["description"]),
|
||||
})
|
||||
origins[path.stem] = {"name": data["name"], "powers": powers}
|
||||
return origins
|
||||
|
||||
|
||||
def origin_options(origins: dict[str, dict]) -> str:
|
||||
return "".join(f'<option value="{key}">{html.escape(origin["name"])}</option>'
|
||||
for key, origin in origins.items())
|
||||
|
||||
|
||||
def power_stage_options(origins: dict[str, dict]) -> str:
|
||||
stages = sorted({power["stage"] for origin in origins.values() for power in origin["powers"]}, key=int)
|
||||
return "".join(f'<option value="{stage}">Stade {stage}</option>' for stage in stages)
|
||||
|
||||
|
||||
def read_build_config() -> dict:
|
||||
with BUILD_CONFIG.open(encoding="utf-8") as stream:
|
||||
return yaml.safe_load(stream)
|
||||
|
||||
|
||||
def read_theme_palettes() -> dict[str, dict[str, str]]:
|
||||
source = THEMES_SOURCE.read_text(encoding="utf-8")
|
||||
starts = list(re.finditer(r"^ ([a-z][a-z-]+): \($", source, re.MULTILINE))
|
||||
palettes = {}
|
||||
for index, match in enumerate(starts):
|
||||
body = source[match.end():starts[index + 1].start() if index + 1 < len(starts) else len(source)]
|
||||
colors = dict(re.findall(r'^ ([a-z-]+): rgb\("(#[0-9A-Fa-f]{6})"\),', body, re.MULTILINE))
|
||||
missing = set(THEME_COLORS.values()) - colors.keys()
|
||||
if missing:
|
||||
raise ValueError(f"Theme {match.group(1)} is missing colors: {sorted(missing)}")
|
||||
palettes[match.group(1)] = colors
|
||||
return palettes
|
||||
|
||||
|
||||
def theme_variables(palette: dict[str, str]) -> str:
|
||||
values = [f"--{css_key}:{palette[book_key].lower()};" for css_key, book_key in THEME_COLORS.items()]
|
||||
for name in ("gold", "blood", "light", "accent"):
|
||||
color = palette[THEME_COLORS[name]].lstrip("#")
|
||||
values.append(f"--{name}-rgb:{','.join(str(int(color[i:i + 2], 16)) for i in (0, 2, 4))};")
|
||||
return " ".join(values)
|
||||
|
||||
|
||||
def skills_from_data(data: dict) -> list[dict[str, str]]:
|
||||
skills: list[dict[str, str]] = []
|
||||
defaults = {
|
||||
|
|
@ -153,14 +224,16 @@ def skills_from_data(data: dict) -> list[dict[str, str]]:
|
|||
"Dépeçage": "intelligence", "Médecine": "intelligence",
|
||||
}
|
||||
for category in data["competences"]:
|
||||
def add_entry(entry: dict, parent_id: str = "", parent_name: str = "", inherited: str = "") -> None:
|
||||
def add_entry(entry: dict, parent_id: str = "", parent_name: str = "", inherited: str = "", depth: int = 0) -> None:
|
||||
name = entry["name"]
|
||||
key = f"{parent_id}_{slug(name)}" if parent_id else slug(name)
|
||||
label = f"{parent_name} — {name}" if parent_name else name
|
||||
characteristic = inherited or defaults.get(name, "agilite" if category["name"] == "Athlétisme" else "intelligence")
|
||||
skills.append({"id": key, "name": label, "category": category["name"], "characteristic": characteristic, "description": entry.get("description", "")})
|
||||
skills.append({"id": key, "name": label, "display_name": name, "depth": depth,
|
||||
"category": category["name"], "characteristic": characteristic,
|
||||
"description": entry.get("description", "")})
|
||||
for child in entry.get("subskills", []):
|
||||
add_entry(child, key, label, characteristic)
|
||||
add_entry(child, key, label, characteristic, depth + 1)
|
||||
|
||||
for entry in category.get("entries", []):
|
||||
add_entry(entry)
|
||||
|
|
@ -174,9 +247,9 @@ def skill_rows(skills: list[dict[str, str]]) -> str:
|
|||
if skill["category"] != category:
|
||||
category = skill["category"]
|
||||
rows.append(f'<div class="skill-category"><span>◆</span>{html.escape(category)}</div>')
|
||||
rows.append(f'''<div class="skill-row" title="{html.escape(skill['description'])}">
|
||||
rows.append(f'''<div class="skill-row skill-depth-{min(skill['depth'], 3)}" title="{html.escape(skill['description'])}">
|
||||
<button class="skill-roll" type="action" name="act_skill_{skill['id']}" title="Tester {html.escape(skill['name'])}" aria-label="Tester {html.escape(skill['name'])}"></button>
|
||||
<span class="skill-name">{html.escape(skill['name'])}</span>
|
||||
<span class="skill-name">{html.escape(skill['display_name'])}</span>
|
||||
<select name="attr_{skill['id']}_characteristic">{characteristic_options(skill['characteristic'])}</select>
|
||||
<input type="number" name="attr_{skill['id']}" value="0" min="0">
|
||||
<input type="number" name="attr_{skill['id']}_temp" value="0">
|
||||
|
|
@ -185,17 +258,20 @@ def skill_rows(skills: list[dict[str, str]]) -> str:
|
|||
return "\n".join(rows)
|
||||
|
||||
|
||||
def technique_options(schools: dict[str, list[dict[str, str]]]) -> tuple[str, dict[str, dict[str, str]]]:
|
||||
def technique_options(schools: dict[str, list[dict[str, str]]], trigrams: dict[str, str]) -> tuple[str, dict[str, dict[str, str]]]:
|
||||
options = []
|
||||
indexed: dict[str, dict[str, str]] = {}
|
||||
for school, techniques in schools.items():
|
||||
trigram = trigrams[school.replace("_", "-")]
|
||||
school_label = school.replace("_", " ").title()
|
||||
children = []
|
||||
for index, technique in enumerate(techniques):
|
||||
key = f"{school}:{index}"
|
||||
indexed[key] = {**technique, "school": school}
|
||||
label = f"T{technique['tier']} · {technique['name']} {technique['level']}"
|
||||
indexed[key] = {**technique, "school": school, "school_label": school_label}
|
||||
label = f"{trigram} · T{technique['tier']} · {technique['name']} {technique['level']}"
|
||||
children.append(f'<option value="{key}">{html.escape(label.strip())}</option>')
|
||||
options.append(f'<optgroup label="{html.escape(school.replace("_", " ").title())}">{"".join(children)}</optgroup>')
|
||||
group_label = f"{trigram} · {school_label}"
|
||||
options.append(f'<optgroup label="{html.escape(group_label)}">{"".join(children)}</optgroup>')
|
||||
return "".join(options), indexed
|
||||
|
||||
|
||||
|
|
@ -235,46 +311,60 @@ def skill_target_options(skills: list[dict[str, str]]) -> str:
|
|||
def main() -> None:
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("--check", action="store_true", help="fail when build/ differs from generated output")
|
||||
parser.add_argument("--theme", help="book color theme (defaults to document.color_scheme)")
|
||||
parser.add_argument("--list-themes", action="store_true", help="list color themes from the book and exit")
|
||||
parser.add_argument("--output-dir", type=Path, default=BUILD, help="directory for generated files (default: build/)")
|
||||
args = parser.parse_args()
|
||||
palettes = read_theme_palettes()
|
||||
if args.list_themes:
|
||||
print("\n".join(palettes))
|
||||
return
|
||||
data = read_character_data()
|
||||
config = read_build_config()
|
||||
theme = args.theme or config["document"]["color_scheme"]
|
||||
if theme not in palettes:
|
||||
parser.error(f"unknown theme {theme!r}; choose from: {', '.join(palettes)}")
|
||||
output_dir = args.output_dir
|
||||
max_tier_exclusive = int(config["build"]["max_tier_exclusive"])
|
||||
schools = read_schools(max_tier_exclusive, read_glossary_labels())
|
||||
origins = read_origins(read_glossary_labels())
|
||||
skills = skills_from_data(data)
|
||||
technique_select, techniques = technique_options(schools)
|
||||
technique_select, techniques = technique_options(schools, config["schools"]["trigrams"])
|
||||
generated = {
|
||||
"ravenous.html": render((TEMPLATES / "ravenous.html").read_text(encoding="utf-8"), {
|
||||
"SKILL_ROWS": skill_rows(skills),
|
||||
"TECHNIQUE_OPTIONS": technique_select,
|
||||
"ORIGIN_OPTIONS": origin_options(origins),
|
||||
"POWER_STAGE_OPTIONS": power_stage_options(origins),
|
||||
"CHARACTERISTIC_OPTIONS": characteristic_options("agilite"),
|
||||
"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=(",", ":")),
|
||||
}),
|
||||
"ravenous.css": (TEMPLATES / "ravenous.css").read_text(encoding="utf-8"),
|
||||
"ravenous.css": render((TEMPLATES / "ravenous.css").read_text(encoding="utf-8"),
|
||||
{"THEME_VARS": theme_variables(palettes[theme])}),
|
||||
"translation.json": (TEMPLATES / "translation.json").read_text(encoding="utf-8"),
|
||||
"sheet.json": (TEMPLATES / "sheet.json").read_text(encoding="utf-8"),
|
||||
}
|
||||
digest = hashlib.sha256("".join(generated.values()).encode()).hexdigest()[:12]
|
||||
generated["build-info.json"] = json.dumps({
|
||||
"source": "ravenous_typst/data/src", "schools": len(schools), "max_tier_exclusive": max_tier_exclusive,
|
||||
"techniques": sum(map(len, schools.values())), "skills": len(skills), "content_hash": digest,
|
||||
"techniques": sum(map(len, schools.values())), "skills": len(skills),
|
||||
"origins": len(origins), "powers": sum(len(origin["powers"]) for origin in origins.values()),
|
||||
"theme": theme,
|
||||
"content_hash": digest,
|
||||
}, ensure_ascii=False, indent=2) + "\n"
|
||||
if args.check:
|
||||
stale = [name for name, content in generated.items() if not (BUILD / name).exists() or (BUILD / name).read_text(encoding="utf-8") != content]
|
||||
stale = [name for name, content in generated.items() if not (output_dir / name).exists() or (output_dir / name).read_text(encoding="utf-8") != content]
|
||||
if stale:
|
||||
raise SystemExit("Generated files are stale: " + ", ".join(stale))
|
||||
return
|
||||
BUILD.mkdir(exist_ok=True)
|
||||
for child in BUILD.iterdir():
|
||||
if child.is_file():
|
||||
child.unlink()
|
||||
elif child.is_dir():
|
||||
shutil.rmtree(child)
|
||||
output_dir.mkdir(parents=True, exist_ok=True)
|
||||
for name, content in generated.items():
|
||||
(BUILD / name).write_text(content, encoding="utf-8")
|
||||
(output_dir / name).write_text(content, encoding="utf-8")
|
||||
print(f"Built {len(generated)} files ({len(skills)} skills, {sum(map(len, schools.values()))} techniques).")
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue