La fenêtre de jet pour les attaques à distance prenait trop de hauteur sur petit écran. La difficulté était mal visualisée par les joueurs (et confondue avec les conditions) Le d100 de la zone "tricher" était un peu trop gros Les ajustements sont organisés plus logiquement: difficulté, conditions, ajustements à cocher
79 lines
2.3 KiB
JavaScript
79 lines
2.3 KiB
JavaScript
import { DIFF, DIFFS, ROLL_TYPE_CUISINE, ROLL_TYPE_MEDITATION, ROLL_TYPE_OEUVRE, ROLL_TYPE_SORT, ROLL_TYPE_TACHE } from "./roll-constants.mjs";
|
|
import { ROLLDIALOG_SECTION, RollPart } from "./roll-part.mjs";
|
|
import { Misc } from "../misc.js";
|
|
|
|
export const PART_DIFF = "diff"
|
|
|
|
const EXCLUDED_ROLL_TYPES = [
|
|
ROLL_TYPE_TACHE,
|
|
ROLL_TYPE_MEDITATION,
|
|
ROLL_TYPE_SORT,
|
|
ROLL_TYPE_CUISINE,
|
|
ROLL_TYPE_OEUVRE]
|
|
|
|
export class RollPartDiff extends RollPart {
|
|
|
|
get code() { return PART_DIFF }
|
|
get section() { return ROLLDIALOG_SECTION.CONDITIONS }
|
|
|
|
restore(rollData) {
|
|
const current = this.getCurrent(rollData)
|
|
const saved = this.getSaved(rollData)
|
|
current.value = saved?.value ?? current.value ?? 0
|
|
current.type = saved?.type ?? current.type
|
|
}
|
|
|
|
store(rollData, targetData) {
|
|
const current = this.getCurrent(rollData)
|
|
this.setSaved(targetData, {
|
|
value: current.value,
|
|
type: current.type
|
|
})
|
|
}
|
|
|
|
visible(rollData) {
|
|
if (EXCLUDED_ROLL_TYPES.includes(rollData.type.current) || rollData.type.appreciation) {
|
|
return false
|
|
}
|
|
const current = this.getCurrent(rollData)
|
|
/* TODO: affiner les cas où afficher ou non. devrait s'afficher pour les jets basiques (même si pas d'opposant sélectionné)*/
|
|
return (DIFF.AUCUN !=current.type) && Object.values(DIFF).includes(current.type)
|
|
}
|
|
|
|
prepareContext(rollData) {
|
|
const current = this.getCurrent(rollData)
|
|
const diffType = DIFFS[current.type] ?? DIFFS[DIFF.AUCUN]
|
|
foundry.utils.mergeObject(current,
|
|
{
|
|
type: diffType.key,
|
|
label: diffType?.label ?? '',
|
|
disabled: !diffType.libre,
|
|
value: Misc.inRange(current.value ?? 0, -10, diffType.max),
|
|
min: -10,
|
|
max: diffType.max
|
|
},
|
|
{ inplace: true }
|
|
)
|
|
}
|
|
|
|
setDiff(rollData, diff) {
|
|
const current = this.getCurrent(rollData)
|
|
current.value = diff.diff ?? current.value
|
|
current.type = diff.type ?? current.type
|
|
}
|
|
|
|
getAjustements(rollData) {
|
|
const current = this.getCurrent(rollData)
|
|
return [{
|
|
label: current.label,
|
|
value: current.value
|
|
}]
|
|
}
|
|
|
|
async _onRender(rollDialog, context, options) {
|
|
const input = rollDialog.element.querySelector(`roll-section[name="${this.code}"] input[name="${this.code}"]`)
|
|
|
|
input?.addEventListener("input", e => this.onNumericInputChange(e, rollDialog))
|
|
}
|
|
|
|
} |