Skip to content

Commit

Permalink
feat: Big change to how rolling is performed.
Browse files Browse the repository at this point in the history
Few user-visible changes other than rolls now showing Sum and Effect at the same time.

Fixes xdy#86
  • Loading branch information
jonepatr authored and xdy committed Jan 8, 2021
1 parent e69f1b2 commit f86bfcc
Show file tree
Hide file tree
Showing 24 changed files with 672 additions and 518 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/test-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ jobs:
- name: Install
run: npm ci

# Lint the code
- name: Install
run: npm run lint

# Building is the only test right now (mainly tests if dependabot actually can update)
- name: Build
run: npm run build
Expand Down
127 changes: 75 additions & 52 deletions package-lock.json

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

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"scripts": {
"build": "webpack --mode production",
"build:dev": "webpack",
"lint": "eslint ./src --fix --ext .ts"
"lint": "eslint ./src --fix"
},
"author": "",
"license": "",
Expand Down Expand Up @@ -37,12 +37,12 @@
"fs-extra": "^9.0.1",
"mini-css-extract-plugin": "^1.3.3",
"prettier": "^2.2.1",
"sass": "^1.32.0",
"sass": "^1.32.2",
"sass-loader": "^10.1.0",
"semantic-release": "^17.3.1",
"source-map-loader": "^1.1.0",
"style-loader": "^2.0.0",
"ts-loader": "^8.0.13",
"ts-loader": "^8.0.14",
"ts-node": "^9.1.1",
"typescript": "^4.1.3",
"url-loader": "^4.1.0",
Expand Down
5 changes: 1 addition & 4 deletions src/module/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,10 @@ const DIFFICULTIES = Object.freeze({
}
});

const CRIT = Object.freeze({"SUCCESS": 1, "FAIL": 2});

export const TWODSIX = {
CHARACTERISTICS: CHARACTERISTICS,
VARIANTS: VARIANTS,
ROLLTYPES: ROLLTYPES,
DIFFICULTIES: DIFFICULTIES,
RULESETS: RULESETS,
CRIT: CRIT
RULESETS: RULESETS
};
35 changes: 32 additions & 3 deletions src/module/entities/TwodsixActor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
* Extend the base Actor entity by defining a custom roll data structure which is ideal for the Simple system.
* @extends {Actor}
*/
import {calcModFor} from "../utils/sheetUtils";
import {calcModFor, getKeyByValue} from "../utils/sheetUtils";
import {CharacteristicType, UpdateData} from "../../types/twodsix";
import {TWODSIX} from "../config";
import {TwodsixRollSettings} from "../utils/TwodsixRollSettings";
import {TwodsixDiceRoll} from "../utils/TwodsixDiceRoll";

export default class TwodsixActor extends Actor {

/**
* Augment the basic actor data with additional dynamic data.
*/
Expand Down Expand Up @@ -70,6 +72,34 @@ export default class TwodsixActor extends Actor {
return remaining;
}

public getCharacteristicModifier(characteristic:string):number {
if (characteristic === 'NONE') {
return 0;
} else {
const keyByValue = getKeyByValue(TWODSIX.CHARACTERISTICS, characteristic);
return calcModFor(this.data.data.characteristics[keyByValue].current);
}
}

// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
public async characteristicRoll(tmpSettings:any, showThrowDialog:boolean, showInChat = true):Promise<TwodsixDiceRoll> {
if (!tmpSettings["characteristic"]) {
ui.notifications.error(game.i18n.localize("TWODSIX.Errors.NoCharacteristicForRoll"));
return;
}
const settings = await TwodsixRollSettings.create(showThrowDialog, tmpSettings);
if (!settings.shouldRoll) {
return;
}

const diceRoll = new TwodsixDiceRoll(settings, this);
if (showInChat) {
diceRoll.sendToChat();
}
console.log("DEBUG CHARACTERISTICS ROLL:", diceRoll);
return diceRoll;
}

private static addDamage(damage:number, characteristic:CharacteristicType):number {
let handledDamage = 0;
if (damage + characteristic.damage > characteristic.value) {
Expand Down Expand Up @@ -101,5 +131,4 @@ export default class TwodsixActor extends Actor {
updateData['data.hits.max'] = this.data.data.hits.max;
await this.update(updateData);
}

}
Loading

0 comments on commit f86bfcc

Please sign in to comment.