Restore original cyberpunk body maps and integrity maxima
This commit is contained in:
parent
1683cffc79
commit
e70f1ff02d
27
README.md
27
README.md
|
|
@ -22,7 +22,8 @@ python -m venv .venv
|
|||
```
|
||||
|
||||
Chaque build crée `sheet.html`, `sheet.css`, `translation.json`, `sheet.json`
|
||||
et `build-info.json` dans `build/<variante>/<thème>/`. Il est possible de
|
||||
et `build-info.json` dans `build/<variante>/<thème>/`. Le build cyberpunk copie
|
||||
aussi les deux images originales de `assets/`. Il est possible de
|
||||
choisir un autre répertoire avec `--output-dir`. Charger le HTML, le CSS et
|
||||
la traduction dans les onglets correspondants de l'éditeur de feuille
|
||||
personnalisée Roll20. `sheet.json` est un manifeste; `build-info.json` contient
|
||||
|
|
@ -41,11 +42,25 @@ thèmes `parchment` et `night` changent les couleurs sans modifier les champs
|
|||
ni les jets.
|
||||
|
||||
Dans la variante cyberpunk, 02 affiche aussi deux cartes côte à côte :
|
||||
**Santé** (PV de la tête, du torse et des membres) et **Armure** (protection et
|
||||
intégrité aux mêmes localisations). Les cases sont posées sur une silhouette
|
||||
dessinée en CSS, sans image hébergée. Les noms des attributs de localisation
|
||||
restent ceux du générateur précédent; sur un écran étroit, les cartes se
|
||||
placent l'une sous l'autre.
|
||||
**Santé** (PV de la tête, du torse et des membres) et **Armure** (protection,
|
||||
intégrité et intégrité maximale aux mêmes localisations). Les cases sont
|
||||
posées sur les images originales `robotman_health_r.png` et
|
||||
`robotman_armor_r.png`. Les attributs de localisation existants gardent leurs
|
||||
noms; les nouveaux maxima portent le suffixe `_maximum`. Sur un écran étroit,
|
||||
les cartes se placent l'une sous l'autre. Les champs numériques masquent les
|
||||
flèches de réglage des navigateurs Firefox et Chromium.
|
||||
|
||||
Pour l'aperçu local, le HTML référence les images copiées à côté de
|
||||
`sheet.html`. Dans Roll20, héberger ces deux PNG à une adresse HTTPS publique,
|
||||
puis reconstruire avec `--asset-base-url` pointant vers leur dossier :
|
||||
|
||||
```sh
|
||||
.venv/bin/python tools/build.py --variant cyberpunk --theme parchment \
|
||||
--asset-base-url https://example.org/d10/assets
|
||||
```
|
||||
|
||||
Le HTML généré référence alors les deux URL complètes. Charger ce HTML dans
|
||||
l'éditeur Roll20 avec le CSS et la traduction.
|
||||
|
||||
## Vérifier
|
||||
|
||||
|
|
|
|||
1
TASKS.md
1
TASKS.md
|
|
@ -12,6 +12,7 @@
|
|||
- [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.
|
||||
- [x] Restore original cyberpunk health and armor figures, add integrity maximum per location, and hide number spinners.
|
||||
|
||||
## Live Roll20 checks after local verification
|
||||
|
||||
|
|
|
|||
Binary file not shown.
|
After Width: | Height: | Size: 9.1 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 9.5 KiB |
|
|
@ -40,7 +40,8 @@
|
|||
.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); }
|
||||
.sheet-d10 input[type=number] { text-align: center; }
|
||||
.sheet-d10 input[type=number] { text-align: center; appearance: textfield; -moz-appearance: textfield; }
|
||||
.sheet-d10 input[type=number]::-webkit-inner-spin-button, .sheet-d10 input[type=number]::-webkit-outer-spin-button { margin: 0; appearance: none; -webkit-appearance: none; }
|
||||
.sheet-d10 .sheet-panel { margin: 14px 0 0; padding: 13px 15px 16px; background: var(--d10-panel); border: 1px solid var(--d10-border); }
|
||||
.sheet-d10 .sheet-section-title { display: flex; gap: 9px; align-items: baseline; padding-bottom: 6px; margin-bottom: 11px; border-bottom: 1px solid var(--d10-border); }
|
||||
.sheet-d10 .sheet-section-title span { color: var(--d10-accent); font: bold 11px Arial,sans-serif; }
|
||||
|
|
@ -60,16 +61,8 @@
|
|||
.sheet-d10 .sheet-map-card { min-width: 0; overflow-x: auto; padding: 10px; background: var(--d10-background); border: 1px solid var(--d10-border); }
|
||||
.sheet-d10 .sheet-map-card h3 { margin: 0; padding: 2px 4px 8px; color: var(--d10-accent); font: bold 16px Georgia,serif; text-align: center; border-bottom: 1px solid var(--d10-border); }
|
||||
.sheet-d10 .sheet-body-figure { position: relative; width: 330px; height: 365px; margin: 8px auto 0; }
|
||||
.sheet-d10 .sheet-body-silhouette { position: absolute; inset: 0; color: var(--d10-ink); opacity: .78; pointer-events: none; }
|
||||
.sheet-d10 .sheet-map-armor .sheet-body-silhouette { color: var(--d10-accent); opacity: .64; }
|
||||
.sheet-d10 .sheet-body-shape { position: absolute; display: block; background: currentColor; }
|
||||
.sheet-d10 .sheet-shape-head { top: 38px; left: 136px; width: 58px; height: 61px; border-radius: 46% 46% 42% 42%; }
|
||||
.sheet-d10 .sheet-shape-neck { top: 88px; left: 151px; width: 27px; height: 25px; border-radius: 8px; }
|
||||
.sheet-d10 .sheet-shape-torso { top: 104px; left: 102px; width: 128px; height: 118px; clip-path: polygon(18% 0,82% 0,100% 80%,73% 100%,27% 100%,0 80%); }
|
||||
.sheet-d10 .sheet-shape-left-arm { top: 108px; left: 78px; width: 34px; height: 134px; border-radius: 25px 14px 16px 16px; transform: rotate(9deg); }
|
||||
.sheet-d10 .sheet-shape-right-arm { top: 108px; left: 218px; width: 34px; height: 134px; border-radius: 14px 25px 16px 16px; transform: rotate(-9deg); }
|
||||
.sheet-d10 .sheet-shape-left-leg { top: 210px; left: 117px; width: 44px; height: 127px; border-radius: 0 0 12px 12px; transform: rotate(4deg); }
|
||||
.sheet-d10 .sheet-shape-right-leg { top: 210px; left: 169px; width: 44px; height: 127px; border-radius: 0 0 12px 12px; transform: rotate(-4deg); }
|
||||
.sheet-d10 .sheet-body-image { position: absolute; top: 32px; left: 92px; display: block; width: 146px; height: 300px; pointer-events: none; }
|
||||
.sheet-d10.sheet-theme-night .sheet-body-image { filter: invert(1); }
|
||||
.sheet-d10 .sheet-zone { position: absolute; z-index: 1; display: grid; justify-items: center; gap: 2px; min-width: 56px; padding: 3px; background: var(--d10-panel); border: 1px solid var(--d10-border); border-radius: 5px; box-shadow: 0 2px 5px rgba(0,0,0,.12); }
|
||||
.sheet-d10 .sheet-zone-label { color: var(--d10-accent); font: bold 9px Arial,sans-serif; white-space: nowrap; }
|
||||
.sheet-d10 .sheet-zone input[type=number] { width: 46px; height: 28px; padding: 2px; font-size: 12px; }
|
||||
|
|
@ -79,14 +72,15 @@
|
|||
.sheet-d10 .sheet-zone-right_arm { top: 180px; right: 31px; }
|
||||
.sheet-d10 .sheet-zone-left_leg { top: 280px; left: 61px; }
|
||||
.sheet-d10 .sheet-zone-right_leg { top: 280px; right: 61px; }
|
||||
.sheet-d10 .sheet-map-armor .sheet-zone { grid-template-columns: repeat(2,46px); column-gap: 3px; }
|
||||
.sheet-d10 .sheet-map-armor .sheet-zone { grid-template-columns: repeat(3,42px); column-gap: 3px; }
|
||||
.sheet-d10 .sheet-map-armor .sheet-zone-label { grid-column: 1/-1; }
|
||||
.sheet-d10 .sheet-map-armor .sheet-zone label { display: grid; justify-items: center; gap: 2px; margin: 0 !important; color: var(--d10-accent); font: bold 8px Arial,sans-serif; }
|
||||
.sheet-d10 .sheet-map-armor .sheet-zone-head, .sheet-d10 .sheet-map-armor .sheet-zone-body { left: 113px; }
|
||||
.sheet-d10 .sheet-map-armor .sheet-zone-left_arm { left: 3px; }
|
||||
.sheet-d10 .sheet-map-armor .sheet-zone-right_arm { right: 3px; }
|
||||
.sheet-d10 .sheet-map-armor .sheet-zone-left_leg { left: 28px; }
|
||||
.sheet-d10 .sheet-map-armor .sheet-zone-right_leg { right: 28px; }
|
||||
.sheet-d10 .sheet-map-armor .sheet-zone input[type=number] { width: 42px; }
|
||||
.sheet-d10 .sheet-map-armor .sheet-zone-head, .sheet-d10 .sheet-map-armor .sheet-zone-body { left: 95px; }
|
||||
.sheet-d10 .sheet-map-armor .sheet-zone-left_arm { left: 0; }
|
||||
.sheet-d10 .sheet-map-armor .sheet-zone-right_arm { right: 0; }
|
||||
.sheet-d10 .sheet-map-armor .sheet-zone-left_leg { left: 14px; }
|
||||
.sheet-d10 .sheet-map-armor .sheet-zone-right_leg { right: 14px; }
|
||||
.sheet-d10 .sheet-map-legend { margin: 0; color: var(--d10-accent); font: italic 11px Georgia,serif; text-align: center; }
|
||||
.sheet-d10 .sheet-combat-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 9px; }
|
||||
.sheet-d10 .sheet-combat-field { display: grid; gap: 4px; margin: 0 !important; padding: 8px; color: var(--d10-accent); background: var(--d10-background); font: bold 10px Arial,sans-serif; text-transform: uppercase; }
|
||||
|
|
|
|||
|
|
@ -48,6 +48,8 @@ class BuildTests(unittest.TestCase):
|
|||
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'])
|
||||
self.assertIn('-moz-appearance: textfield', files['sheet.css'])
|
||||
self.assertIn('::-webkit-inner-spin-button', files['sheet.css'])
|
||||
self.assertNotIn('Ravenous', files['sheet.html'])
|
||||
self.assertIn('--d10-accent:', files['sheet.css'])
|
||||
self.assertEqual(files, build.build(variant, theme, Path(tmp)))
|
||||
|
|
@ -74,11 +76,18 @@ class BuildTests(unittest.TestCase):
|
|||
self.assertIn('class="sheet-body-maps"', markup)
|
||||
self.assertIn('class="sheet-map-card sheet-map-health"', markup)
|
||||
self.assertIn('class="sheet-map-card sheet-map-armor"', markup)
|
||||
for kind in ('health', 'armor'):
|
||||
image = f'robotman_{kind}_r.png'
|
||||
self.assertIn(f'src="{image}"', markup)
|
||||
self.assertEqual(build.ASSETS.joinpath(image).read_bytes(),
|
||||
Path(tmp, image).read_bytes())
|
||||
for location in build.LOCATIONS:
|
||||
for prefix in ('Life_Points', 'Armor_Protection_Points', 'Armor_Integrity_Points'):
|
||||
self.assertEqual(markup.count(f'name="attr_{prefix}_{location}"'), 1)
|
||||
self.assertEqual(markup.count(f'name="attr_Armor_Integrity_Points_{location}_maximum"'), 1)
|
||||
else:
|
||||
self.assertNotIn('class="sheet-body-maps"', markup)
|
||||
self.assertNotIn('robotman_health_r.png', markup)
|
||||
|
||||
def test_theme_is_visual_only(self):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
|
|
@ -87,6 +96,19 @@ class BuildTests(unittest.TestCase):
|
|||
self.assertEqual(one['sheet.html'].replace('theme-parchment', 'theme-night'), two['sheet.html'])
|
||||
self.assertNotEqual(one['sheet.css'], two['sheet.css'])
|
||||
|
||||
def test_hosted_image_urls(self):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
files = build.build('cyberpunk', 'parchment', Path(tmp),
|
||||
asset_base_url='https://example.org/d10/assets')
|
||||
self.assertIn('src="https://example.org/d10/assets/robotman_health_r.png"', files['sheet.html'])
|
||||
self.assertIn('src="https://example.org/d10/assets/robotman_armor_r.png"', files['sheet.html'])
|
||||
build.build('cyberpunk', 'parchment', Path(tmp), check=True,
|
||||
asset_base_url='https://example.org/d10/assets')
|
||||
with self.assertRaisesRegex(ValueError, 'missing or stale'):
|
||||
build.build('cyberpunk', 'parchment', Path(tmp), check=True)
|
||||
with self.assertRaisesRegex(ValueError, 'HTTPS'):
|
||||
build.build('cyberpunk', 'parchment', Path(tmp), asset_base_url='http://example.org')
|
||||
|
||||
def test_rejects_bad_data(self):
|
||||
source = build.read_yaml(build.DATA / 'sheet_model.yaml')
|
||||
skills = build.read_yaml(build.DATA / 'cyberpunk_skills.yaml')
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import yaml
|
|||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
DATA = ROOT / 'data'
|
||||
ASSETS = ROOT / 'assets'
|
||||
IDENT = re.compile(r'^[A-Za-z][A-Za-z0-9_-]*$')
|
||||
COLOR = re.compile(r'^#[0-9a-fA-F]{6}$')
|
||||
TABS = (('skills', 'Compétences'), ('combat', 'Combat'), ('other', 'Autres'))
|
||||
|
|
@ -147,23 +148,24 @@ def render_skill(group, skill, variant):
|
|||
f'{roll(name_field, threshold)}</div>')
|
||||
|
||||
|
||||
def render_body_map(locations, kind):
|
||||
def render_body_map(locations, kind, asset_base_url=''):
|
||||
title = 'Santé' if kind == 'health' else 'Armure'
|
||||
legend = 'PV par localisation' if kind == 'health' else 'P = protection · I = intégrité'
|
||||
legend = 'PV par localisation' if kind == 'health' else 'P = protection · I = intégrité · Max = intégrité maximale'
|
||||
image_name = f'robotman_{kind}_r.png'
|
||||
image_url = f'{asset_base_url.rstrip("/")}/{image_name}' if asset_base_url else image_name
|
||||
parts = [f'<div class="sheet-map-card sheet-map-{kind}"><h3>{title}</h3>',
|
||||
'<div class="sheet-body-figure"><div class="sheet-body-silhouette" aria-hidden="true">']
|
||||
for shape in ('head', 'neck', 'torso', 'left-arm', 'right-arm', 'left-leg', 'right-leg'):
|
||||
parts.append(f'<span class="sheet-body-shape sheet-shape-{shape}"></span>')
|
||||
parts.append('</div>')
|
||||
f'<div class="sheet-body-figure"><img class="sheet-body-image" src="{esc(image_url)}" alt="" aria-hidden="true" width="146" height="300">']
|
||||
for location in locations:
|
||||
label = LOCATIONS[location]
|
||||
parts.append(f'<div class="sheet-zone sheet-zone-{location}"><span class="sheet-zone-label">{label}</span>')
|
||||
if kind == 'health':
|
||||
parts.append(f'<input type="number" name="attr_Life_Points_{location}" value="0" aria-label="PV {label}" title="PV {label}">')
|
||||
else:
|
||||
for field, short in (('Armor_Protection_Points', 'P'), ('Armor_Integrity_Points', 'I')):
|
||||
descriptor = 'Protection' if short == 'P' else 'Intégrité'
|
||||
parts.append(f'<label>{short}<input type="number" name="attr_{field}_{location}" value="0" aria-label="{descriptor} {label}" title="{descriptor} {label}"></label>')
|
||||
for field, short, descriptor in (('Armor_Protection_Points', 'P', 'Protection'),
|
||||
('Armor_Integrity_Points', 'I', 'Intégrité'),
|
||||
('Armor_Integrity_Points', 'Max', 'Intégrité maximale')):
|
||||
suffix = '_maximum' if short == 'Max' else ''
|
||||
parts.append(f'<label>{short}<input type="number" name="attr_{field}_{location}{suffix}" value="0" aria-label="{descriptor} {label}" title="{descriptor} {label}"></label>')
|
||||
parts.append('</div>')
|
||||
parts.append(f'</div><p class="sheet-map-legend">{legend}</p></div>')
|
||||
return ''.join(parts)
|
||||
|
|
@ -198,7 +200,7 @@ def render_repeating_block(block, attributes, expanded=False):
|
|||
return ''.join(parts)
|
||||
|
||||
|
||||
def render(model, skills, variant, theme_name, theme):
|
||||
def render(model, skills, variant, theme_name, theme, asset_base_url=''):
|
||||
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>',
|
||||
|
|
@ -225,8 +227,8 @@ def render(model, skills, variant, theme_name, theme):
|
|||
f'<span>/</span><label>Maximum<input type="number" name="attr_{key}_maximum" value="0" title="Maximum"></label></div>')
|
||||
if model.get('health_locations'):
|
||||
parts.append('</div><div class="sheet-body-maps">')
|
||||
parts.append(render_body_map(model['health_locations'], 'health'))
|
||||
parts.append(render_body_map(model['health_locations'], 'armor'))
|
||||
parts.append(render_body_map(model['health_locations'], 'health', asset_base_url))
|
||||
parts.append(render_body_map(model['health_locations'], 'armor', asset_base_url))
|
||||
parts.append('</div>')
|
||||
else:
|
||||
parts.append('</div>')
|
||||
|
|
@ -299,36 +301,47 @@ def render(model, skills, variant, theme_name, theme):
|
|||
return html_text, css
|
||||
|
||||
|
||||
def build(variant, theme_name, output, check=False):
|
||||
def build(variant, theme_name, output, check=False, asset_base_url=''):
|
||||
source = read_yaml(DATA / 'sheet_model.yaml')
|
||||
themes = read_yaml(DATA / 'themes.yaml')['themes']
|
||||
if variant not in source['variants']:
|
||||
raise ValueError(f'unknown variant: {variant}')
|
||||
if theme_name not in themes:
|
||||
raise ValueError(f'unknown theme: {theme_name}')
|
||||
if asset_base_url and not re.fullmatch(r'https://[^\s<>"\']+', asset_base_url):
|
||||
raise ValueError('asset base URL must be HTTPS')
|
||||
model = source['variants'][variant]
|
||||
skills = read_yaml(DATA / model['skills'])
|
||||
theme = themes[theme_name]
|
||||
validate({**model, 'version': source['version']}, skills, theme)
|
||||
html_text, css = render(model, skills, variant, theme_name, theme)
|
||||
html_text, css = render(model, skills, variant, theme_name, theme, asset_base_url)
|
||||
manifest = {'html': 'sheet.html', 'css': 'sheet.css', 'authors': 'Dandaedre',
|
||||
'roll20userid': '1067910', 'instructions': f'{model["title"]} generated from D10 YAML'}
|
||||
translation = {}
|
||||
files = {'sheet.html': html_text, 'sheet.css': css,
|
||||
'sheet.json': json.dumps(manifest, ensure_ascii=False, indent=2) + '\n',
|
||||
'translation.json': json.dumps(translation, indent=2) + '\n'}
|
||||
if model.get('health_locations'):
|
||||
for kind in ('health', 'armor'):
|
||||
name = f'robotman_{kind}_r.png'
|
||||
files[name] = (ASSETS / name).read_bytes()
|
||||
digest = hashlib.sha256((html_text + css).encode())
|
||||
for name in sorted(files):
|
||||
if isinstance(files[name], bytes):
|
||||
digest.update(files[name])
|
||||
files['build-info.json'] = json.dumps({'variant': variant, 'theme': theme_name,
|
||||
'skills': sum(len(g.get('skills', [])) for s in skills['sections'] for g in s['groups']),
|
||||
'sha256': hashlib.sha256((html_text + css).encode()).hexdigest()}, indent=2) + '\n'
|
||||
'sha256': digest.hexdigest()}, indent=2) + '\n'
|
||||
if check:
|
||||
stale = [name for name, content in files.items()
|
||||
if not (output / name).exists() or (output / name).read_text(encoding='utf-8') != content]
|
||||
if not (output / name).exists() or (output / name).read_bytes() !=
|
||||
(content if isinstance(content, bytes) else content.encode('utf-8'))]
|
||||
if stale:
|
||||
raise ValueError(f'generated files are missing or stale: {", ".join(stale)}')
|
||||
else:
|
||||
output.mkdir(parents=True, exist_ok=True)
|
||||
for name, content in files.items():
|
||||
(output / name).write_text(content, encoding='utf-8')
|
||||
(output / name).write_bytes(content if isinstance(content, bytes) else content.encode('utf-8'))
|
||||
return files
|
||||
|
||||
|
||||
|
|
@ -339,13 +352,14 @@ def main():
|
|||
parser.add_argument('--output-dir', type=Path)
|
||||
parser.add_argument('--list-themes', action='store_true')
|
||||
parser.add_argument('--check', action='store_true', help='verify existing output without writing')
|
||||
parser.add_argument('--asset-base-url', default='', help='public HTTPS directory for body images in Roll20')
|
||||
args = parser.parse_args()
|
||||
if args.list_themes:
|
||||
print('\n'.join(read_yaml(DATA / 'themes.yaml')['themes']))
|
||||
return
|
||||
output = args.output_dir or ROOT / 'build' / args.variant / args.theme
|
||||
try:
|
||||
build(args.variant, args.theme, output, check=args.check)
|
||||
build(args.variant, args.theme, output, check=args.check, asset_base_url=args.asset_base_url)
|
||||
except ValueError as error:
|
||||
parser.error(str(error))
|
||||
print(output)
|
||||
|
|
|
|||
Loading…
Reference in New Issue