Nouvelle fenêtre: attaque/defense
quelques améliorations préparation pour gérer les messages de résultats en fonction du type de jet (attaque/compétence/...) quelques corrections (suppression du filtre de compétences quand on change de type de jet, astrologie, ..)
This commit is contained in:
55
module/roll/roll-type.mjs
Normal file
55
module/roll/roll-type.mjs
Normal file
@@ -0,0 +1,55 @@
|
||||
import { DIFF } from "./roll-constants.mjs"
|
||||
import { PART_DIFF } from "./roll-part-diff.mjs"
|
||||
|
||||
const DEFAULT_DIFF_TYPES = [DIFF.LIBRE, DIFF.IMPOSEE, DIFF.DEFAUT]
|
||||
|
||||
export class RollType {
|
||||
|
||||
onReady() { }
|
||||
|
||||
get code() { throw new Error(`Pas de code défini pour ${this}`) }
|
||||
get name() { return this.code }
|
||||
get icon() { return `systems/foundryvtt-reve-de-dragon/assets/actions/${this.code}.svg` }
|
||||
get chatResultTemplate() { return `systems/foundryvtt-reve-de-dragon/templates/roll/result/chat-${this.code}.hbs` }
|
||||
|
||||
toTypeData(rollData) {
|
||||
return { code: this.code, name: this.name, icon: this.icon, section: 'type', template: this.template, selected: this.isSelected(rollData) }
|
||||
}
|
||||
|
||||
isAllowed(rollData) { return rollData.type.allowed == undefined || rollData.type.allowed.includes(this.code) }
|
||||
visible(rollData) { return true }
|
||||
|
||||
title(rollData) { return this.code }
|
||||
isSelected(rollData) { return rollData.type.current == this.code }
|
||||
|
||||
setRollDataType(rollData) {
|
||||
rollData.type.opposed = rollData.opponent != undefined
|
||||
rollData.type.resistance = false /** TODO */
|
||||
}
|
||||
|
||||
onSelect(rollData) {
|
||||
const possibleTypes = [
|
||||
rollData.current[PART_DIFF].type,
|
||||
this.typeFromOpponents(rollData),
|
||||
rollData.selected[PART_DIFF].type
|
||||
]
|
||||
const type = possibleTypes.find(m => DEFAULT_DIFF_TYPES.includes(m)) ??DIFF.DEFAUT
|
||||
this.setDiffType(rollData, type)
|
||||
}
|
||||
|
||||
|
||||
typeFromOpponents(rollData) {
|
||||
if (rollData.type.opposed) {
|
||||
if (rollData.type.resistance) {
|
||||
return DIFF.IMPOSEE
|
||||
}
|
||||
return DIFF.LIBRE
|
||||
}
|
||||
return undefined
|
||||
}
|
||||
|
||||
setDiffType(rollData, type) {
|
||||
rollData.current[PART_DIFF].type = type
|
||||
this.setRollDataType(rollData)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user