mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 03:31:07 +01:00
/fr now supports type=X, where X is Hope or Fear, if not supplied, defaults to Hope
This commit is contained in:
parent
bfd8031ecf
commit
265e35b680
4 changed files with 49 additions and 13 deletions
|
|
@ -249,6 +249,7 @@ Hooks.on('chatMessage', (_, message) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (message.startsWith('/fr')) {
|
if (message.startsWith('/fr')) {
|
||||||
|
console.log("fr message", message);
|
||||||
const result =
|
const result =
|
||||||
message.trim().toLowerCase() === '/fr' ? { result: {} } : rollCommandToJSON(message.replace(/\/fr\s?/, ''));
|
message.trim().toLowerCase() === '/fr' ? { result: {} } : rollCommandToJSON(message.replace(/\/fr\s?/, ''));
|
||||||
if (!result) {
|
if (!result) {
|
||||||
|
|
@ -258,6 +259,10 @@ Hooks.on('chatMessage', (_, message) => {
|
||||||
|
|
||||||
const { result: rollCommand, flavor } = result;
|
const { result: rollCommand, flavor } = result;
|
||||||
|
|
||||||
|
console.log("rollCommand", rollCommand);
|
||||||
|
const fateType = rollCommand.type ?? "Hope";
|
||||||
|
console.log("fateType", fateType);
|
||||||
|
|
||||||
const target = getCommandTarget({ allowNull: true });
|
const target = getCommandTarget({ allowNull: true });
|
||||||
const title = 'Fate';
|
const title = 'Fate';
|
||||||
|
|
||||||
|
|
@ -265,6 +270,7 @@ Hooks.on('chatMessage', (_, message) => {
|
||||||
target,
|
target,
|
||||||
title,
|
title,
|
||||||
label: 'test',
|
label: 'test',
|
||||||
|
fateType
|
||||||
});
|
});
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import D20RollDialog from '../applications/dialogs/d20RollDialog.mjs';
|
import D20RollDialog from '../applications/dialogs/d20RollDialog.mjs';
|
||||||
import D20Roll from './d20Roll.mjs';
|
import D20Roll from './d20Roll.mjs';
|
||||||
import { setDiceSoNiceForFateRoll } from '../helpers/utils.mjs';
|
import { setDiceSoNiceForHopeFateRoll, setDiceSoNiceForFearFateRoll } from '../helpers/utils.mjs';
|
||||||
|
|
||||||
export default class FateRoll extends D20Roll {
|
export default class FateRoll extends D20Roll {
|
||||||
constructor(formula, data = {}, options = {}) {
|
constructor(formula, data = {}, options = {}) {
|
||||||
|
|
@ -30,13 +30,27 @@ export default class FateRoll extends D20Roll {
|
||||||
// this.#hopeDice = `d${face}`;
|
// this.#hopeDice = `d${face}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get dFear() {
|
||||||
|
// if ( !(this.terms[1] instanceof foundry.dice.terms.Die) ) return;
|
||||||
|
if (!(this.dice[0] instanceof foundry.dice.terms.Die)) this.createBaseDice();
|
||||||
|
return this.dice[0];
|
||||||
|
// return this.#fearDice;
|
||||||
|
}
|
||||||
|
|
||||||
|
set dFear(faces) {
|
||||||
|
if (!(this.dice[0] instanceof foundry.dice.terms.Die)) this.createBaseDice();
|
||||||
|
this.dice[0].faces = this.getFaces(faces);
|
||||||
|
// this.#fearDice = `d${face}`;
|
||||||
|
}
|
||||||
|
|
||||||
get isCritical() {
|
get isCritical() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
get fateDie() {
|
get fateDie() {
|
||||||
return "Hope";
|
console.log("fateRoll this", this);
|
||||||
|
return this.data.fateType;
|
||||||
}
|
}
|
||||||
|
|
||||||
static getHooks(hooks) {
|
static getHooks(hooks) {
|
||||||
|
|
@ -64,18 +78,25 @@ export default class FateRoll extends D20Roll {
|
||||||
console.log("config", config);
|
console.log("config", config);
|
||||||
console.log("message", message);
|
console.log("message", message);
|
||||||
|
|
||||||
await setDiceSoNiceForFateRoll(
|
if (roll.fateDie === "Hope") {
|
||||||
roll,
|
await setDiceSoNiceForHopeFateRoll(
|
||||||
config.roll.fate.dice
|
roll,
|
||||||
);
|
config.roll.fate.dice
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
await setDiceSoNiceForFearFateRoll(
|
||||||
|
roll,
|
||||||
|
config.roll.fate.dice
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static postEvaluate(roll, config = {}) {
|
static postEvaluate(roll, config = {}) {
|
||||||
const data = super.postEvaluate(roll, config);
|
const data = super.postEvaluate(roll, config);
|
||||||
|
|
||||||
data.fate = {
|
data.fate = {
|
||||||
dice: roll.dHope.denomination,
|
dice: roll.fateDie === "Hope" ? roll.dHope.denomination : roll.dFear.denomination,
|
||||||
value: roll.dHope.total,
|
value: roll.fateDie === "Hope" ? roll.dHope.total : roll.dFear.total,
|
||||||
fateDie: roll.fateDie
|
fateDie: roll.fateDie
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,14 +34,15 @@ export const renderFateButton = async event => {
|
||||||
{
|
{
|
||||||
target,
|
target,
|
||||||
title: button.dataset.title,
|
title: button.dataset.title,
|
||||||
label: button.dataset.label
|
label: button.dataset.label,
|
||||||
|
fateType
|
||||||
},
|
},
|
||||||
event
|
event
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const enrichedFateRoll = async (
|
export const enrichedFateRoll = async (
|
||||||
{ target, title, label },
|
{ target, title, label, fateType },
|
||||||
event
|
event
|
||||||
) => {
|
) => {
|
||||||
const config = {
|
const config = {
|
||||||
|
|
@ -50,14 +51,15 @@ export const enrichedFateRoll = async (
|
||||||
roll: {
|
roll: {
|
||||||
label: label,
|
label: label,
|
||||||
},
|
},
|
||||||
hasRoll: true
|
hasRoll: true,
|
||||||
|
fateType: fateType
|
||||||
};
|
};
|
||||||
|
|
||||||
if (target) {
|
if (target) {
|
||||||
await target.diceRoll(config);
|
await target.diceRoll(config);
|
||||||
} else {
|
} else {
|
||||||
// For no target, call FateRoll directly with basic data
|
// For no target, call FateRoll directly with basic data
|
||||||
config.data = { experiences: {}, traits: {} };
|
config.data = { experiences: {}, traits: {}, fateType: fateType };
|
||||||
config.source = { actor: null };
|
config.source = { actor: null };
|
||||||
await CONFIG.Dice.daggerheart.FateRoll.build(config);
|
await CONFIG.Dice.daggerheart.FateRoll.build(config);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -69,13 +69,20 @@ export const setDiceSoNiceForDualityRoll = async (rollResult, advantageState, ho
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const setDiceSoNiceForFateRoll = async (rollResult, hopeFaces) => {
|
export const setDiceSoNiceForHopeFateRoll = async (rollResult, hopeFaces) => {
|
||||||
if (!game.modules.get('dice-so-nice')?.active) return;
|
if (!game.modules.get('dice-so-nice')?.active) return;
|
||||||
const { diceSoNice } = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.appearance);
|
const { diceSoNice } = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.appearance);
|
||||||
const diceSoNicePresets = await getDiceSoNicePreset(diceSoNice.hope, hopeFaces);
|
const diceSoNicePresets = await getDiceSoNicePreset(diceSoNice.hope, hopeFaces);
|
||||||
rollResult.dice[0].options = diceSoNicePresets.hope;
|
rollResult.dice[0].options = diceSoNicePresets.hope;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const setDiceSoNiceForFearFateRoll = async (rollResult, fearFaces) => {
|
||||||
|
if (!game.modules.get('dice-so-nice')?.active) return;
|
||||||
|
const { diceSoNice } = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.appearance);
|
||||||
|
const diceSoNicePresets = await getDiceSoNicePreset(diceSoNice.fear, fearFaces);
|
||||||
|
rollResult.dice[0].options = diceSoNicePresets.fear;
|
||||||
|
};
|
||||||
|
|
||||||
export const chunkify = (array, chunkSize, mappingFunc) => {
|
export const chunkify = (array, chunkSize, mappingFunc) => {
|
||||||
var chunkifiedArray = [];
|
var chunkifiedArray = [];
|
||||||
for (let i = 0; i < array.length; i += chunkSize) {
|
for (let i = 0; i < array.length; i += chunkSize) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue