forked from public/foundryvtt-reve-de-dragon
Jet V2 pour les créatures
This commit is contained in:
@@ -12,22 +12,30 @@ export class RollPartCarac extends RollPartSelect {
|
||||
|
||||
loadRefs(rollData) {
|
||||
const refs = this.getRefs(rollData)
|
||||
refs.all = this.$getActorCaracs(rollData)
|
||||
const actor = rollData.active.actor
|
||||
refs.all = [...this.$getActorCaracs(actor), ...this.$getCaracCompetenceCreature(actor)]
|
||||
refs.caracs = refs.all
|
||||
this.$selectCarac(rollData)
|
||||
}
|
||||
|
||||
choices(refs) { return refs.caracs }
|
||||
|
||||
$getActorCaracs(rollData) {
|
||||
return Object.entries(rollData.active.actor.getCarac())
|
||||
$getActorCaracs(actor) {
|
||||
return Object.entries(actor.getCarac())
|
||||
.filter(([key, c]) => key != 'taille')
|
||||
/* TODO: filter by context */
|
||||
.map(([key, carac]) => {
|
||||
return RollPartCarac.$extractCarac(key, carac)
|
||||
})
|
||||
}
|
||||
|
||||
$getCaracCompetenceCreature(actor) {
|
||||
if (actor.isPersonnage()) {
|
||||
return []
|
||||
}
|
||||
return actor.getCompetences()
|
||||
.map(it => { return { key: it.name, label: it.name, value: parseInt(it.system.carac_value) } })
|
||||
}
|
||||
|
||||
static $extractCarac(key, carac) {
|
||||
return {
|
||||
key: key,
|
||||
@@ -40,7 +48,6 @@ export class RollPartCarac extends RollPartSelect {
|
||||
allowed = allowed.filter(it => it != undefined)
|
||||
const refs = this.getRefs(rollData)
|
||||
refs.caracs = allowed.length > 0
|
||||
// ? refs.all.filter(it => allowed.includes(Grammar.toLowerCaseNoAccent(it.key)))
|
||||
? refs.all.filter(it => allowed.includes(it.key))
|
||||
: refs.all
|
||||
this.$selectCarac(rollData)
|
||||
|
||||
Reference in New Issue
Block a user