Saisie de valeurs négatives

This commit is contained in:
2026-02-17 00:36:08 +01:00
parent e15ed9d05d
commit 929d6af173
10 changed files with 58 additions and 67 deletions
+1
View File
@@ -4,6 +4,7 @@
- les soins d'un joueur à l'autre fonctionne de nouveau - les soins d'un joueur à l'autre fonctionne de nouveau
- la fenêtre de jet de compétence s'ouvre avec la caractéristique et la difficulté par défaut - la fenêtre de jet de compétence s'ouvre avec la caractéristique et la difficulté par défaut
- on peut saisir des valeurs négatives au clavier en sélectionnant les conditions/difficultés
## 13.0.29 - Le tricorne d'Illysis ## 13.0.29 - Le tricorne d'Illysis
+1 -6
View File
@@ -65,12 +65,7 @@ export class RollPartConditions extends RollPart {
async _onRender(rollDialog, context, options) { async _onRender(rollDialog, context, options) {
const input = rollDialog.element.querySelector(`roll-section[name="${this.code}"] input[name="${this.code}"]`) const input = rollDialog.element.querySelector(`roll-section[name="${this.code}"] input[name="${this.code}"]`)
input?.addEventListener("input", e => this.onInputChange(e, rollDialog)) input?.addEventListener("input", e => this.onNumericInputChange(e, rollDialog))
}
onInputChange(event, rollDialog) {
this.getCurrent(rollDialog.rollData).value = parseInt(event.currentTarget.value)
rollDialog.render()
} }
} }
+1 -6
View File
@@ -73,12 +73,7 @@ export class RollPartDiff extends RollPart {
async _onRender(rollDialog, context, options) { async _onRender(rollDialog, context, options) {
const input = rollDialog.element.querySelector(`roll-section[name="${this.code}"] input[name="${this.code}"]`) const input = rollDialog.element.querySelector(`roll-section[name="${this.code}"] input[name="${this.code}"]`)
input?.addEventListener("input", e => this.onInputChange(e, rollDialog)) input?.addEventListener("input", e => this.onNumericInputChange(e, rollDialog))
}
onInputChange(event, rollDialog) {
this.getCurrent(rollDialog.rollData).value = parseInt(event.currentTarget.value)
rollDialog.render()
} }
} }
+10 -4
View File
@@ -1,5 +1,3 @@
import { ALL_ROLL_TYPES } from "./roll-dialog.mjs"
export const ROLLDIALOG_SECTION = { export const ROLLDIALOG_SECTION = {
ACTION: 'action', ACTION: 'action',
CARAC: 'carac', CARAC: 'carac',
@@ -9,7 +7,6 @@ export const ROLLDIALOG_SECTION = {
AJUSTEMENTS: 'ajustements', AJUSTEMENTS: 'ajustements',
} }
export class RollPart { export class RollPart {
static settingKey(rollPart, key) { return `roll-part-${rollPart.code}.${key}` } static settingKey(rollPart, key) { return `roll-part-${rollPart.code}.${key}` }
@@ -75,7 +72,7 @@ export class RollPart {
isValid(rollData) { return true } isValid(rollData) { return true }
visible(rollData) { return true } visible(rollData) { return true }
onReady() { } onReady(rollParts) { }
loadRefs(rollData) { } loadRefs(rollData) { }
prepareContext(rollData) { } prepareContext(rollData) { }
@@ -103,4 +100,13 @@ export class RollPart {
async _onRender(rollDialog, context, options) { } async _onRender(rollDialog, context, options) { }
getHooks() { return [] } getHooks() { return [] }
onNumericInputChange(event, rollDialog, setValue = value => this.getCurrent(rollDialog.rollData).value = value) {
if (isNaN(event.currentTarget.value) || event.currentTarget.value == "") {
return
}
setValue(parseInt(event.currentTarget.value))
rollDialog.render()
}
} }
+6 -7
View File
@@ -1,8 +1,7 @@
<label for="{{code}}">Conditions</label> <label for="{{code}}">Conditions</label>
{{numberInput current.value <input type="number"
name=name name="{{name}}"
step=1 value="{{current.value}}"
min=current.min pattern="^(-|+)?\d+$"
max=current.max min="{{current.min}}" max="{{current.max}}" step="1"
disabled=rollData.type.retry {{#if rollData.type.retry}}disabled{{/if}}>
}}
+12 -13
View File
@@ -9,24 +9,23 @@
{{#if current.recette}} {{#if current.recette}}
<selected-numeric-value>{{plusMoins current.value}}</selected-numeric-value> <selected-numeric-value>{{plusMoins current.value}}</selected-numeric-value>
{{else if current.ingredient}} {{else if current.ingredient}}
{{numberInput current.value <input type="number"
name='diff-var' name='diff-var'
step=1 value="{{current.value}}"
min=-10 pattern="^(-|+)?\d+$"
max=0 min="-10" max="0" step="1"
disabled=rollData.type.retry {{#if rollData.type.retry}}disabled{{/if}}>
}}
{{/if}} {{/if}}
</subline> </subline>
<subline> <subline>
<label for="proportions">Proportions</label> <label for="proportions">Proportions</label>
{{numberInput current.proportions <input type="number"
name='proportions' name='proportions'
step=1 value="{{current.proportions}}"
min=1 pattern="^\d+$"
max=(either current.proportionsMax 10) min="1" max="{{either current.proportionsMax 10}}" step="1"
disabled=rollData.type.retry {{#if rollData.type.retry}}disabled{{/if}}>
}}
{{#if (and current.sust (ne current.sust 1))}}<span>(&times; {{current.sust}})</span>{{/if}} {{#if (and current.sust (ne current.sust 1))}}<span>(&times; {{current.sust}})</span>{{/if}}
</subline> </subline>
<subline> <subline>
+6 -7
View File
@@ -1,10 +1,9 @@
<subline> <subline>
<label for="{{code}}">{{current.label}}&nbsp;</label> <label for="{{code}}">{{current.label}}&nbsp;</label>
{{numberInput current.value <input type="number"
name=name name="{{name}}"
step=1 value="{{current.value}}"
min=current.min pattern="^(-|+)?\d+$"
max=current.max min="{{current.min}}" max="{{current.max}}" step="1"
disabled=(or rollData.type.retry current.disabled) {{#if (or rollData.type.retry current.disabled)}}disabled{{/if}}>
}}
</subline> </subline>
+5 -6
View File
@@ -6,10 +6,9 @@
{{current.label}} {{current.label}}
</label> </label>
<label for="malusenc"></label> <label for="malusenc"></label>
{{numberInput current.value <input type="number"
name='malusenc' name='malusenc'
step=1 value="{{current.value}}"
min=-30 pattern="^(-)?\d+$"
max=0 min="-30" max="0" step="1"
disabled=rollData.type.retry {{#if rollData.type.retry}}disabled{{/if}}>
}}
+11 -12
View File
@@ -8,13 +8,12 @@
{{selectOptions refs.sorts selected=current.key valueAttr="key" labelAttr="label"}} {{selectOptions refs.sorts selected=current.key valueAttr="key" labelAttr="label"}}
</select> </select>
{{#if current.isDiffVariable}} {{#if current.isDiffVariable}}
{{numberInput current.value <input type="number"
name='diff-var' name='diff-var'
step=1 value="{{current.value}}"
min=-20 pattern="^(-)?\d+$"
max=-1 min="-20" max="-1" step="1"
disabled=rollData.type.retry {{#if rollData.type.retry}}disabled{{/if}}>
}}
{{else}} {{else}}
<selected-numeric-value>{{plusMoins current.value}}</selected-numeric-value> <selected-numeric-value>{{plusMoins current.value}}</selected-numeric-value>
{{/if}} {{/if}}
@@ -23,13 +22,13 @@
<label for="ptreve-var">Rêve {{itemSort-coutReve current.sort}}&nbsp;</span> <label for="ptreve-var">Rêve {{itemSort-coutReve current.sort}}&nbsp;</span>
</label> </label>
{{#if current.isReveVariable}} {{#if current.isReveVariable}}
{{numberInput current.ptreve <input type="number"
name='ptreve-var' name='ptreve-var'
step=1 value="{{current.ptreve}}"
min=1 pattern="^\d+$"
max=30 min="{{1}}" max="{{60}}" step="1"
disabled=rollData.type.retry {{#if rollData.type.retry}}disabled{{/if}}>
}}
{{/if}} {{/if}}
<span>&nbsp;(actuel: {{rollData.active.actor.system.reve.reve.value}})</span> <span>&nbsp;(actuel: {{rollData.active.actor.system.reve.reve.value}})</span>
</subline> </subline>
+5 -6
View File
@@ -1,8 +1,7 @@
<label for="{{name}}">Forcer </label> <label for="{{name}}">Forcer </label>
<img src="systems/foundryvtt-reve-de-dragon/assets/ui/d100.svg" data-tooltip="Forcer le résultat du jet de dé"/> <img src="systems/foundryvtt-reve-de-dragon/assets/ui/d100.svg" data-tooltip="Forcer le résultat du jet de dé"/>
{{numberInput current.resultat <input type="number"
name=name name="{{name}}"
step=1 value="{{current.resultat}}"
min=-1 pattern="^(-|+)?\d+$"
max=100 min="-1" max="100" step="1">
}}