Organize base skills into four subtabs

This commit is contained in:
Dandaedre 2026-09-19 00:21:30 +02:00
parent 1bef84c634
commit 1683cffc79
Signed by: Dandaedre
GPG Key ID: 440C6592E8A26D99
7 changed files with 142 additions and 31 deletions

View File

@ -29,10 +29,14 @@ personnalisée Roll20. `sheet.json` est un manifeste; `build-info.json` contient
la variante, le thème, le nombre de compétences et une empreinte du résultat.
Les sections **01 Caractéristiques** et **02 Ressources** restent visibles.
Trois onglets organisent le reste : **Compétences**, **Combat** et **Autres**
(sections répétables). Le choix de l'onglet est stocké dans l'attribut
`d10_tab`; les personnages qui avaient enregistré `core` affichent
**Compétences** jusqu'au prochain clic. L'en-tête reste visible. Les
La variante base a deux onglets principaux, **Compétences** et **Combat**.
Dans Compétences, quatre sous-onglets séparent **Combat et combat libre**,
**Compétences libres**, **Magie** et **Équipement**. Les lignes répétables
gardent leurs noms d'attributs et de section. La variante cyberpunk conserve
les onglets **Compétences**, **Combat** et **Autres**. Le choix principal est
stocké dans `d10_tab`, celui des sous-onglets base dans `d10_skill_tab`.
Les personnages qui avaient enregistré `core` ou, pour la variante base,
`other` affichent **Compétences** jusqu'au prochain clic. L'en-tête reste visible. Les
thèmes `parchment` et `night` changent les couleurs sans modifier les champs
ni les jets.

View File

@ -11,6 +11,7 @@
- [x] Remove unused legacy sheet sources and minitest, retain Mod scripts in scripts/, and keep the Ravenous model local.
- [x] Keep 01 Caractéristiques and 02 Ressources visible above the three remaining tabs; preserve the old core tab value.
- [x] Present cyberpunk health and armour locations on side-by-side body maps without changing field names.
- [x] Divide base skills into fight/free fight, free skills, magic, and equipment subtabs; keep cyberpunk navigation and stored fields.
## Live Roll20 checks after local verification

View File

@ -27,6 +27,11 @@ variants:
- {id: general-combat-skills, name: Combat libre, fields: [skillname, skilllevel]}
- {id: magic-skills, name: Magie, fields: [skillname, skilllevel]}
- {id: equipment, name: Équipement, fields: [name, notes]}
skill_tabs:
- {id: fight, name: Combat et combat libre, content: [fixed_skills, general-combat-skills]}
- {id: free, name: Compétences libres, content: [skills]}
- {id: magic, name: Magie, content: [magic-skills]}
- {id: equipment, name: Équipement, content: [equipment]}
cyberpunk:
title: Système D10 Cyberpunk
skills: cyberpunk_skills.yaml

View File

@ -18,6 +18,7 @@
.sheet-d10 .sheet-identity label, .sheet-d10 .sheet-die-choice { display: grid; gap: 3px; margin: 0 !important; color: var(--d10-accent); font: bold 10px Arial,sans-serif; letter-spacing: .07em; text-transform: uppercase; }
.sheet-d10 .sheet-die-choice { align-self: end; }
.sheet-d10 .sheet-tab-nav { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 4px; margin: 14px 0 0; border-bottom: 2px solid var(--d10-accent); }
.sheet-d10.sheet-variant-base .sheet-tab-nav { grid-template-columns: repeat(2,minmax(0,1fr)); }
.sheet-d10 .sheet-tab-nav button[type=action] { width: 100%; min-height: 38px; margin: 0 !important; padding: 7px 5px; color: var(--d10-accent); background: var(--d10-background); border: 1px solid var(--d10-border); border-bottom: 0; border-radius: 3px 3px 0 0; box-shadow: none; font: bold 12px Georgia,serif; text-shadow: none; }
.sheet-d10 .sheet-tab-nav button[type=action]:hover, .sheet-d10 .sheet-tab-nav button[type=action]:focus { background: var(--d10-panel); outline: 2px solid var(--d10-border); outline-offset: -2px; }
.sheet-d10 .sheet-page { display: none; }
@ -25,10 +26,17 @@
.sheet-d10 .sheet-tab-state[value="skills"] ~ .sheet-page-skills,
.sheet-d10 .sheet-tab-state[value="combat"] ~ .sheet-page-combat,
.sheet-d10 .sheet-tab-state[value="other"] ~ .sheet-page-other { display: block; }
.sheet-d10.sheet-variant-base .sheet-tab-state[value="other"] ~ .sheet-page-skills { display: block; }
.sheet-d10 .sheet-tab-state[value="core"] ~ .sheet-tab-nav .sheet-tab-skills,
.sheet-d10 .sheet-tab-state[value="skills"] ~ .sheet-tab-nav .sheet-tab-skills,
.sheet-d10 .sheet-tab-state[value="combat"] ~ .sheet-tab-nav .sheet-tab-combat,
.sheet-d10 .sheet-tab-state[value="other"] ~ .sheet-tab-nav .sheet-tab-other { color: var(--d10-panel); background: var(--d10-accent); border-color: var(--d10-accent); }
.sheet-d10.sheet-variant-base .sheet-tab-state[value="other"] ~ .sheet-tab-nav .sheet-tab-skills { color: var(--d10-panel); background: var(--d10-accent); border-color: var(--d10-accent); }
.sheet-d10 .sheet-skill-tab-nav { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 5px; margin: 2px 0 12px; }
.sheet-d10 .sheet-skill-tab-nav button[type=action] { min-height: 37px; margin: 0 !important; padding: 6px 4px; color: var(--d10-accent); background: var(--d10-background); border: 1px solid var(--d10-border); border-radius: 3px; box-shadow: none; font: bold 11px Georgia,serif; text-shadow: none; }
.sheet-d10 .sheet-skill-tab-nav button[type=action]:hover, .sheet-d10 .sheet-skill-tab-nav button[type=action]:focus { background: var(--d10-panel); outline: 2px solid var(--d10-border); outline-offset: -2px; }
.sheet-d10 .sheet-skill-pane { display: none; }
.sheet-d10 .sheet-skill-pane details { margin-top: 0; }
.sheet-d10 input, .sheet-d10 select { box-sizing: border-box; width: 100%; min-width: 0; height: 30px; margin: 0 !important; padding: 3px 6px; color: var(--d10-ink); background: var(--d10-panel); border: 1px solid var(--d10-border); border-radius: 2px; box-shadow: none; font: 13px Arial,sans-serif; }
.sheet-d10 input:focus, .sheet-d10 select:focus { outline: 2px solid var(--d10-accent); outline-offset: 1px; }
.sheet-d10 input[type=checkbox] { width: 18px; height: 18px; padding: 0; accent-color: var(--d10-accent); }
@ -104,6 +112,12 @@
.sheet-d10 summary { padding: 7px 10px; color: var(--d10-accent); background: var(--d10-background); font-weight: bold; cursor: pointer; }
.sheet-d10 fieldset { display: flex; flex-wrap: wrap; gap: 7px; padding: 10px; border: 0; }
.sheet-d10 fieldset label { display: grid; gap: 3px; margin: 0 !important; color: var(--d10-accent); font: bold 9px Arial,sans-serif; text-transform: uppercase; }
.sheet-d10 .sheet-repeater { display: flex; flex-wrap: wrap; gap: 7px; align-items: end; width: 100%; }
.sheet-d10 .sheet-repeater label { flex: 1 1 110px; min-width: 0; }
.sheet-d10 .sheet-repeater .sheet-repeater-skillname, .sheet-d10 .sheet-repeater .sheet-repeater-name, .sheet-d10 .sheet-repeater .sheet-repeater-notes { flex-grow: 2; }
.sheet-d10 .sheet-repeater .sheet-repeater-skilllevel, .sheet-d10 .sheet-repeater .sheet-repeater-skillcost, .sheet-d10 .sheet-repeater .sheet-repeater-quantity, .sheet-d10 .sheet-repeater .sheet-repeater-damage { flex: 0 1 70px; }
.sheet-d10 .sheet-repeater .sheet-repeater-attribute { flex: 1 1 130px; }
.sheet-d10 .sheet-repeater .sheet-roll { flex: 0 0 34px; }
.sheet-rolltemplate-d10skillcheck { padding: 7px 9px; color: var(--d10-ink); background: var(--d10-panel); border: 1px solid var(--d10-border); border-left: 4px solid var(--d10-accent); font: 12px Georgia,serif; }
@media (max-width: 760px) {
.sheet-d10 { padding: 9px; }
@ -112,6 +126,7 @@
.sheet-d10 .sheet-hero-mark { width: 42px; height: 42px; font-size: 14px; }
.sheet-d10 .sheet-die-choice { grid-column: 2; }
.sheet-d10 .sheet-tab-nav button[type=action] { min-height: 36px; padding: 5px 2px; font-size: 10px; }
.sheet-d10 .sheet-skill-tab-nav { grid-template-columns: repeat(2,minmax(0,1fr)); }
.sheet-d10 .sheet-skill-head, .sheet-d10 .sheet-skill-row { grid-template-columns: minmax(110px,1fr) 72px 48px 48px 36px; gap: 4px; padding: 4px; }
.sheet-d10 .sheet-body-maps { grid-template-columns: 1fr; }
}

View File

@ -23,7 +23,7 @@ class BuildTests(unittest.TestCase):
self.assertIn('sheet-rolltemplate-d10skillcheck', files['sheet.html'])
self.assertIn('class="sheet-stat-grid"', files['sheet.html'])
self.assertIn('class="sheet-skill-head"', files['sheet.html'])
self.assertEqual(files['sheet.html'].count('class="sheet-page sheet-page-'), 3)
self.assertEqual(files['sheet.html'].count('class="sheet-page sheet-page-'), 2 if variant == 'base' else 3)
self.assertIn('name="attr_d10_tab" value="skills"', files['sheet.html'])
self.assertNotIn('name="act_tab_core"', files['sheet.html'])
self.assertLess(files['sheet.html'].index('01</span>'), files['sheet.html'].index('class="sheet-tab-nav"'))
@ -31,6 +31,20 @@ class BuildTests(unittest.TestCase):
self.assertIn('.sheet-tab-state[value="skills"] ~ .sheet-page-skills', files['sheet.css'])
self.assertIn('.sheet-tab-state[value="core"] ~ .sheet-page-skills', files['sheet.css'])
self.assertEqual(files['sheet.html'].count('class="sheet-skill-row'), info['skills'])
if variant == 'base':
markup = files['sheet.html']
self.assertNotIn('name="act_tab_other"', markup)
self.assertEqual(markup.count('class="sheet-skill-pane sheet-skill-pane-'), 4)
self.assertLess(markup.index('name="attr_general_skilllevel_Perfection"'), markup.index('class="sheet-skill-pane sheet-skill-pane-free"'))
for tab, section in (('fight', 'general-combat-skills'), ('free', 'skills'),
('magic', 'magic-skills'), ('equipment', 'equipment')):
self.assertIn(f'name="act_skill_tab_{tab}"', markup)
self.assertIn(f'.sheet-skill-tab-state[value="{tab}"] ~ .sheet-skill-pane-{tab}', files['sheet.css'])
self.assertLess(markup.index(f'class="sheet-skill-pane sheet-skill-pane-{tab}"'),
markup.index(f'class="repeating_{section}"'))
self.assertEqual(markup.count(f'class="repeating_{section}"'), 1)
else:
self.assertNotIn('class="sheet-skill-pane sheet-skill-pane-', files['sheet.html'])
self.assertIn('.sheet-d10 .sheet-stat-grid { display: grid;', files['sheet.css'])
self.assertIn('.sheet-d10 .sheet-skill-head, .sheet-d10 .sheet-skill-row { display: grid;', files['sheet.css'])
self.assertIn('.sheet-d10 .sheet-body-maps { display: grid; grid-template-columns: repeat(2,minmax(0,1fr));', files['sheet.css'])
@ -87,6 +101,10 @@ class BuildTests(unittest.TestCase):
build.validate(model, skills, {**theme, 'accent': 'red'})
with self.assertRaisesRegex(ValueError, 'unsupported health location'):
build.validate({**model, 'health_locations': ['tail']}, skills, theme)
base = {**source['variants']['base'], 'version': 1}
base_skills = build.read_yaml(build.DATA / 'base_skills.yaml')
with self.assertRaisesRegex(ValueError, 'each skill group and repeating section exactly once'):
build.validate({**base, 'skill_tabs': base['skill_tabs'][:-1]}, base_skills, theme)
if __name__ == '__main__':

View File

@ -2,8 +2,9 @@ import assert from 'node:assert/strict';
import { readFileSync } from 'node:fs';
import vm from 'node:vm';
const tabs = ['skills', 'combat', 'other'];
for (const variant of ['base', 'cyberpunk']) {
const tabs = variant === 'base' ? ['skills', 'combat'] : ['skills', 'combat', 'other'];
const skillTabs = variant === 'base' ? ['fight', 'free', 'magic', 'equipment'] : [];
const html = readFileSync(`build/${variant}/parchment/sheet.html`, 'utf8');
const script = html.match(/<script type="text\/worker">\s*([\s\S]*?)<\/script>/)?.[1];
assert.ok(script, `${variant}: generated sheet worker`);
@ -16,7 +17,7 @@ for (const variant of ['base', 'cyberpunk']) {
},
setAttrs: changes => Object.assign(attributes, changes),
});
assert.equal(handlers.size, tabs.length);
assert.equal(handlers.size, tabs.length + skillTabs.length);
assert.ok(!handlers.has('clicked:tab_core'));
for (const tab of tabs) {
assert.match(html, new RegExp(`name="act_tab_${tab}"`));
@ -24,4 +25,12 @@ for (const variant of ['base', 'cyberpunk']) {
handlers.get(`clicked:tab_${tab}`)();
assert.equal(attributes.d10_tab, tab);
}
for (const tab of skillTabs) {
assert.match(html, new RegExp(`name="act_skill_tab_${tab}"`));
assert.match(html, new RegExp(`class="sheet-skill-pane sheet-skill-pane-${tab}"`));
handlers.get(`clicked:skill_tab_${tab}`)();
assert.equal(attributes.d10_skill_tab, tab);
}
if (variant === 'base') assert.match(html, /name="attr_d10_skill_tab" value="fight"/);
if (variant === 'cyberpunk') assert.ok(!handlers.has('clicked:skill_tab_fight'));
}

View File

@ -19,6 +19,10 @@ LOCATIONS = {
'left_arm': 'Bras gauche', 'right_arm': 'Bras droit',
'left_leg': 'Jambe gauche', 'right_leg': 'Jambe droite',
}
FIELD_LABELS = {
'skillname': 'Nom', 'skilllevel': 'Niveau', 'skillcost': 'Coût',
'name': 'Nom', 'notes': 'Notes', 'damage': 'Dégâts', 'quantity': 'Quantité',
}
def read_yaml(path):
@ -84,10 +88,26 @@ def validate(model, skills, theme):
generated_fields.add(stem)
if skill.get('parent') and skill['parent'] not in seen:
raise ValueError(f'unknown or later parent for {key}')
repeating_ids = set()
for block in model['repeating']:
ident(block['id'])
if block['id'] in repeating_ids:
raise ValueError(f'duplicate repeating section: {block["id"]}')
repeating_ids.add(block['id'])
for field in block['fields']:
ident(field)
if model.get('skill_tabs'):
tab_ids = set()
content_ids = []
for tab in model['skill_tabs']:
key = ident(tab['id'])
if key in tab_ids:
raise ValueError(f'duplicate skill tab: {key}')
tab_ids.add(key)
content_ids.extend(tab['content'])
expected = repeating_ids | {'fixed_skills'}
if set(content_ids) != expected or len(content_ids) != len(expected):
raise ValueError('skill tabs must place each skill group and repeating section exactly once')
def roll(label, threshold):
@ -149,8 +169,38 @@ def render_body_map(locations, kind):
return ''.join(parts)
def render_fixed_skills(skills, variant, show_sections=True):
parts = []
for section in skills['sections']:
if show_sections:
parts.append(f'<h3 class="sheet-subheading">{esc(section["name"])}</h3>')
for group in section['groups']:
parts.append(f'<div class="sheet-skill-group"><h4>{esc(group["name"])}</h4>'
'<div class="sheet-skill-head"><span>Compétence</span><span>Carac.</span><span>Niveau</span><span>Coût</span><span>Jet</span></div>')
parts.extend(render_skill(group, skill, variant) for skill in group.get('skills', []))
parts.append('</div>')
return ''.join(parts)
def render_repeating_block(block, attributes, expanded=False):
parts = [f'<details{" open" if expanded else ""}><summary>{esc(block["name"])}</summary>'
f'<fieldset class="repeating_{esc(block["id"])}"><div class="sheet-repeater">']
for field in block['fields']:
kind = 'number' if field in ('skilllevel', 'skillcost', 'quantity', 'damage') else 'text'
parts.append(f'<label class="sheet-repeater-{field}">{esc(FIELD_LABELS.get(field, field))}<input type="{kind}" name="attr_{esc(field)}"></label>')
if 'skilllevel' in block['fields']:
options = ''.join(
f'<option value="@{{base-{item["id"]}}}+@{{exal-{item["id"]}}}">{esc(item["name"])}</option>'
for item in attributes)
parts.append(f'<label class="sheet-repeater-attribute">Caractéristique<select name="attr_attribute_select">{options}</select></label>')
parts.append(roll('@{skillname}', '@{skilllevel}+@{attribute_select}'))
parts.append('</div></fieldset></details>')
return ''.join(parts)
def render(model, skills, variant, theme_name, theme):
parts = [f'<div class="sheet-d10 sheet-theme-{esc(theme_name)}">',
tabs = TABS[:-1] if model.get('skill_tabs') else TABS
parts = [f'<div class="sheet-d10 sheet-variant-{variant} sheet-theme-{esc(theme_name)}">',
'<header class="sheet-hero"><div class="sheet-hero-mark">D10</div>',
f'<div class="sheet-hero-main"><span class="sheet-eyebrow">Feuille de personnage</span><h1>{esc(model["title"])}</h1>',
'<div class="sheet-identity"><label>Nom <input type="text" name="attr_character_name"></label>',
@ -185,7 +235,7 @@ def render(model, skills, variant, theme_name, theme):
'<input type="hidden" class="sheet-tab-state" name="attr_d10_tab" value="skills">',
'<nav class="sheet-tab-nav" aria-label="Sections de la feuille">',
*(f'<button type="action" class="sheet-tab-button sheet-tab-{key}" name="act_tab_{key}">{label}</button>'
for key, label in TABS),
for key, label in tabs),
'</nav><div class="sheet-page sheet-page-combat"><section class="sheet-panel"><div class="sheet-section-title"><span>03</span><h2>Combat</h2></div><div class="sheet-combat-grid">',
])
for item in model.get('combat', []):
@ -201,32 +251,38 @@ def render(model, skills, variant, theme_name, theme):
f'<input type="number" name="attr_general_item_weapon{number}" value="0" title="Dégâts">'
f'<input type="checkbox" name="attr_item_weapon{number}_activation" value="1" title="Équipée"></div>')
parts.append('</div></section></div><div class="sheet-page sheet-page-skills"><section class="sheet-panel"><div class="sheet-section-title"><span>04</span><h2>Compétences</h2></div>')
for section in skills['sections']:
parts.append(f'<h3 class="sheet-subheading">{esc(section["name"])}</h3>')
for group in section['groups']:
parts.append(f'<div class="sheet-skill-group"><h4>{esc(group["name"])}</h4>'
'<div class="sheet-skill-head"><span>Compétence</span><span>Carac.</span><span>Niveau</span><span>Coût</span><span>Jet</span></div>')
parts.extend(render_skill(group, skill, variant) for skill in group.get('skills', []))
if model.get('skill_tabs'):
skill_tabs = model['skill_tabs']
parts.append(f'<input type="hidden" class="sheet-skill-tab-state" name="attr_d10_skill_tab" value="{skill_tabs[0]["id"]}">')
parts.append('<nav class="sheet-skill-tab-nav" aria-label="Catégories de compétences">')
for tab in skill_tabs:
parts.append(f'<button type="action" class="sheet-skill-tab-button sheet-skill-tab-{tab["id"]}" name="act_skill_tab_{tab["id"]}">{esc(tab["name"])}</button>')
parts.append('</nav>')
repeating = {block['id']: block for block in model['repeating']}
for tab in skill_tabs:
parts.append(f'<div class="sheet-skill-pane sheet-skill-pane-{tab["id"]}">')
for content in tab['content']:
parts.append(render_fixed_skills(skills, variant, show_sections=False) if content == 'fixed_skills'
else render_repeating_block(repeating[content], model['attributes'], expanded=True))
parts.append('</div>')
parts.append('</section></div><div class="sheet-page sheet-page-other"><section class="sheet-panel"><div class="sheet-section-title"><span>05</span><h2>Autres</h2></div>')
for block in model['repeating']:
parts.append(f'<details><summary>{esc(block["name"])}</summary>'
f'<fieldset class="repeating_{esc(block["id"])}">')
for field in block['fields']:
kind = 'number' if field in ('skilllevel', 'skillcost', 'quantity', 'damage') else 'text'
parts.append(f'<label>{esc(field)} <input type="{kind}" name="attr_{esc(field)}"></label>')
if 'skilllevel' in block['fields']:
options = ''.join(
f'<option value="@{{base-{item["id"]}}}+@{{exal-{item["id"]}}}">{esc(item["name"])}</option>'
for item in model['attributes'])
parts.append(f'<select name="attr_attribute_select">{options}</select>')
parts.append(roll('@{skillname}', '@{skilllevel}+@{attribute_select}'))
parts.append('</fieldset></details>')
parts.append('</section></div></div>')
else:
parts.append(render_fixed_skills(skills, variant))
parts.append('</section></div>')
if not model.get('skill_tabs'):
parts.append('<div class="sheet-page sheet-page-other"><section class="sheet-panel"><div class="sheet-section-title"><span>05</span><h2>Autres</h2></div>')
for block in model['repeating']:
parts.append(render_repeating_block(block, model['attributes']))
parts.append('</section></div>')
parts.append('</div>')
html_text = '\n'.join(parts) + '\n'
css = '.sheet-d10, .sheet-rolltemplate-d10skillcheck {\n' + '\n'.join(
f' --d10-{key}: {value};' for key, value in theme.items()) + '\n}\n'
css += (ROOT / 'templates' / 'sheet.css').read_text(encoding='utf-8')
if model.get('skill_tabs'):
css += '\n'.join(
f'.sheet-d10 .sheet-skill-tab-state[value="{tab["id"]}"] ~ .sheet-skill-pane-{tab["id"]} {{ display: block; }}\n'
f'.sheet-d10 .sheet-skill-tab-state[value="{tab["id"]}"] ~ .sheet-skill-tab-nav .sheet-skill-tab-{tab["id"]} {{ color: var(--d10-panel); background: var(--d10-accent); border-color: var(--d10-accent); }}\n'
for tab in model['skill_tabs'])
html_text += '''<rolltemplate class="sheet-rolltemplate-d10skillcheck">
<div><strong>{{name}}</strong> — {{roll_name}}</div>
<div>Seuil: {{threshold}} · Résultat: {{result}}</div>
@ -235,7 +291,10 @@ def render(model, skills, variant, theme_name, theme):
html_text += '<script type="text/worker">\n'
html_text += ''.join(
f'on("clicked:tab_{key}", function () {{ setAttrs({{d10_tab: "{key}"}}); }});\n'
for key, _ in TABS)
for key, _ in tabs)
html_text += ''.join(
f'on("clicked:skill_tab_{tab["id"]}", function () {{ setAttrs({{d10_skill_tab: "{tab["id"]}"}}); }});\n'
for tab in model.get('skill_tabs', []))
html_text += '</script>\n'
return html_text, css