Skip to content

Commit

Permalink
Fixed issues with total gp
Browse files Browse the repository at this point in the history
  • Loading branch information
Zamrod committed Dec 24, 2020
1 parent 5cd1837 commit f1223bd
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
23 changes: 22 additions & 1 deletion src/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ class App extends Application {
}
);
// summing up the total
/*
const calcOverflow = (currency, divider) => {
return {
remainder: currency % divider,
Expand All @@ -106,9 +107,10 @@ class App extends Application {
totalCurrency.pp += overflow.overflow;
console.log(totalCurrency);

*/
}

let totalPartyGP = actors.reduce((totalGP, actor) => totalGP + parseFloat(actor.totalGP), 0).toFixed(2);

this.state = {
activeTab: this.activeTab,
Expand All @@ -117,6 +119,7 @@ class App extends Application {
actors: actors,
languages: languages,
totalCurrency: totalCurrency,
totalPartyGP: totalPartyGP,
};
}

Expand All @@ -142,6 +145,23 @@ class App extends Application {
this.update();
return this.state;
}

getTotalGP(currency) {
// summing up the total
const calcOverflow = (currency, divider) => {
return {
remainder: currency % divider,
overflow: Math.floor(currency / divider),
};
};
let gold = currency.cp / 100 + currency.sp / 10 + currency.ep / 2 + currency.gp + currency.pp * 10;
return gold;
}

htmlDecode(input) {
var doc = new DOMParser().parseFromString(input, "text/html");
return doc.documentElement.textContent;
}

getActorDetails(actor) {
const data = actor.data.data;
Expand Down Expand Up @@ -211,6 +231,7 @@ class App extends Application {
languages: data.traits.languages.value.map(code => CONFIG.DND5E.languages[code]),
alignment: data.details.alignment,
currency: data.currency,
totalGP: this.getTotalGP(data.currency).toFixed(2),
};
}

Expand Down
2 changes: 1 addition & 1 deletion src/config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const config = {
name: "VTTA Party",
version: "2.1.4",
version: "2.3.0",
};

export default config;

0 comments on commit f1223bd

Please sign in to comment.