Added props in actor object : isCharacter, isAdversary, isMinion, isArmy, canDoInitiativeRoll
Minion ignore now the DP in init roll
This commit is contained in:
@@ -130,11 +130,11 @@ export class ActorL5r5e extends Actor {
|
|||||||
prepareData() {
|
prepareData() {
|
||||||
super.prepareData();
|
super.prepareData();
|
||||||
|
|
||||||
if (this.isCharacter) {
|
if (this.isCharacterType) {
|
||||||
const system = this.system;
|
const system = this.system;
|
||||||
|
|
||||||
// No automation for npc as they cheat in stats
|
// No automation for npc as they cheat in stats
|
||||||
if (this.type === "character") {
|
if (this.isCharacter) {
|
||||||
ActorL5r5e.computeDerivedAttributes(system);
|
ActorL5r5e.computeDerivedAttributes(system);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -242,10 +242,50 @@ export class ActorL5r5e extends Actor {
|
|||||||
* Return true if this actor is a PC or NPC
|
* Return true if this actor is a PC or NPC
|
||||||
* @return {boolean}
|
* @return {boolean}
|
||||||
*/
|
*/
|
||||||
get isCharacter() {
|
get isCharacterType() {
|
||||||
return ["character", "npc"].includes(this.type);
|
return ["character", "npc"].includes(this.type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return true if this actor is a Character
|
||||||
|
* @return {boolean}
|
||||||
|
*/
|
||||||
|
get isCharacter() {
|
||||||
|
return this.type === "character";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return true if this actor is an Adversary
|
||||||
|
* @return {boolean}
|
||||||
|
*/
|
||||||
|
get isAdversary() {
|
||||||
|
return this.type === "npc" && this.system.type === "adversary";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return true if this actor is a Minion
|
||||||
|
* @return {boolean}
|
||||||
|
*/
|
||||||
|
get isMinion() {
|
||||||
|
return this.type === "npc" && this.system.type === "minion";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return true if this actor is an Army
|
||||||
|
* @return {boolean}
|
||||||
|
*/
|
||||||
|
get isArmy() {
|
||||||
|
return this.type === "army";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return true if this actor can do a initiative roll
|
||||||
|
* @returns {boolean}
|
||||||
|
*/
|
||||||
|
get canDoInitiativeRoll() {
|
||||||
|
return game.combat?.combatants.some((c) => c.tokenId === this.token?._id && !c.initiative);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return true if a weapon is equipped
|
* Return true if a weapon is equipped
|
||||||
* @return {boolean}
|
* @return {boolean}
|
||||||
@@ -275,7 +315,7 @@ export class ActorL5r5e extends Actor {
|
|||||||
* @return {boolean}
|
* @return {boolean}
|
||||||
*/
|
*/
|
||||||
get isPrepared() {
|
get isPrepared() {
|
||||||
if (!this.isCharacter) {
|
if (!this.isCharacterType) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -286,7 +326,7 @@ export class ActorL5r5e extends Actor {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Prepared is a boolean or if null we get the info in the actor
|
// Prepared is a boolean or if null we get the info in the actor
|
||||||
let isPrepared = this.type === "character" ? cfg.character : cfg[this.system.type];
|
let isPrepared = this.isCharacter ? cfg.character : cfg[this.system.type];
|
||||||
if (isPrepared === "null") {
|
if (isPrepared === "null") {
|
||||||
isPrepared = this.system.prepared ? "true" : "false";
|
isPrepared = this.system.prepared ? "true" : "false";
|
||||||
}
|
}
|
||||||
@@ -299,7 +339,7 @@ export class ActorL5r5e extends Actor {
|
|||||||
* @return {number|null}
|
* @return {number|null}
|
||||||
*/
|
*/
|
||||||
get statusRank() {
|
get statusRank() {
|
||||||
if (!this.isCharacter) {
|
if (!this.isCharacterType) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return Math.floor(this.system.social.status / 10);
|
return Math.floor(this.system.social.status / 10);
|
||||||
@@ -310,7 +350,7 @@ export class ActorL5r5e extends Actor {
|
|||||||
* @return {number|null}
|
* @return {number|null}
|
||||||
*/
|
*/
|
||||||
get intrigueRank() {
|
get intrigueRank() {
|
||||||
if (!this.isCharacter) {
|
if (!this.isCharacterType) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return this.type === "npc" ? this.system.conflict_rank.social : this.system.identity.school_rank;
|
return this.type === "npc" ? this.system.conflict_rank.social : this.system.identity.school_rank;
|
||||||
@@ -321,7 +361,7 @@ export class ActorL5r5e extends Actor {
|
|||||||
* @return {number|null}
|
* @return {number|null}
|
||||||
*/
|
*/
|
||||||
get martialRank() {
|
get martialRank() {
|
||||||
if (!this.isCharacter) {
|
if (!this.isCharacterType) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return this.type === "npc" ? this.system.conflict_rank.martial : this.system.identity.school_rank;
|
return this.type === "npc" ? this.system.conflict_rank.martial : this.system.identity.school_rank;
|
||||||
|
|||||||
@@ -220,7 +220,7 @@ export class ArmySheetL5r5e extends BaseSheetL5r5e {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
async _updateLinkedActorData(type, actor, isInit = false) {
|
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);
|
console.warn("L5R5E | Wrong actor type", actor?.type, actor);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -621,12 +621,29 @@ export class BaseCharacterSheetL5r5e extends BaseSheetL5r5e {
|
|||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
const li = $(event.currentTarget);
|
const li = $(event.currentTarget);
|
||||||
const weapon = this._getWeaponInfos(li.data("weapon-id") || null);
|
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({
|
new game.l5r5e.DicePickerDialog({
|
||||||
ringId: li.data("ring") || null,
|
ringId: li.data("ring") || null,
|
||||||
skillId: weapon?.skill || li.data("skill") || null,
|
skillId: weapon?.skill || li.data("skill") || null,
|
||||||
skillCatId: li.data("skillcat") || null,
|
skillCatId: li.data("skillcat") || null,
|
||||||
isInitiativeRoll: li.data("initiative") || false,
|
isInitiativeRoll: isInitiative,
|
||||||
actor: this.actor,
|
actor: this.actor,
|
||||||
itemUuid: weapon?.uuid,
|
itemUuid: weapon?.uuid,
|
||||||
}).render(true);
|
}).render(true);
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ export class CombatL5r5e extends Combat {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Skip non character types (army)
|
// Skip non character types (army)
|
||||||
if (!combatant.actor.isCharacter) {
|
if (!combatant.actor.isCharacterType) {
|
||||||
updatedCombatants.push({
|
updatedCombatants.push({
|
||||||
_id: combatant.id,
|
_id: combatant.id,
|
||||||
initiative: 0,
|
initiative: 0,
|
||||||
@@ -53,7 +53,7 @@ export class CombatL5r5e extends Combat {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Prepared is a boolean or if null we get the info in the actor sheet
|
// Prepared is a boolean or if null we get the info in the actor sheet
|
||||||
const isPc = combatant.actor.type === "character";
|
const isPc = combatant.actor.isCharacter;
|
||||||
const isPrepared = combatant.actor.isPrepared;
|
const isPrepared = combatant.actor.isPrepared;
|
||||||
const actorSystem = combatant.actor.system;
|
const actorSystem = combatant.actor.system;
|
||||||
|
|
||||||
@@ -65,7 +65,7 @@ export class CombatL5r5e extends Combat {
|
|||||||
isPrepared === "true" ? actorSystem.focus : actorSystem.is_compromised ? 1 : actorSystem.vigilance;
|
isPrepared === "true" ? actorSystem.focus : actorSystem.is_compromised ? 1 : actorSystem.vigilance;
|
||||||
|
|
||||||
// Roll only for PC and Adversary
|
// Roll only for PC and Adversary
|
||||||
if (isPc || actorSystem.type === "adversary") {
|
if (isPc || combatant.actor.isAdversary) {
|
||||||
// DicePicker management
|
// DicePicker management
|
||||||
// formula is empty on the fist call (combat tab buttons)
|
// formula is empty on the fist call (combat tab buttons)
|
||||||
if (!formula && !combatant.initiative) {
|
if (!formula && !combatant.initiative) {
|
||||||
@@ -174,14 +174,14 @@ export class CombatL5r5e extends Combat {
|
|||||||
/**
|
/**
|
||||||
* Define how the array of Combatants is sorted in the displayed list of the tracker.
|
* Define how the array of Combatants is sorted in the displayed list of the tracker.
|
||||||
* This method can be overridden by a system or module which needs to display combatants in an alternative order.
|
* This method can be overridden by a system or module which needs to display combatants in an alternative order.
|
||||||
* By default sort by initiative, falling back to name
|
* By default, sort by initiative, falling back to name
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
_sortCombatants(a, b) {
|
_sortCombatants(a, b) {
|
||||||
// if tie : sort by honor, less honorable first
|
// if tie : sort by honor, less honorable first
|
||||||
if (a.initiative === b.initiative) {
|
if (a.initiative === b.initiative) {
|
||||||
// skip if no actor or if armies
|
// skip if no actor or if armies
|
||||||
if (!a.actor || !b.actor || a.actor.type === "army" || b.actor.type === "army") {
|
if (!a.actor || !b.actor || a.actor.isArmy || b.actor.isArmy) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -403,7 +403,7 @@ export class DicePickerDialog extends FormApplication {
|
|||||||
canUseVoidPoint:
|
canUseVoidPoint:
|
||||||
this.object.difficulty.addVoidPoint ||
|
this.object.difficulty.addVoidPoint ||
|
||||||
!this._actor ||
|
!this._actor ||
|
||||||
(this._actor.isCharacter && this._actor.system.void_points.value > 0),
|
(this._actor.isCharacterType && this._actor.system.void_points.value > 0),
|
||||||
disableSubmit: this.object.skill.value < 1 && this.object.ring.value < 1,
|
disableSubmit: this.object.skill.value < 1 && this.object.ring.value < 1,
|
||||||
difficultyHiddenIsLock: this._difficultyHiddenIsLock.gm || this._difficultyHiddenIsLock.option,
|
difficultyHiddenIsLock: this._difficultyHiddenIsLock.gm || this._difficultyHiddenIsLock.option,
|
||||||
};
|
};
|
||||||
@@ -536,8 +536,8 @@ export class DicePickerDialog extends FormApplication {
|
|||||||
ui.notifications.warn(game.i18n.localize("COMBAT.NoneActive"));
|
ui.notifications.warn(game.i18n.localize("COMBAT.NoneActive"));
|
||||||
return this.close();
|
return this.close();
|
||||||
}
|
}
|
||||||
const combatant = game.combat.combatants.find((c) => c.actor.id === this._actor.id && c.initiative > 0);
|
|
||||||
if (combatant) {
|
if (!this._actor.canDoInitiativeRoll) {
|
||||||
ui.notifications.error(game.i18n.localize("l5r5e.conflict.initiative.already_set"));
|
ui.notifications.error(game.i18n.localize("l5r5e.conflict.initiative.already_set"));
|
||||||
return this.close();
|
return this.close();
|
||||||
}
|
}
|
||||||
@@ -721,7 +721,7 @@ export class DicePickerDialog extends FormApplication {
|
|||||||
const targetGrp = Array.from(game.user.targets).reduce(
|
const targetGrp = Array.from(game.user.targets).reduce(
|
||||||
(acc, tgt) => {
|
(acc, tgt) => {
|
||||||
const targetActor = tgt.document.actor;
|
const targetActor = tgt.document.actor;
|
||||||
if (!targetActor.isCharacter) {
|
if (!targetActor.isCharacterType) {
|
||||||
return acc;
|
return acc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -250,7 +250,7 @@ export class RollnKeepDialog extends FormApplication {
|
|||||||
...(await super.getData(options)),
|
...(await super.getData(options)),
|
||||||
isGM: game.user.isGM,
|
isGM: game.user.isGM,
|
||||||
showChoices: options.editable && !rollData.rnkEnded,
|
showChoices: options.editable && !rollData.rnkEnded,
|
||||||
showStrifeBt: options.editable && rollData.summary.strife > 0 && rollData.actor?.isCharacter,
|
showStrifeBt: options.editable && rollData.summary.strife > 0 && rollData.actor?.isCharacterType,
|
||||||
cssClass: this.options.classes.join(" "),
|
cssClass: this.options.classes.join(" "),
|
||||||
data: this.object,
|
data: this.object,
|
||||||
l5r5e: rollData,
|
l5r5e: rollData,
|
||||||
@@ -713,7 +713,7 @@ export class RollnKeepDialog extends FormApplication {
|
|||||||
// Apply strife to actor
|
// Apply strife to actor
|
||||||
const strifeApplied = Math.min(this.roll.l5r5e.summary.strife, Math.max(0, formData.strifeApplied));
|
const strifeApplied = Math.min(this.roll.l5r5e.summary.strife, Math.max(0, formData.strifeApplied));
|
||||||
const actorMod = strifeApplied - this.roll.l5r5e.strifeApplied;
|
const actorMod = strifeApplied - this.roll.l5r5e.strifeApplied;
|
||||||
if (actorMod !== 0 && this.roll.l5r5e.actor?.isCharacter) {
|
if (actorMod !== 0 && this.roll.l5r5e.actor?.isCharacterType) {
|
||||||
await this.roll.l5r5e.actor.update({
|
await this.roll.l5r5e.actor.update({
|
||||||
system: {
|
system: {
|
||||||
strife: {
|
strife: {
|
||||||
|
|||||||
@@ -125,9 +125,7 @@ export class GmMonitor extends FormApplication {
|
|||||||
...(await super.getData(options)),
|
...(await super.getData(options)),
|
||||||
data: {
|
data: {
|
||||||
...this.object,
|
...this.object,
|
||||||
actors: this.object.actors.filter((e) =>
|
actors: this.object.actors.filter((a) => (this.object.view === "armies" ? a.isArmy : !a.isArmy)),
|
||||||
this.object.view === "armies" ? e.type === "army" : e.type !== "army"
|
|
||||||
),
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -178,7 +176,7 @@ export class GmMonitor extends FormApplication {
|
|||||||
case "weapons":
|
case "weapons":
|
||||||
return this._getTooltipWeapons(actor);
|
return this._getTooltipWeapons(actor);
|
||||||
case "global":
|
case "global":
|
||||||
return actor.type === "army" ? this._getTooltipArmiesGlobal(actor) : this._getTooltipGlobal(actor);
|
return actor.isArmy ? this._getTooltipArmiesGlobal(actor) : this._getTooltipGlobal(actor);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -197,12 +197,12 @@ export class GmToolbox extends FormApplication {
|
|||||||
|
|
||||||
for await (const actor of game.actors.contents) {
|
for await (const actor of game.actors.contents) {
|
||||||
// Only characters types
|
// Only characters types
|
||||||
if (!actor.isCharacter) {
|
if (!actor.isCharacterType) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Manage left/right button
|
// Manage left/right button
|
||||||
if (!isAll && (actor.type !== "character" || !actor.hasPlayerOwner)) {
|
if (!isAll && (!actor.isCharacter || !actor.hasPlayerOwner)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ export class ArmyCohortSheetL5r5e extends ItemSheetL5r5e {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
async _updateLinkedActorData(actor) {
|
async _updateLinkedActorData(actor) {
|
||||||
if (!actor || actor.documentName !== "Actor" || !actor.isCharacter) {
|
if (!actor || actor.documentName !== "Actor" || !actor.isCharacterType) {
|
||||||
console.warn("L5R5E | Wrong actor type", actor?.type, actor);
|
console.warn("L5R5E | Wrong actor type", actor?.type, actor);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user