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

View File

@@ -4,6 +4,7 @@
- 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
- on peut saisir des valeurs négatives au clavier en sélectionnant les conditions/difficultés
## 13.0.29 - Le tricorne d'Illysis

View File

@@ -65,12 +65,7 @@ export class RollPartConditions extends RollPart {
async _onRender(rollDialog, context, options) {
const input = rollDialog.element.querySelector(`roll-section[name="${this.code}"] input[name="${this.code}"]`)
input?.addEventListener("input", e => this.onInputChange(e, rollDialog))
}
onInputChange(event, rollDialog) {
this.getCurrent(rollDialog.rollData).value = parseInt(event.currentTarget.value)
rollDialog.render()
input?.addEventListener("input", e => this.onNumericInputChange(e, rollDialog))
}
}

View File

@@ -73,12 +73,7 @@ export class RollPartDiff extends RollPart {
async _onRender(rollDialog, context, options) {
const input = rollDialog.element.querySelector(`roll-section[name="${this.code}"] input[name="${this.code}"]`)
input?.addEventListener("input", e => this.onInputChange(e, rollDialog))
}
onInputChange(event, rollDialog) {
this.getCurrent(rollDialog.rollData).value = parseInt(event.currentTarget.value)
rollDialog.render()
input?.addEventListener("input", e => this.onNumericInputChange(e, rollDialog))
}
}

View File

@@ -1,5 +1,3 @@
import { ALL_ROLL_TYPES } from "./roll-dialog.mjs"
export const ROLLDIALOG_SECTION = {
ACTION: 'action',
CARAC: 'carac',
@@ -9,7 +7,6 @@ export const ROLLDIALOG_SECTION = {
AJUSTEMENTS: 'ajustements',
}
export class RollPart {
static settingKey(rollPart, key) { return `roll-part-${rollPart.code}.${key}` }
@@ -75,7 +72,7 @@ export class RollPart {
isValid(rollData) { return true }
visible(rollData) { return true }
onReady() { }
onReady(rollParts) { }
loadRefs(rollData) { }
prepareContext(rollData) { }
@@ -103,4 +100,13 @@ export class RollPart {
async _onRender(rollDialog, context, options) { }
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()
}
}

View File

@@ -1,8 +1,7 @@
<label for="{{code}}">Conditions</label>
{{numberInput current.value
name=name
step=1
min=current.min
max=current.max
disabled=rollData.type.retry
}}
<input type="number"
name="{{name}}"
value="{{current.value}}"
pattern="^(-|+)?\d+$"
min="{{current.min}}" max="{{current.max}}" step="1"
{{#if rollData.type.retry}}disabled{{/if}}>

View File

@@ -9,24 +9,23 @@
{{#if current.recette}}
<selected-numeric-value>{{plusMoins current.value}}</selected-numeric-value>
{{else if current.ingredient}}
{{numberInput current.value
name='diff-var'
step=1
min=-10
max=0
disabled=rollData.type.retry
}}
<input type="number"
name='diff-var'
value="{{current.value}}"
pattern="^(-|+)?\d+$"
min="-10" max="0" step="1"
{{#if rollData.type.retry}}disabled{{/if}}>
{{/if}}
</subline>
<subline>
<label for="proportions">Proportions</label>
{{numberInput current.proportions
<input type="number"
name='proportions'
step=1
min=1
max=(either current.proportionsMax 10)
disabled=rollData.type.retry
}}
value="{{current.proportions}}"
pattern="^\d+$"
min="1" max="{{either current.proportionsMax 10}}" step="1"
{{#if rollData.type.retry}}disabled{{/if}}>
{{#if (and current.sust (ne current.sust 1))}}<span>(&times; {{current.sust}})</span>{{/if}}
</subline>
<subline>

View File

@@ -1,10 +1,9 @@
<subline>
<label for="{{code}}">{{current.label}}&nbsp;</label>
{{numberInput current.value
name=name
step=1
min=current.min
max=current.max
disabled=(or rollData.type.retry current.disabled)
}}
<input type="number"
name="{{name}}"
value="{{current.value}}"
pattern="^(-|+)?\d+$"
min="{{current.min}}" max="{{current.max}}" step="1"
{{#if (or rollData.type.retry current.disabled)}}disabled{{/if}}>
</subline>

View File

@@ -6,10 +6,9 @@
{{current.label}}
</label>
<label for="malusenc"></label>
{{numberInput current.value
<input type="number"
name='malusenc'
step=1
min=-30
max=0
disabled=rollData.type.retry
}}
value="{{current.value}}"
pattern="^(-)?\d+$"
min="-30" max="0" step="1"
{{#if rollData.type.retry}}disabled{{/if}}>

View File

@@ -8,13 +8,12 @@
{{selectOptions refs.sorts selected=current.key valueAttr="key" labelAttr="label"}}
</select>
{{#if current.isDiffVariable}}
{{numberInput current.value
<input type="number"
name='diff-var'
step=1
min=-20
max=-1
disabled=rollData.type.retry
}}
value="{{current.value}}"
pattern="^(-)?\d+$"
min="-20" max="-1" step="1"
{{#if rollData.type.retry}}disabled{{/if}}>
{{else}}
<selected-numeric-value>{{plusMoins current.value}}</selected-numeric-value>
{{/if}}
@@ -23,13 +22,13 @@
<label for="ptreve-var">Rêve {{itemSort-coutReve current.sort}}&nbsp;</span>
</label>
{{#if current.isReveVariable}}
{{numberInput current.ptreve
<input type="number"
name='ptreve-var'
step=1
min=1
max=30
disabled=rollData.type.retry
}}
value="{{current.ptreve}}"
pattern="^\d+$"
min="{{1}}" max="{{60}}" step="1"
{{#if rollData.type.retry}}disabled{{/if}}>
{{/if}}
<span>&nbsp;(actuel: {{rollData.active.actor.system.reve.reve.value}})</span>
</subline>

View File

@@ -1,8 +1,7 @@
<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é"/>
{{numberInput current.resultat
name=name
step=1
min=-1
max=100
}}
<input type="number"
name="{{name}}"
value="{{current.resultat}}"
pattern="^(-|+)?\d+$"
min="-1" max="100" step="1">