diff --git a/module/SystemProvider.js b/module/SystemProvider.js index 360bb07..1b89cf4 100644 --- a/module/SystemProvider.js +++ b/module/SystemProvider.js @@ -42,9 +42,22 @@ export class SystemProvider { } export class archmageProvider extends SystemProvider { + constructor(id) { + super(id); + Handlebars.registerHelper("partyOverviewGetSkillList", function (skill, actors, opt) { + return actors.map((actor) => { + return { + ...(actor.icons[skill] || { bonus: 0, relationship: "" }), + }; + }); + }); + } + get tabs() { return { + backgrounds: { id: "backgrounds", visible: true, localization: "ARCHMAGE.backgrounds" }, coins: { id: "coins", visible: true, localization: "party-overview.WEALTH" }, + icons: { id: "icons", visible: true, localization: "ARCHMAGE.iconRelationships" }, }; } @@ -52,12 +65,43 @@ export class archmageProvider extends SystemProvider { return "/modules/party-overview/templates/archmage.hbs"; } + getBackgrounds(backgrounds) { + const bg = []; + for (const [key, value] of Object.entries(backgrounds)) { + if (value.name.value) bg.push(`${value.name.value} (${value.bonus.value > -1 ? "+" : ""}${value.bonus.value})`); + } + return bg.join(", "); + } + + getIcons(icons) { + const relationships = { + Positive: "+", + Negative: "-", + Conflicted: "~", + }; + const iconFilter = {}; + Object.keys(icons) + .filter((icon) => icons[icon].relationship.value.length > 0) + .map((icon) => { + iconFilter[icons[icon].name.value] = { + bonus: icons[icon].bonus.value, + relationship: relationships[icons[icon].relationship.value], + results: icons[icon].results, + }; + }); + return iconFilter; + } + getTotalGP(coins) { - return coins.copper.value ?? 0 / 100 + coins.silver.value ?? 0 / 10 + coins.gold.value ?? 0 + coins.platinum.value ?? 0 * 10; + return coins.copper / 100 + coins.silver / 10 + coins.gold + coins.platinum * 10; } getActorDetails(actor) { const data = actor.data.data; + const coins = {}; + Object.keys(data.coins).forEach((coin) => { + coins[coin] = data.coins[coin].value ?? 0; + }); return { id: actor.id, name: actor.name, @@ -67,13 +111,11 @@ export class archmageProvider extends SystemProvider { md: data.attributes.md, recoveries: data.attributes.recoveries, - coins: { - copper: data.coins.copper.value ?? 0, - silver: data.coins.silver.value ?? 0, - gold: data.coins.gold.value ?? 0, - platinum: data.coins.platinum.value ?? 0, - }, - totalGP: this.getTotalGP(data.coins).toFixed(2), + backgrounds: this.getBackgrounds(data.backgrounds), + icons: this.getIcons(data.icons), + + coins: coins, + totalGP: this.getTotalGP(coins).toFixed(2), }; } @@ -93,11 +135,29 @@ export class archmageProvider extends SystemProvider { } ); let totalPartyGP = actors.reduce((totalGP, actor) => totalGP + parseFloat(actor.totalGP), 0).toFixed(2); + let icons = new Set(); + actors.forEach((actor) => { + Object.keys(actor.icons).forEach((icon) => { + icons.add(icon); + }); + }); + icons = Array.from(icons).sort(); + + // .filter((lore) => lore !== undefined) + // .map((icon) => icon.property) + // .sort(); + // actors = actors.map((actor) => { + // return { + // ...actor, + // lore: lores.map((lore) => actor.lore && actor.lore.includes(lore)), + // }; + // }); return [ actors, { totalCurrency: totalCurrency, totalPartyGP: totalPartyGP, + icons, }, ]; } diff --git a/style/party-overview.css b/style/party-overview.css index 67ab824..a80130c 100644 --- a/style/party-overview.css +++ b/style/party-overview.css @@ -149,6 +149,7 @@ button.party-overview-button:not(.wfrp4e) { flex-basis: 100%; } +.party-overview-window.archmage .proficiencies.tab .header .num, .party-overview-window.dnd5e .proficiencies.tab .header .num, .party-overview-window.pf2e .proficiencies.tab .header .num { flex: 1; @@ -171,3 +172,18 @@ div.party-overview-window .table-row .num.party-overview-ellipsis { white-space: nowrap; text-overflow: clip; } + +.party-overview-window li.po-archmage-icon { + display: block; + -webkit-box-flex: 0; + -ms-flex: 0 0 14px; + flex: 0 0 14px; + width: 14px; + height: 14px; + margin: 0 1px; + background: #fff; + border: 1px solid #000; + text-align: center; + line-height: 14px; + font-size: 14px; +} diff --git a/templates/archmage.hbs b/templates/archmage.hbs index 7bd0e67..dc8891f 100644 --- a/templates/archmage.hbs +++ b/templates/archmage.hbs @@ -6,10 +6,10 @@ {{> "modules/party-overview/templates/parts/FilterButton.html"}}
Name
+
-
{{#each actors as | actor | }} @@ -18,14 +18,65 @@
{{ actor.shortestName }}
{{ actor.hp.value }}/{{ actor.hp.max }}
+
{{ actor.recoveries.value }}/{{ actor.recoveries.max }}
{{ actor.ac.value }}
{{ actor.pd.value }}
{{ actor.md.value }}
-
{{ actor.recoveries.value }}/{{ actor.recoveries.max }}
{{/each}} + +
+
+ {{> "modules/party-overview/templates/parts/FilterButton.html"}} +
Name
+
{{localize "ARCHMAGE.backgrounds"}}
+
+ + {{#each actors as | actor | }} +
+ {{> "modules/party-overview/templates/parts/ToggleVisibilityButton.html" actor=actor}} +
{{ actor.shortestName }}
+ +
{{ actor.backgrounds }}
+
+ {{/each}} +
+ + +
+
+ {{> "modules/party-overview/templates/parts/FilterButton.html"}} +
{{localize "party-overview.NAME"}}
+ {{#each actors as | actor | }} + {{> "modules/party-overview/templates/parts/ToggleVisibilityButton.html" actor=actor}} +
+ {{ actor.shortestName }} +
+ {{/each}} +
+ + {{#each icons as | key | }} +
+
+
{{key}}
+ {{#each (partyOverviewGetSkillList key ../actors)}} +
+ {{#if this.relationship}}{{this.relationship}}{{this.bonus}}{{/if}} + {{#if this.results}} +
    + {{#each this.results as | result | }} + {{#if (gt result 0)}}
  • {{result}}
  • {{/if}} + {{/each}} +
+ {{/if}} +
+ {{/each}} +
+ {{/each}} +
+
@@ -59,5 +110,6 @@
{{totalPartyGP}}
+