Added props in actor object : isCharacter, isAdversary, isMinion, isArmy, canDoInitiativeRoll

Minion ignore now the DP in init roll
This commit is contained in:
Vlyan
2022-07-31 18:41:50 +02:00
parent 798b0fdf03
commit 40147ae8d3
9 changed files with 83 additions and 28 deletions

View File

@@ -220,7 +220,7 @@ export class ArmySheetL5r5e extends BaseSheetL5r5e {
* @private
*/
async _updateLinkedActorData(type, actor, isInit = false) {
if (!actor || actor.documentName !== "Actor" || !actor.isCharacter) {
if (!actor || actor.documentName !== "Actor" || !actor.isCharacterType) {
console.warn("L5R5E | Wrong actor type", actor?.type, actor);
return;
}

View File

@@ -621,12 +621,29 @@ export class BaseCharacterSheetL5r5e extends BaseSheetL5r5e {
event.stopPropagation();
const li = $(event.currentTarget);
const weapon = this._getWeaponInfos(li.data("weapon-id") || null);
const isInitiative = li.data("initiative") || false;
if (isInitiative) {
if (!game.combat) {
ui.notifications.warn(game.i18n.localize("COMBAT.NoneActive"));
return;
}
if (!this.actor.canDoInitiativeRoll) {
ui.notifications.error(game.i18n.localize("l5r5e.conflict.initiative.already_set"));
return;
}
// Minion specific
if (this.actor.isMinion) {
this.actor.rollInitiative().then();
return;
}
}
new game.l5r5e.DicePickerDialog({
ringId: li.data("ring") || null,
skillId: weapon?.skill || li.data("skill") || null,
skillCatId: li.data("skillcat") || null,
isInitiativeRoll: li.data("initiative") || false,
isInitiativeRoll: isInitiative,
actor: this.actor,
itemUuid: weapon?.uuid,
}).render(true);