Add category subtabs to cyberpunk skills

This commit is contained in:
Dandaedre 2026-09-19 00:28:00 +02:00
parent 2f9adf8844
commit bf5e2c7afe
Signed by: Dandaedre
GPG Key ID: 440C6592E8A26D99
8 changed files with 61 additions and 10 deletions

View File

@ -34,8 +34,11 @@ 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 onglets **Compétences**, **Combat** et **Autres**. Ses compétences fixes ont
trois sous-onglets issus des sections du catalogue YAML : **Physique**,
**Intellectuelles** et **Social**. Les champs répétables restent dans **Autres**.
Le choix principal est stocké dans `d10_tab`, celui des sous-onglets base dans
`d10_skill_tab` et celui des catégories cyberpunk dans `d10_category_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

View File

@ -14,6 +14,7 @@
- [x] Divide base skills into fight/free fight, free skills, magic, and equipment subtabs; keep cyberpunk navigation and stored fields.
- [x] Restore original cyberpunk health and armor figures, add integrity maximum per location, and hide number spinners.
- [x] Restore readable labels in night-theme repeating rows after Roll20 restructures their fieldsets.
- [x] Add cyberpunk skill category subtabs for the full catalogue, preserving fixed skills and repeating fields.
## Live Roll20 checks after local verification

View File

@ -1,5 +1,6 @@
sections:
- name: Physique
- id: physique
name: Physique
groups:
- name: Combat
skills:
@ -152,7 +153,8 @@ sections:
- id: essaimdedrones
name: Essaim de Drones
parent: pilotagededrones
- name: Intellectuelles
- id: intellectuelles
name: Intellectuelles
groups:
- name: Techniques
skills:
@ -376,7 +378,8 @@ sections:
- id: stratgie
name: Stratégie
parent: thoriemilitaire
- name: Social
- id: social
name: Social
groups:
- name: Sociales
skills:

View File

@ -35,6 +35,7 @@ variants:
cyberpunk:
title: Système D10 Cyberpunk
skills: cyberpunk_skills.yaml
skill_category_tabs: true
attributes:
- {id: Force, name: Force}
- {id: Agilite, name: Agilité}

View File

@ -33,6 +33,7 @@
.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-category-tab-nav { grid-template-columns: repeat(3,minmax(0,1fr)); }
.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; }

View File

@ -44,7 +44,10 @@ class BuildTests(unittest.TestCase):
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.assertEqual(files['sheet.html'].count('class="sheet-skill-pane sheet-category-pane-'), 3)
self.assertIn('name="attr_d10_category_tab" value="physique"', files['sheet.html'])
for tab in ('physique', 'intellectuelles', 'social'):
self.assertIn(f'.sheet-category-tab-state[value="{tab}"] ~ .sheet-category-pane-{tab}', files['sheet.css'])
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'])
@ -115,9 +118,11 @@ class BuildTests(unittest.TestCase):
theme = build.read_yaml(build.DATA / 'themes.yaml')['themes']['night']
model = {**source['variants']['cyberpunk'], 'version': 1}
build.validate(model, skills, theme)
bad = {'sections': [{'name': 'Test', 'groups': [{'name': 'Test', 'skills': [
bad = {'sections': [{'id': 'test', 'name': 'Test', 'groups': [{'name': 'Test', 'skills': [
{'id': 'one', 'name': 'One'}, {'id': 'one', 'name': 'Duplicate'}]}]}]}
with self.assertRaisesRegex(ValueError, 'duplicate skill'):
build.validate({**model, 'skill_category_tabs': False}, bad, theme)
with self.assertRaisesRegex(ValueError, 'at least two unique'):
build.validate(model, bad, theme)
with self.assertRaisesRegex(ValueError, 'invalid theme color'):
build.validate(model, skills, {**theme, 'accent': 'red'})

View File

@ -5,6 +5,7 @@ import vm from 'node:vm';
for (const variant of ['base', 'cyberpunk']) {
const tabs = variant === 'base' ? ['skills', 'combat'] : ['skills', 'combat', 'other'];
const skillTabs = variant === 'base' ? ['fight', 'free', 'magic', 'equipment'] : [];
const categoryTabs = variant === 'cyberpunk' ? ['physique', 'intellectuelles', 'social'] : [];
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`);
@ -17,7 +18,7 @@ for (const variant of ['base', 'cyberpunk']) {
},
setAttrs: changes => Object.assign(attributes, changes),
});
assert.equal(handlers.size, tabs.length + skillTabs.length);
assert.equal(handlers.size, tabs.length + skillTabs.length + categoryTabs.length);
assert.ok(!handlers.has('clicked:tab_core'));
for (const tab of tabs) {
assert.match(html, new RegExp(`name="act_tab_${tab}"`));
@ -31,6 +32,13 @@ for (const variant of ['base', 'cyberpunk']) {
handlers.get(`clicked:skill_tab_${tab}`)();
assert.equal(attributes.d10_skill_tab, tab);
}
for (const tab of categoryTabs) {
assert.match(html, new RegExp(`name="act_category_tab_${tab}"`));
assert.match(html, new RegExp(`class="sheet-skill-pane sheet-category-pane-${tab}"`));
handlers.get(`clicked:category_tab_${tab}`)();
assert.equal(attributes.d10_category_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'));
if (variant === 'cyberpunk') assert.match(html, /name="attr_d10_category_tab" value="physique"/);
}

View File

@ -71,6 +71,13 @@ def validate(model, skills, theme):
sections = skills['sections']
if not isinstance(sections, list) or not sections:
raise ValueError('skills need sections')
if model.get('skill_category_tabs'):
if model.get('skill_tabs'):
raise ValueError('choose one skill tab layout')
category_ids = [ident(section.get('id')) for section in sections
if any(group.get('skills') for group in section['groups'])]
if len(category_ids) < 2 or len(category_ids) != len(set(category_ids)):
raise ValueError('skill categories need at least two unique tab identifiers')
generated_fields = set()
for section in sections:
for group in section['groups']:
@ -171,9 +178,9 @@ def render_body_map(locations, kind, asset_base_url=''):
return ''.join(parts)
def render_fixed_skills(skills, variant, show_sections=True):
def render_fixed_skills(skills, variant, show_sections=True, sections=None):
parts = []
for section in skills['sections']:
for section in (skills['sections'] if sections is None else sections):
if show_sections:
parts.append(f'<h3 class="sheet-subheading">{esc(section["name"])}</h3>')
for group in section['groups']:
@ -267,6 +274,19 @@ def render(model, skills, variant, theme_name, theme, asset_base_url=''):
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>')
elif model.get('skill_category_tabs'):
categories = [section for section in skills['sections']
if any(group.get('skills') for group in section['groups'])]
parts.append(f'<input type="hidden" class="sheet-category-tab-state" name="attr_d10_category_tab" value="{esc(categories[0]["id"])}">')
parts.append('<nav class="sheet-skill-tab-nav sheet-category-tab-nav" aria-label="Catégories de compétences">')
for section in categories:
key = section['id']
parts.append(f'<button type="action" class="sheet-skill-tab-button sheet-category-tab-{key}" name="act_category_tab_{key}">{esc(section["name"])}</button>')
parts.append('</nav>')
for section in categories:
parts.append(f'<div class="sheet-skill-pane sheet-category-pane-{section["id"]}">')
parts.append(render_fixed_skills(skills, variant, show_sections=False, sections=[section]))
parts.append('</div>')
else:
parts.append(render_fixed_skills(skills, variant))
parts.append('</section></div>')
@ -285,6 +305,11 @@ def render(model, skills, variant, theme_name, theme, asset_base_url=''):
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'])
if model.get('skill_category_tabs'):
css += '\n'.join(
f'.sheet-d10 .sheet-category-tab-state[value="{section["id"]}"] ~ .sheet-category-pane-{section["id"]} {{ display: block; }}\n'
f'.sheet-d10 .sheet-category-tab-state[value="{section["id"]}"] ~ .sheet-category-tab-nav .sheet-category-tab-{section["id"]} {{ color: var(--d10-panel); background: var(--d10-accent); border-color: var(--d10-accent); }}\n'
for section in skills['sections'] if any(group.get('skills') for group in section['groups']))
html_text += '''<rolltemplate class="sheet-rolltemplate-d10skillcheck">
<div><strong>{{name}}</strong> — {{roll_name}}</div>
<div>Seuil: {{threshold}} · Résultat: {{result}}</div>
@ -297,6 +322,10 @@ def render(model, skills, variant, theme_name, theme, asset_base_url=''):
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', []))
if model.get('skill_category_tabs'):
html_text += ''.join(
f'on("clicked:category_tab_{section["id"]}", function () {{ setAttrs({{d10_category_tab: "{section["id"]}"}}); }});\n'
for section in skills['sections'] if any(group.get('skills') for group in section['groups']))
html_text += '</script>\n'
return html_text, css