Message si un combatant n'a pas d'actor
Par exemple, après suppression d'un acteur, les combatants correspondant aux tokens n'ont plus d'acteur.
This commit is contained in:
parent
b4281afba8
commit
e1b10bc489
@ -50,8 +50,13 @@ export class RdDCombatManager extends Combat {
|
|||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
cleanSonne() {
|
cleanSonne() {
|
||||||
for (let combatant of this.data.combatants) {
|
for (let combatant of this.data.combatants) {
|
||||||
|
if (combatant.actor){
|
||||||
combatant.actor.verifierSonneRound(this.current.round);
|
combatant.actor.verifierSonneRound(this.current.round);
|
||||||
}
|
}
|
||||||
|
else{
|
||||||
|
ui.notifications.warn(`Le combatant ${combatant.name} n'est pas associé à un acteur!`)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
@ -171,10 +176,13 @@ export class RdDCombatManager extends Combat {
|
|||||||
|
|
||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
static buildListeActionsCombat(combatant) {
|
static buildListeActionsCombat(combatant) {
|
||||||
const actor = combatant.actor; // Easy access
|
if (combatant.actor == undefined) {
|
||||||
let items = actor.data.items;
|
ui.notifications.warn(`Le combatant ${combatant.name} n'est pas associé à un acteur, impossible de déterminer ses actions de combat!`)
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
let items = combatant.actor.data.items;
|
||||||
let actions = []
|
let actions = []
|
||||||
if (actor.isCreature()) {
|
if (combatant.actor.isCreature()) {
|
||||||
actions = actions.concat(items.filter(it => RdDItemCompetenceCreature.isCompetenceAttaque(it))
|
actions = actions.concat(items.filter(it => RdDItemCompetenceCreature.isCompetenceAttaque(it))
|
||||||
.map(competence => RdDItemCompetenceCreature.toArme(competence)));
|
.map(competence => RdDItemCompetenceCreature.toArme(competence)));
|
||||||
} else {
|
} else {
|
||||||
@ -184,7 +192,7 @@ export class RdDCombatManager extends Combat {
|
|||||||
.concat(RdDItemArme.mainsNues());
|
.concat(RdDItemArme.mainsNues());
|
||||||
|
|
||||||
let competences = items.filter(it => it.type == 'competence');
|
let competences = items.filter(it => it.type == 'competence');
|
||||||
actions = actions.concat(RdDCombatManager.finalizeArmeList(armes, competences, actor.data.data.carac));
|
actions = actions.concat(RdDCombatManager.finalizeArmeList(armes, competences, combatant.actor.data.data.carac));
|
||||||
|
|
||||||
actions.push({ name: "Draconic", data: { initOnly: true, competence: "Draconic" } });
|
actions.push({ name: "Draconic", data: { initOnly: true, competence: "Draconic" } });
|
||||||
}
|
}
|
||||||
@ -251,17 +259,20 @@ export class RdDCombatManager extends Combat {
|
|||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
static rollInitiativeCompetence(combatantId, arme) {
|
static rollInitiativeCompetence(combatantId, arme) {
|
||||||
const combatant = game.combat.getCombatant(combatantId);
|
const combatant = game.combat.getCombatant(combatantId);
|
||||||
const actor = combatant.actor;
|
if (combatant.actor == undefined) {
|
||||||
|
ui.notifications.warn(`Le combatant ${combatant.name} n'est pas associé à un acteur, impossible de déterminer ses actions de combat!`)
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
let initInfo = "";
|
let initInfo = "";
|
||||||
let initOffset = 0;
|
let initOffset = 0;
|
||||||
let caracForInit = 0;
|
let caracForInit = 0;
|
||||||
let compNiveau = 0;
|
let compNiveau = 0;
|
||||||
let competence = { name: "Aucune" };
|
let competence = { name: "Aucune" };
|
||||||
if (actor.getSurprise() == "totale") {
|
if (combatant.actor.getSurprise() == "totale") {
|
||||||
initOffset = -1; // To force 0
|
initOffset = -1; // To force 0
|
||||||
initInfo = "Surprise Totale"
|
initInfo = "Surprise Totale"
|
||||||
} else if (actor.getSurprise() == "demi") {
|
} else if (combatant.actor.getSurprise() == "demi") {
|
||||||
initOffset = 0;
|
initOffset = 0;
|
||||||
initInfo = "Demi Surprise"
|
initInfo = "Demi Surprise"
|
||||||
} else if (arme.name == "Autre action") {
|
} else if (arme.name == "Autre action") {
|
||||||
@ -276,13 +287,13 @@ export class RdDCombatManager extends Combat {
|
|||||||
compNiveau = competence.data.niveau;
|
compNiveau = competence.data.niveau;
|
||||||
initInfo = arme.name + " / " + arme.data.competence;
|
initInfo = arme.name + " / " + arme.data.competence;
|
||||||
|
|
||||||
if (actor.data.type == 'creature' || actor.data.type == 'entite') {
|
if (combatant.actor.data.type == 'creature' || combatant.actor.data.type == 'entite') {
|
||||||
caracForInit = competence.data.carac_value;
|
caracForInit = competence.data.carac_value;
|
||||||
if (competence.data.categorie == "lancer") {
|
if (competence.data.categorie == "lancer") {
|
||||||
initOffset = 5;
|
initOffset = 5;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
caracForInit = actor.data.data.carac[competence.data.defaut_carac].value;
|
caracForInit = combatant.actor.data.data.carac[competence.data.defaut_carac].value;
|
||||||
if (competence.data.categorie == "lancer") { // Offset de principe pour les armes de jet
|
if (competence.data.categorie == "lancer") { // Offset de principe pour les armes de jet
|
||||||
initOffset = 4;
|
initOffset = 4;
|
||||||
}
|
}
|
||||||
@ -294,7 +305,7 @@ export class RdDCombatManager extends Combat {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let malus = actor.getEtatGeneral(); // Prise en compte état général
|
let malus = combatant.actor.getEtatGeneral(); // Prise en compte état général
|
||||||
// Cas des créatures et entités vs personnages
|
// Cas des créatures et entités vs personnages
|
||||||
let rollFormula = initOffset + "+ ( (" + RdDCombatManager.calculInitiative(compNiveau, caracForInit) + " + " + malus + ") /100)";
|
let rollFormula = initOffset + "+ ( (" + RdDCombatManager.calculInitiative(compNiveau, caracForInit) + " + " + malus + ") /100)";
|
||||||
// Garder la trace de l'arme/compétence utilisée pour l'iniative
|
// Garder la trace de l'arme/compétence utilisée pour l'iniative
|
||||||
|
Loading…
Reference in New Issue
Block a user