From 70704a0df030f481a80ac054cf6c6fd3735be751 Mon Sep 17 00:00:00 2001 From: Dandaedre Date: Sat, 19 Sep 2026 04:20:19 +0200 Subject: [PATCH] Simplify ranged roll ammunition payload --- TASKS.md | 1 + templates/cyberpunk-weapons.js | 4 +++- tests/test_build.py | 1 + tests/test_tabs.mjs | 2 +- tools/build.py | 4 ++-- 5 files changed, 8 insertions(+), 4 deletions(-) diff --git a/TASKS.md b/TASKS.md index eddf595..1e9dbce 100644 --- a/TASKS.md +++ b/TASKS.md @@ -34,6 +34,7 @@ - [x] Publish one build per variant and add a base-only Parchemin/Nuit selector. - [x] Show burst and automatic damage per successful shot, with the per-success bonus on natural 1s. - [x] Mark combat rolls with cs1cf10 and all other dice rolls with cs1cfX for the selected die. +- [x] Simplify ranged attack ammunition roll data and expose worker progress in the weapon row. ## Live Roll20 checks after local verification diff --git a/templates/cyberpunk-weapons.js b/templates/cyberpunk-weapons.js index e50f89b..c1180b3 100644 --- a/templates/cyberpunk-weapons.js +++ b/templates/cyberpunk-weapons.js @@ -50,7 +50,9 @@ function d10WeaponAttack(event, mode, ranged) { `{{attack_roll=[[${dice}d10<${threshold}cs1cf10]]}} {{threshold=[[${threshold}]]}} ` + `${multipleShots ? '{{damage_list=[[0]]}}' : '{{damage=[[0]]}}'} {{special=${d10Text(get('notes'))}}}` + (mode === 'single' || mode === 'melee' ? ` {{rmax=${d10Whole(get('rmax')) || 'sans limite'}}}` : '') + - (ranged ? ` {{ammo=${remaining}/${d10Whole(get('magazine_size'))} · chargeurs de réserve ${d10Whole(get('ammo_reserve'))}}}` : ''); + (ranged ? ` {{ammo_info=1}} {{ammo=${remaining}}} {{magazine=${d10Whole(get('magazine_size'))}}} ` + + `{{reserve=${d10Whole(get('ammo_reserve'))}}}` : ''); + setAttrs({[prefix + 'weapon_status']: 'Jet en cours…'}); startRoll(command, result => { const successes = d10Whole(result.results.attack_roll.result); const computed = multipleShots diff --git a/tests/test_build.py b/tests/test_build.py index 9d81d27..0adc183 100644 --- a/tests/test_build.py +++ b/tests/test_build.py @@ -72,6 +72,7 @@ class BuildTests(unittest.TestCase): for action in ('fire_single', 'fire_burst', 'fire_auto', 'reload', 'damage_only'): self.assertIn(f'name="act_{action}"', files['sheet.html']) self.assertIn('name="attr_ammo_current"', files['sheet.html']) + self.assertIn('', files['sheet.html']) self.assertIn('name="attr_damage_per_success"', files['sheet.html']) self.assertIn('d10<${threshold}cs1cf10', files['sheet.html']) self.assertEqual(files['sheet.html'].count('name="attr_rmax"'), 2) diff --git a/tests/test_tabs.mjs b/tests/test_tabs.mjs index 608f554..9d3d195 100644 --- a/tests/test_tabs.mjs +++ b/tests/test_tabs.mjs @@ -87,7 +87,7 @@ for (const variant of ['base', 'cyberpunk']) { }); handlers.get('clicked:repeating_distance:fire_single')({ sourceAttribute: ranged + 'fire_single' }); assert.match(rolls.at(-1), /\?\{Nombre de dés\|1\}d10<8cs1cf10/); - assert.match(rolls.at(-1), /chargeurs de réserve 3/); + assert.match(rolls.at(-1), /\{\{ammo_info=1\}\} \{\{ammo=4\}\} \{\{magazine=10\}\} \{\{reserve=3\}\}/); assert.equal(attributes[ranged + 'ammo_current'], 4); assert.equal(finished.at(-1).computed.damage, 5); assert.match(rolls.at(-1), /rmax=1/); diff --git a/tools/build.py b/tools/build.py index f9e0399..5349947 100644 --- a/tools/build.py +++ b/tools/build.py @@ -273,7 +273,7 @@ def render_weapon_block(block, combat_skills): actions.append(('damage_only', 'Dégâts')) parts.append('
' + ''.join( f'' for key, label in actions) + '
') - parts.append('') + parts.append('') return ''.join(parts) @@ -456,7 +456,7 @@ def render(model, skills, variant, theme_name, theme, themes, asset_base_url='')
Réussites{{#attack_roll}}{{attack_roll}}{{/attack_roll}}{{#damage_roll}}{{damage_roll}}{{/damage_roll}}{{#damage}}Dégâts{{computed::damage}}{{/damage}}{{#damage_list}}Dégâts par tir{{computed::damage_list}}{{/damage_list}}
{{#threshold}}
Seuil : {{threshold}}
{{/threshold}} {{#rmax}}
Rmax : {{rmax}}
{{/rmax}} -{{#ammo}}
Chargeur : {{ammo}}
{{/ammo}} +{{#ammo_info}}
Chargeur : {{ammo}} / {{magazine}} · chargeurs de réserve : {{reserve}}
{{/ammo_info}} {{#special}}
{{special}}
{{/special}} '''