mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-07-21 18:09:54 +02:00
Added ComboDice modifier for dice rolls
This commit is contained in:
parent
eccab6ad64
commit
bc7060ce36
7 changed files with 43 additions and 3 deletions
|
|
@ -38,6 +38,8 @@ CONFIG.RegionBehavior.dataModels = {
|
|||
};
|
||||
|
||||
Object.assign(CONFIG.Dice.termTypes, dice.diceTypes);
|
||||
CONFIG.Dice.terms.d = dice.BaseDie;
|
||||
CONFIG.Dice.types = [dice.BaseDie, CONFIG.Dice.terms.f];
|
||||
|
||||
CONFIG.Actor.documentClass = documents.DhpActor;
|
||||
CONFIG.Actor.dataModels = models.actors.config;
|
||||
|
|
|
|||
|
|
@ -4,4 +4,5 @@ export { default as DamageRoll } from './damageRoll.mjs';
|
|||
export { default as DHRoll } from './dhRoll.mjs';
|
||||
export { default as DualityRoll } from './dualityRoll.mjs';
|
||||
export { default as FateRoll } from './fateRoll.mjs';
|
||||
export { BaseDie } from './die/_module.mjs';
|
||||
export { diceTypes } from './die/_module.mjs';
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import HopeDie from './hopeDie.mjs';
|
|||
import FearDie from './fearDie.mjs';
|
||||
import AdvantageDie from './advantageDie.mjs';
|
||||
import DisadvantageDie from './disadvantageDie.mjs';
|
||||
export { default as BaseDie } from './baseDie.mjs';
|
||||
|
||||
export const diceTypes = {
|
||||
DualityDie,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
export default class AdvantageDie extends foundry.dice.terms.Die {
|
||||
import BaseDie from './baseDie.mjs';
|
||||
|
||||
export default class AdvantageDie extends BaseDie {
|
||||
constructor(options) {
|
||||
super(options);
|
||||
|
||||
|
|
|
|||
31
module/dice/die/baseDie.mjs
Normal file
31
module/dice/die/baseDie.mjs
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
import { adjustDice } from '../../helpers/utils.mjs';
|
||||
|
||||
export default class BaseDie extends foundry.dice.terms.Die {
|
||||
static MODIFIERS = {
|
||||
...foundry.dice.terms.Die.MODIFIERS,
|
||||
c: 'comboDice'
|
||||
};
|
||||
|
||||
async comboDice(modifier) {
|
||||
/* ComboDice only works with exactly two dice and both have to be the same denomination */
|
||||
if (this.number !== 2) return false;
|
||||
|
||||
const maxIncreasesDiceSize = modifier.endsWith('1');
|
||||
return this.continueCombo(maxIncreasesDiceSize);
|
||||
}
|
||||
|
||||
async continueCombo(maxIncreasesDiceSize) {
|
||||
const lastIndex = this.results.length - 1;
|
||||
|
||||
/* The Combo only continues if the latest roll was higher than the previous */
|
||||
if (this.results[lastIndex].result <= this.results[lastIndex - 1].result) return false;
|
||||
|
||||
const increaseDiceSize = maxIncreasesDiceSize && this.results[lastIndex].result === this.faces;
|
||||
const denomination = increaseDiceSize ? adjustDice(this.denomination, false) : this.denomination;
|
||||
const newRoll = await (new Roll(`1${denomination}`)).evaluate();
|
||||
this.results.push({ result: newRoll.total, active: true });
|
||||
this.number += 1;
|
||||
|
||||
return this.continueCombo();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
export default class DisadvantageDie extends foundry.dice.terms.Die {
|
||||
import BaseDie from './baseDie.mjs';
|
||||
|
||||
export default class DisadvantageDie extends BaseDie {
|
||||
constructor(options) {
|
||||
super(options);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import { updateResourcesForDualityReroll } from '../helpers.mjs';
|
||||
import BaseDie from './baseDie.mjs';
|
||||
|
||||
export default class DualityDie extends foundry.dice.terms.Die {
|
||||
export default class DualityDie extends BaseDie {
|
||||
constructor(options) {
|
||||
super(options);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue