mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-11 19:25:21 +01:00
[Feature] Become Unstoppable (#1321)
* Added implementation of unstoppable * Forgot to add the updated Unstoppable Feature itself * Added immunity for hidden and SRD additions for immunity
This commit is contained in:
parent
e6a242ba43
commit
b9508e19e8
45 changed files with 502 additions and 122 deletions
|
|
@ -10,6 +10,7 @@ export default class DamageReductionDialog extends HandlebarsApplicationMixin(Ap
|
|||
this.reject = reject;
|
||||
this.actor = actor;
|
||||
this.damage = damage;
|
||||
this.damageType = damageType;
|
||||
this.rulesDefault = game.settings.get(
|
||||
CONFIG.DH.id,
|
||||
CONFIG.DH.SETTINGS.gameSettings.Automation
|
||||
|
|
@ -57,6 +58,11 @@ export default class DamageReductionDialog extends HandlebarsApplicationMixin(Ap
|
|||
null
|
||||
);
|
||||
|
||||
this.reduceSeverity = this.damageType.reduce((value, curr) => {
|
||||
return Math.max(this.actor.system.rules.damageReduction.reduceSeverity[curr], value);
|
||||
}, 0);
|
||||
this.actor.system.rules.damageReduction.reduceSeverity[this.damageType];
|
||||
|
||||
this.thresholdImmunities = Object.keys(actor.system.rules.damageReduction.thresholdImmunities).reduce(
|
||||
(acc, key) => {
|
||||
if (actor.system.rules.damageReduction.thresholdImmunities[key])
|
||||
|
|
@ -111,7 +117,9 @@ export default class DamageReductionDialog extends HandlebarsApplicationMixin(Ap
|
|||
CONFIG.DH.GENERAL.ruleChoice.onWithToggle.id,
|
||||
CONFIG.DH.GENERAL.ruleChoice.offWithToggle.id
|
||||
].includes(this.rulesDefault);
|
||||
context.thresholdImmunities = this.thresholdImmunities;
|
||||
context.reduceSeverity = this.reduceSeverity;
|
||||
context.thresholdImmunities =
|
||||
Object.keys(this.thresholdImmunities).length > 0 ? this.thresholdImmunities : null;
|
||||
|
||||
const { selectedArmorMarks, selectedStressMarks, stressReductions, currentMarks, currentDamage } =
|
||||
this.getDamageInfo();
|
||||
|
|
@ -173,6 +181,9 @@ export default class DamageReductionDialog extends HandlebarsApplicationMixin(Ap
|
|||
this.damage - armorMarkReduction - selectedStressMarks.length - stressReductions.length,
|
||||
0
|
||||
);
|
||||
if (this.reduceSeverity) {
|
||||
currentDamage = Math.max(currentDamage - this.reduceSeverity, 0);
|
||||
}
|
||||
|
||||
if (this.thresholdImmunities[currentDamage]) currentDamage = 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -33,7 +33,10 @@ export default class DHTokenHUD extends foundry.applications.hud.TokenHUD {
|
|||
: context.canToggleCombat;
|
||||
context.systemStatusEffects = Object.keys(context.statusEffects).reduce((acc, key) => {
|
||||
const effect = context.statusEffects[key];
|
||||
if (effect.systemEffect) acc[key] = effect;
|
||||
if (effect.systemEffect) {
|
||||
const disabled = !effect.isActive && this.actor.system.rules.conditionImmunities[key];
|
||||
acc[key] = { ...effect, disabled };
|
||||
}
|
||||
|
||||
return acc;
|
||||
}, {});
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ export default class CharacterSheet extends DHBaseActorSheet {
|
|||
toggleEquipItem: CharacterSheet.#toggleEquipItem,
|
||||
toggleResourceDice: CharacterSheet.#toggleResourceDice,
|
||||
handleResourceDice: CharacterSheet.#handleResourceDice,
|
||||
advanceResourceDie: CharacterSheet.#advanceResourceDie,
|
||||
cancelBeastform: CharacterSheet.#cancelBeastform,
|
||||
useDowntime: this.useDowntime
|
||||
},
|
||||
|
|
@ -147,6 +148,10 @@ export default class CharacterSheet extends DHBaseActorSheet {
|
|||
htmlElement.querySelectorAll('.armor-marks-input').forEach(element => {
|
||||
element.addEventListener('change', this.updateArmorMarks.bind(this));
|
||||
});
|
||||
|
||||
htmlElement.querySelectorAll('.item-resource.die').forEach(element => {
|
||||
element.addEventListener('contextmenu', this.lowerResourceDie.bind(this));
|
||||
});
|
||||
}
|
||||
|
||||
/** @inheritdoc */
|
||||
|
|
@ -857,6 +862,27 @@ export default class CharacterSheet extends DHBaseActorSheet {
|
|||
});
|
||||
}
|
||||
|
||||
/** */
|
||||
static #advanceResourceDie(_, target) {
|
||||
this.updateResourceDie(target, true);
|
||||
}
|
||||
|
||||
lowerResourceDie(event) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
this.updateResourceDie(event.target, false);
|
||||
}
|
||||
|
||||
async updateResourceDie(target, advance) {
|
||||
const item = await getDocFromElement(target);
|
||||
if (!item) return;
|
||||
|
||||
const advancedValue = item.system.resource.value + (advance ? 1 : -1);
|
||||
await item.update({
|
||||
'system.resource.value': Math.min(advancedValue, Number(item.system.resource.dieFaces.split('d')[1]))
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ export default class DhTokenPlaceable extends foundry.canvas.placeables.Token {
|
|||
acc.push({
|
||||
name: game.i18n.localize(statusData.name),
|
||||
statuses: [status],
|
||||
img: statusData.icon,
|
||||
img: statusData.icon ?? statusData.img,
|
||||
tint: effect.tint
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1519,6 +1519,10 @@ export const itemResourceTypes = {
|
|||
diceValue: {
|
||||
id: 'diceValue',
|
||||
label: 'DAGGERHEART.CONFIG.ItemResourceType.diceValue'
|
||||
},
|
||||
die: {
|
||||
id: 'die',
|
||||
label: 'DAGGERHEART.CONFIG.ItemResourceType.die'
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -57,6 +57,13 @@ export default class DhpAdversary extends BaseDataActor {
|
|||
hitPoints: resourceField(0, 0, 'DAGGERHEART.GENERAL.HitPoints.plural', true),
|
||||
stress: resourceField(0, 0, 'DAGGERHEART.GENERAL.stress', true)
|
||||
}),
|
||||
rules: new fields.SchemaField({
|
||||
conditionImmunities: new fields.SchemaField({
|
||||
hidden: new fields.BooleanField({ initial: false }),
|
||||
restrained: new fields.BooleanField({ initial: false }),
|
||||
vulnerable: new fields.BooleanField({ initial: false })
|
||||
})
|
||||
}),
|
||||
attack: new ActionField({
|
||||
initial: {
|
||||
name: 'Attack',
|
||||
|
|
|
|||
|
|
@ -250,6 +250,10 @@ export default class DhCharacter extends BaseDataActor {
|
|||
thresholdImmunities: new fields.SchemaField({
|
||||
minor: new fields.BooleanField({ initial: false })
|
||||
}),
|
||||
reduceSeverity: new fields.SchemaField({
|
||||
magical: new fields.NumberField({ initial: 0, min: 0 }),
|
||||
physical: new fields.NumberField({ initial: 0, min: 0 })
|
||||
}),
|
||||
disabledArmor: new fields.BooleanField({ intial: false })
|
||||
}),
|
||||
attack: new fields.SchemaField({
|
||||
|
|
@ -279,6 +283,11 @@ export default class DhCharacter extends BaseDataActor {
|
|||
})
|
||||
})
|
||||
}),
|
||||
conditionImmunities: new fields.SchemaField({
|
||||
hidden: new fields.BooleanField({ initial: false }),
|
||||
restrained: new fields.BooleanField({ initial: false }),
|
||||
vulnerable: new fields.BooleanField({ initial: false })
|
||||
}),
|
||||
runeWard: new fields.BooleanField({ initial: false }),
|
||||
burden: new fields.SchemaField({
|
||||
ignore: new fields.BooleanField()
|
||||
|
|
|
|||
|
|
@ -51,6 +51,13 @@ export default class DhCompanion extends BaseDataActor {
|
|||
}
|
||||
}
|
||||
),
|
||||
rules: new fields.SchemaField({
|
||||
conditionImmunities: new fields.SchemaField({
|
||||
hidden: new fields.BooleanField({ initial: false }),
|
||||
restrained: new fields.BooleanField({ initial: false }),
|
||||
vulnerable: new fields.BooleanField({ initial: false })
|
||||
})
|
||||
}),
|
||||
attack: new ActionField({
|
||||
initial: {
|
||||
name: 'Attack',
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ export default class EffectsField extends fields.ArrayField {
|
|||
static async applyEffects(targets) {
|
||||
if (!this.effects?.length || !targets?.length) return;
|
||||
|
||||
const conditions = CONFIG.DH.GENERAL.conditions();
|
||||
let effects = this.effects;
|
||||
const messageTargets = [];
|
||||
targets.forEach(async baseToken => {
|
||||
|
|
@ -56,7 +57,20 @@ export default class EffectsField extends fields.ArrayField {
|
|||
const token =
|
||||
canvas.tokens.get(baseToken.id) ?? foundry.utils.fromUuidSync(baseToken.actorId).prototypeToken;
|
||||
if (!token) return;
|
||||
messageTargets.push(token.document ?? token);
|
||||
|
||||
const messageToken = token.document ?? token;
|
||||
const conditionImmunities = messageToken.actor.system.rules.conditionImmunities ?? {};
|
||||
messageTargets.push({
|
||||
token: messageToken,
|
||||
conditionImmunities: Object.values(conditionImmunities).some(x => x)
|
||||
? game.i18n.format('DAGGERHEART.UI.Chat.effectSummary.immunityTo', {
|
||||
immunities: Object.keys(conditionImmunities)
|
||||
.filter(x => conditionImmunities[x])
|
||||
.map(x => game.i18n.localize(conditions[x].name))
|
||||
.join(', ')
|
||||
})
|
||||
: null
|
||||
});
|
||||
|
||||
effects.forEach(async e => {
|
||||
const effect = this.item.effects.get(e._id);
|
||||
|
|
|
|||
|
|
@ -57,6 +57,27 @@ export default class DhActiveEffect extends foundry.documents.ActiveEffect {
|
|||
update.img = 'icons/magic/life/heart-cross-blue.webp';
|
||||
}
|
||||
|
||||
const immuneStatuses =
|
||||
data.statuses?.filter(
|
||||
status =>
|
||||
this.parent.system.rules?.conditionImmunities &&
|
||||
this.parent.system.rules.conditionImmunities[status]
|
||||
) ?? [];
|
||||
if (immuneStatuses.length > 0) {
|
||||
update.statuses = data.statuses.filter(x => !immuneStatuses.includes(x));
|
||||
const conditions = CONFIG.DH.GENERAL.conditions();
|
||||
const scrollingTexts = immuneStatuses.map(status => ({
|
||||
text: game.i18n.format('DAGGERHEART.ACTIVEEFFECT.immuneStatusText', {
|
||||
status: game.i18n.localize(conditions[status].name)
|
||||
})
|
||||
}));
|
||||
if (update.statuses.length > 0) {
|
||||
setTimeout(() => scrollingTexts, 500);
|
||||
} else {
|
||||
this.parent.queueScrollText(scrollingTexts);
|
||||
}
|
||||
}
|
||||
|
||||
if (Object.keys(update).length > 0) {
|
||||
await this.updateSource(update);
|
||||
}
|
||||
|
|
@ -76,7 +97,10 @@ export default class DhActiveEffect extends foundry.documents.ActiveEffect {
|
|||
change.value = change.value.replaceAll(/origin\.@/gi, '@');
|
||||
try {
|
||||
const effect = foundry.utils.fromUuidSync(change.effect.origin);
|
||||
const doc = effect.parent?.parent;
|
||||
const doc =
|
||||
effect.parent?.parent instanceof game.system.api.documents.DhpActor
|
||||
? effect.parent
|
||||
: effect.parent.parent;
|
||||
if (doc) parseModel = doc;
|
||||
} catch (_) {}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,10 @@ export const preloadHandlebarsTemplates = async function () {
|
|||
'systems/daggerheart/templates/sheets/global/partials/action-item.hbs',
|
||||
'systems/daggerheart/templates/sheets/global/partials/domain-card-item.hbs',
|
||||
'systems/daggerheart/templates/sheets/global/partials/item-resource.hbs',
|
||||
'systems/daggerheart/templates/sheets/global/partials/resource-section.hbs',
|
||||
'systems/daggerheart/templates/sheets/global/partials/resource-section/resource-section.hbs',
|
||||
'systems/daggerheart/templates/sheets/global/partials/resource-section/simple.hbs',
|
||||
'systems/daggerheart/templates/sheets/global/partials/resource-section/dice-value.hbs',
|
||||
'systems/daggerheart/templates/sheets/global/partials/resource-section/die.hbs',
|
||||
'systems/daggerheart/templates/sheets/global/partials/resource-bar.hbs',
|
||||
'systems/daggerheart/templates/components/card-preview.hbs',
|
||||
'systems/daggerheart/templates/levelup/parts/selectable-card-preview.hbs',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue