forked from public/foundryvtt-reve-de-dragon
Gestion attaques v2 et initiative
This commit is contained in:
@@ -25,6 +25,8 @@ import { RdDPossession } from "../rdd-possession.js";
|
||||
import { BASE_CORPS_A_CORPS, BASE_ESQUIVE, POSSESSION_SANS_DRACONIC } from "../item/base-items.js";
|
||||
import { RollDataAjustements } from "../rolldata-ajustements.js";
|
||||
import { MappingCreatureArme } from "../item/mapping-creature-arme.mjs";
|
||||
import RollDialog from "../roll/roll-dialog.mjs";
|
||||
import { ROLL_TYPE_ATTAQUE, ROLL_TYPE_COMP, ROLL_TYPE_JEU, ROLL_TYPE_MEDITATION, ROLL_TYPE_OEUVRE, ROLL_TYPE_TACHE } from "../roll/roll-constants.mjs";
|
||||
|
||||
/**
|
||||
* Classe de base pour les acteurs disposant de rêve (donc, pas des objets)
|
||||
@@ -407,6 +409,20 @@ export class RdDBaseActorReve extends RdDBaseActor {
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async rollCompetenceV2(rollData) {
|
||||
foundry.utils.mergeObject(rollData, {
|
||||
ids: {
|
||||
actorId: this.id
|
||||
},
|
||||
type: {
|
||||
allowed: [ROLL_TYPE_COMP, ROLL_TYPE_OEUVRE, ROLL_TYPE_TACHE, ROLL_TYPE_JEU, ROLL_TYPE_MEDITATION],
|
||||
|
||||
}
|
||||
})
|
||||
rollData.ids.actorId = rollData.ids.actorId ?? this.id
|
||||
await RollDialog.create(rollData)
|
||||
}
|
||||
|
||||
async rollCompetence(idOrName, options = { tryTarget: true, arme: undefined }) {
|
||||
RdDEmpoignade.checkEmpoignadeEnCours(this)
|
||||
const competence = this.getCompetence(idOrName);
|
||||
@@ -449,6 +465,46 @@ export class RdDBaseActorReve extends RdDBaseActor {
|
||||
}
|
||||
}
|
||||
|
||||
rollAttaque(token) {
|
||||
token = token ?? RdDUtility.getSelectedToken(this)
|
||||
|
||||
if (Targets.hasTargets()) {
|
||||
Targets.selectOneTargetToken(target => {
|
||||
if (Targets.isTargetEntite(target)) {
|
||||
ui.notifications.warn(`Vous ne pouvez pas attaquer une entité non incarnée!!!!`)
|
||||
return
|
||||
}
|
||||
|
||||
RdDCombat.rddCombatTarget(target, this, token).attaqueV2();
|
||||
})
|
||||
}
|
||||
else {
|
||||
return RdDConfirm.confirmer({
|
||||
settingConfirmer: "confirmer-combat-sans-cible",
|
||||
content: `<p>Voulez vous faire une attaque sans choisir de cible valide?
|
||||
<br>Tous les jets de combats devront être gérés à la main
|
||||
</p>`,
|
||||
title: 'Ne pas utiliser les automatisation de combat',
|
||||
buttonLabel: "Pas d'automatisation",
|
||||
onAction: async () => {
|
||||
this.rollCompetenceV2({
|
||||
ids: {
|
||||
actorId: this.id,
|
||||
actorTokenId: token?.id,
|
||||
},
|
||||
selected: {
|
||||
conditions: { value: 0 }
|
||||
},
|
||||
type: {
|
||||
allowed: [ROLL_TYPE_COMP, ROLL_TYPE_ATTAQUE, ROLL_TYPE_OEUVRE, ROLL_TYPE_TACHE, ROLL_TYPE_JEU],
|
||||
current: ROLL_TYPE_COMP
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/** --------------------------------------------
|
||||
* @param {*} arme item d'arme/compétence de créature
|
||||
* @param {*} categorieArme catégorie d'attaque à utiliser: competence (== melee), lancer, tir; naturelle, possession
|
||||
|
@@ -34,17 +34,17 @@ export class RdDBaseActorSang extends RdDBaseActorReve {
|
||||
|
||||
getFatigueActuelle() {
|
||||
if (ReglesOptionnelles.isUsing("appliquer-fatigue")) {
|
||||
return Math.max(0, Math.min(this.getFatigueMax(), Misc.toInt(this.system.sante.fatigue?.value)))
|
||||
return Math.max(0, Math.min(this.getFatigueMax(), Misc.toInt(this.system.sante.fatigue?.value)))
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
isCumulFatigueCauseSommeil(cumulFatigue){
|
||||
isCumulFatigueCauseSommeil(cumulFatigue) {
|
||||
return ReglesOptionnelles.isUsing("appliquer-fatigue")
|
||||
? (this.getFatigueRestante() <= cumulFatigue)
|
||||
: (this.getEnduranceActuelle() <= cumulFatigue)
|
||||
? (this.getFatigueRestante() <= cumulFatigue)
|
||||
: (this.getEnduranceActuelle() <= cumulFatigue)
|
||||
}
|
||||
getFatigueRestante() {return this.getFatigueMax() - this.getFatigueActuelle() }
|
||||
getFatigueRestante() { return this.getFatigueMax() - this.getFatigueActuelle() }
|
||||
getFatigueMin() { return this.system.sante.endurance.max - this.system.sante.endurance.value }
|
||||
|
||||
malusFatigue() {
|
||||
@@ -195,7 +195,7 @@ export class RdDBaseActorSang extends RdDBaseActorReve {
|
||||
const endActuelle = this.getEnduranceActuelle();
|
||||
const blessure = await RdDItemBlessure.createBlessure(this, encaissement.gravite, encaissement.dmg?.loc.label ?? '', attackerToken);
|
||||
if (blessure.isCritique()) {
|
||||
encaissement.endurance = endActuelle;
|
||||
encaissement.endurance = endActuelle
|
||||
}
|
||||
|
||||
if (blessure.isMort()) {
|
||||
|
@@ -56,10 +56,8 @@ export class RdDBaseActorSheet extends foundry.appv1.sheets.ActorSheet {
|
||||
this._appliquerRechercheObjets(formData.conteneurs, formData.inventaires);
|
||||
formData.conteneurs = RdDUtility.conteneursRacine(formData.conteneurs);
|
||||
formData.competences.filter(it => it.type == ITEM_TYPES.competencecreature)
|
||||
.forEach(it => {
|
||||
const competenceCreature = new RdDItemCompetenceCreature(it.toObject(), { parent: it.parent });
|
||||
it.isdommages = competenceCreature.isDommages();
|
||||
})
|
||||
.forEach(it => it.isdommages = it.isDommages()
|
||||
)
|
||||
|
||||
return formData;
|
||||
}
|
||||
|
@@ -769,11 +769,15 @@ export class RdDBaseActor extends Actor {
|
||||
return this.itemTypes[ITEM_TYPES.possession]
|
||||
.map(p => {
|
||||
return {
|
||||
name: p.name,
|
||||
label: p.name,
|
||||
action: 'possession',
|
||||
possessionid: p.system.possessionid,
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
listActionsCombat() {
|
||||
const possessions = this.listActionsPossessions()
|
||||
return possessions.length > 0 ? possessions : this.listActions({})
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user