mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-07-21 18:09:54 +02:00
Compare commits
2 commits
1e30ea42ba
...
0fbfe388b0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0fbfe388b0 | ||
|
|
7a01793f67 |
6 changed files with 78 additions and 73 deletions
|
|
@ -185,8 +185,10 @@ export default class D20Roll extends DHRoll {
|
||||||
return changeKeys;
|
return changeKeys;
|
||||||
}
|
}
|
||||||
|
|
||||||
static postEvaluate(roll, config = {}) {
|
static async buildEvaluate(roll, config = {}, message = {}) {
|
||||||
const data = super.postEvaluate(roll, config);
|
await super.buildEvaluate(roll, config, message);
|
||||||
|
|
||||||
|
const data = config.roll;
|
||||||
data.type = config.actionType;
|
data.type = config.actionType;
|
||||||
data.difficulty = config.roll.difficulty;
|
data.difficulty = config.roll.difficulty;
|
||||||
if (config.targets?.length) {
|
if (config.targets?.length) {
|
||||||
|
|
@ -222,7 +224,6 @@ export default class D20Roll extends DHRoll {
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
data.modifierTotal = roll.modifierTotal;
|
data.modifierTotal = roll.modifierTotal;
|
||||||
return data;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
resetFormula() {
|
resetFormula() {
|
||||||
|
|
|
||||||
|
|
@ -13,32 +13,38 @@ export default class DamageRoll extends DHRoll {
|
||||||
|
|
||||||
static DefaultDialog = DamageDialog;
|
static DefaultDialog = DamageDialog;
|
||||||
|
|
||||||
|
/** @inheritdoc */
|
||||||
static async buildEvaluate(roll, config = {}, message = {}) {
|
static async buildEvaluate(roll, config = {}, message = {}) {
|
||||||
if (config.dialog.configure === false) roll.constructFormula(config);
|
if (config.dialog.configure === false) roll.constructFormula(config);
|
||||||
if (config.evaluate !== false) for (const roll of config.roll) await roll.roll.evaluate();
|
for (const roll of config.roll) await roll.roll.evaluate();
|
||||||
|
|
||||||
roll._evaluated = true;
|
roll._evaluated = true;
|
||||||
|
|
||||||
const parts = [];
|
const parts = [];
|
||||||
for (const roll of config.roll) {
|
for (const rollData of config.roll) {
|
||||||
parts.push(this.postEvaluate(roll));
|
const roll = rollData.roll;
|
||||||
roll.roll = JSON.stringify(roll.roll.toJSON());
|
parts.push({
|
||||||
|
...rollData,
|
||||||
|
...roll.options.roll,
|
||||||
|
total: roll.total,
|
||||||
|
formula: roll.formula,
|
||||||
|
dice: roll.dice.map(d => ({
|
||||||
|
dice: d.denomination,
|
||||||
|
total: d.total,
|
||||||
|
formula: d.formula,
|
||||||
|
results: d.results
|
||||||
|
})),
|
||||||
|
damageTypes: [...(rollData.damageTypes ?? [])],
|
||||||
|
roll,
|
||||||
|
type: config.type,
|
||||||
|
modifierTotal: this.calculateTotalModifiers(roll)
|
||||||
|
});
|
||||||
|
rollData.roll = JSON.stringify(roll.toJSON());
|
||||||
}
|
}
|
||||||
|
|
||||||
config.damage = this.unifyDamageRoll(parts);
|
config.damage = this.unifyDamageRoll(parts);
|
||||||
}
|
}
|
||||||
|
|
||||||
static postEvaluate(roll, config = {}) {
|
|
||||||
return {
|
|
||||||
...roll,
|
|
||||||
...super.postEvaluate(roll.roll, config),
|
|
||||||
damageTypes: [...(roll.damageTypes ?? [])],
|
|
||||||
roll: roll.roll,
|
|
||||||
type: config.type,
|
|
||||||
modifierTotal: this.calculateTotalModifiers(roll.roll)
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
static async buildPost(roll, config, message) {
|
static async buildPost(roll, config, message) {
|
||||||
const chatMessage = config.source?.message
|
const chatMessage = config.source?.message
|
||||||
? ui.chat.collection.get(config.source.message)
|
? ui.chat.collection.get(config.source.message)
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,9 @@ export default class DHRoll extends Roll {
|
||||||
|
|
||||||
if (config.skips?.createMessage) config.messageRoll = roll;
|
if (config.skips?.createMessage) config.messageRoll = roll;
|
||||||
|
|
||||||
await this.buildEvaluate(roll, config, (message = {}));
|
if (config.evaluate !== false) {
|
||||||
|
await this.buildEvaluate(roll, config, (message = {}));
|
||||||
|
}
|
||||||
await this.buildPost(roll, config, (message = {}));
|
await this.buildPost(roll, config, (message = {}));
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
@ -72,27 +74,14 @@ export default class DHRoll extends Roll {
|
||||||
return roll;
|
return roll;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Evaluates the roll and assigns roll data into the config.
|
||||||
|
* This is only called if config.evaluate is not set to false
|
||||||
|
* @protected
|
||||||
|
*/
|
||||||
static async buildEvaluate(roll, config = {}, message = {}) {
|
static async buildEvaluate(roll, config = {}, message = {}) {
|
||||||
if (config.evaluate !== false) {
|
await roll.evaluate();
|
||||||
await roll.evaluate();
|
config.roll = {
|
||||||
config.roll = this.postEvaluate(roll, config);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static async buildPost(roll, config, message) {
|
|
||||||
for (const hook of config.hooks) {
|
|
||||||
if (Hooks.call(`${CONFIG.DH.id}.postRoll${hook.capitalize()}`, config, message) === false) return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (config.skips?.createMessage) {
|
|
||||||
await triggerChatRollFx([roll]);
|
|
||||||
} else if (!config.source?.message) {
|
|
||||||
config.message = await this.toMessage(roll, config);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static postEvaluate(roll, config = {}) {
|
|
||||||
return {
|
|
||||||
...roll.options.roll,
|
...roll.options.roll,
|
||||||
total: roll.total,
|
total: roll.total,
|
||||||
formula: roll.formula,
|
formula: roll.formula,
|
||||||
|
|
@ -105,6 +94,22 @@ export default class DHRoll extends Roll {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Runs any post configuration events that need to happen towards the end, such as hooks and dice so nice
|
||||||
|
* @protected
|
||||||
|
*/
|
||||||
|
static async buildPost(roll, config, message) {
|
||||||
|
for (const hook of config.hooks) {
|
||||||
|
if (Hooks.call(`${CONFIG.DH.id}.postRoll${hook.capitalize()}`, config, message) === false) return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (config.skips?.createMessage) {
|
||||||
|
await triggerChatRollFx([roll]);
|
||||||
|
} else if (!config.source?.message) {
|
||||||
|
config.message = await this.toMessage(roll, config);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static async toMessage(roll, config) {
|
static async toMessage(roll, config) {
|
||||||
const item = config.data.parent?.items?.get?.(config.source.item) ?? null;
|
const item = config.data.parent?.items?.get?.(config.source.item) ?? null;
|
||||||
const action = item ? item.system.actions.get(config.source.action) : null;
|
const action = item ? item.system.actions.get(config.source.action) : null;
|
||||||
|
|
|
||||||
|
|
@ -232,22 +232,10 @@ export default class DualityRoll extends D20Roll {
|
||||||
return changeKeys;
|
return changeKeys;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @inheritdoc */
|
||||||
static async buildEvaluate(roll, config = {}, message = {}) {
|
static async buildEvaluate(roll, config = {}, message = {}) {
|
||||||
await super.buildEvaluate(roll, config, message);
|
await super.buildEvaluate(roll, config, message);
|
||||||
|
config.roll.hope = {
|
||||||
await setDiceSoNiceForDualityRoll(
|
|
||||||
roll,
|
|
||||||
config.roll.advantage.type,
|
|
||||||
config.roll.hope.dice,
|
|
||||||
config.roll.fear.dice,
|
|
||||||
config.roll.advantage.dice
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
static postEvaluate(roll, config = {}) {
|
|
||||||
const data = super.postEvaluate(roll, config);
|
|
||||||
|
|
||||||
data.hope = {
|
|
||||||
dice: roll.dHope.denomination,
|
dice: roll.dHope.denomination,
|
||||||
value: this.guaranteedCritical ? 0 : roll.dHope.total,
|
value: this.guaranteedCritical ? 0 : roll.dHope.total,
|
||||||
rerolled: {
|
rerolled: {
|
||||||
|
|
@ -255,7 +243,7 @@ export default class DualityRoll extends D20Roll {
|
||||||
rerolls: roll.dHope.results.filter(x => x.rerolled)
|
rerolls: roll.dHope.results.filter(x => x.rerolled)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
data.fear = {
|
config.roll.fear = {
|
||||||
dice: roll.dFear.denomination,
|
dice: roll.dFear.denomination,
|
||||||
value: this.guaranteedCritical ? 0 : roll.dFear.total,
|
value: this.guaranteedCritical ? 0 : roll.dFear.total,
|
||||||
rerolled: {
|
rerolled: {
|
||||||
|
|
@ -263,11 +251,11 @@ export default class DualityRoll extends D20Roll {
|
||||||
rerolls: roll.dFear.results.filter(x => x.rerolled)
|
rerolls: roll.dFear.results.filter(x => x.rerolled)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
data.rally = {
|
config.roll.rally = {
|
||||||
dice: roll.dRally?.denomination,
|
dice: roll.dRally?.denomination,
|
||||||
value: roll.dRally?.total
|
value: roll.dRally?.total
|
||||||
};
|
};
|
||||||
data.result = {
|
config.roll.result = {
|
||||||
duality: roll.withHope ? 1 : roll.withFear ? -1 : 0,
|
duality: roll.withHope ? 1 : roll.withFear ? -1 : 0,
|
||||||
total: this.guaranteedCritical ? 0 : roll.dHope.total + roll.dFear.total,
|
total: this.guaranteedCritical ? 0 : roll.dHope.total + roll.dFear.total,
|
||||||
label: roll.totalLabel
|
label: roll.totalLabel
|
||||||
|
|
@ -275,11 +263,18 @@ export default class DualityRoll extends D20Roll {
|
||||||
|
|
||||||
if (roll._rallyIndex && roll.data?.parent)
|
if (roll._rallyIndex && roll.data?.parent)
|
||||||
roll.data.parent.deleteEmbeddedDocuments('ActiveEffect', [roll._rallyIndex]);
|
roll.data.parent.deleteEmbeddedDocuments('ActiveEffect', [roll._rallyIndex]);
|
||||||
|
|
||||||
return data;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @inheritdoc */
|
||||||
static async buildPost(roll, config, message) {
|
static async buildPost(roll, config, message) {
|
||||||
|
await setDiceSoNiceForDualityRoll(
|
||||||
|
roll,
|
||||||
|
config.roll.advantage.type,
|
||||||
|
config.roll.hope.dice,
|
||||||
|
config.roll.fear.dice,
|
||||||
|
config.roll.advantage.dice
|
||||||
|
);
|
||||||
|
|
||||||
await super.buildPost(roll, config, message);
|
await super.buildPost(roll, config, message);
|
||||||
|
|
||||||
await DualityRoll.dualityUpdate(config);
|
await DualityRoll.dualityUpdate(config);
|
||||||
|
|
|
||||||
|
|
@ -75,25 +75,23 @@ export default class FateRoll extends D20Roll {
|
||||||
this.terms[0] = new foundry.dice.terms.Die({ faces: 12 });
|
this.terms[0] = new foundry.dice.terms.Die({ faces: 12 });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @inheritdoc */
|
||||||
static async buildEvaluate(roll, config = {}, message = {}) {
|
static async buildEvaluate(roll, config = {}, message = {}) {
|
||||||
await super.buildEvaluate(roll, config, message);
|
await super.buildEvaluate(roll, config, message);
|
||||||
|
config.roll.fate = {
|
||||||
|
dice: roll.fateDie === 'Hope' ? roll.dHope.denomination : roll.dFear.denomination,
|
||||||
|
value: roll.fateDie === 'Hope' ? roll.dHope.total : roll.dFear.total,
|
||||||
|
fateDie: roll.fateDie
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @inheritdoc */
|
||||||
|
static async buildPost(roll, config, message) {
|
||||||
if (roll.fateDie === 'Hope') {
|
if (roll.fateDie === 'Hope') {
|
||||||
await setDiceSoNiceForHopeFateRoll(roll, config.roll.fate.dice);
|
await setDiceSoNiceForHopeFateRoll(roll, config.roll.fate.dice);
|
||||||
} else {
|
} else {
|
||||||
await setDiceSoNiceForFearFateRoll(roll, config.roll.fate.dice);
|
await setDiceSoNiceForFearFateRoll(roll, config.roll.fate.dice);
|
||||||
}
|
}
|
||||||
}
|
return super.buildPost(roll, config, message);
|
||||||
|
|
||||||
static postEvaluate(roll, config = {}) {
|
|
||||||
const data = super.postEvaluate(roll, config);
|
|
||||||
|
|
||||||
data.fate = {
|
|
||||||
dice: roll.fateDie === 'Hope' ? roll.dHope.denomination : roll.dFear.denomination,
|
|
||||||
value: roll.fateDie === 'Hope' ? roll.dHope.total : roll.dFear.total,
|
|
||||||
fateDie: roll.fateDie
|
|
||||||
};
|
|
||||||
|
|
||||||
return data;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
"id": "daggerheart",
|
"id": "daggerheart",
|
||||||
"title": "Daggerheart",
|
"title": "Daggerheart",
|
||||||
"description": "An unofficial implementation of the Daggerheart system",
|
"description": "An unofficial implementation of the Daggerheart system",
|
||||||
"version": "2.5.0",
|
"version": "2.5.1",
|
||||||
"compatibility": {
|
"compatibility": {
|
||||||
"minimum": "14.364",
|
"minimum": "14.364",
|
||||||
"verified": "14.364",
|
"verified": "14.364",
|
||||||
|
|
@ -10,7 +10,7 @@
|
||||||
},
|
},
|
||||||
"url": "https://github.com/Foundryborne/daggerheart",
|
"url": "https://github.com/Foundryborne/daggerheart",
|
||||||
"manifest": "https://raw.githubusercontent.com/Foundryborne/daggerheart/v14/system.json",
|
"manifest": "https://raw.githubusercontent.com/Foundryborne/daggerheart/v14/system.json",
|
||||||
"download": "https://github.com/Foundryborne/daggerheart/releases/download/2.5.0/system.zip",
|
"download": "https://github.com/Foundryborne/daggerheart/releases/download/2.5.1/system.zip",
|
||||||
"authors": [
|
"authors": [
|
||||||
{
|
{
|
||||||
"name": "WBHarry"
|
"name": "WBHarry"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue