Use individual ranged action handlers

This commit is contained in:
Dandaedre 2026-09-19 05:31:30 +02:00
parent 6542c31a86
commit afe2b11fab
Signed by: Dandaedre
GPG Key ID: 440C6592E8A26D99
4 changed files with 23 additions and 30 deletions

View File

@ -105,10 +105,8 @@ défaut nommée `Test: X` avec le message `Bouton reçu par le worker`. Cette vo
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 passent par l'événement de section
`clicked:repeating_distance`, puis sont distribués selon le suffixe du bouton,
afin de contourner les événements d'action nommés que Roll20 ne déclenchait pas.
Les identifiants d'action répétables n'utilisent plus de tiret bas
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
boutons, pas des attributs sauvegardés, donc ce changement ne déplace aucune
donnée de personnage.

View File

@ -41,6 +41,7 @@
- [x] Reduce weapon diagnostics to fixed chat messages without attribute access or game calculations.
- [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] Raise the Torse control on both cyberpunk body maps for better silhouette alignment.
## Live Roll20 checks after local verification

View File

@ -105,23 +105,17 @@ function d10WeaponDamage(event) {
});
}
on('clicked:repeating_distance', event => {
const action = ['firesingle', 'fireburst', 'fireauto', 'reload', 'damage']
.find(candidate => event.sourceAttribute.endsWith(candidate));
if (!action) return;
if (action === 'reload') {
d10WeaponReload(event);
return;
}
if (D10_WEAPON_DIAGNOSTIC) {
const label = {firesingle: 'Tir simple', fireburst: 'Rafale',
fireauto: 'Automatique', damage: 'Dégâts distance'}[action];
d10WeaponTest(label);
return;
}
if (action === 'damage') d10WeaponDamage(event);
else d10WeaponAttack(event, {firesingle: 'single', fireburst: 'burst', fireauto: 'auto'}[action], true);
});
for (const [action, mode, label] of [
['firesingle', 'single', 'Tir simple'],
['fireburst', 'burst', 'Rafale'],
['fireauto', 'auto', 'Automatique'],
]) {
on('clicked:repeating_distance:' + action, event => D10_WEAPON_DIAGNOSTIC
? d10WeaponTest(label) : 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_melee:attack', event => D10_WEAPON_DIAGNOSTIC
? d10WeaponTest('Attaque de mêlée') : d10WeaponAttack(event, 'melee', false));

View File

@ -34,7 +34,7 @@ for (const variant of ['base', 'cyberpunk']) {
},
finishRoll: (id, computed) => finished.push({ id, computed }),
});
assert.equal(handlers.size, tabs.length + skillTabs.length + categoryTabs.length + arsenalTabs.length + 1 + (variant === 'cyberpunk' ? 3 : 0));
assert.equal(handlers.size, tabs.length + skillTabs.length + categoryTabs.length + arsenalTabs.length + 1 + (variant === 'cyberpunk' ? 7 : 0));
assert.ok(!handlers.has('clicked:tab_core'));
for (const tab of tabs) {
assert.match(html, new RegExp(`name="act_tab_${tab}"`));
@ -85,7 +85,7 @@ for (const variant of ['base', 'cyberpunk']) {
[ranged + 'magazine_size']: '10', [ranged + 'ammo_reserve']: '3',
[ranged + 'single_cost']: '1', [ranged + 'burst_cost']: '3',
});
handlers.get('clicked:repeating_distance')({ sourceAttribute: ranged + 'firesingle' });
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/);
@ -94,30 +94,30 @@ for (const variant of ['base', 'cyberpunk']) {
assert.equal(attributes[ranged + 'ammo_current'], '5');
assert.equal(attributes[ranged + 'weapon_status'], undefined);
assert.equal(finished.at(-1).computed, undefined);
handlers.get('clicked:repeating_distance')({ sourceAttribute: ranged + 'fireburst' });
handlers.get('clicked:repeating_distance:fireburst')({ sourceAttribute: ranged + 'fireburst' });
assert.match(rolls.at(-1), /name=Test: Rafale/);
assert.equal(attributes[ranged + 'ammo_current'], '5');
attributes[ranged + 'auto_cost'] = '5';
handlers.get('clicked:repeating_distance')({ sourceAttribute: ranged + 'fireauto' });
handlers.get('clicked:repeating_distance:fireauto')({ sourceAttribute: ranged + 'fireauto' });
assert.match(rolls.at(-1), /name=Test: Automatique/);
handlers.get('clicked:repeating_distance')({ sourceAttribute: ranged + 'damage' });
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');
attributes[ranged + 'ammo_current'] = '4';
handlers.get('clicked:repeating_distance')({ sourceAttribute: ranged + 'reload' });
handlers.get('clicked:repeating_distance:reload')({ sourceAttribute: ranged + 'reload' });
assert.equal(attributes[ranged + 'ammo_current'], 10);
assert.equal(attributes[ranged + 'ammo_reserve'], 2);
handlers.get('clicked:repeating_distance')({ sourceAttribute: ranged + 'reload' });
handlers.get('clicked:repeating_distance:reload')({ sourceAttribute: ranged + 'reload' });
assert.equal(attributes[ranged + 'ammo_reserve'], 2);
assert.match(attributes[ranged + 'weapon_status'], /déjà plein/);
attributes[ranged + 'ammo_current'] = 4;
attributes[ranged + 'ammo_reserve'] = 0;
handlers.get('clicked:repeating_distance')({ sourceAttribute: ranged + 'reload' });
handlers.get('clicked:repeating_distance:reload')({ sourceAttribute: ranged + 'reload' });
assert.equal(attributes[ranged + 'ammo_current'], 4);
assert.match(attributes[ranged + 'weapon_status'], /Aucun chargeur/);
attributes[ranged + 'ammo_reserve'] = 2;
attributes[ranged + 'magazine_size'] = 0;
handlers.get('clicked:repeating_distance')({ sourceAttribute: ranged + 'reload' });
handlers.get('clicked:repeating_distance:reload')({ sourceAttribute: ranged + 'reload' });
assert.equal(attributes[ranged + 'ammo_reserve'], 2);
assert.match(attributes[ranged + 'weapon_status'], /Taille du chargeur/);
const melee = 'repeating_melee_-test_';