Skip to content

Commit

Permalink
fix: Refixes damage update and handles damage from previous migration…
Browse files Browse the repository at this point in the history
… by showing an error message with what could be done to fix it.
  • Loading branch information
xdy committed Oct 10, 2020
1 parent 1a7efff commit 9359924
Show file tree
Hide file tree
Showing 16 changed files with 252 additions and 180 deletions.
122 changes: 70 additions & 52 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "twodsix",
"version": "0.6.32",
"version": "0.6.33-beta.2",
"description": "A 2d6 system",
"scripts": {
"build": "webpack --mode production",
Expand Down
10 changes: 10 additions & 0 deletions src/module/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

export const TWODSIX:any = {};

TWODSIX.CHARACTERISTICS = {
"strength": "STR",
"dexterity": "DEX",
"endurance": "END",
"intelligence": "INT",
"education": "EDU",
"socialStanding": "SOC",
"psionicStrength": "PSI"
};

/**
* The sets of rules variants one can use
* Not currently used for anything. TODO Remove?
Expand Down
4 changes: 3 additions & 1 deletion src/module/entities/TwodsixItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ export default class TwodsixItem extends Item {
const itemCharacteristic = itemData.data.characteristic;
if (this.actor.data.data.characteristics) { //Temporary fix until issue #102
const actorCharacteristics = Object.values(this.actor.data.data.characteristics);
const activeCharacteristic:any = actorCharacteristics.filter((c:any) => c.shortLabel === itemCharacteristic);
const activeCharacteristic:any = actorCharacteristics.filter((c:any) => {
return c.shortLabel === itemCharacteristic;
});

let mod = 0;
if (activeCharacteristic.length) {
Expand Down
19 changes: 19 additions & 0 deletions src/module/handlebars.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import * as util from "util";
import {advantageDisadvantageTerm} from "./i18n";
import {calcModFor, getKeyByValue} from "./utils/sheetUtils";
import {TWODSIX} from "./config";

export default function registerHandlebarsHelpers():void {

let showedError = false;

Handlebars.registerHelper('advantageDisadvantageTerm', (str) => {
return advantageDisadvantageTerm(str);
});
Expand All @@ -17,4 +21,19 @@ export default function registerHandlebarsHelpers():void {
Handlebars.registerHelper('concat', function (a, b) {
return a + b;
});

Handlebars.registerHelper('skillCharacteristic', (actor, characteristic) => {
const actorData = actor.data;
const characteristicElement = actorData.characteristics[getKeyByValue(TWODSIX.CHARACTERISTICS, characteristic)];
if (characteristicElement) {
const mod = calcModFor(characteristicElement.current);
return game.i18n.localize("TWODSIX.Items.Skills." + characteristicElement.shortLabel) + "(" + (mod < 0 ? "" : "+") + mod + ")";
} else {
if (!showedError) {
ui.notifications.error("TWODSIX.Handlebars.CantShowCharacteristic");
showedError = true;
}
return "XXX";
}
});
}
Loading

0 comments on commit 9359924

Please sign in to comment.