mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 11:41:08 +01:00
Merged with development
This commit is contained in:
commit
bd76e22e8d
1096 changed files with 11080 additions and 5102 deletions
|
|
@ -1,10 +1,13 @@
|
|||
import { emitAsGM, GMUpdateEvent } from '../systemRegistration/socket.mjs';
|
||||
import { LevelOptionType } from '../data/levelTier.mjs';
|
||||
import DHFeature from '../data/item/feature.mjs';
|
||||
import { damageKeyToNumber } from '../helpers/utils.mjs';
|
||||
import { createScrollText, damageKeyToNumber, versionCompare } from '../helpers/utils.mjs';
|
||||
import DhCompanionLevelUp from '../applications/levelup/companionLevelup.mjs';
|
||||
|
||||
export default class DhpActor extends Actor {
|
||||
#scrollTextQueue = [];
|
||||
#scrollTextInterval;
|
||||
|
||||
/**
|
||||
* Return the first Actor active owner.
|
||||
*/
|
||||
|
|
@ -27,7 +30,7 @@ export default class DhpActor extends Actor {
|
|||
|
||||
/** @inheritDoc */
|
||||
static migrateData(source) {
|
||||
if(source.system?.attack && !source.system.attack.type) source.system.attack.type = "attack";
|
||||
if (source.system?.attack && !source.system.attack.type) source.system.attack.type = 'attack';
|
||||
return super.migrateData(source);
|
||||
}
|
||||
|
||||
|
|
@ -572,19 +575,15 @@ export default class DhpActor extends Actor {
|
|||
if (armorSlotResult) {
|
||||
const { modifiedDamage, armorSpent, stressSpent } = armorSlotResult;
|
||||
updates.find(u => u.key === 'hitPoints').value = modifiedDamage;
|
||||
if(armorSpent) {
|
||||
if (armorSpent) {
|
||||
const armorUpdate = updates.find(u => u.key === 'armor');
|
||||
if(armorUpdate)
|
||||
armorUpdate.value += armorSpent;
|
||||
else
|
||||
updates.push({ value: armorSpent, key: 'armor' });
|
||||
if (armorUpdate) armorUpdate.value += armorSpent;
|
||||
else updates.push({ value: armorSpent, key: 'armor' });
|
||||
}
|
||||
if(stressSpent) {
|
||||
if (stressSpent) {
|
||||
const stressUpdate = updates.find(u => u.key === 'stress');
|
||||
if(stressUpdate)
|
||||
stressUpdate.value += stressSpent;
|
||||
else
|
||||
updates.push({ value: stressSpent, key: 'stress' });
|
||||
if (stressUpdate) stressUpdate.value += stressSpent;
|
||||
else updates.push({ value: stressSpent, key: 'stress' });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -754,4 +753,45 @@ export default class DhpActor extends Actor {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
queueScrollText(scrollingTextData) {
|
||||
this.#scrollTextQueue.push(...scrollingTextData.map(data => () => createScrollText(this, data)));
|
||||
if (!this.#scrollTextInterval) {
|
||||
const scrollFunc = this.#scrollTextQueue.pop();
|
||||
scrollFunc?.();
|
||||
|
||||
const intervalFunc = () => {
|
||||
const scrollFunc = this.#scrollTextQueue.pop();
|
||||
scrollFunc?.();
|
||||
if (this.#scrollTextQueue.length === 0) {
|
||||
clearInterval(this.#scrollTextInterval);
|
||||
this.#scrollTextInterval = null;
|
||||
}
|
||||
};
|
||||
|
||||
this.#scrollTextInterval = setInterval(intervalFunc.bind(this), 600);
|
||||
}
|
||||
}
|
||||
|
||||
/** @inheritdoc */
|
||||
async importFromJSON(json) {
|
||||
if (!this.type === 'character') return await super.importFromJSON(json);
|
||||
|
||||
if (!CONST.WORLD_DOCUMENT_TYPES.includes(this.documentName)) {
|
||||
throw new Error('Only world Documents may be imported');
|
||||
}
|
||||
|
||||
const parsedJSON = JSON.parse(json);
|
||||
if (versionCompare(parsedJSON._stats.systemVersion, '1.1.0')) {
|
||||
const confirmed = await foundry.applications.api.DialogV2.confirm({
|
||||
window: {
|
||||
title: game.i18n.localize('DAGGERHEART.ACTORS.Character.InvalidOldCharacterImportTitle')
|
||||
},
|
||||
content: game.i18n.localize('DAGGERHEART.ACTORS.Character.InvalidOldCharacterImportText')
|
||||
});
|
||||
if (!confirmed) return;
|
||||
}
|
||||
|
||||
return await super.importFromJSON(json);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,10 @@ export default class DhpChatMessage extends foundry.documents.ChatMessage {
|
|||
/* We can change to fully implementing the renderHTML function if needed, instead of augmenting it. */
|
||||
const html = await super.renderHTML({ actor: actorData, author: this.author });
|
||||
|
||||
if (this.flags.core?.RollTable) {
|
||||
html.querySelector('.roll-buttons.apply-buttons').remove();
|
||||
}
|
||||
|
||||
this.enrichChatMessage(html);
|
||||
this.addChatListeners(html);
|
||||
|
||||
|
|
@ -43,6 +47,18 @@ export default class DhpChatMessage extends foundry.documents.ChatMessage {
|
|||
return super._preDelete(options, user);
|
||||
}
|
||||
|
||||
/** @inheritDoc */
|
||||
_onUpdate(changes, options, userId) {
|
||||
super._onUpdate(changes, options, userId);
|
||||
|
||||
const lastMessage = Array.from(game.messages).sort((a, b) => b.timestamp - a.timestamp)[0];
|
||||
if (lastMessage.id === this.id && ui.chat.isAtBottom) {
|
||||
setTimeout(() => {
|
||||
ui.chat.scrollBottom();
|
||||
}, 5);
|
||||
}
|
||||
}
|
||||
|
||||
enrichChatMessage(html) {
|
||||
const elements = html.querySelectorAll('[data-perm-id]');
|
||||
elements.forEach(e => {
|
||||
|
|
@ -55,7 +71,7 @@ export default class DhpChatMessage extends foundry.documents.ChatMessage {
|
|||
});
|
||||
|
||||
if (this.isContentVisible) {
|
||||
if(this.type === 'dualityRoll') {
|
||||
if (this.type === 'dualityRoll') {
|
||||
html.classList.add('duality');
|
||||
switch (this.system.roll?.result?.duality) {
|
||||
case 1:
|
||||
|
|
@ -70,27 +86,28 @@ export default class DhpChatMessage extends foundry.documents.ChatMessage {
|
|||
}
|
||||
}
|
||||
|
||||
const autoExpandRoll = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.appearance).expandRollMessage,
|
||||
rollSections = html.querySelectorAll(".roll-part"),
|
||||
itemDesc = html.querySelector(".domain-card-move");
|
||||
const autoExpandRoll = game.settings.get(
|
||||
CONFIG.DH.id,
|
||||
CONFIG.DH.SETTINGS.gameSettings.appearance
|
||||
).expandRollMessage,
|
||||
rollSections = html.querySelectorAll('.roll-part'),
|
||||
itemDesc = html.querySelector('.domain-card-move');
|
||||
rollSections.forEach(s => {
|
||||
if(s.classList.contains("roll-section")) {
|
||||
if (s.classList.contains('roll-section')) {
|
||||
const toExpand = s.querySelector('[data-action="expandRoll"]');
|
||||
toExpand.classList.toggle("expanded", autoExpandRoll.roll);
|
||||
} else if(s.classList.contains("damage-section"))
|
||||
s.classList.toggle("expanded", autoExpandRoll.damage);
|
||||
else if(s.classList.contains("target-section"))
|
||||
s.classList.toggle("expanded", autoExpandRoll.target);
|
||||
toExpand.classList.toggle('expanded', autoExpandRoll.roll);
|
||||
} else if (s.classList.contains('damage-section'))
|
||||
s.classList.toggle('expanded', autoExpandRoll.damage);
|
||||
else if (s.classList.contains('target-section')) s.classList.toggle('expanded', autoExpandRoll.target);
|
||||
});
|
||||
if(itemDesc && autoExpandRoll.desc)
|
||||
itemDesc.setAttribute("open", "");
|
||||
if (itemDesc && autoExpandRoll.desc) itemDesc.setAttribute('open', '');
|
||||
}
|
||||
|
||||
if(!game.user.isGM) {
|
||||
const applyButtons = html.querySelector(".apply-buttons");
|
||||
|
||||
if (!game.user.isGM) {
|
||||
const applyButtons = html.querySelector('.apply-buttons');
|
||||
applyButtons?.remove();
|
||||
if(!this.isAuthor && !this.speakerActor?.isOwner) {
|
||||
const buttons = html.querySelectorAll(".ability-card-footer > .ability-use-button");
|
||||
if (!this.isAuthor && !this.speakerActor?.isOwner) {
|
||||
const buttons = html.querySelectorAll('.ability-card-footer > .ability-use-button');
|
||||
buttons.forEach(b => b.remove());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,6 +28,14 @@ export default class DHItem extends foundry.documents.Item {
|
|||
return doc;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
||||
/** @inheritDoc */
|
||||
static migrateData(source) {
|
||||
if (source.system?.attack && !source.system.attack.type) source.system.attack.type = 'attack';
|
||||
return super.migrateData(source);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
* @param {object} options - Options which modify the getRollData method.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue