Skip to content

Commit

Permalink
13th Age support 2
Browse files Browse the repository at this point in the history
Fix #32
  • Loading branch information
mclemente committed Feb 6, 2022
1 parent 2cd7da5 commit 4e4f43d
Show file tree
Hide file tree
Showing 3 changed files with 138 additions and 10 deletions.
76 changes: 68 additions & 8 deletions module/SystemProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,66 @@ 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" },
};
}

get template() {
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,
Expand All @@ -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),
};
}

Expand All @@ -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,
},
];
}
Expand Down
16 changes: 16 additions & 0 deletions style/party-overview.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}
56 changes: 54 additions & 2 deletions templates/archmage.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
{{> "modules/party-overview/templates/parts/FilterButton.html"}}
<div class="text">Name</div>
<div class="num" title="{{localize "ARCHMAGE.health"}}"><i class="fas fa-heart"></i></div>
<div class="num" title="{{localize "ARCHMAGE.recoveries"}}"><i class="fas fa-medkit"></i></div>
<div class="num" title="{{localize "ARCHMAGE.ac.label"}}"><i class="fas fa-shield-alt"></i></div>
<div class="num" title="{{localize "ARCHMAGE.pd.label"}}"><i class="fas fa-hard-hat"></i></div>
<div class="num" title="{{localize "ARCHMAGE.md.label"}}"><i class="fas fa-brain"></i></div>
<div class="num" title="{{localize "ARCHMAGE.recoveries"}}"><i class="fas fa-medkit"></i></div>
</div>

{{#each actors as | actor | }}
Expand All @@ -18,14 +18,65 @@
<div class="text">{{ actor.shortestName }}</div>

<div class="num">{{ actor.hp.value }}/{{ actor.hp.max }}</div>
<div class="num">{{ actor.recoveries.value }}/{{ actor.recoveries.max }}</div>
<div class="num">{{ actor.ac.value }}</div>
<div class="num">{{ actor.pd.value }}</div>
<div class="num">{{ actor.md.value }}</div>
<div class="num">{{ actor.recoveries.value }}/{{ actor.recoveries.max }}</div>
</div>
{{/each}}
</div>

<!-- Backgrounds -->
<div class="tab" data-tab="backgrounds" data-group="party">
<div class="table-row header">
{{> "modules/party-overview/templates/parts/FilterButton.html"}}
<div class="text">Name</div>
<div class="text">{{localize "ARCHMAGE.backgrounds"}}</div>
</div>

{{#each actors as | actor | }}
<div class="table-row">
{{> "modules/party-overview/templates/parts/ToggleVisibilityButton.html" actor=actor}}
<div class="text">{{ actor.shortestName }}</div>

<div class="text">{{ actor.backgrounds }}</div>
</div>
{{/each}}
</div>

<!-- Icons -->
<div class="tab proficiencies" data-tab="icons" data-group="party">
<div class="table-row header">
{{> "modules/party-overview/templates/parts/FilterButton.html"}}
<div class="text">{{localize "party-overview.NAME"}}</div>
{{#each actors as | actor | }}
{{> "modules/party-overview/templates/parts/ToggleVisibilityButton.html" actor=actor}}
<div class="num party-overview-ellipsis party-overview-ellipsis-no-border" title="{{ actor.shortestName }}">
{{ actor.shortestName }}
</div>
{{/each}}
</div>

{{#each icons as | key | }}
<div class="table-row">
<div></div>
<div class="text">{{key}}</div>
{{#each (partyOverviewGetSkillList key ../actors)}}
<div class="num flexrow" style="flex: 1;">
<span style="flex: 0 0 24px;">{{#if this.relationship}}{{this.relationship}}{{this.bonus}}{{/if}}</span>
{{#if this.results}}
<ul class="flexrow" style="align-content: center; margin: 0; padding: 0;">
{{#each this.results as | result | }}
{{#if (gt result 0)}}<li class="po-archmage-icon">{{result}}</li>{{/if}}
{{/each}}
</ul>
{{/if}}
</div>
{{/each}}
</div>
{{/each}}
</div>

<!-- Currency -->
<div class="tab" data-tab="coins" data-group="party">
<div class="table-row header">
Expand Down Expand Up @@ -59,5 +110,6 @@
<div class="text icon"><b>{{totalPartyGP}}</b></div>
</div>
</div>

</section>
</div>

0 comments on commit 4e4f43d

Please sign in to comment.