mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 03:31:07 +01:00
Merge branch 'main' into feature/313-preset-measured-templates
This commit is contained in:
commit
7d2de14709
81 changed files with 611 additions and 446 deletions
|
|
@ -178,10 +178,17 @@ export default class DhpDowntime extends HandlebarsApplicationMixin(ApplicationV
|
|||
}
|
||||
|
||||
static async takeDowntime() {
|
||||
const moves = Object.values(this.moveData).flatMap(category => {
|
||||
return Object.values(category.moves)
|
||||
.filter(x => x.selected)
|
||||
.flatMap(move => [...Array(move.selected).keys()].map(_ => move));
|
||||
const moves = Object.keys(this.moveData).flatMap(categoryKey => {
|
||||
const category = this.moveData[categoryKey];
|
||||
return Object.keys(category.moves)
|
||||
.filter(x => category.moves[x].selected)
|
||||
.flatMap(key => {
|
||||
const move = category.moves[key];
|
||||
return [...Array(move.selected).keys()].map(_ => ({
|
||||
...move,
|
||||
movePath: `${categoryKey}.moves.${key}`
|
||||
}));
|
||||
});
|
||||
});
|
||||
|
||||
const cls = getDocumentClass('ChatMessage');
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ export default class ImageSelectDialog extends HandlebarsApplicationMixin(Applic
|
|||
tag: 'form',
|
||||
classes: ['daggerheart', 'dialog', 'dh-style', 'image-select'],
|
||||
position: {
|
||||
width: 600,
|
||||
width: 612,
|
||||
height: 'auto'
|
||||
},
|
||||
window: {
|
||||
|
|
@ -30,7 +30,10 @@ export default class ImageSelectDialog extends HandlebarsApplicationMixin(Applic
|
|||
|
||||
/** @override */
|
||||
static PARTS = {
|
||||
main: { template: 'systems/daggerheart/templates/dialogs/image-select/main.hbs' },
|
||||
main: {
|
||||
template: 'systems/daggerheart/templates/dialogs/image-select/main.hbs',
|
||||
scrollable: ['.images-container']
|
||||
},
|
||||
footer: { template: 'systems/daggerheart/templates/dialogs/image-select/footer.hbs' }
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ export default class DhActiveEffectConfig extends foundry.applications.sheets.Ac
|
|||
CONFIG.DH.SETTINGS.gameSettings.appearance
|
||||
).showGenericStatusEffects;
|
||||
if (!useGeneric) {
|
||||
partContext.statuses = Object.values(CONFIG.DH.GENERAL.conditions).map(status => ({
|
||||
partContext.statuses = Object.values(CONFIG.DH.GENERAL.conditions()).map(status => ({
|
||||
value: status.id,
|
||||
label: game.i18n.localize(status.name)
|
||||
}));
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ export default class CharacterSheet extends DHBaseActorSheet {
|
|||
toggleEquipItem: CharacterSheet.#toggleEquipItem,
|
||||
toggleResourceDice: CharacterSheet.#toggleResourceDice,
|
||||
handleResourceDice: CharacterSheet.#handleResourceDice,
|
||||
cancelBeastform: CharacterSheet.#cancelBeastform,
|
||||
useDowntime: this.useDowntime
|
||||
},
|
||||
window: {
|
||||
|
|
@ -209,24 +210,33 @@ export default class CharacterSheet extends DHBaseActorSheet {
|
|||
context.resources.stress.emptyPips =
|
||||
context.resources.stress.max < maxResource ? maxResource - context.resources.stress.max : 0;
|
||||
|
||||
context.inventory = {
|
||||
currency: {
|
||||
title: game.i18n.localize('DAGGERHEART.CONFIG.Gold.title'),
|
||||
coins: game.i18n.localize('DAGGERHEART.CONFIG.Gold.coins'),
|
||||
handfuls: game.i18n.localize('DAGGERHEART.CONFIG.Gold.handfuls'),
|
||||
bags: game.i18n.localize('DAGGERHEART.CONFIG.Gold.bags'),
|
||||
chests: game.i18n.localize('DAGGERHEART.CONFIG.Gold.chests')
|
||||
}
|
||||
};
|
||||
|
||||
const homebrewCurrency = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Homebrew).currency;
|
||||
if (homebrewCurrency.enabled) {
|
||||
context.inventory.currency = homebrewCurrency;
|
||||
context.inventory = { currencies: {} };
|
||||
const { title, ...currencies } = game.settings.get(
|
||||
CONFIG.DH.id,
|
||||
CONFIG.DH.SETTINGS.gameSettings.Homebrew
|
||||
).currency;
|
||||
for (let key in currencies) {
|
||||
context.inventory.currencies[key] = {
|
||||
...currencies[key],
|
||||
field: context.systemFields.gold.fields[key],
|
||||
value: context.source.system.gold[key]
|
||||
};
|
||||
}
|
||||
// context.inventory = {
|
||||
// currency: {
|
||||
// title: game.i18n.localize('DAGGERHEART.CONFIG.Gold.title'),
|
||||
// coins: game.i18n.localize('DAGGERHEART.CONFIG.Gold.coins'),
|
||||
// handfuls: game.i18n.localize('DAGGERHEART.CONFIG.Gold.handfuls'),
|
||||
// bags: game.i18n.localize('DAGGERHEART.CONFIG.Gold.bags'),
|
||||
// chests: game.i18n.localize('DAGGERHEART.CONFIG.Gold.chests')
|
||||
// }
|
||||
// };
|
||||
|
||||
if (context.inventory.length === 0) {
|
||||
context.inventory = Array(1).fill(Array(5).fill([]));
|
||||
}
|
||||
context.beastformActive = this.document.effects.find(x => x.type === 'beastform');
|
||||
|
||||
// if (context.inventory.length === 0) {
|
||||
// context.inventory = Array(1).fill(Array(5).fill([]));
|
||||
// }
|
||||
|
||||
return context;
|
||||
}
|
||||
|
|
@ -848,6 +858,15 @@ export default class CharacterSheet extends DHBaseActorSheet {
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
static async #cancelBeastform(_, target) {
|
||||
const item = await getDocFromElement(target);
|
||||
if (!item) return;
|
||||
game.system.api.fields.ActionFields.BeastformField.handleActiveTransformations.call(item);
|
||||
}
|
||||
|
||||
/**
|
||||
* Open the downtime application.
|
||||
* @type {ApplicationClickAction}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import { socketEvent } from '../../../systemRegistration/socket.mjs';
|
|||
import GroupRollDialog from '../../dialogs/group-roll-dialog.mjs';
|
||||
import DhpActor from '../../../documents/actor.mjs';
|
||||
import DHItem from '../../../documents/item.mjs';
|
||||
import DhParty from '../../../data/actor/party.mjs';
|
||||
|
||||
export default class Party extends DHBaseActorSheet {
|
||||
constructor(options) {
|
||||
|
|
@ -19,7 +20,8 @@ export default class Party extends DHBaseActorSheet {
|
|||
static DEFAULT_OPTIONS = {
|
||||
classes: ['party'],
|
||||
position: {
|
||||
width: 550
|
||||
width: 550,
|
||||
height: 900,
|
||||
},
|
||||
window: {
|
||||
resizable: true
|
||||
|
|
@ -79,6 +81,9 @@ export default class Party extends DHBaseActorSheet {
|
|||
}
|
||||
};
|
||||
|
||||
static ALLOWED_ACTOR_TYPES = ['character', 'companion', 'adversary'];
|
||||
static DICE_ROLL_ACTOR_TYPES = ['character'];
|
||||
|
||||
async _onRender(context, options) {
|
||||
await super._onRender(context, options);
|
||||
this._createFilterMenus();
|
||||
|
|
@ -92,23 +97,17 @@ export default class Party extends DHBaseActorSheet {
|
|||
async _prepareContext(_options) {
|
||||
const context = await super._prepareContext(_options);
|
||||
|
||||
context.inventory = {
|
||||
currency: {
|
||||
title: game.i18n.localize('DAGGERHEART.CONFIG.Gold.title'),
|
||||
coins: game.i18n.localize('DAGGERHEART.CONFIG.Gold.coins'),
|
||||
handfuls: game.i18n.localize('DAGGERHEART.CONFIG.Gold.handfuls'),
|
||||
bags: game.i18n.localize('DAGGERHEART.CONFIG.Gold.bags'),
|
||||
chests: game.i18n.localize('DAGGERHEART.CONFIG.Gold.chests')
|
||||
}
|
||||
};
|
||||
|
||||
const homebrewCurrency = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Homebrew).currency;
|
||||
if (homebrewCurrency.enabled) {
|
||||
context.inventory.currency = homebrewCurrency;
|
||||
}
|
||||
|
||||
if (context.inventory.length === 0) {
|
||||
context.inventory = Array(1).fill(Array(5).fill([]));
|
||||
context.inventory = { currencies: {} };
|
||||
const { title, ...currencies } = game.settings.get(
|
||||
CONFIG.DH.id,
|
||||
CONFIG.DH.SETTINGS.gameSettings.Homebrew
|
||||
).currency;
|
||||
for (let key in currencies) {
|
||||
context.inventory.currencies[key] = {
|
||||
...currencies[key],
|
||||
field: context.systemFields.gold.fields[key],
|
||||
value: context.source.system.gold[key]
|
||||
};
|
||||
}
|
||||
|
||||
return context;
|
||||
|
|
@ -277,13 +276,17 @@ export default class Party extends DHBaseActorSheet {
|
|||
}
|
||||
|
||||
static async #tagTeamRoll() {
|
||||
new game.system.api.applications.dialogs.TagTeamDialog(this.document.system.partyMembers).render({
|
||||
new game.system.api.applications.dialogs.TagTeamDialog(
|
||||
this.document.system.partyMembers.filter(x => Party.DICE_ROLL_ACTOR_TYPES.includes(x.type))
|
||||
).render({
|
||||
force: true
|
||||
});
|
||||
}
|
||||
|
||||
static async #groupRoll(params) {
|
||||
new GroupRollDialog(this.document.system.partyMembers).render({ force: true });
|
||||
static async #groupRoll(_params) {
|
||||
new GroupRollDialog(
|
||||
this.document.system.partyMembers.filter(x => Party.DICE_ROLL_ACTOR_TYPES.includes(x.type))
|
||||
).render({ force: true });
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -453,17 +456,17 @@ export default class Party extends DHBaseActorSheet {
|
|||
event.stopPropagation();
|
||||
|
||||
const data = foundry.applications.ux.TextEditor.implementation.getDragEventData(event);
|
||||
const item = await foundry.utils.fromUuid(data.uuid);
|
||||
const document = await foundry.utils.fromUuid(data.uuid);
|
||||
|
||||
if (item instanceof DhpActor) {
|
||||
if (document instanceof DhpActor && Party.ALLOWED_ACTOR_TYPES.includes(document.type)) {
|
||||
const currentMembers = this.document.system.partyMembers.map(x => x.uuid);
|
||||
if (currentMembers.includes(data.uuid)) {
|
||||
return ui.notifications.warn(game.i18n.localize('DAGGERHEART.UI.Notifications.duplicateCharacter'));
|
||||
}
|
||||
|
||||
await this.document.update({ 'system.partyMembers': [...currentMembers, item.uuid] });
|
||||
} else if (item instanceof DHItem) {
|
||||
this.document.createEmbeddedDocuments('Item', [item.toObject()]);
|
||||
await this.document.update({ 'system.partyMembers': [...currentMembers, document.uuid] });
|
||||
} else if (document instanceof DHItem) {
|
||||
this.document.createEmbeddedDocuments('Item', [document.toObject()]);
|
||||
} else {
|
||||
ui.notifications.warn(game.i18n.localize('DAGGERHEART.UI.Notifications.onlyCharactersInPartySheet'));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -420,19 +420,6 @@ export default function DHApplicationMixin(Base) {
|
|||
];
|
||||
|
||||
if (usable) {
|
||||
options.unshift({
|
||||
name: 'DAGGERHEART.APPLICATIONS.ContextMenu.cancelBeastform',
|
||||
icon: 'fa-solid fa-ban',
|
||||
condition: target => {
|
||||
const doc = getDocFromElementSync(target);
|
||||
return doc && doc.system?.actions?.some(a => a.type === 'beastform');
|
||||
},
|
||||
callback: async target =>
|
||||
game.system.api.fields.ActionFields.BeastformField.handleActiveTransformations.call(
|
||||
await getDocFromElement(target)
|
||||
)
|
||||
});
|
||||
|
||||
options.unshift({
|
||||
name: 'DAGGERHEART.GENERAL.damage',
|
||||
icon: 'fa-solid fa-explosion',
|
||||
|
|
|
|||
|
|
@ -132,12 +132,21 @@ export default class DhpChatLog extends foundry.applications.sidebar.tabs.ChatLo
|
|||
}
|
||||
|
||||
async actionUseButton(event, message) {
|
||||
const { moveIndex, actionIndex } = event.currentTarget.dataset;
|
||||
const { moveIndex, actionIndex, movePath } = event.currentTarget.dataset;
|
||||
const parent = await foundry.utils.fromUuid(message.system.actor);
|
||||
const actionType = message.system.moves[moveIndex].actions[actionIndex];
|
||||
const cls = game.system.api.models.actions.actionsTypes[actionType.type];
|
||||
const action = new cls(
|
||||
{ ...actionType, _id: foundry.utils.randomID(), name: game.i18n.localize(actionType.name) },
|
||||
{
|
||||
...actionType,
|
||||
_id: foundry.utils.randomID(),
|
||||
name: game.i18n.localize(actionType.name),
|
||||
originItem: {
|
||||
type: CONFIG.DH.ITEM.originItemType.restMove,
|
||||
itemPath: movePath,
|
||||
actionIndex: actionIndex
|
||||
}
|
||||
},
|
||||
{ parent: parent.system }
|
||||
);
|
||||
|
||||
|
|
@ -192,9 +201,18 @@ export default class DhpChatLog extends foundry.applications.sidebar.tabs.ChatLo
|
|||
|
||||
async groupRollButton(event, message) {
|
||||
const path = event.currentTarget.dataset.path;
|
||||
const isLeader = path === 'leader';
|
||||
const { actor: actorData, trait } = foundry.utils.getProperty(message.system, path);
|
||||
const actor = game.actors.get(actorData._id);
|
||||
|
||||
if (!actor) {
|
||||
return ui.notifications.error(
|
||||
game.i18n.format('DAGGERHEART.UI.Notifications.documentIsMissing', {
|
||||
documentType: game.i18n.localize('TYPES.Actor.character')
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
if (!actor.testUserPermission(game.user, 'OWNER')) {
|
||||
return ui.notifications.warn(game.i18n.localize('DAGGERHEART.UI.Notifications.noActorOwnership'));
|
||||
}
|
||||
|
|
@ -214,7 +232,7 @@ export default class DhpChatLog extends foundry.applications.sidebar.tabs.ChatLo
|
|||
hasRoll: true,
|
||||
skips: {
|
||||
createMessage: true,
|
||||
resources: true
|
||||
resources: !isLeader
|
||||
}
|
||||
};
|
||||
const result = await actor.diceRoll({
|
||||
|
|
@ -225,6 +243,9 @@ export default class DhpChatLog extends foundry.applications.sidebar.tabs.ChatLo
|
|||
})
|
||||
});
|
||||
|
||||
if (!result) return;
|
||||
await game.system.api.fields.ActionFields.CostField.execute.call({ actor }, result);
|
||||
|
||||
const newMessageData = foundry.utils.deepClone(message.system);
|
||||
foundry.utils.setProperty(newMessageData, `${path}.result`, result.roll);
|
||||
const renderData = { system: new game.system.api.models.chatMessages.config.groupRoll(newMessageData) };
|
||||
|
|
|
|||
|
|
@ -88,6 +88,17 @@ export default class DhCountdowns extends HandlebarsApplicationMixin(Application
|
|||
this.toggleCollapsedPosition(undefined, !ui.sidebar.expanded);
|
||||
}
|
||||
|
||||
/** Returns countdown data filtered by ownership */
|
||||
#getCountdowns() {
|
||||
const setting = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Countdowns);
|
||||
const values = Object.entries(setting.countdowns).map(([key, countdown]) => ({
|
||||
key,
|
||||
countdown,
|
||||
ownership: DhCountdowns.#getPlayerOwnership(game.user, setting, countdown)
|
||||
}));
|
||||
return values.filter((v) => v.ownership !== CONST.DOCUMENT_OWNERSHIP_LEVELS.NONE);
|
||||
}
|
||||
|
||||
/** @override */
|
||||
async _prepareContext(options) {
|
||||
const context = await super._prepareContext(options);
|
||||
|
|
@ -98,11 +109,7 @@ export default class DhCountdowns extends HandlebarsApplicationMixin(Application
|
|||
CONFIG.DH.GENERAL.countdownAppMode.iconOnly;
|
||||
|
||||
const setting = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Countdowns);
|
||||
context.countdowns = Object.keys(setting.countdowns).reduce((acc, key) => {
|
||||
const countdown = setting.countdowns[key];
|
||||
const ownership = DhCountdowns.#getPlayerOwnership(game.user, setting, countdown);
|
||||
if (ownership === CONST.DOCUMENT_OWNERSHIP_LEVELS.NONE) return acc;
|
||||
|
||||
context.countdowns = this.#getCountdowns().reduce((acc, { key, countdown, ownership }) => {
|
||||
const playersWithAccess = game.users.reduce((acc, user) => {
|
||||
const ownership = DhCountdowns.#getPlayerOwnership(user, setting, countdown);
|
||||
if (!user.isGM && ownership && ownership !== CONST.DOCUMENT_OWNERSHIP_LEVELS.NONE) {
|
||||
|
|
@ -238,4 +245,9 @@ export default class DhCountdowns extends HandlebarsApplicationMixin(Application
|
|||
});
|
||||
Hooks.callAll(socketEvent.Refresh, data);
|
||||
}
|
||||
|
||||
async _onRender(context, options) {
|
||||
await super._onRender(context, options);
|
||||
this.element.hidden = !game.user.isGM && this.#getCountdowns().length === 0;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -294,7 +294,7 @@ export class ItemBrowser extends HandlebarsApplicationMixin(ApplicationV2) {
|
|||
const property = foundry.utils.getProperty(item, field.key);
|
||||
if (Array.isArray(property)) property.join(', ');
|
||||
if (typeof field.format !== 'function') return property ?? '-';
|
||||
return field.format(property);
|
||||
return game.i18n.localize(field.format(property));
|
||||
}
|
||||
|
||||
formatChoices(data) {
|
||||
|
|
@ -430,7 +430,7 @@ export class ItemBrowser extends HandlebarsApplicationMixin(ApplicationV2) {
|
|||
if (matchesMenu) this.#filteredItems.browser.input.add(item.id);
|
||||
|
||||
const { search } = this.#filteredItems.browser;
|
||||
li.hidden = !(search.has(item.id) && matchesMenu);
|
||||
li.hidden = !((this.#search.browser.query.length === 0 || search.has(item.id)) && matchesMenu);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -469,6 +469,7 @@ export class ItemBrowser extends HandlebarsApplicationMixin(ApplicationV2) {
|
|||
|
||||
static resetFilters() {
|
||||
this.render({ force: true });
|
||||
this.loadItems();
|
||||
}
|
||||
|
||||
static getFolderConfig(folder, property = 'columns') {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue