mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 03:31:07 +01:00
120 - Countdowns (#158)
* Added the shell of the Countdown application * Added countdown automation * Fixed overflow layout and added confirmation on countdown removal * Added ownership to countdowns
This commit is contained in:
parent
3464717958
commit
c15d55a505
33 changed files with 1222 additions and 137 deletions
|
|
@ -1,18 +1,13 @@
|
|||
import DHAbilityUse from "./abilityUse.mjs";
|
||||
import DHAdversaryRoll from "./adversaryRoll.mjs";
|
||||
import DHDamageRoll from "./damageRoll.mjs";
|
||||
import DHDualityRoll from "./dualityRoll.mjs";
|
||||
import DHAbilityUse from './abilityUse.mjs';
|
||||
import DHAdversaryRoll from './adversaryRoll.mjs';
|
||||
import DHDamageRoll from './damageRoll.mjs';
|
||||
import DHDualityRoll from './dualityRoll.mjs';
|
||||
|
||||
export {
|
||||
DHAbilityUse,
|
||||
DHAdversaryRoll,
|
||||
DHDamageRoll,
|
||||
DHDualityRoll,
|
||||
}
|
||||
export { DHAbilityUse, DHAdversaryRoll, DHDamageRoll, DHDualityRoll };
|
||||
|
||||
export const config = {
|
||||
abilityUse: DHAbilityUse,
|
||||
adversaryRoll: DHAdversaryRoll,
|
||||
damageRoll: DHDamageRoll,
|
||||
dualityRoll: DHDualityRoll,
|
||||
};
|
||||
abilityUse: DHAbilityUse,
|
||||
adversaryRoll: DHAdversaryRoll,
|
||||
damageRoll: DHDamageRoll,
|
||||
dualityRoll: DHDualityRoll
|
||||
};
|
||||
|
|
|
|||
139
module/data/countdowns.mjs
Normal file
139
module/data/countdowns.mjs
Normal file
|
|
@ -0,0 +1,139 @@
|
|||
import { countdownTypes } from '../config/generalConfig.mjs';
|
||||
import { RefreshType, socketEvent } from '../helpers/socket.mjs';
|
||||
|
||||
export default class DhCountdowns extends foundry.abstract.DataModel {
|
||||
static defineSchema() {
|
||||
const fields = foundry.data.fields;
|
||||
|
||||
return {
|
||||
narrative: new fields.EmbeddedDataField(DhCountdownData),
|
||||
encounter: new fields.EmbeddedDataField(DhCountdownData)
|
||||
};
|
||||
}
|
||||
|
||||
static CountdownCategories = { narrative: 'narrative', combat: 'combat' };
|
||||
}
|
||||
|
||||
class DhCountdownData extends foundry.abstract.DataModel {
|
||||
static LOCALIZATION_PREFIXES = ['DAGGERHEART.Countdown']; // Nots ure why this won't work. Setting labels manually for now
|
||||
|
||||
static defineSchema() {
|
||||
const fields = foundry.data.fields;
|
||||
return {
|
||||
countdowns: new fields.TypedObjectField(new fields.EmbeddedDataField(DhCountdown)),
|
||||
ownership: new fields.SchemaField({
|
||||
default: new fields.NumberField({
|
||||
required: true,
|
||||
choices: Object.values(CONST.DOCUMENT_OWNERSHIP_LEVELS),
|
||||
initial: CONST.DOCUMENT_OWNERSHIP_LEVELS.NONE
|
||||
}),
|
||||
players: new fields.TypedObjectField(
|
||||
new fields.SchemaField({
|
||||
type: new fields.NumberField({
|
||||
required: true,
|
||||
choices: Object.values(CONST.DOCUMENT_OWNERSHIP_LEVELS),
|
||||
initial: CONST.DOCUMENT_OWNERSHIP_LEVELS.INHERIT
|
||||
})
|
||||
})
|
||||
)
|
||||
})
|
||||
};
|
||||
}
|
||||
|
||||
get playerOwnership() {
|
||||
return Array.from(game.users).reduce((acc, user) => {
|
||||
acc[user.id] = {
|
||||
value: user.isGM
|
||||
? CONST.DOCUMENT_OWNERSHIP_LEVELS.OWNER
|
||||
: this.ownership.players[user.id] && this.ownership.players[user.id].type !== -1
|
||||
? this.ownership.players[user.id].type
|
||||
: this.ownership.default,
|
||||
isGM: user.isGM
|
||||
};
|
||||
|
||||
return acc;
|
||||
}, {});
|
||||
}
|
||||
}
|
||||
|
||||
class DhCountdown extends foundry.abstract.DataModel {
|
||||
static defineSchema() {
|
||||
const fields = foundry.data.fields;
|
||||
return {
|
||||
name: new fields.StringField({
|
||||
required: true,
|
||||
label: 'DAGGERHEART.Countdown.FIELDS.countdowns.element.name.label'
|
||||
}),
|
||||
img: new fields.FilePathField({
|
||||
categories: ['IMAGE'],
|
||||
base64: false,
|
||||
initial: 'icons/magic/time/hourglass-yellow-green.webp'
|
||||
}),
|
||||
ownership: new fields.SchemaField({
|
||||
default: new fields.NumberField({
|
||||
required: true,
|
||||
choices: Object.values(CONST.DOCUMENT_OWNERSHIP_LEVELS),
|
||||
initial: CONST.DOCUMENT_OWNERSHIP_LEVELS.NONE
|
||||
}),
|
||||
players: new fields.TypedObjectField(
|
||||
new fields.SchemaField({
|
||||
type: new fields.NumberField({
|
||||
required: true,
|
||||
choices: Object.values(CONST.DOCUMENT_OWNERSHIP_LEVELS),
|
||||
initial: CONST.DOCUMENT_OWNERSHIP_LEVELS.INHERIT
|
||||
})
|
||||
})
|
||||
)
|
||||
}),
|
||||
progress: new fields.SchemaField({
|
||||
current: new fields.NumberField({
|
||||
required: true,
|
||||
integer: true,
|
||||
initial: 0,
|
||||
label: 'DAGGERHEART.Countdown.FIELDS.countdowns.element.progress.current.label'
|
||||
}),
|
||||
max: new fields.NumberField({
|
||||
required: true,
|
||||
integer: true,
|
||||
initial: 1,
|
||||
label: 'DAGGERHEART.Countdown.FIELDS.countdowns.element.progress.max.label'
|
||||
}),
|
||||
type: new fields.SchemaField({
|
||||
value: new fields.StringField({
|
||||
required: true,
|
||||
choices: countdownTypes,
|
||||
initial: countdownTypes.spotlight.id,
|
||||
label: 'DAGGERHEART.Countdown.FIELDS.countdowns.element.progress.type.value.label'
|
||||
}),
|
||||
label: new fields.StringField({
|
||||
label: 'DAGGERHEART.Countdown.FIELDS.countdowns.element.progress.type.label.label'
|
||||
})
|
||||
})
|
||||
})
|
||||
};
|
||||
}
|
||||
|
||||
get playerOwnership() {
|
||||
return Array.from(game.users).reduce((acc, user) => {
|
||||
acc[user.id] = {
|
||||
value: user.isGM
|
||||
? CONST.DOCUMENT_OWNERSHIP_LEVELS.OWNER
|
||||
: this.ownership.players[user.id] && this.ownership.players[user.id].type !== -1
|
||||
? this.ownership.players[user.id].type
|
||||
: this.ownership.default,
|
||||
isGM: user.isGM
|
||||
};
|
||||
|
||||
return acc;
|
||||
}, {});
|
||||
}
|
||||
}
|
||||
|
||||
export const registerCountdownHooks = () => {
|
||||
Hooks.on(socketEvent.Refresh, ({ refreshType, application }) => {
|
||||
if (refreshType === RefreshType.Countdown) {
|
||||
foundry.applications.instances.get(application)?.render();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
|
@ -10,45 +10,44 @@
|
|||
const fields = foundry.data.fields;
|
||||
|
||||
export default class BaseDataItem extends foundry.abstract.TypeDataModel {
|
||||
/** @returns {ItemDataModelMetadata}*/
|
||||
static get metadata() {
|
||||
return {
|
||||
label: "Base Item",
|
||||
type: "base",
|
||||
hasDescription: false,
|
||||
isQuantifiable: false,
|
||||
};
|
||||
}
|
||||
/** @returns {ItemDataModelMetadata}*/
|
||||
static get metadata() {
|
||||
return {
|
||||
label: 'Base Item',
|
||||
type: 'base',
|
||||
hasDescription: false,
|
||||
isQuantifiable: false
|
||||
};
|
||||
}
|
||||
|
||||
/** @inheritDoc */
|
||||
static defineSchema() {
|
||||
const schema = {};
|
||||
/** @inheritDoc */
|
||||
static defineSchema() {
|
||||
const schema = {};
|
||||
|
||||
if (this.metadata.hasDescription)
|
||||
schema.description = new fields.HTMLField({ required: true, nullable: true });
|
||||
if (this.metadata.hasDescription) schema.description = new fields.HTMLField({ required: true, nullable: true });
|
||||
|
||||
if (this.metadata.isQuantifiable)
|
||||
schema.quantity = new fields.NumberField({ integer: true, initial: 1, min: 0, required: true });
|
||||
if (this.metadata.isQuantifiable)
|
||||
schema.quantity = new fields.NumberField({ integer: true, initial: 1, min: 0, required: true });
|
||||
|
||||
return schema;
|
||||
}
|
||||
return schema;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenient access to the item's actor, if it exists.
|
||||
* @returns {foundry.documents.Actor | null}
|
||||
*/
|
||||
get actor() {
|
||||
return this.parent.actor;
|
||||
}
|
||||
/**
|
||||
* Convenient access to the item's actor, if it exists.
|
||||
* @returns {foundry.documents.Actor | null}
|
||||
*/
|
||||
get actor() {
|
||||
return this.parent.actor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtain a data object used to evaluate any dice rolls associated with this Item Type
|
||||
* @param {object} [options] - Options which modify the getRollData method.
|
||||
* @returns {object}
|
||||
*/
|
||||
getRollData(options = {}) {
|
||||
const actorRollData = this.actor?.getRollData() ?? {};
|
||||
const data = { ...actorRollData, item: { ...this } };
|
||||
return data;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Obtain a data object used to evaluate any dice rolls associated with this Item Type
|
||||
* @param {object} [options] - Options which modify the getRollData method.
|
||||
* @returns {object}
|
||||
*/
|
||||
getRollData(options = {}) {
|
||||
const actorRollData = this.actor?.getRollData() ?? {};
|
||||
const data = { ...actorRollData, item: { ...this } };
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,16 +19,16 @@ export default class DHClass extends BaseDataItem {
|
|||
return {
|
||||
...super.defineSchema(),
|
||||
domains: new fields.ArrayField(new fields.StringField(), { max: 2 }),
|
||||
classItems: new ForeignDocumentUUIDArrayField({type: 'Item', required: false}),
|
||||
classItems: new ForeignDocumentUUIDArrayField({ type: 'Item', required: false }),
|
||||
|
||||
evasion: new fields.NumberField({ initial: 0, integer: true }),
|
||||
hopeFeatures: new foundry.data.fields.ArrayField(new ActionField()),
|
||||
classFeatures: new foundry.data.fields.ArrayField(new ActionField()),
|
||||
subclasses: new ForeignDocumentUUIDArrayField({type: 'Item', required: false}),
|
||||
subclasses: new ForeignDocumentUUIDArrayField({ type: 'Item', required: false }),
|
||||
inventory: new fields.SchemaField({
|
||||
take: new ForeignDocumentUUIDArrayField({type: 'Item', required: false}),
|
||||
choiceA: new ForeignDocumentUUIDArrayField({type: 'Item', required: false}),
|
||||
choiceB: new ForeignDocumentUUIDArrayField({type: 'Item', required: false}),
|
||||
take: new ForeignDocumentUUIDArrayField({ type: 'Item', required: false }),
|
||||
choiceA: new ForeignDocumentUUIDArrayField({ type: 'Item', required: false }),
|
||||
choiceB: new ForeignDocumentUUIDArrayField({ type: 'Item', required: false })
|
||||
}),
|
||||
characterGuide: new fields.SchemaField({
|
||||
suggestedTraits: new fields.SchemaField({
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
import BaseDataItem from "./base.mjs";
|
||||
import BaseDataItem from './base.mjs';
|
||||
import ActionField from '../fields/actionField.mjs';
|
||||
|
||||
export default class DHConsumable extends BaseDataItem {
|
||||
/** @inheritDoc */
|
||||
/** @inheritDoc */
|
||||
static get metadata() {
|
||||
return foundry.utils.mergeObject(super.metadata, {
|
||||
label: "TYPES.Item.consumable",
|
||||
type: "consumable",
|
||||
label: 'TYPES.Item.consumable',
|
||||
type: 'consumable',
|
||||
hasDescription: true,
|
||||
isQuantifiable: true,
|
||||
isQuantifiable: true
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,10 +5,10 @@ export default class DHMiscellaneous extends BaseDataItem {
|
|||
/** @inheritDoc */
|
||||
static get metadata() {
|
||||
return foundry.utils.mergeObject(super.metadata, {
|
||||
label: "TYPES.Item.miscellaneous",
|
||||
type: "miscellaneous",
|
||||
label: 'TYPES.Item.miscellaneous',
|
||||
type: 'miscellaneous',
|
||||
hasDescription: true,
|
||||
isQuantifiable: true,
|
||||
isQuantifiable: true
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import BaseDataItem from './base.mjs';
|
|||
const featureSchema = () => {
|
||||
return new foundry.data.fields.SchemaField({
|
||||
name: new foundry.data.fields.StringField({ required: true }),
|
||||
effects: new ForeignDocumentUUIDArrayField({type: 'Item', required: false}),
|
||||
effects: new ForeignDocumentUUIDArrayField({ type: 'ActiveEffect', required: false }),
|
||||
actions: new foundry.data.fields.ArrayField(new ActionField())
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -5,7 +5,8 @@ export default class DhAutomation extends foundry.abstract.DataModel {
|
|||
const fields = foundry.data.fields;
|
||||
return {
|
||||
hope: new fields.BooleanField({ required: true, initial: false }),
|
||||
actionPoints: new fields.BooleanField({ required: true, initial: false })
|
||||
actionPoints: new fields.BooleanField({ required: true, initial: false }),
|
||||
countdowns: new fields.BooleanField({ requireD: true, initial: false })
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue