Possessions dans HUD

Permettre de commencer les possessions V2
This commit is contained in:
2025-12-05 19:24:48 +01:00
parent 98e8c7a10c
commit 05036877ed
7 changed files with 47 additions and 26 deletions

View File

@@ -121,7 +121,7 @@ export class RdDBaseActorReve extends RdDBaseActor {
getDraconicOuPossession() {
return [
...this.getDraconics(),
...this.itemTypes[ITEM_TYPES.competencecreature].filter(it => it.system.ispossession || it.system.categorie == CATEGORIES_COMPETENCES_CREATURES.possession.key),
...this.itemTypes[ITEM_TYPES.competencecreature].filter(it => it.isCompetencePossession()),
this.getConjurationNaturelle()
].sort(Misc.descending(it => it.system.niveau));
}
@@ -164,7 +164,7 @@ export class RdDBaseActorReve extends RdDBaseActor {
return this.itemTypes[ITEM_TYPES.competencecreature]
.filter(it => it.isAttaque())
.map(it => it.attaqueCreature())
.filter(it => it != undefined);
.filter(it => it != undefined)
}
async computeArmure(dmg) { return this.getProtectionNaturelle() }

View File

@@ -220,6 +220,7 @@ export class RdDBaseActor extends Actor {
isEntite() { return false }
isEntiteIncarnee() { return false }
isEntiteNonIncarnee() { return false }
isEntiteBlurette() { return false }
isHautRevant() { return false }
isVehicule() { return false }
isPersonnage() { return false }
@@ -848,6 +849,7 @@ export class RdDBaseActor extends Actor {
listActionsPossessions() {
return this.itemTypes[ITEM_TYPES.possession]
.filter(it => !it.system.possede)
.map(p => {
return {
label: p.name,
@@ -856,9 +858,4 @@ export class RdDBaseActor extends Actor {
}
})
}
listActionsCombat() {
const possessions = this.listActionsPossessions()
return possessions.length > 0 ? possessions : this.listActions({})
}
}

View File

@@ -19,8 +19,8 @@ export class RdDEntite extends RdDBaseActorReve {
isEntite() { return true }
isEntiteNonIncarnee() { return this.system.definition.typeentite == ENTITE_NONINCARNE }
isEntiteIncarnee() { return [ENTITE_INCARNE, ENTITE_BLURETTE].includes(this.system.definition.typeentite) }
isEntiteBlurette() { return this.system.definition.typeentite !== ENTITE_BLURETTE }
isEntiteIncarnee() { return !this.isEntiteNonIncarnee() }
isEntiteBlurette() { return this.system.definition.typeentite == ENTITE_BLURETTE }
getReveActuel() {
return Misc.toInt(this.system.carac.reve?.value)
@@ -101,6 +101,15 @@ export class RdDEntite extends RdDBaseActorReve {
return true
}
listActionsPossessions() {
if (this.isEntiteNonIncarnee()) {
return this.itemTypes[ITEM_TYPES.competencecreature]
.filter(it => it.system.ispossession)
.map(it => it.attaqueCreature())
.filter(it => it != undefined)
}
return super.listActionsPossessions()
}
/* -------------------------------------------- */
async setEntiteReveAccordee(actor) {
if (this.isEntiteIncarnee()) {

View File

@@ -205,7 +205,7 @@ export class RdDItem extends Item {
return this.isCompetence() && ['melee', 'tir', 'lancer'].includes(this.system.categorie)
}
isCompetencePossession() { return ITEM_TYPES.competencecreature == this.type && this.system.categorie == "possession" }
isCompetencePossession() { return ITEM_TYPES.competencecreature == this.type && this.system.categorie == CATEGORIES_COMPETENCES_CREATURES.possession.key }
isTemporel() { return typesObjetsTemporels.includes(this.type) }
isOeuvre() { return typesObjetsOeuvres.includes(this.type) }
isDraconique() { return RdDItem.getItemTypesDraconiques().includes(this.type) }

View File

@@ -34,7 +34,7 @@ export class RdDTokenHud {
const actor = RdDCombatManager.getActorCombatant(combatant, { warning: false })
if (actor) {
if (OptionsAvancees.isUsing(ROLL_DIALOG_V2)) {
await RdDTokenHud.addExtensionHudCombat(html, combatant, actor, token)
await RdDTokenHud.addExtensionHudCombatV2(html, combatant, actor, token)
}
else {
const actions = RdDCombatManager.listActionsActorCombatant(actor)
@@ -47,17 +47,28 @@ export class RdDTokenHud {
}
}
static async addExtensionHudCombat(html, combatant, actor, token) {
const actionsActor = actor.listActionsCombat();
static async addExtensionHudCombatV2(html, combatant, actor, token) {
const isPossession = actor.listActionsPossessions().length > 0;
const actionsCombat = isPossession ? [] : actor.listAttaques()
const ajustements = combatant?.initiative ?
[
{ label: 'Initiative +1', action: 'delta', value: 1 },
{ label: 'Initiative -1', action: 'delta', value: -1 }
] : []
const autres = [{ label: "Autre action", action: 'autre' }]
const actions = Misc.indexed(actionsActor.concat(ajustements).concat(autres))
const actions = Misc.indexed([
...actionsCombat,
...ajustements,
...autres
])
const hudData = { combatant, token, actions };
const hudData = {
combatant,
token,
isPossession,
isEntiteNonIncarnee: actor.isEntiteNonIncarnee(),
actions,
};
const hud = $(await renderTemplate('systems/foundryvtt-reve-de-dragon/templates/hud-actor-combat.hbs', hudData))
$(html).find('div.col.left').append(hud)
@@ -84,6 +95,7 @@ export class RdDTokenHud {
}
})
list.find('.rdd-attaque-v2').click(event => combatant.actor.rollAttaque(token))
list.find('.rdd-possession-v2').click(event => combatant.actor.rollPossession())
}
static async addExtensionHudInit(html, combatant, actions) {