[Feature] Beastform Types (#372)

* Temp

* Finished Evolved

* Fixed hybrid

* Changed generalConfig.tiers to be number based

* Weaponhandling while in beastform

* Added unarmed strike in sidebar

* Added DamageEnricher

* Added effect enricher

* Corrected downtime buttons and actions

* Added BeastformTooltip

* Split the BeastformDialog into parts with tabs

* Added temp beastform features

* rollData change

* Improvement

* character.getRollData cleanup
This commit is contained in:
WBHarry 2025-07-20 21:56:22 +02:00 committed by GitHub
parent 867947c2c5
commit 42a705a870
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
93 changed files with 2795 additions and 538 deletions

View file

@ -92,7 +92,7 @@ export default class D20Roll extends DHRoll {
configureModifiers() {
this.applyAdvantage();
this.baseTerms = foundry.utils.deepClone(this.dice);
this.options.roll.modifiers = this.applyBaseBonus();
@ -147,8 +147,7 @@ export default class D20Roll extends DHRoll {
const difficulty = config.roll.difficulty ?? target.difficulty ?? target.evasion;
target.hit = this.isCritical || roll.total >= difficulty;
});
} else if (config.roll.difficulty)
data.success = roll.isCritical || roll.total >= config.roll.difficulty;
} else if (config.roll.difficulty) data.success = roll.isCritical || roll.total >= config.roll.difficulty;
data.advantage = {
type: config.roll.advantage,
dice: roll.dAdvantage?.denomination,

View file

@ -11,8 +11,8 @@ export default class DamageRoll extends DHRoll {
static DefaultDialog = DamageDialog;
static async buildEvaluate(roll, config = {}, message = {}) {
if ( config.evaluate !== false ) {
for ( const roll of config.roll ) await roll.roll.evaluate();
if (config.evaluate !== false) {
for (const roll of config.roll) await roll.roll.evaluate();
}
roll._evaluated = true;
const parts = config.roll.map(r => this.postEvaluate(r));
@ -27,7 +27,7 @@ export default class DamageRoll extends DHRoll {
roll: roll.roll,
type: config.type,
modifierTotal: this.calculateTotalModifiers(roll.roll)
}
};
}
static async buildPost(roll, config, message) {
@ -46,33 +46,33 @@ export default class DamageRoll extends DHRoll {
resource.total += r.total;
resource.parts.push(r);
unified[r.applyTo] = resource;
})
});
return unified;
}
static formatGlobal(rolls) {
let formula, total;
const applyTo = new Set(rolls.flatMap(r => r.applyTo));
if(applyTo.size > 1) {
if (applyTo.size > 1) {
const data = {};
rolls.forEach(r => {
if(data[r.applyTo]) {
data[r.applyTo].formula += ` + ${r.formula}` ;
data[r.applyTo].total += r.total ;
if (data[r.applyTo]) {
data[r.applyTo].formula += ` + ${r.formula}`;
data[r.applyTo].total += r.total;
} else {
data[r.applyTo] = {
formula: r.formula,
total: r.total
}
};
}
});
formula = Object.entries(data).reduce((a, [k,v]) => a + ` ${k}: ${v.formula}`, '');
total = Object.entries(data).reduce((a, [k,v]) => a + ` ${k}: ${v.total}`, '');
formula = Object.entries(data).reduce((a, [k, v]) => a + ` ${k}: ${v.formula}`, '');
total = Object.entries(data).reduce((a, [k, v]) => a + ` ${k}: ${v.total}`, '');
} else {
formula = rolls.map(r => r.formula).join(' + ');
total = rolls.reduce((a,c) => a + c.total, 0)
total = rolls.reduce((a, c) => a + c.total, 0);
}
return {formula, total}
return { formula, total };
}
applyBaseBonus(part) {
@ -94,17 +94,17 @@ export default class DamageRoll extends DHRoll {
}
constructFormula(config) {
this.options.roll.forEach( part => {
part.roll = new Roll(part.formula);
this.constructFormulaPart(config, part)
})
this.options.roll.forEach(part => {
part.roll = new Roll(Roll.replaceFormulaData(part.formula, config.data));
this.constructFormulaPart(config, part);
});
return this.options.roll;
}
constructFormulaPart(config, part) {
part.roll.terms = Roll.parse(part.roll.formula, config.data);
if(part.applyTo === CONFIG.DH.GENERAL.healingTypes.hitPoints.id) {
if (part.applyTo === CONFIG.DH.GENERAL.healingTypes.hitPoints.id) {
part.modifiers = this.applyBaseBonus(part);
this.addModifiers(part);
part.modifiers?.forEach(m => {
@ -118,7 +118,7 @@ export default class DamageRoll extends DHRoll {
...this.constructor.parse(part.extraFormula, this.options.data)
);
}
if (config.isCritical && part.applyTo === CONFIG.DH.GENERAL.healingTypes.hitPoints.id) {
const tmpRoll = Roll.fromTerms(part.roll.terms)._evaluateSync({ maximize: true }),
criticalBonus = tmpRoll.total - this.constructor.calculateTotalModifiers(tmpRoll);

View file

@ -57,13 +57,14 @@ export default class DHRoll extends Roll {
// Create Chat Message
if (config.source?.message) {
if(Object.values(config.roll)?.length) {
const pool = foundry.dice.terms.PoolTerm.fromRolls(Object.values(config.roll).flatMap(r => r.parts.map(p => p.roll)));
if (Object.values(config.roll)?.length) {
const pool = foundry.dice.terms.PoolTerm.fromRolls(
Object.values(config.roll).flatMap(r => r.parts.map(p => p.roll))
);
roll = Roll.fromTerms([pool]);
}
if (game.modules.get('dice-so-nice')?.active) await game.dice3d.showForRoll(roll, game.user, true);
} else
config.message = await this.toMessage(roll, config);
} else config.message = await this.toMessage(roll, config);
}
static postEvaluate(roll, config = {}) {
@ -76,7 +77,7 @@ export default class DHRoll extends Roll {
formula: d.formula,
results: d.results
}))
}
};
}
static async toMessage(roll, config) {

View file

@ -63,24 +63,22 @@ export default class DualityRoll extends D20Roll {
}
setRallyChoices() {
return this.data?.parent?.effects.reduce((a,c) => {
const change = c.changes.find(ch => ch.key === 'system.bonuses.rally');
if(change) a.push({ value: c.id, label: change.value });
return a;
}, []);
return this.data?.parent?.effects.reduce((a, c) => {
const change = c.changes.find(ch => ch.key === 'system.bonuses.rally');
if (change) a.push({ value: c.id, label: change.value });
return a;
}, []);
}
get dRally() {
if(!this.rallyFaces) return null;
if(this.hasDisadvantage || this.hasAdvantage)
return this.dice[3];
else
return this.dice[2];
if (!this.rallyFaces) return null;
if (this.hasDisadvantage || this.hasAdvantage) return this.dice[3];
else return this.dice[2];
}
get rallyFaces() {
const rallyChoice = this.rallyChoices?.find(r => r.value === this._rallyIndex)?.label;
return rallyChoice ? this.getFaces(rallyChoice) : null;
return rallyChoice ? this.getFaces(rallyChoice) : null;
}
get isCritical() {
@ -129,13 +127,13 @@ export default class DualityRoll extends D20Roll {
if (this.hasAdvantage || this.hasDisadvantage) {
const dieFaces = this.advantageFaces,
advDie = new foundry.dice.terms.Die({ faces: dieFaces, number: this.advantageNumber });
if(this.advantageNumber > 1) advDie.modifiers = ['kh'];
if (this.advantageNumber > 1) advDie.modifiers = ['kh'];
this.terms.push(
new foundry.dice.terms.OperatorTerm({ operator: this.hasDisadvantage ? '-' : '+' }),
advDie
);
}
if(this.rallyFaces)
if (this.rallyFaces)
this.terms.push(
new foundry.dice.terms.OperatorTerm({ operator: this.hasDisadvantage ? '-' : '+' }),
new foundry.dice.terms.Die({ faces: this.rallyFaces })
@ -162,7 +160,7 @@ export default class DualityRoll extends D20Roll {
static postEvaluate(roll, config = {}) {
const data = super.postEvaluate(roll, config);
data.hope = {
dice: roll.dHope.denomination,
value: roll.dHope.total
@ -181,7 +179,7 @@ export default class DualityRoll extends D20Roll {
label: roll.totalLabel
};
if(roll._rallyIndex && roll.data?.parent)
if (roll._rallyIndex && roll.data?.parent)
roll.data.parent.deleteEmbeddedDocuments('ActiveEffect', [roll._rallyIndex]);
setDiceSoNiceForDualityRoll(roll, data.advantage.type);