Skip to content

Commit

Permalink
Merge pull request #6 from emdant/emdant-pathfinder
Browse files Browse the repository at this point in the history
Adapted lore for PF1e and fixed character values
  • Loading branch information
mclemente authored Sep 15, 2021
2 parents dfa6041 + abbe66f commit 3e8954a
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 37 deletions.
71 changes: 38 additions & 33 deletions module/SystemProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,21 +178,25 @@ export class dnd5eProvider extends SystemProvider {
}

export class pf1Provider extends SystemProvider {
static knowledgeKeys = ["kar", "kdu", "ken", "kge", "khi", "klo", "kna", "kno", "kpl", "kre"];

get loadTemplates() {
return ["modules/party-overview/templates/parts/PF2e-Lore.html", "modules/party-overview/templates/parts/PF2e-Bulk.html"];
return [
"modules/party-overview/templates/parts/PF1e-Knowledge.html",
"modules/party-overview/templates/parts/PF2e-Bulk.html"
];
}

get template() {
return "/modules/party-overview/templates/pf1.hbs";
return "/modules/party-overview/templates/pf1.hbs"
}

getLore(data) {
let result = [];
for (let key in data) {
result.push(data[key].name);
}

return result;
getKnowledge(skills) {
return pf1Provider.knowledgeKeys.reduce((knowledge, key) => {
if (skills[key].rank > 0)
knowledge[key] = skills[key].mod;
return knowledge
}, {});
}

getTotalGP(currency) {
Expand All @@ -201,35 +205,40 @@ export class pf1Provider extends SystemProvider {

getActorDetails(actor) {
const data = actor.data.data;
const currency = {
cp: parseInt(data.currency.cp) + parseInt(data.altCurrency.cp), // some actors have a string value instead of an integer
sp: parseInt(data.currency.sp) + parseInt(data.altCurrency.sp),
gp: parseInt(data.currency.gp) + parseInt(data.altCurrency.gp),
pp: parseInt(data.currency.pp) + parseInt(data.altCurrency.pp),
};
return {
id: actor.id,
name: actor.name,
hp: {
value: data.attributes.hp.value,
max: data.attributes.hp.max,
max: data.attributes.hp.max
},
armor: data.armor.total ? data.armor.total : 10,
shieldAC: data.shield && data.shield.total ? `(+${data.shield.total})` : "",
perception: data.skills.per.mod,
armor: data.attributes.ac.normal.total,
perception: `+${data.skills.per.mod}`,
speed: data.attributes.speed.land.total,

saves: {
fortitude: data.attributes.savingThrows.fort.total,
reflex: data.attributes.savingThrows.ref.total,
will: data.attributes.savingThrows.will.total,
fortitude: `+${data.attributes.savingThrows.fort.total}`,
reflex: `+${data.attributes.savingThrows.ref.total}`,
will: `+${data.attributes.savingThrows.will.total}`,
},
languages: data.traits.languages ? data.traits.languages.value.map((code) => game.i18n.localize(CONFIG.PF1.languages[code])) : [],
currency: data.currency,
languages: data.traits.languages ? data.traits.languages.value.map(code => game.i18n.localize(CONFIG.PF1.languages[code])) : [],
currency: currency,

lore: this.getLore(actor.data.data.skills.lor.subSkills),
totalGP: this.getTotalGP(data.currency).toFixed(2),
};
knowledge: this.getKnowledge(actor.data.data.skills),
totalGP: this.getTotalGP(currency).toFixed(2)
}
}

getUpdate(actors) {
let languages = actors
.reduce((languages, actor) => [...new Set(languages.concat(actor.languages))], [])
.filter((language) => language !== undefined)
.filter(language => language !== undefined)
.sort();
let totalCurrency = actors.reduce(
(currency, actor) => {
Expand All @@ -246,26 +255,22 @@ export class pf1Provider extends SystemProvider {
}
);
let totalPartyGP = actors.reduce((totalGP, actor) => totalGP + parseFloat(actor.totalGP), 0).toFixed(2);
let lores = actors
.reduce((lore, actor) => [...new Set(lore.concat(actor.lore))], [])
.filter((lore) => lore !== undefined)
.sort();
actors = actors.map((actor) => {
actors = actors.map(actor => {
return {
...actor,
languages: languages.map((language) => actor.languages && actor.languages.includes(language)),
lore: lores.map((lore) => actor.lore && actor.lore.includes(lore)),
};
languages: languages.map(language => actor.languages && actor.languages.includes(language))
}
});

return [
actors,
{
languages: languages,
totalCurrency: totalCurrency,
totalPartyGP: totalPartyGP,
lore: lores,
},
];
knowledges: pf1Provider.knowledgeKeys,
}
]
}
}

Expand Down
31 changes: 31 additions & 0 deletions templates/parts/PF1e-Knowledge.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<div class='tab' data-tab='lore' data-group='party'>
<div class='table-row header'>
{{> 'modules/party-overview/templates/parts/FilterButton.html'}}
<div class='text'>{{localize 'party-overview.NAME'}}</div>
<div class='num' style='flex: 1' title="{{localize 'PF1.SkillKAr'}}"><i class='value fas fa-hand-sparkles'></i></div>
<div class='num' style='flex: 1' title="{{localize 'PF1.SkillKDu'}}"><i class='value fas fa-dungeon'></i></div>
<div class='num' style='flex: 1' title="{{localize 'PF1.SkillKEn'}}"><i class='value fas fa-cogs'></i></div>
<div class='num' style='flex: 1' title="{{localize 'PF1.SkillKGe'}}"><i class='value fas fa-map'></i></div>
<div class='num' style='flex: 1' title="{{localize 'PF1.SkillKHi'}}"><i class='value fas fa-landmark'></i></div>
<div class='num' style='flex: 1' title="{{localize 'PF1.SkillKLo'}}"><i class='value fas fa-address-book'></i></div>
<div class='num' style='flex: 1' title="{{localize 'PF1.SkillKNa'}}"><i class='value fas fa-leaf'></i></div>
<div class='num' style='flex: 1' title="{{localize 'PF1.SkillKNo'}}"><i class='value fas fa-crown'></i></div>
<div class='num' style='flex: 1' title="{{localize 'PF1.SkillKPl'}}"><i class='value fas fa-globe'></i></div>
<div class='num' style='flex: 1' title="{{localize 'PF1.SkillKRe'}}"><i class='value fas fa-place-of-worship'></i></div>
</div>

{{#each actors as | actor | }}
<div class='table-row'>
<div class='button'>
<button class='btn-toggle-visibility' data-actor='{{actor.id }}'>
{{#if actor.isHidden }}<i class='value fas fa-eye-slash'></i>{{else}}<i
class='value fas fa-eye'></i>{{/if}}
</button>
</div>
<div class='text'>{{ actor.shortestName }}</div>
{{#each ../knowledges as | k | }}
<div class='num' style='flex: 1'>{{#if (lookup actor.knowledge @k)}}+{{lookup actor.knowledge @k}}{{else}}<i class='value fas fa-times' style='color: gray'></i>{{/if}}</div>
{{/each}}
</div>
{{/each}}
</div>
8 changes: 4 additions & 4 deletions templates/pf1.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<li class="item" data-tab="general">{{localize "party-overview.GENERAL"}}</li>
<li class="item" data-tab="currencies">{{localize "party-overview.WEALTH"}}</li>
<li class="item" data-tab="languages">{{localize "PF1.Languages"}}</li>
<li class="item" data-tab="lore">{{localize "PF1.SkillLor"}}</li>
<li class="item" data-tab="lore">{{localize "PF1.KnowledgeSkills"}}</li>
</nav>
<section class="content">
<div class="tab" data-tab="general" data-group="party">
Expand All @@ -14,7 +14,7 @@
<div class="num" title="{{localize "PF1.ArmorClass"}}"><i class="fas fa-shield-alt"></i></div>
<div class="num" title="{{localize "PF1.SkillPer"}}"><i class="far fa-eye"></i></div>
<div class="num" title="{{localize "PF1.SavingThrowFort"}}"><i class="fas fa-hard-hat"></i></div>
<div class=" num" title="{{localize "PF1.SavingThrowRef"}}"><i class="fas fa-running"></i></div>
<div class="num" title="{{localize "PF1.SavingThrowRef"}}"><i class="fas fa-running"></i></div>
<div class="num" title="{{localize "PF1.SavingThrowWill"}}"><i class="fas fa-brain"></i></div>
</div>

Expand All @@ -39,8 +39,8 @@
<!-- Languages -->
{{> "modules/party-overview/templates/parts/Languages.html"}}

<!-- Lore -->
{{> "modules/party-overview/templates/parts/PF2e-Lore.html"}}
<!-- Knowledge -->
{{> "modules/party-overview/templates/parts/PF1e-Knowledge.html"}}

<!-- Currency -->
<div class="tab" data-tab="currencies" data-group="party">
Expand Down

0 comments on commit 3e8954a

Please sign in to comment.