diff --git a/docs/craft-json-v1.md b/docs/craft-json-v1.md index 6cf2cc2..996c0d1 100644 --- a/docs/craft-json-v1.md +++ b/docs/craft-json-v1.md @@ -43,7 +43,7 @@ player chooses the actual pool whenever the attack is rolled. | `type` | Destination | Allowed fields besides `type` | | --- | --- | --- | -| `attack` | Combat → Attaques | `name`, `dice`, `threshold`, `temp`, `base_damage`, `damage_per_success`, `break_damage`, `rmax`, `notes`, `dodge_threshold`, `parry_threshold`, `reposition_threshold` | +| `attack` | Combat → Attaques | `name`, `dice`, `threshold`, `temp`, `auto_successes`, `roll_dice`, `base_damage`, `damage_per_success`, `break_damage`, `rmax`, `notes`, `dodge_threshold`, `parry_threshold`, `reposition_threshold` | | `protection` | Combat → Protections | `name`, `protection`, `integrity`, `integrity_max`, `parry`, `dodge`, `effects` | | `consumable` | Potions & nourriture | `name`, `kind`, `quantity`, `duration`, `description` | | `modifier` | Effets temporaires | `name`, `duration`, `description` | diff --git a/docs/ravenous-craft-v1.schema.json b/docs/ravenous-craft-v1.schema.json index f5027e5..a1096f6 100644 --- a/docs/ravenous-craft-v1.schema.json +++ b/docs/ravenous-craft-v1.schema.json @@ -48,6 +48,8 @@ "dice": { "$ref": "#/$defs/value" }, "threshold": { "$ref": "#/$defs/value" }, "temp": { "$ref": "#/$defs/value" }, + "auto_successes": { "$ref": "#/$defs/value" }, + "roll_dice": { "$ref": "#/$defs/value" }, "base_damage": { "$ref": "#/$defs/value" }, "damage_per_success": { "$ref": "#/$defs/value" }, "break_damage": { "$ref": "#/$defs/value" }, diff --git a/roll20_mod/ravenous_craft_import.js b/roll20_mod/ravenous_craft_import.js index 932053f..e10ef66 100644 --- a/roll20_mod/ravenous_craft_import.js +++ b/roll20_mod/ravenous_craft_import.js @@ -15,7 +15,7 @@ var VERSION = 1; var LIMITS = { items: 100, text: 10000, name: 150 }; var FIELDS = { - attack: ['name', 'dice', 'threshold', 'temp', 'base_damage', 'damage_per_success', + attack: ['name', 'dice', 'threshold', 'temp', 'auto_successes', 'roll_dice', 'base_damage', 'damage_per_success', 'break_damage', 'rmax', 'notes', 'dodge_threshold', 'parry_threshold', 'reposition_threshold'], protection: ['name', 'protection', 'integrity', 'integrity_max', 'parry', 'dodge', diff --git a/src/ravenous.css b/src/ravenous.css index 62a77f0..c64900a 100644 --- a/src/ravenous.css +++ b/src/ravenous.css @@ -104,6 +104,10 @@ .attack-card>.attack-roll { align-self:end; } .attack-card>label,.attack-card>label.grow { width:auto; min-width:0; margin:0 !important; } .attack-card>textarea,.attack-card>.attack-thresholds { grid-column:1/-1; } +.attack-options { grid-column:1/-1; display:flex; gap:14px; align-items:end; padding:4px 8px; background:var(--light); border-left:3px solid var(--blood); } +.attack-options>label:first-child { width:110px; } +.attack-options .attack-roll-toggle { display:flex; flex-direction:row; align-items:center; gap:6px; width:auto; height:28px; } +.attack-options .attack-roll-toggle input { width:auto; height:auto; min-height:0; margin:0; } .attack-thresholds { display:flex; flex-basis:100%; gap:7px; align-items:end; padding:4px 8px; background:var(--accent); border-left:3px solid var(--gold); } .attack-thresholds>span { flex:1; align-self:center; color:var(--muted); font-size:9px; text-transform:uppercase; } .attack-thresholds label { width:75px; margin:0 !important; } diff --git a/src/ravenous.html b/src/ravenous.html index ae40290..a1f4ff2 100644 --- a/src/ravenous.html +++ b/src/ravenous.html @@ -150,6 +150,7 @@ +
Seuils défensifs
@@ -234,7 +235,7 @@
{{title}}
{{#subtitle}}
{{subtitle}}
{{/subtitle}} {{#skillcheck}}
{{computed::outcome}}
Dé {{roll}}
Seuil {{threshold}}
Marge (seuil − dé) {{computed::margin}}
{{/skillcheck}} - {{#attackcheck}}
{{computed::attack_successes}} réussite(s)
Jet {{attack_roll}}
{{/attackcheck}} + {{#attackcheck}}
{{computed::attack_successes}} réussite(s)
Jet {{attack_roll}}
{{#autosuccesses}}
Réussites automatiques {{autosuccesses}}
{{/autosuccesses}}{{/attackcheck}} {{#defense}}
{{computed::defense_successes}} réussite(s)
Jet {{defense_roll}}
{{/defense}} {{#finalsuccesses}}
Succès restants {{computed::finalsuccesses}}
{{/finalsuccesses}} {{#result}}{{^attackcheck}}
{{result}}
{{/attackcheck}}{{/result}} @@ -339,13 +340,17 @@ const performSkillRoll = (title, threshold) => getAttrs(["character_name","skill on("clicked:repeating_attacks:attack", event => { const prefix = event.sourceAttribute.replace(/attack$/, ""); - const fields = ["name","dice","threshold","temp","base_damage","damage_per_success","break_damage","rmax","dodge_threshold","parry_threshold","reposition_threshold","notes"]; + const fields = ["name","dice","threshold","temp","auto_successes","roll_dice","base_damage","damage_per_success","break_damage","rmax","dodge_threshold","parry_threshold","reposition_threshold","notes"]; getAttrs(["character_name","roll_whisper", ...fields.map(field => prefix + field)], values => { const get = field => values[prefix + field]; + const rollDice = get("roll_dice") !== "0"; + const autoSuccesses = Math.max(0, Math.floor(number(get("auto_successes")))); const diceQuery = `?{Nombre de dés|${Math.max(1, Math.floor(number(get("dice")) || 1))}}`; - const command = `&{template:ravenous} {{theme=@{theme}}} {{title=${templateText(get("name") || "Attaque")}}} {{subtitle=Attaque · ${templateText(values.character_name)}}} {{attackcheck=1}} {{attack_successes=[[0]]}} {{attack_roll=[[${diceQuery}d10<${number(get("threshold")) + number(get("temp"))}]]}} {{pool=[[${diceQuery}]]d10}} {{threshold=[[${number(get("threshold"))}+${number(get("temp"))}]]}} {{damage=${number(get("base_damage"))} + ${number(get("damage_per_success"))}/R}} {{breakdamage=${number(get("break_damage"))}}} {{thresholds=Esq. ${number(get("dodge_threshold"))} · Par. ${number(get("parry_threshold"))} · Repos. ${number(get("reposition_threshold"))}}} {{buttons=[Défendre](~${prefix}defend) [Dégâts](~${prefix}damage) [Subir](~${prefix}take_damage)}} {{details=RMax ${number(get("rmax"))} · ${templateText(get("notes"))}}}`; + const diceExpression = rollDice ? `${diceQuery}d10<${number(get("threshold")) + number(get("temp"))}` : "0"; + const pool = rollDice ? `[[${diceQuery}]]d10` : "0d10"; + const command = `&{template:ravenous} {{theme=@{theme}}} {{title=${templateText(get("name") || "Attaque")}}} {{subtitle=Attaque · ${templateText(values.character_name)}}} {{attackcheck=1}} {{attack_successes=[[0]]}} {{attack_roll=[[${diceExpression}]]}} {{autosuccesses=${autoSuccesses}}} {{pool=${pool}}} {{threshold=[[${number(get("threshold"))}+${number(get("temp"))}]]}} {{damage=${number(get("base_damage"))} + ${number(get("damage_per_success"))}/R}} {{breakdamage=${number(get("break_damage"))}}} {{thresholds=Esq. ${number(get("dodge_threshold"))} · Par. ${number(get("parry_threshold"))} · Repos. ${number(get("reposition_threshold"))}}} {{buttons=[Défendre](~${prefix}defend) [Dégâts](~${prefix}damage) [Subir](~${prefix}take_damage)}} {{details=RMax ${number(get("rmax"))} · ${templateText(get("notes"))}}}`; startRoll(`${values.roll_whisper || ""}${command}`, results => { - const successes = results.results.attack_roll.result; + const successes = Math.max(0, results.results.attack_roll.result + autoSuccesses); attackRolls[results.rollId] = {successes, baseDamage: number(get("base_damage")), damagePerSuccess: number(get("damage_per_success")), breakDamage: number(get("break_damage")), rmax: number(get("rmax"))}; finishRoll(results.rollId, {attack_successes: successes}); }); diff --git a/tests/test_worker.mjs b/tests/test_worker.mjs index 2fff9cd..7172c71 100644 --- a/tests/test_worker.mjs +++ b/tests/test_worker.mjs @@ -161,6 +161,26 @@ test('attack and defense cap remaining successes at RMax', () => { assert.doesNotMatch(sheetWorker.rolls[1].command, /@\{selected\|/); }); +test('automatic attack successes work with dice enabled or disabled', () => { + const prefix = 'repeating_attacks_fixed_'; + const sheetWorker = worker({ + [prefix + 'name']: 'Fixe', [prefix + 'dice']: '4', [prefix + 'threshold']: '6', + [prefix + 'auto_successes']: '3', [prefix + 'roll_dice']: '1', [prefix + 'rmax']: '9', + }); + sheetWorker.queueRoll('with-dice', { attack_roll: 2 }); + sheetWorker.fire('clicked:repeating_attacks:attack', { sourceAttribute: prefix + 'attack' }); + assert.equal(sheetWorker.rolls[0].computed.attack_successes, 5); + assert.match(sheetWorker.rolls[0].command, /\?\{Nombre de dés\|4\}d10/); + assert.match(sheetWorker.rolls[0].command, /\{\{autosuccesses=3\}\}/); + + sheetWorker.attrs[prefix + 'roll_dice'] = '0'; + sheetWorker.queueRoll('without-dice', { attack_roll: 0 }); + sheetWorker.fire('clicked:repeating_attacks:attack', { sourceAttribute: prefix + 'attack' }); + assert.equal(sheetWorker.rolls[1].computed.attack_successes, 3); + assert.doesNotMatch(sheetWorker.rolls[1].command, /\?\{Nombre de dés/); + assert.match(sheetWorker.rolls[1].command, /\{\{attack_roll=\[\[0\]\]\}\}/); +}); + test('Subir reports damage and armor break after selected mitigation', () => { const prefix = 'repeating_attacks_a_'; const sheetWorker = worker({