Skip to content

Commit

Permalink
Merge pull request #67 from Robak132/master
Browse files Browse the repository at this point in the history
Feature: Expanded integration for WFRP4
  • Loading branch information
mclemente authored May 1, 2023
2 parents b8bf7d7 + ab8d95d commit 84574f5
Show file tree
Hide file tree
Showing 5 changed files with 344 additions and 39 deletions.
26 changes: 0 additions & 26 deletions module/SystemProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -1311,32 +1311,6 @@ export class tormenta20Provider extends SystemProvider {
}
}

export class wfrp4eProvider extends SystemProvider {
get customCSS() {
return "wfrp4e";
}

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

getActorDetails(actor) {
const data = actor.system;
return {
id: actor.id,
name: actor.name,
wounds: {
value: data.status.wounds.value,
max: data.status.wounds.max,
},
advantage: data.status.advantage.value,
movement: data.details.move.value,
walk: data.details.move.walk,
run: data.details.move.run,
};
}
}

export class cyphersystemProvider extends SystemProvider {
get customCSS() {
return "cyphersystem";
Expand Down
3 changes: 2 additions & 1 deletion module/api.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// prettier-ignore
import { SystemProvider, archmageProvider, bitdProvider, dccProvider, dnd35eProvider, dnd4eProvider, dnd5eProvider, pf1Provider, pf2eProvider,
scumAndVillainyProvider, sfrpgProvider, swadeProvider, tormenta20Provider, wfrp4eProvider, cyphersystemProvider, CoC7Provider, GURPSProvider,
scumAndVillainyProvider, sfrpgProvider, swadeProvider, tormenta20Provider, cyphersystemProvider, CoC7Provider, GURPSProvider,
cofSystemProvider, shinobigamiProvider} from "./SystemProvider.js";
import {wfrp4eProvider} from "./systemProviders/wfrp4eProvider.js";

export const availableSystemProviders = {};
export let currentSystemProvider = undefined;
Expand Down
159 changes: 159 additions & 0 deletions module/systemProviders/wfrp4eProvider.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
import {SystemProvider} from "../SystemProvider.js";

export class wfrp4eProvider extends SystemProvider {
get customCSS() {
return "wfrp4e";
}

get tabs() {
return {
currencies: { id: "currencies", visible: true, localization: "Money" },
skills: { id: "skills", visible: true, localization: "Skills" },
talents: { id: "talents", visible: true, localization: "Talents"},
equipment: { id: "equipment", visible: true, localization: "Trappings" },
};
}

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

get width() {
return 700;
}

getCurrency(actor) {
const money = actor.getItemTypes("money").map(m => m.toObject());
const currency = {
bp: money.find(i => i.name === game.i18n.localize("NAME.BP")).system.quantity.value,
ss: money.find(i => i.name === game.i18n.localize("NAME.SS")).system.quantity.value,
gc: money.find(i => i.name === game.i18n.localize("NAME.GC")).system.quantity.value,
total: 0
}
currency.total = (currency.bp / 240 + currency.ss / 20 + currency.gc).toFixed(2)
return currency
}
getTalents(actor) {
let talents = []
actor.getItemTypes("talent")
.map(talent => ({
name: talent.name,
test: talent.system.tests.value}))
.forEach(talent => {
let old_talent = talents.find(t => t.name === talent.name && t.test === t.test)
if (old_talent !== undefined) {
talents = talents.filter(t => t !== old_talent);
old_talent.advances += 1;
talents.push(old_talent);
} else {
talent.advances = 1;
talents.push(talent);
}
})
talents = talents.map(talent => ({
name: talent.advances > 1 ? `${talent.name} (${talent.advances})` : talent.name,
test: talent.test
}))
talents.sort((a,b) => a.name.localeCompare(b.name))
return talents
}
getSkills(actor) {
let skills = actor.getItemTypes("skill")
.filter(skill => skill.system.advances.value > 0)
.map(skill => ({
name: skill.name,
nameSpec: skill.name.substring(skill.name.indexOf("(")+1, skill.name.length-1),
total: skill.system.total.value,
advanced: skill.system.advanced.value
}));
skills.sort((a,b) => a.name.localeCompare(b.name))

let meleeRanged = skills.filter(skill => skill.name.includes(game.i18n.localize("NAME.Melee")) || skill.name.includes(game.i18n.localize("NAME.Ranged")))
let languages = skills.filter(skill => skill.name.includes(game.i18n.localize("NAME.Language")))
let lore = skills.filter(skill => skill.name.includes(game.i18n.localize("NAME.Lore")))
let trade = skills.filter(skill => skill.name.includes(game.i18n.localize("NAME.Trade")))

let otherBasic = skills.filter(skill => skill.advanced === "bsc" && !meleeRanged.includes(skill))
let otherAdvanced = skills.filter(skill =>
!meleeRanged.includes(skill) &&
!languages.includes(skill) &&
!lore.includes(skill) &&
!trade.includes(skill) &&
!otherBasic.includes(skill))

return {
meleeRanged: meleeRanged,
languages: languages,
lore: lore,
trade: trade,
otherBasic: otherBasic,
otherAdvanced: otherAdvanced
}
}
getWeapons(actor) {
let weapons = actor.getItemTypes("weapon")
.map(weapon => ({
name: weapon.name,
category: WFRP4E.weaponGroups[weapon.system.weaponGroup.value]
}))
weapons.sort((a,b) => a.name.localeCompare(b.name))

return weapons
}

getActorDetails(actor) {
const data = actor.system;
return {
id: actor.id,
name: actor.name,
wounds: {
value: data.status.wounds.value,
max: data.status.wounds.max,
},
advantage: data.status.advantage.value,
movement: data.details.move.value,
fortune: data.status.fortune.value,
fate: data.status.fate.value,
resilience: data.status.resilience.value,
resolve: data.status.resolve.value,
corruption: {
value: data.status.corruption.value,
max: data.status.corruption.max,
},
status: data.details.status.value,
encumbrance: {
value: data.status.encumbrance.current,
max: data.status.encumbrance.max,
},
exp: {
value: data.details.experience.total - data.details.experience.spent,
total: data.details.experience.total
},
skills: this.getSkills(actor),
talents: this.getTalents(actor),
weapons: this.getWeapons(actor),
currency: this.getCurrency(actor)
};
}

getUpdate(actors) {
const totalCurrency = {
bp: 0,
ss: 0,
gc: 0,
total: 0
}
for (const actor of actors) {
totalCurrency.bp += actor.currency.bp;
totalCurrency.ss += actor.currency.ss;
totalCurrency.gc += actor.currency.gc;
}
totalCurrency.total = (totalCurrency.bp / 240 + totalCurrency.ss / 20 + totalCurrency.gc).toFixed(2)
return [
actors,
{
totalCurrency: totalCurrency,
},
];
}
}
9 changes: 7 additions & 2 deletions style/party-overview.css
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ div.party-overview-window nav .item.active {
}

div.party-overview-window .table-row {
color: black;
display: flex;
display: -webkit-flex;
flex-direction: row;
Expand Down Expand Up @@ -124,6 +125,10 @@ div.party-overview-window .table-row.header {
font-weight: bold;
}

div.party-overview-window.wfrp4e .table-row .text.small {
font-size: 10px;
}

div.party-overview-window.wfrp4e .table-row .button {
margin-right: 6px;
}
Expand All @@ -132,11 +137,11 @@ div.party-overview-window.wfrp4e .table-row .button button {
padding: 2px 0px 0px 0px;
height: 34px;
border: 1px solid black;
border-image: url(/systems/wfrp4e/ui/footer-button.png) 10 repeat;
border-image: url(/systems/wfrp4e/ui/footer-button.webp) 10 repeat;
border-image-width: 4px;
border-image-outset: 0px;
box-shadow: 2px 2px 1px #00000085;
background: url(/systems/wfrp4e/ui/sidebar_button-background_red.png) repeat;
background: url(/systems/wfrp4e/ui/sidebar_button-background_red.webp) repeat;
background-origin: padding-box;
color: #dadada;
font-family: CaslonAntique;
Expand Down
Loading

0 comments on commit 84574f5

Please sign in to comment.