Cleanup code
This commit is contained in:
Vendored
+17
-55
@@ -124,7 +124,6 @@ var TEMPLATE_PARTIALS = [
|
||||
"systems/fvtt-chroniques-de-l-etrange/templates/actor/parts/cde-character-treasures.html",
|
||||
"systems/fvtt-chroniques-de-l-etrange/templates/actor/parts/cde-character-items.html",
|
||||
"systems/fvtt-chroniques-de-l-etrange/templates/actor/parts/cde-character-kungfus.html",
|
||||
"systems/fvtt-chroniques-de-l-etrange/templates/actor/parts/cde-character-spells.html",
|
||||
"systems/fvtt-chroniques-de-l-etrange/templates/actor/parts/cde-npc-supernaturals.html",
|
||||
"systems/fvtt-chroniques-de-l-etrange/templates/actor/parts/cde-npc-spells.html",
|
||||
"systems/fvtt-chroniques-de-l-etrange/templates/actor/parts/cde-npc-kungfus.html",
|
||||
@@ -826,6 +825,9 @@ var CharacterDataModel = class extends foundry.abstract.TypeDataModel {
|
||||
};
|
||||
return schema;
|
||||
}
|
||||
prepareDerivedData() {
|
||||
this.anti_initiative = 25 - (this.initiative ?? 0);
|
||||
}
|
||||
};
|
||||
|
||||
// src/data/actors/npc.js
|
||||
@@ -871,6 +873,11 @@ var NpcDataModel = class extends foundry.abstract.TypeDataModel {
|
||||
})
|
||||
};
|
||||
}
|
||||
prepareDerivedData() {
|
||||
this.anti_initiative = 25 - (this.initiative ?? 0);
|
||||
this.vitality.calcul = (this.aptitudes.physical.value ?? 0) * 4;
|
||||
this.hei.calcul = (this.aptitudes.spiritual.value ?? 0) * 4;
|
||||
}
|
||||
};
|
||||
|
||||
// src/data/items/item.js
|
||||
@@ -1068,58 +1075,25 @@ var CDEMessage = class extends ChatMessage {
|
||||
this.#enrichChatCard(html);
|
||||
return html;
|
||||
}
|
||||
getAssociatedActor() {
|
||||
if (this.speaker.scene && this.speaker.token) {
|
||||
const scene = game.scenes.get(this.speaker.scene);
|
||||
const token = scene?.tokens.get(this.speaker.token);
|
||||
if (token) return token.actor;
|
||||
}
|
||||
return game.actors.get(this.speaker.actor);
|
||||
}
|
||||
#enrichChatCard(html) {
|
||||
const actor = this.getAssociatedActor();
|
||||
let img;
|
||||
let nameText;
|
||||
if (this.isContentVisible) {
|
||||
img = actor?.img ?? this.author.avatar;
|
||||
nameText = this.alias;
|
||||
} else {
|
||||
img = this.author.avatar;
|
||||
nameText = this.author.name;
|
||||
}
|
||||
const avatar = document.createElement("a");
|
||||
avatar.classList.add("avatar");
|
||||
const tokenDoc = this.speaker.scene && this.speaker.token ? game.scenes.get(this.speaker.scene)?.tokens.get(this.speaker.token) : null;
|
||||
const actor = tokenDoc?.actor ?? game.actors.get(this.speaker.actor) ?? null;
|
||||
const [img, nameText] = this.isContentVisible ? [actor?.img ?? this.author.avatar, this.alias] : [this.author.avatar, this.author.name];
|
||||
const avatarImg = Object.assign(document.createElement("img"), { src: img, alt: nameText });
|
||||
const avatar = Object.assign(document.createElement("a"), { className: "avatar" });
|
||||
if (actor) avatar.dataset.uuid = actor.uuid;
|
||||
const avatarImg = document.createElement("img");
|
||||
Object.assign(avatarImg, { src: img, alt: nameText });
|
||||
avatar.append(avatarImg);
|
||||
const name = document.createElement("span");
|
||||
name.classList.add("name-stacked");
|
||||
const title = document.createElement("span");
|
||||
title.classList.add("title");
|
||||
title.append(nameText);
|
||||
const title = Object.assign(document.createElement("span"), { className: "title", textContent: nameText });
|
||||
const name = Object.assign(document.createElement("span"), { className: "name-stacked" });
|
||||
name.append(title);
|
||||
const sender = html.querySelector(".message-sender");
|
||||
sender?.replaceChildren(avatar, name);
|
||||
html.querySelector(".message-sender")?.replaceChildren(avatar, name);
|
||||
}
|
||||
};
|
||||
|
||||
// src/documents/actor.js
|
||||
var CDEActor = class extends Actor {
|
||||
getRollData() {
|
||||
const data = this.toObject(false).system;
|
||||
return data;
|
||||
}
|
||||
prepareBaseData() {
|
||||
super.prepareBaseData();
|
||||
if (this.type === ACTOR_TYPES.character) {
|
||||
this.system.anti_initiative = 25 - (this.system.initiative ?? 0);
|
||||
}
|
||||
if (this.type === ACTOR_TYPES.npc) {
|
||||
this.system.vitality.calcul = (this.system.aptitudes.physical.value ?? 0) * 4;
|
||||
this.system.hei.calcul = (this.system.aptitudes.spiritual.value ?? 0) * 4;
|
||||
this.system.anti_initiative = 25 - (this.system.initiative ?? 0);
|
||||
}
|
||||
return this.toObject(false).system;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1196,15 +1170,6 @@ function registerDice() {
|
||||
function registerHandlebarsHelpers() {
|
||||
const { Handlebars } = globalThis;
|
||||
if (!Handlebars) return;
|
||||
Handlebars.registerHelper("select", function(selected, options) {
|
||||
const escapedValue = RegExp.escape(Handlebars.escapeExpression(selected));
|
||||
const rgx = new RegExp(` value=["']${escapedValue}["']`);
|
||||
const html = options.fn(this);
|
||||
return html.replace(rgx, "$& selected");
|
||||
});
|
||||
Handlebars.registerHelper("getMagicBackground", function(magic) {
|
||||
return game.i18n.localize(MAGICS[magic]?.background ?? "");
|
||||
});
|
||||
Handlebars.registerHelper("getMagicLabel", function(magic) {
|
||||
return game.i18n.localize(MAGICS[magic]?.label ?? "");
|
||||
});
|
||||
@@ -1217,9 +1182,6 @@ function registerHandlebarsHelpers() {
|
||||
Handlebars.registerHelper("getMagicSpecialityClassIcon", function(magic, speciality) {
|
||||
return MAGICS[magic]?.speciality?.[speciality]?.classicon ?? "";
|
||||
});
|
||||
Handlebars.registerHelper("getMagicSpecialityIcon", function(magic, speciality) {
|
||||
return MAGICS[magic]?.speciality?.[speciality]?.icon ?? "";
|
||||
});
|
||||
Handlebars.registerHelper("getMagicSpecialityElementIcon", function(magic, speciality) {
|
||||
return MAGICS[magic]?.speciality?.[speciality]?.elementicon ?? "";
|
||||
});
|
||||
|
||||
Vendored
+2
-2
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user