mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-18 16:09:03 +01:00
Add Serrated & Self-Correcting
This commit is contained in:
parent
bf74596389
commit
4bbf1a82d2
6 changed files with 80 additions and 40 deletions
|
|
@ -64,7 +64,6 @@ export default class DamageDialog extends HandlebarsApplicationMixin(Application
|
||||||
const { ...rest } = foundry.utils.expandObject(formData.object);
|
const { ...rest } = foundry.utils.expandObject(formData.object);
|
||||||
foundry.utils.mergeObject(this.config.roll, rest.roll);
|
foundry.utils.mergeObject(this.config.roll, rest.roll);
|
||||||
foundry.utils.mergeObject(this.config.modifiers, rest.modifiers);
|
foundry.utils.mergeObject(this.config.modifiers, rest.modifiers);
|
||||||
console.log(rest)
|
|
||||||
this.config.selectedRollMode = rest.selectedRollMode;
|
this.config.selectedRollMode = rest.selectedRollMode;
|
||||||
|
|
||||||
this.render();
|
this.render();
|
||||||
|
|
|
||||||
|
|
@ -333,7 +333,7 @@ export default function DHApplicationMixin(Base) {
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
if (usable)
|
if (usable) {
|
||||||
options.unshift({
|
options.unshift({
|
||||||
name: 'DAGGERHEART.GENERAL.damage',
|
name: 'DAGGERHEART.GENERAL.damage',
|
||||||
icon: 'fa-solid fa-explosion',
|
icon: 'fa-solid fa-explosion',
|
||||||
|
|
@ -353,24 +353,11 @@ export default function DHApplicationMixin(Base) {
|
||||||
icon: 'fa-solid fa-burst',
|
icon: 'fa-solid fa-burst',
|
||||||
condition: target => {
|
condition: target => {
|
||||||
const doc = getDocFromElementSync(target);
|
const doc = getDocFromElementSync(target);
|
||||||
return doc?.system?.attack?.damage.parts.length || doc?.damage?.parts.length;
|
return doc && !(doc.type === 'domainCard' && doc.system.inVault);
|
||||||
},
|
},
|
||||||
callback: async (target, event) => {
|
callback: async (target, event) => (await getDocFromElement(target)).use(event)
|
||||||
const doc = await getDocFromElement(target),
|
|
||||||
action = doc?.system?.attack ?? doc;
|
|
||||||
return action && action.use(event, { byPassRoll: true });
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
}
|
||||||
options.unshift({
|
|
||||||
name: 'DAGGERHEART.APPLICATIONS.ContextMenu.useItem',
|
|
||||||
icon: 'fa-solid fa-burst',
|
|
||||||
condition: target => {
|
|
||||||
const doc = getDocFromElementSync(target);
|
|
||||||
return doc && !(doc.type === 'domainCard' && doc.system.inVault);
|
|
||||||
},
|
|
||||||
callback: async (target, event) => (await getDocFromElement(target)).use(event)
|
|
||||||
});
|
|
||||||
|
|
||||||
if (toChat)
|
if (toChat)
|
||||||
options.push({
|
options.push({
|
||||||
|
|
|
||||||
|
|
@ -121,12 +121,12 @@ export default class DamageRoll extends DHRoll {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* To Remove When Reaction System */
|
/* To Remove When Reaction System */
|
||||||
if(index === 0 && part.applyTo === CONFIG.DH.GENERAL.healingTypes.hitPoints.id && config.modifiers.rally?.value) {
|
if(index === 0 && part.applyTo === CONFIG.DH.GENERAL.healingTypes.hitPoints.id) {
|
||||||
const rallyFaces = config.modifiers.rally.values.find(r => r.value === config.modifiers.rally.value)?.label;
|
for(const mod in config.modifiers) {
|
||||||
part.roll.terms.push(
|
const modifier = config.modifiers[mod];
|
||||||
new foundry.dice.terms.OperatorTerm({ operator: '+' }),
|
if(modifier.beforeCrit === true && (modifier.enabled || modifier.value))
|
||||||
...this.constructor.parse(`1${rallyFaces}`)
|
modifier.callback(part);
|
||||||
);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (part.extraFormula) {
|
if (part.extraFormula) {
|
||||||
|
|
@ -144,8 +144,11 @@ export default class DamageRoll extends DHRoll {
|
||||||
|
|
||||||
/* To Remove When Reaction System */
|
/* To Remove When Reaction System */
|
||||||
if(index === 0 && part.applyTo === CONFIG.DH.GENERAL.healingTypes.hitPoints.id) {
|
if(index === 0 && part.applyTo === CONFIG.DH.GENERAL.healingTypes.hitPoints.id) {
|
||||||
if(config.modifiers.massive?.enabled) config.modifiers.massive.callback(part);
|
for(const mod in config.modifiers) {
|
||||||
if(config.modifiers.powerful?.enabled) config.modifiers.powerful.callback(part);
|
const modifier = config.modifiers[mod];
|
||||||
|
if(!modifier.beforeCrit && (modifier.enabled || modifier.value))
|
||||||
|
modifier.callback(part);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (part.roll._formula = this.constructor.getFormula(part.roll.terms));
|
return (part.roll._formula = this.constructor.getFormula(part.roll.terms));
|
||||||
|
|
@ -154,11 +157,8 @@ export default class DamageRoll extends DHRoll {
|
||||||
/* To Remove When Reaction System */
|
/* To Remove When Reaction System */
|
||||||
static temporaryModifierBuilder(config) {
|
static temporaryModifierBuilder(config) {
|
||||||
const mods = {};
|
const mods = {};
|
||||||
|
|
||||||
if(config.data?.parent) {
|
if(config.data?.parent) {
|
||||||
if(config.data.parent.appliedEffects) {
|
if(config.data.parent.appliedEffects) {
|
||||||
const effects = config.data.parent.appliedEffects;
|
|
||||||
|
|
||||||
// Bardic Rally
|
// Bardic Rally
|
||||||
mods.rally = {
|
mods.rally = {
|
||||||
label: "DAGGERHEART.CLASS.Feature.rallyDice",
|
label: "DAGGERHEART.CLASS.Feature.rallyDice",
|
||||||
|
|
@ -168,8 +168,13 @@ export default class DamageRoll extends DHRoll {
|
||||||
return a;
|
return a;
|
||||||
}, []),
|
}, []),
|
||||||
value: null,
|
value: null,
|
||||||
callback: (...args) => {
|
beforeCrit: true,
|
||||||
|
callback: (part) => {
|
||||||
|
const rallyFaces = config.modifiers.rally.values.find(r => r.value === config.modifiers.rally.value)?.label;
|
||||||
|
part.roll.terms.push(
|
||||||
|
new foundry.dice.terms.OperatorTerm({ operator: '+' }),
|
||||||
|
...this.parse(`1${rallyFaces}`)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
@ -177,9 +182,9 @@ export default class DamageRoll extends DHRoll {
|
||||||
const item = config.data.parent.items?.get(config.source.item);
|
const item = config.data.parent.items?.get(config.source.item);
|
||||||
if(item) {
|
if(item) {
|
||||||
// Massive (Weapon Feature)
|
// Massive (Weapon Feature)
|
||||||
if(item.effects.has("cffkpiwGpEGhjiUC"))
|
if(item.system.itemFeatures.find(f => f.value === "massive"))
|
||||||
mods.massive = {
|
mods.massive = {
|
||||||
label: item.effects.get("cffkpiwGpEGhjiUC").name,
|
label: CONFIG.DH.ITEM.weaponFeatures.massive.label,
|
||||||
enabled: true,
|
enabled: true,
|
||||||
callback: (part) => {
|
callback: (part) => {
|
||||||
part.roll.terms[0].modifiers.push(`kh${part.roll.terms[0].number}`);
|
part.roll.terms[0].modifiers.push(`kh${part.roll.terms[0].number}`);
|
||||||
|
|
@ -188,20 +193,50 @@ export default class DamageRoll extends DHRoll {
|
||||||
};
|
};
|
||||||
|
|
||||||
// Powerful (Weapon Feature)
|
// Powerful (Weapon Feature)
|
||||||
if(item.effects.has("DCie5eR1dZH2Qvln"))
|
if(item.system.itemFeatures.find(f => f.value === "powerful"))
|
||||||
mods.powerful = {
|
mods.powerful = {
|
||||||
label: item.effects.get("DCie5eR1dZH2Qvln").name,
|
label: CONFIG.DH.ITEM.weaponFeatures.powerful.label,
|
||||||
enabled: true,
|
enabled: true,
|
||||||
callback: (part) => {
|
callback: (part) => {
|
||||||
part.roll.terms[0].modifiers.push(`kh${part.roll.terms[0].number}`);
|
part.roll.terms[0].modifiers.push(`kh${part.roll.terms[0].number}`);
|
||||||
part.roll.terms[0].number += 1;
|
part.roll.terms[0].number += 1;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Brutal (Weapon Feature)
|
||||||
|
if(item.system.itemFeatures.find(f => f.value === "brutal"))
|
||||||
|
mods.brutal = {
|
||||||
|
label: CONFIG.DH.ITEM.weaponFeatures.brutal.label,
|
||||||
|
enabled: true,
|
||||||
|
beforeCrit: true,
|
||||||
|
callback: (part) => {
|
||||||
|
part.roll.terms[0].modifiers.push(`x${part.roll.terms[0].faces}`);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Serrated (Weapon Feature)
|
||||||
|
if(item.system.itemFeatures.find(f => f.value === "serrated"))
|
||||||
|
mods.serrated = {
|
||||||
|
label: CONFIG.DH.ITEM.weaponFeatures.serrated.label,
|
||||||
|
enabled: true,
|
||||||
|
callback: (part) => {
|
||||||
|
part.roll.terms[0].modifiers.push(`sc8`);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Self-Correcting (Weapon Feature)
|
||||||
|
if(item.system.itemFeatures.find(f => f.value === "selfCorrecting"))
|
||||||
|
mods.selfCorrecting = {
|
||||||
|
label: CONFIG.DH.ITEM.weaponFeatures.selfCorrecting.label,
|
||||||
|
enabled: true,
|
||||||
|
callback: (part) => {
|
||||||
|
part.roll.terms[0].modifiers.push(`sc6`);
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
config.modifiers = mods;
|
config.modifiers = mods;
|
||||||
console.log(config)
|
|
||||||
return mods;
|
return mods;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -211,8 +211,7 @@ export default class DHRoll extends Roll {
|
||||||
}
|
}
|
||||||
|
|
||||||
static temporaryModifierBuilder(config) {
|
static temporaryModifierBuilder(config) {
|
||||||
const mods = new Map();
|
return {};
|
||||||
return mods;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -172,6 +172,26 @@ Roll.replaceFormulaData = function (formula, data = {}, { missing, warn = false
|
||||||
return nativeReplaceFormulaData(formula, data, { missing, warn });
|
return nativeReplaceFormulaData(formula, data, { missing, warn });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
foundry.dice.terms.Die.MODIFIERS.sc = "selfCorrecting";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the configured value as result if 1 is rolled
|
||||||
|
* Example: 6d6sc6 Roll 6d6, each result of 1 will be changed into 6
|
||||||
|
* @param {string} modifier The matched modifier query
|
||||||
|
*/
|
||||||
|
foundry.dice.terms.Die.prototype.selfCorrecting = function(modifier) {
|
||||||
|
const rgx = /(?:sc)([0-9]+)/i;
|
||||||
|
const match = modifier.match(rgx);
|
||||||
|
if ( !match ) return false;
|
||||||
|
let [target] = match.slice(1);
|
||||||
|
target = parseInt(target);
|
||||||
|
for ( const r of this.results ) {
|
||||||
|
if ( r.result === 1 ) {
|
||||||
|
r.result = target;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export const getDamageKey = damage => {
|
export const getDamageKey = damage => {
|
||||||
return ['none', 'minor', 'major', 'severe'][damage];
|
return ['none', 'minor', 'major', 'severe'][damage];
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
line-height: 17px;
|
line-height: 17px;
|
||||||
|
white-space: nowrap;
|
||||||
color: light-dark(@dark, @beige);
|
color: light-dark(@dark, @beige);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue