Skip to content

Commit

Permalink
Merge pull request #52 from mclemente/V10-Update
Browse files Browse the repository at this point in the history
V10 update
  • Loading branch information
mclemente authored Aug 31, 2022
2 parents d261466 + b588a1b commit 4bd59ec
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 55 deletions.
6 changes: 2 additions & 4 deletions module.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
{
"id": "party-overview",
"name": "party-overview",
"title": "Party Overview",
"description": "Provides an instant overview about vital stats of the players active in the current scene",
"version": "2.14",

This comment has been minimized.

Copy link
@shemetz

shemetz Sep 1, 2022

the version number should be bumped as well, no?

This comment has been minimized.

Copy link
@mclemente

mclemente Sep 1, 2022

Author Owner

The version number is updated automatically by the release script (https://github.com/mclemente/party-overview/blob/master/.github/workflows/main.yml), so I never bother updating it.

"minimumCoreVersion": "0.8.9",
"languages": [
{
"lang": "en",
Expand Down Expand Up @@ -53,7 +51,7 @@
}
],
"compatibility": {
"minimum": "0.8.9",
"verified": "10.273"
"minimum": "10",
"verified": "10"
}
}
71 changes: 36 additions & 35 deletions module/SystemProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export class SystemProvider {
* @param {Document} actor
*/
getActorDetails(actor) {
const data = actor.data.data;
const data = actor.system;
return {
id: actor.id,
name: actor.name,
Expand Down Expand Up @@ -129,7 +129,7 @@ export class archmageProvider extends SystemProvider {
}

getActorDetails(actor) {
const data = actor.data.data;
const data = actor.system;
const coins = {};
Object.keys(data.coins).forEach((coin) => {
coins[coin] = data.coins[coin].value ?? 0;
Expand Down Expand Up @@ -209,7 +209,7 @@ export class bitdProvider extends SystemProvider {
}

getActorDetails(actor) {
const data = actor.data.data;
const data = actor.system;
return {
id: actor.id,
name: actor.name,
Expand All @@ -226,7 +226,7 @@ export class dccProvider extends SystemProvider {
}

getActorDetails(actor) {
const data = actor.data.data;
const data = actor.system;
return {
id: actor.id,
name: actor.name,
Expand Down Expand Up @@ -260,7 +260,7 @@ export class dnd35eProvider extends SystemProvider {
}

getActorDetails(actor) {
const data = actor.data.data;
const data = actor.system;
return {
id: actor.id,
name: actor.name,
Expand Down Expand Up @@ -345,7 +345,7 @@ export class dnd4eProvider extends SystemProvider {
}

getActorDetails(actor) {
const data = actor.data.data;
const data = actor.system;
return {
id: actor.id,
name: actor.name,
Expand Down Expand Up @@ -555,7 +555,7 @@ export class dnd5eProvider extends SystemProvider {
}

getActorDetails(actor) {
const data = actor.data.data;
const data = actor.system;
return {
id: actor.id,
name: actor.name,
Expand Down Expand Up @@ -672,7 +672,7 @@ export class pf1Provider extends SystemProvider {
}

getActorDetails(actor) {
const data = actor.data.data;
const data = actor.system;
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),
Expand All @@ -698,7 +698,7 @@ export class pf1Provider extends SystemProvider {
languages: data.traits.languages ? data.traits.languages.value.map((code) => game.i18n.localize(CONFIG.PF1.languages[code])) : [],
currency: currency,

knowledge: this.getKnowledge(actor.data.data.skills),
knowledge: this.getKnowledge(actor.system.skills),
totalGP: this.getTotalGP(currency).toFixed(2),
};
}
Expand Down Expand Up @@ -795,21 +795,21 @@ export class pf2eProvider extends SystemProvider {
};
const currency = { pp: 0, gp: 0, sp: 0, cp: 0 };
data.items
.filter((a) => coins.includes(a.data?.flags?.babele?.originalName) || coins.includes(a.name))
.map((a) => (currency[wealth[a.data?.flags?.babele?.originalName || a.name]] += a.quantity));
.filter((a) => coins.includes(a.flags?.babele?.originalName) || coins.includes(a.name))
.map((a) => (currency[wealth[a.flags?.babele?.originalName || a.name]] += a.quantity));
return currency;
}

getItemsValue(data) {
const coins = ["Platinum Pieces", "Gold Pieces", "Silver Pieces", "Copper Pieces"];
const currency = { pp: 0, gp: 0, sp: 0, cp: 0 };
const items = data.items.filter(
(a) => a.data.data.price && a.data.data.identification.status == "identified" && !(coins.includes(a.data?.flags?.babele?.originalName) || coins.includes(a.name))
(a) => a.system.price && a.system.identification.status == "identified" && !(coins.includes(a.flags?.babele?.originalName) || coins.includes(a.name))
);
for (const item of items) {
let value = item.data.data.price.value;
let value = item.system.price.value;
for (let coin in value) {
currency[coin] += Number(value[coin]) * (item.data.data.quantity?.value ?? item.data.data.quantity);
currency[coin] += Number(value[coin]) * (item.system.quantity?.value ?? item.system.quantity);
}
}
return currency.cp / 100 + currency.sp / 10 + currency.gp + currency.pp * 10;
Expand Down Expand Up @@ -852,16 +852,16 @@ export class pf2eProvider extends SystemProvider {
}

getActorDetails(actor) {
const data = actor.data.data;
const currency = this.getCurrency(actor.data);
const itemsValue = this.getItemsValue(actor.data).toFixed(2);
const data = actor.system;
const currency = this.getCurrency(actor);
const itemsValue = this.getItemsValue(actor).toFixed(2);
const totalGP = this.getTotalGP(currency).toFixed(2);
const sumItemsGP = (Number(itemsValue) + Number(totalGP)).toFixed(2);
return {
id: actor.id,
name: actor.name,
type: actor.type,
bulk: actor.inventory.bulk,
bulk: actor.inventory?.bulk || { value: { normal: 0, light: 0 }, encumberedAt: 0, max: 0 },
hp: data.attributes.hp || { value: 0, max: 0 },
heroPoints: data.resources?.heroPoints || { value: 0, max: 0 },
focus: data.resources?.focus || { value: 0, max: 0 },
Expand All @@ -888,7 +888,7 @@ export class pf2eProvider extends SystemProvider {
itemsValue: itemsValue,
sumItemsGP: sumItemsGP,

lore: this.getLore(actor.data),
lore: this.getLore(actor),
totalGP: totalGP,
};
}
Expand Down Expand Up @@ -934,7 +934,7 @@ export class pf2eProvider extends SystemProvider {
totalPartyGP: totalPartyGP,
sumItemsGP: (Number(itemsValue) + Number(totalPartyGP)).toFixed(2),
lore: lores,
skills: CONFIG.PF2E.skills,
skills: CONFIG.PF2E.skills || {},
},
];
}
Expand All @@ -960,7 +960,7 @@ export class scumAndVillainyProvider extends SystemProvider {
}

getActorDetails(actor) {
const data = actor.data.data;
const data = actor.system;
const base = {
id: actor.id,
name: actor.name,
Expand Down Expand Up @@ -1045,7 +1045,7 @@ export class sfrpgProvider extends SystemProvider {
}

getActorDetails(actor) {
const data = actor.data.data;
const data = actor.system;
return {
id: actor.id,
name: actor.name,
Expand Down Expand Up @@ -1074,7 +1074,7 @@ export class sfrpgProvider extends SystemProvider {
languages: data.traits.languages ? data.traits.languages.value.map((code) => game.i18n.localize(CONFIG.SFRPG.languages[code])) : [],
currency: data.currency,

lore: this.getLore(actor.data.data.skills),
lore: this.getLore(actor.system.skills),
};
}

Expand Down Expand Up @@ -1129,17 +1129,18 @@ export class swadeProvider extends SystemProvider {
}

getActorDetails(actor) {
const data = actor.system;
return {
id: actor.id,
name: actor.name,
current_wounds: actor.data.data.wounds.value,
max_wounds: actor.data.data.wounds.max,
current_fatigue: actor.data.data.fatigue.value,
max_fatigue: actor.data.data.fatigue.max,
bennies: actor.data.data.bennies.value,
parry: actor.data.data.stats.parry.value,
toughness: actor.data.data.stats.toughness.value,
armor: actor.data.data.stats.toughness.armor,
current_wounds: data.wounds.value,
max_wounds: data.wounds.max,
current_fatigue: data.fatigue.value,
max_fatigue: data.fatigue.max,
bennies: data.bennies.value,
parry: data.stats.parry.value,
toughness: data.stats.toughness.value,
armor: data.stats.toughness.armor,
};
}
}
Expand Down Expand Up @@ -1241,7 +1242,7 @@ export class tormenta20Provider extends SystemProvider {
}

getActorDetails(actor) {
const data = actor.data.data;
const data = actor.system;
return {
id: actor.id,
name: actor.name,
Expand Down Expand Up @@ -1310,7 +1311,7 @@ export class wfrp4eProvider extends SystemProvider {
}

getActorDetails(actor) {
const data = actor.data.data;
const data = actor.system;
return {
id: actor.id,
name: actor.name,
Expand Down Expand Up @@ -1340,7 +1341,7 @@ export class cyphersystemProvider extends SystemProvider {
}

getActorDetails(actor) {
const data = actor.data.data;
const data = actor.system;
return {
id: actor.id,
name: actor.name,
Expand Down Expand Up @@ -1385,7 +1386,7 @@ export class CoC7Provider extends SystemProvider {
}

getActorDetails(actor) {
const data = actor.data.data;
const data = actor.system;
return {
id: actor.id,
name: actor.name,
Expand Down
9 changes: 2 additions & 7 deletions module/logic.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,8 @@ class PartyOverviewApp extends Application {
update() {
let actors = game.actors.contents.filter((a) => a.hasPlayerOwner);
if (this.displayMode == DISPLAY_MODE.SHOW_PC_ONLY) {
let users = game.users
.filter((u) => u.data.character)
.map((u) => {
if (game.version < 10) return u.data.character;
return u.data.character.id;
});
actors = actors.filter((playerActor) => users.includes(playerActor.data._id));
let users = game.users.filter((u) => u.character).map((u) => u.character.id);
actors = actors.filter((playerActor) => users.includes(playerActor.id));
} else if (this.displayMode != DISPLAY_MODE.SHOW_MORE) {
actors = actors
.map((playerActor) => playerActor.getActiveTokens())
Expand Down
14 changes: 5 additions & 9 deletions module/settings.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import { availableSystemProviders, currentSystemProvider, getDefaultSystemProvider, updateSystemProvider } from "./api.js";

const debouncedReload = foundry.utils.debounce(() => {
window.location.reload();
}, 100);

export function registerSettings() {
game.settings.registerMenu("party-overview", "PartyOverviewSystemSettings", {
name: "Party Overview System Settings",
Expand Down Expand Up @@ -70,14 +66,13 @@ export class SystemProviderSettings extends FormApplication {
const type = provider.id.substring(0, dotPosition);
const id = provider.id.substring(dotPosition + 1);
if (type === "native") {
let title = id == game.system.id ? game.system.data.title : id;
let title = id == game.system.id ? game.system.title : id;
provider.selectTitle = (game.i18n.localize("party-overview.SystemProvider.choices.native") + " " + title).trim();
} else {
let name;
if (type === "module") {
name = game.modules.get(id).data.title;
var name = game.modules.get(id).title;
} else {
name = game.system.data.title;
name = game.system.title;
}
provider.selectTitle = game.i18n.format(`party-overview.SystemProvider.choices.${type}`, { name });
}
Expand Down Expand Up @@ -138,7 +133,8 @@ export class SystemProviderSettings extends FormApplication {
if (event.currentTarget?.dataset?.action === "reset") {
game.settings.settings.get("party-overview.systemProvider").default = getDefaultSystemProvider();
await game.settings.set("party-overview", "tabVisibility", currentSystemProvider.tabs);
debouncedReload();
this.close();
SettingsConfig.reloadConfirm({ world: true });
}
});
}
Expand Down

0 comments on commit 4bd59ec

Please sign in to comment.