mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 03:31:07 +01:00
[Feature] 494 - Adversaries Tier 1 (#500)
* Some work * More work * Finished Tier 1
This commit is contained in:
parent
3014be79ad
commit
263dfa69ae
70 changed files with 15171 additions and 972 deletions
|
|
@ -10,10 +10,8 @@ export default class DHDamageAction extends DHBaseAction {
|
|||
|
||||
const isAdversary = this.actor.type === 'adversary';
|
||||
if (isAdversary && this.actor.system.type === CONFIG.DH.ACTOR.adversaryTypes.horde.id) {
|
||||
const hasHordeDamage = this.actor.effects.find(
|
||||
x => x.name === game.i18n.localize('DAGGERHEART.CONFIG.AdversaryType.horde.label')
|
||||
);
|
||||
if (hasHordeDamage) return part.valueAlt;
|
||||
const hasHordeDamage = this.actor.effects.find(x => x.type === 'horde');
|
||||
if (hasHordeDamage && !hasHordeDamage.disabled) return part.valueAlt;
|
||||
}
|
||||
|
||||
return formulaValue;
|
||||
|
|
@ -47,7 +45,9 @@ export default class DHDamageAction extends DHBaseAction {
|
|||
formulas = this.formatFormulas(formulas, systemData);
|
||||
|
||||
const config = {
|
||||
title: game.i18n.format(`DAGGERHEART.UI.Chat.${ this.type === 'healing' ? 'healing' : 'damage'}Roll.title`, { damage: game.i18n.localize(this.name) }),
|
||||
title: game.i18n.format(`DAGGERHEART.UI.Chat.${this.type === 'healing' ? 'healing' : 'damage'}Roll.title`, {
|
||||
damage: game.i18n.localize(this.name)
|
||||
}),
|
||||
roll: formulas,
|
||||
targets: systemData.targets?.filter(t => t.hit) ?? data.targets,
|
||||
hasSave: this.hasSave,
|
||||
|
|
|
|||
|
|
@ -1,9 +1,11 @@
|
|||
import BaseEffect from './baseEffect.mjs';
|
||||
import BeastformEffect from './beastformEffect.mjs';
|
||||
import HordeEffect from './hordeEffect.mjs';
|
||||
|
||||
export { BaseEffect, BeastformEffect };
|
||||
export { BaseEffect, BeastformEffect, HordeEffect };
|
||||
|
||||
export const config = {
|
||||
base: BaseEffect,
|
||||
beastform: BeastformEffect
|
||||
beastform: BeastformEffect,
|
||||
horde: HordeEffect
|
||||
};
|
||||
|
|
|
|||
3
module/data/activeEffect/hordeEffect.mjs
Normal file
3
module/data/activeEffect/hordeEffect.mjs
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
import BaseEffect from './baseEffect.mjs';
|
||||
|
||||
export default class HordeEffect extends BaseEffect {}
|
||||
|
|
@ -117,29 +117,46 @@ export default class DhpAdversary extends BaseDataActor {
|
|||
if (allowed === false) return false;
|
||||
|
||||
if (this.type === CONFIG.DH.ACTOR.adversaryTypes.horde.id) {
|
||||
if (changes.system?.resources?.hitPoints?.value) {
|
||||
const halfHP = Math.ceil(this.resources.hitPoints.max / 2);
|
||||
const newHitPoints = changes.system.resources.hitPoints.value;
|
||||
const previouslyAboveHalf = this.resources.hitPoints.value < halfHP;
|
||||
const loweredBelowHalf = previouslyAboveHalf && newHitPoints >= halfHP;
|
||||
const raisedAboveHalf = !previouslyAboveHalf && newHitPoints < halfHP;
|
||||
if (loweredBelowHalf) {
|
||||
await this.parent.createEmbeddedDocuments('ActiveEffect', [
|
||||
{
|
||||
name: game.i18n.localize('DAGGERHEART.CONFIG.AdversaryType.horde.label'),
|
||||
img: 'icons/magic/movement/chevrons-down-yellow.webp',
|
||||
disabled: !game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Automation)
|
||||
.hordeDamage
|
||||
}
|
||||
]);
|
||||
} else if (raisedAboveHalf) {
|
||||
const hordeEffects = this.parent.effects.filter(
|
||||
x => x.name === game.i18n.localize('DAGGERHEART.CONFIG.AdversaryType.horde.label')
|
||||
);
|
||||
await this.parent.deleteEmbeddedDocuments(
|
||||
'ActiveEffect',
|
||||
hordeEffects.map(x => x.id)
|
||||
);
|
||||
const autoHordeDamage = game.settings.get(
|
||||
CONFIG.DH.id,
|
||||
CONFIG.DH.SETTINGS.gameSettings.Automation
|
||||
).hordeDamage;
|
||||
if (autoHordeDamage && changes.system?.resources?.hitPoints?.value) {
|
||||
const hordeActiveEffect = this.parent.effects.find(x => x.type === 'horde');
|
||||
if (hordeActiveEffect) {
|
||||
const halfHP = Math.ceil(this.resources.hitPoints.max / 2);
|
||||
const newHitPoints = changes.system.resources.hitPoints.value;
|
||||
const previouslyAboveHalf = this.resources.hitPoints.value < halfHP;
|
||||
const loweredBelowHalf = previouslyAboveHalf && newHitPoints >= halfHP;
|
||||
const raisedAboveHalf = !previouslyAboveHalf && newHitPoints < halfHP;
|
||||
if (loweredBelowHalf) {
|
||||
await hordeActiveEffect.update({ disabled: false });
|
||||
} else if (raisedAboveHalf) {
|
||||
await hordeActiveEffect.update({ disabled: true });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_onUpdate(changes, options, userId) {
|
||||
super._onUpdate(changes, options, userId);
|
||||
|
||||
if (game.user.id === userId) {
|
||||
if (changes.system.type) {
|
||||
const existingHordeEffect = this.parent.effects.find(x => x.type === 'horde');
|
||||
if (changes.system.type === CONFIG.DH.ACTOR.adversaryTypes.horde.id) {
|
||||
if (!existingHordeEffect)
|
||||
this.parent.createEmbeddedDocuments('ActiveEffect', [
|
||||
{
|
||||
type: 'horde',
|
||||
name: game.i18n.localize('DAGGERHEART.CONFIG.AdversaryType.horde.label'),
|
||||
img: 'icons/magic/movement/chevrons-down-yellow.webp',
|
||||
disabled: true
|
||||
}
|
||||
]);
|
||||
} else {
|
||||
existingHordeEffect?.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue