cypher actor embeds complete
This commit is contained in:
+69
-2
@@ -9,6 +9,17 @@ const TEMPLATE_FILES = ["actor.hbs", "actor-inline.hbs"];
|
||||
const TEMPLATE_BASE = "embeds";
|
||||
const TEMPLATES = normalizeTemplatePaths(TEMPLATE_FILES, TEMPLATE_BASE);
|
||||
|
||||
function csLocKey(name) {
|
||||
return `CYPHERSYSTEM.${name[0].toUpperCase()}${name.slice(1)}`;
|
||||
}
|
||||
|
||||
function enrich(text, options) {
|
||||
return foundry.applications.ux.TextEditor.implementation.enrichHTML(
|
||||
text,
|
||||
options,
|
||||
);
|
||||
}
|
||||
|
||||
async function buildActorEmbedHTML(doc, content, config, options) {
|
||||
// Types: community, pc, marker, npc, vehicle
|
||||
// LIMITED access can see Name and Description
|
||||
@@ -51,8 +62,11 @@ async function buildActorEmbedHTML(doc, content, config, options) {
|
||||
const context = {
|
||||
config: { ...config },
|
||||
actor: doc,
|
||||
basic: doc.system.basic,
|
||||
pools: doc.system.pools,
|
||||
actorName: config?.label ?? doc.name,
|
||||
sentence: doc.system.basic,
|
||||
stats: [],
|
||||
pools: [],
|
||||
enriched: {},
|
||||
options,
|
||||
viewFullDocument: doc.testUserPermission(
|
||||
game.user,
|
||||
@@ -61,6 +75,59 @@ async function buildActorEmbedHTML(doc, content, config, options) {
|
||||
icon,
|
||||
user: game.user,
|
||||
};
|
||||
for (const basic of ["rank", "level", "tier"]) {
|
||||
const value = doc.system.basic?.[basic];
|
||||
if (value !== undefined && value !== null) {
|
||||
context.stats.push({
|
||||
name: csLocKey(basic),
|
||||
value,
|
||||
});
|
||||
}
|
||||
}
|
||||
if (!config.inline) {
|
||||
context.enriched.notes = await enrich(doc.system.notes, options);
|
||||
context.enriched.description = await enrich(
|
||||
doc.system.description,
|
||||
options,
|
||||
);
|
||||
if (doc.type === "pc") {
|
||||
context.enriched.gmNotes = await enrich(doc.system.gmNotes, options);
|
||||
}
|
||||
}
|
||||
for (const pool of [
|
||||
"health",
|
||||
"infrastructure",
|
||||
"might",
|
||||
"speed",
|
||||
"intellect",
|
||||
]) {
|
||||
if (doc.system.pools?.[pool]) {
|
||||
context.pools.push({
|
||||
name: csLocKey(pool),
|
||||
value: doc.system.pools[pool],
|
||||
});
|
||||
}
|
||||
}
|
||||
let armor = doc.system.combat?.armor;
|
||||
if (armor !== undefined && armor !== null) {
|
||||
const ratingTotal = armor?.ratingTotal;
|
||||
if (ratingTotal !== undefined && ratingTotal != null) {
|
||||
armor = ratingTotal;
|
||||
}
|
||||
context.stats.push({
|
||||
name: csLocKey("armor"),
|
||||
value: armor,
|
||||
noInline: true,
|
||||
});
|
||||
}
|
||||
let damage = doc.system.combat?.damage;
|
||||
if (damage !== undefined && damage !== null) {
|
||||
context.stats.push({
|
||||
name: csLocKey("damage"),
|
||||
value: damage,
|
||||
noInline: true,
|
||||
});
|
||||
}
|
||||
const template = config.inline
|
||||
? TEMPLATES["actor-inline.hbs"]
|
||||
: TEMPLATES["actor.hbs"];
|
||||
|
||||
Reference in New Issue
Block a user