diff --git a/README.md b/README.md index 069782f..7b4067d 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,13 @@ Trois onglets organisent le reste : **Compétences**, **Combat** et **Autres** 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. + ## Vérifier ```sh diff --git a/TASKS.md b/TASKS.md index 2c02884..d832ece 100644 --- a/TASKS.md +++ b/TASKS.md @@ -10,6 +10,7 @@ - [x] Split the generated sheet into Personnage, Compétences, Combat, and Autres tabs; verify action handlers and builds. - [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. ## Live Roll20 checks after local verification diff --git a/templates/sheet.css b/templates/sheet.css index c1428ed..d319b38 100644 --- a/templates/sheet.css +++ b/templates/sheet.css @@ -48,10 +48,38 @@ .sheet-d10 .sheet-resource strong { align-self: center; font-size: 12px; } .sheet-d10 .sheet-resource label { display: grid; gap: 3px; margin: 0 !important; color: var(--d10-accent); font: bold 9px Arial,sans-serif; text-transform: uppercase; } .sheet-d10 .sheet-resource > span { align-self: end; text-align: center; font-size: 18px; } -.sheet-d10 .sheet-location-head, .sheet-d10 .sheet-location { display: grid; grid-template-columns: minmax(120px,1fr) repeat(3,95px); gap: 8px; align-items: center; padding: 5px 9px; } -.sheet-d10 .sheet-location-head { color: var(--d10-accent); font: bold 9px Arial,sans-serif; text-transform: uppercase; text-align: center; } -.sheet-d10 .sheet-location-head span:first-child { text-align: left; } -.sheet-d10 .sheet-location:nth-child(odd) { background: var(--d10-background); } +.sheet-d10 .sheet-body-maps { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; margin-top: 13px; } +.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-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; } +.sheet-d10 .sheet-zone-head { top: 8px; left: 136px; } +.sheet-d10 .sheet-zone-body { top: 125px; left: 136px; } +.sheet-d10 .sheet-zone-left_arm { top: 180px; left: 31px; } +.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-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-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; } .sheet-d10 .sheet-combat-actions { display: flex; align-items: center; gap: 8px; margin-top: 10px; padding: 8px; background: var(--d10-background); } @@ -85,5 +113,5 @@ .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-head, .sheet-d10 .sheet-skill-row { grid-template-columns: minmax(110px,1fr) 72px 48px 48px 36px; gap: 4px; padding: 4px; } - .sheet-d10 .sheet-location-head, .sheet-d10 .sheet-location { grid-template-columns: minmax(75px,1fr) repeat(3,60px); gap: 4px; } + .sheet-d10 .sheet-body-maps { grid-template-columns: 1fr; } } diff --git a/tests/test_build.py b/tests/test_build.py index 825b5ef..417b448 100644 --- a/tests/test_build.py +++ b/tests/test_build.py @@ -33,6 +33,7 @@ class BuildTests(unittest.TestCase): self.assertEqual(files['sheet.html'].count('class="sheet-skill-row'), info['skills']) 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.assertNotIn('Ravenous', files['sheet.html']) self.assertIn('--d10-accent:', files['sheet.css']) self.assertEqual(files, build.build(variant, theme, Path(tmp))) @@ -56,6 +57,14 @@ class BuildTests(unittest.TestCase): if variant == 'cyberpunk': self.assertIn('Life_Points_head', declared) self.assertIn('repeating_distance', markup) + 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 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) + else: + self.assertNotIn('class="sheet-body-maps"', markup) def test_theme_is_visual_only(self): with tempfile.TemporaryDirectory() as tmp: @@ -76,6 +85,8 @@ class BuildTests(unittest.TestCase): build.validate(model, bad, theme) with self.assertRaisesRegex(ValueError, 'invalid theme color'): build.validate(model, skills, {**theme, 'accent': 'red'}) + with self.assertRaisesRegex(ValueError, 'unsupported health location'): + build.validate({**model, 'health_locations': ['tail']}, skills, theme) if __name__ == '__main__': diff --git a/tools/build.py b/tools/build.py index 063fb81..cf4f33b 100644 --- a/tools/build.py +++ b/tools/build.py @@ -14,6 +14,11 @@ DATA = ROOT / 'data' 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')) +LOCATIONS = { + 'head': 'Tête', 'body': 'Torse', + 'left_arm': 'Bras gauche', 'right_arm': 'Bras droit', + 'left_leg': 'Jambe gauche', 'right_leg': 'Jambe droite', +} def read_yaml(path): @@ -52,6 +57,10 @@ def validate(model, skills, theme): fields.add(key) for location in model.get('health_locations', []): ident(location) + if location not in LOCATIONS: + raise ValueError(f'unsupported health location: {location}') + if len(set(model.get('health_locations', []))) != len(model.get('health_locations', [])): + raise ValueError('duplicate health location') if not isinstance(model.get('weapons', 0), int) or not 0 <= model.get('weapons', 0) <= 10: raise ValueError('weapons must be an integer from 0 to 10') sections = skills['sections'] @@ -118,6 +127,28 @@ def render_skill(group, skill, variant): f'{roll(name_field, threshold)}') +def render_body_map(locations, kind): + title = 'Santé' if kind == 'health' else 'Armure' + legend = 'PV par localisation' if kind == 'health' else 'P = protection · I = intégrité' + parts = [f'
{legend}