diff --git a/README.md b/README.md index 388c19a..62f65fa 100644 --- a/README.md +++ b/README.md @@ -99,12 +99,6 @@ sections sont conservés; les nouvelles valeurs doivent être renseignées sur les personnages existants. Les anciennes sections historiques `ranged-weapons` et `melee-weapons` ne migrent pas automatiquement. -Le build actuel active temporairement le diagnostic des boutons d'armes. -Chaque attaque et bouton **Dégâts** envoie uniquement une carte Roll20 par -défaut nommée `Test: X` avec le message `Bouton reçu par le worker`. Cette voie -ne lit aucun attribut, ne modifie aucun état et ne lance aucun dé; `[[0]]` sert -seulement de valeur technique à `startRoll`. Les calculs de combat et la dépense de munitions sont contournés pendant ce -diagnostic; **Recharger** conserve son comportement normal. Les boutons de Distance utilisent chacun un événement nommé. Les identifiants d'action répétables n'utilisent plus de tiret bas (`firesingle`, `fireburst`, `fireauto` et `damage`); ce sont des identifiants de diff --git a/TASKS.md b/TASKS.md index d914c97..2161f9c 100644 --- a/TASKS.md +++ b/TASKS.md @@ -42,6 +42,7 @@ - [x] Route every ranged action through Roll20's repeating-section click event. - [x] Remove underscores from repeating weapon action names for Roll20 event compatibility. - [x] Replace the ignored ranged section dispatcher with individual underscore-free events. +- [x] Remove temporary weapon diagnostics and restore attacks, damage, ammunition, reloads, and chat details. - [x] Raise the Torse control on both cyberpunk body maps for better silhouette alignment. ## Live Roll20 checks after local verification diff --git a/templates/cyberpunk-weapons.js b/templates/cyberpunk-weapons.js index df8ae23..af2c6f6 100644 --- a/templates/cyberpunk-weapons.js +++ b/templates/cyberpunk-weapons.js @@ -1,5 +1,4 @@ const D10_COMBAT_SKILLS = __COMBAT_SKILLS__; -const D10_WEAPON_DIAGNOSTIC = true; const d10Number = value => Number.isFinite(Number(value)) ? Number(value) : 0; const d10Whole = value => Math.max(0, Math.floor(d10Number(value))); const d10Text = value => String(value || '').replace(/[{}]/g, ''); @@ -16,12 +15,6 @@ const d10ShotDamage = (roll, successes, threshold, base, bonus) => { return shots.map(value => Math.max(0, d10Number(base) + (value === 1 ? d10Number(bonus) : 0))).join(', '); }; -function d10WeaponTest(label) { - const command = `&{template:default} {{name=Test: ${label}}} ` + - `{{Message=Bouton reçu par le worker}} {{Diagnostic=[[0]]}}`; - startRoll(command, result => finishRoll(result.rollId)); -} - function d10WeaponFields(prefix, callback) { const fields = ['name', 'weapon_type', 'accuracy', 'base_threshold', 'skill_id', 'damage', 'damage_per_success', 'rmax', 'notes', 'ammo_current', @@ -53,11 +46,13 @@ function d10WeaponAttack(event, mode, ranged) { const dice = mode === 'burst' ? '(?{Nombre de dés|1}+1)' : '?{Nombre de dés|1}'; const multipleShots = mode === 'burst' || mode === 'auto'; const command = `&{template:d10weapon} {{name=${d10Text(get('name') || 'Arme')}}} ` + - `{{attack_roll=[[${dice}d10<${threshold}cs1cf10]]}} ` + - `${multipleShots ? '{{damage_list=[[0]]}}' : '{{damage=[[0]]}}'}` + - (ranged ? '' : ` {{mode=${modeName}}} {{type=${d10Text(get('weapon_type'))}}} ` + - `{{threshold=[[${threshold}]]}} {{special=${d10Text(get('notes'))}}} ` + - `{{rmax=${d10Whole(get('rmax')) || 'sans limite'}}}`); + `{{mode=${modeName}}} {{type=${d10Text(get('weapon_type'))}}} ` + + `{{attack_roll=[[${dice}d10<${threshold}cs1cf10]]}} {{threshold=[[${threshold}]]}} ` + + `${multipleShots ? '{{damage_list=[[0]]}}' : '{{damage=[[0]]}}'} ` + + `{{special=${d10Text(get('notes'))}}}` + + (multipleShots ? '' : ` {{rmax=${d10Whole(get('rmax')) || 'sans limite'}}}`) + + (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); @@ -105,19 +100,15 @@ function d10WeaponDamage(event) { }); } -for (const [action, mode, label] of [ - ['firesingle', 'single', 'Tir simple'], - ['fireburst', 'burst', 'Rafale'], - ['fireauto', 'auto', 'Automatique'], +for (const [action, mode] of [ + ['firesingle', 'single'], + ['fireburst', 'burst'], + ['fireauto', 'auto'], ]) { - on('clicked:repeating_distance:' + action, event => D10_WEAPON_DIAGNOSTIC - ? d10WeaponTest(label) : d10WeaponAttack(event, mode, true)); + on('clicked:repeating_distance:' + action, event => d10WeaponAttack(event, mode, true)); } on('clicked:repeating_distance:reload', d10WeaponReload); -on('clicked:repeating_distance:damage', event => D10_WEAPON_DIAGNOSTIC - ? d10WeaponTest('Dégâts distance') : d10WeaponDamage(event)); +on('clicked:repeating_distance:damage', d10WeaponDamage); -on('clicked:repeating_melee:attack', event => D10_WEAPON_DIAGNOSTIC - ? d10WeaponTest('Attaque de mêlée') : d10WeaponAttack(event, 'melee', false)); -on('clicked:repeating_melee:damage', event => D10_WEAPON_DIAGNOSTIC - ? d10WeaponTest('Dégâts mêlée') : d10WeaponDamage(event)); +on('clicked:repeating_melee:attack', event => d10WeaponAttack(event, 'melee', false)); +on('clicked:repeating_melee:damage', d10WeaponDamage); diff --git a/tests/test_build.py b/tests/test_build.py index 4760c28..1feb754 100644 --- a/tests/test_build.py +++ b/tests/test_build.py @@ -75,8 +75,8 @@ class BuildTests(unittest.TestCase): self.assertIn('', files['sheet.html']) self.assertIn('name="attr_damage_per_success"', files['sheet.html']) self.assertIn('d10<${threshold}cs1cf10', files['sheet.html']) - self.assertIn('const D10_WEAPON_DIAGNOSTIC = true;', files['sheet.html']) - self.assertIn('&{template:default} {{name=Test: ${label}}}', files['sheet.html']) + self.assertNotIn('D10_WEAPON_DIAGNOSTIC', files['sheet.html']) + self.assertIn('{{#ammo_info}}
Chargeur :', files['sheet.html']) self.assertEqual(files['sheet.html'].count('name="attr_rmax"'), 2) self.assertNotIn('name="attr_attack_dice"', files['sheet.html']) contacts = re.search(r'
(.*?)
', diff --git a/tests/test_tabs.mjs b/tests/test_tabs.mjs index 82221ab..0900558 100644 --- a/tests/test_tabs.mjs +++ b/tests/test_tabs.mjs @@ -86,23 +86,31 @@ for (const variant of ['base', 'cyberpunk']) { [ranged + 'single_cost']: '1', [ranged + 'burst_cost']: '3', }); handlers.get('clicked:repeating_distance:firesingle')({ sourceAttribute: ranged + 'firesingle' }); - assert.match(rolls.at(-1), /template:default/); - assert.match(rolls.at(-1), /name=Test: Tir simple/); - assert.match(rolls.at(-1), /Message=Bouton reçu par le worker/); - assert.match(rolls.at(-1), /Diagnostic=\[\[0\]\]/); - assert.doesNotMatch(rolls.at(-1), /Section=|Arme=|Jet=|Chargeur=/); - assert.equal(attributes[ranged + 'ammo_current'], '5'); - assert.equal(attributes[ranged + 'weapon_status'], undefined); - assert.equal(finished.at(-1).computed, undefined); + assert.match(rolls.at(-1), /template:d10weapon/); + assert.match(rolls.at(-1), /name=Torpille/); + assert.match(rolls.at(-1), /mode=Tir simple/); + assert.match(rolls.at(-1), /\?\{Nombre de dés\|1\}d10<8cs1cf10/); + assert.match(rolls.at(-1), /ammo=4/); + assert.equal(attributes[ranged + 'ammo_current'], 4); + assert.equal(finished.at(-1).computed.damage, 5); handlers.get('clicked:repeating_distance:fireburst')({ sourceAttribute: ranged + 'fireburst' }); - assert.match(rolls.at(-1), /name=Test: Rafale/); - assert.equal(attributes[ranged + 'ammo_current'], '5'); + assert.match(rolls.at(-1), /mode=Rafale/); + assert.match(rolls.at(-1), /\(\?\{Nombre de dés\|1\}\+1\)d10<8cs1cf10/); + assert.equal(attributes[ranged + 'ammo_current'], 1); + assert.equal(finished.at(-1).computed.damage_list, '6, 5'); + attributes[ranged + 'ammo_current'] = 5; attributes[ranged + 'auto_cost'] = '5'; handlers.get('clicked:repeating_distance:fireauto')({ sourceAttribute: ranged + 'fireauto' }); - assert.match(rolls.at(-1), /name=Test: Automatique/); + assert.match(rolls.at(-1), /mode=Automatique/); + assert.equal(attributes[ranged + 'ammo_current'], 0); + assert.equal(finished.at(-1).computed.damage_list, '6, 5'); handlers.get('clicked:repeating_distance:damage')({ sourceAttribute: ranged + 'damage' }); - assert.match(rolls.at(-1), /name=Test: Dégâts distance/); - assert.equal(attributes[ranged + 'ammo_current'], '5'); + assert.match(rolls.at(-1), /mode=Dégâts/); + assert.equal(finished.at(-1).computed.damage, 5); + const rollCount = rolls.length; + handlers.get('clicked:repeating_distance:firesingle')({ sourceAttribute: ranged + 'firesingle' }); + assert.equal(rolls.length, rollCount); + assert.match(attributes[ranged + 'weapon_status'], /Chargeur insuffisant/); attributes[ranged + 'ammo_current'] = '4'; handlers.get('clicked:repeating_distance:reload')({ sourceAttribute: ranged + 'reload' }); assert.equal(attributes[ranged + 'ammo_current'], 10); @@ -127,8 +135,11 @@ for (const variant of ['base', 'cyberpunk']) { [melee + 'base_threshold']: '4', }); handlers.get('clicked:repeating_melee:attack')({ sourceAttribute: melee + 'attack' }); - assert.match(rolls.at(-1), /name=Test: Attaque de mêlée/); + assert.match(rolls.at(-1), /mode=Mêlée/); + assert.match(rolls.at(-1), /\?\{Nombre de dés\|1\}d10<4cs1cf10/); + assert.equal(finished.at(-1).computed.damage, 6); handlers.get('clicked:repeating_melee:damage')({ sourceAttribute: melee + 'damage' }); - assert.match(rolls.at(-1), /name=Test: Dégâts mêlée/); + assert.match(rolls.at(-1), /mode=Dégâts/); + assert.equal(finished.at(-1).computed.damage, 6); } } diff --git a/tools/build.py b/tools/build.py index 72db040..2aec10d 100644 --- a/tools/build.py +++ b/tools/build.py @@ -456,6 +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_info}}
Chargeur : {{ammo}} / {{magazine}} · chargeurs de réserve : {{reserve}}
{{/ammo_info}} {{#special}}
{{special}}
{{/special}} '''