Initial skeleton

This commit is contained in:
2026-03-05 21:51:31 +01:00
commit 12458925a1
53 changed files with 6646 additions and 0 deletions
+9
View File
@@ -0,0 +1,9 @@
export { default as AwECharacterSheet } from "./sheets/character-sheet.mjs"
export { default as AwECreatureSheet } from "./sheets/creature-sheet.mjs"
export { default as AwEAbilitySheet } from "./sheets/ability-sheet.mjs"
export { default as AwEFieldSheet } from "./sheets/field-sheet.mjs"
export { default as AwEArchetypeSheet } from "./sheets/archetype-sheet.mjs"
export { default as AwEBackgroundSheet } from "./sheets/background-sheet.mjs"
export { default as AwEKitSheet } from "./sheets/kit-sheet.mjs"
export { default as AwEWeaponSheet } from "./sheets/weapon-sheet.mjs"
export { default as AwEEquipmentSheet } from "./sheets/equipment-sheet.mjs"
@@ -0,0 +1,17 @@
import AwEItemSheet from "./base-item-sheet.mjs"
export default class AwEAbilitySheet extends AwEItemSheet {
/** @override */
static DEFAULT_OPTIONS = {
classes: ["ability"],
position: { width: 620 },
window: { contentClasses: ["ability-content"] }
}
/** @override */
static PARTS = {
main: {
template: "systems/fvtt-adventures-with-emmy/templates/ability.hbs"
}
}
}
@@ -0,0 +1,17 @@
import AwEItemSheet from "./base-item-sheet.mjs"
export default class AwEArchetypeSheet extends AwEItemSheet {
/** @override */
static DEFAULT_OPTIONS = {
classes: ["archetype"],
position: { width: 620 },
window: { contentClasses: ["archetype-content"] }
}
/** @override */
static PARTS = {
main: {
template: "systems/fvtt-adventures-with-emmy/templates/archetype.hbs"
}
}
}
@@ -0,0 +1,17 @@
import AwEItemSheet from "./base-item-sheet.mjs"
export default class AwEBackgroundSheet extends AwEItemSheet {
/** @override */
static DEFAULT_OPTIONS = {
classes: ["background"],
position: { width: 620 },
window: { contentClasses: ["background-content"] }
}
/** @override */
static PARTS = {
main: {
template: "systems/fvtt-adventures-with-emmy/templates/background.hbs"
}
}
}
@@ -0,0 +1,231 @@
const { HandlebarsApplicationMixin } = foundry.applications.api
export default class AwEActorSheet extends HandlebarsApplicationMixin(foundry.applications.sheets.ActorSheetV2) {
/**
* Different sheet modes.
* @enum {number}
*/
static SHEET_MODES = { EDIT: 0, PLAY: 1 }
constructor(options = {}) {
super(options)
this.#dragDrop = this.#createDragDropHandlers()
}
#dragDrop
/** @override */
static DEFAULT_OPTIONS = {
classes: ["awemmy", "actor"],
position: {
width: 900,
height: "auto"
},
form: {
submitOnChange: true
},
window: {
resizable: true
},
dragDrop: [{ dragSelector: '[data-drag="true"], .rollable', dropSelector: null }],
actions: {
editImage: AwEActorSheet.#onEditImage,
toggleSheet: AwEActorSheet.#onToggleSheet,
edit: AwEActorSheet.#onItemEdit,
delete: AwEActorSheet.#onItemDelete
}
}
/**
* The current sheet mode.
* @type {number}
*/
_sheetMode = this.constructor.SHEET_MODES.PLAY
/**
* Is the sheet currently in 'Play' mode?
* @type {boolean}
*/
get isPlayMode() {
return this._sheetMode === this.constructor.SHEET_MODES.PLAY
}
/**
* Is the sheet currently in 'Edit' mode?
* @type {boolean}
*/
get isEditMode() {
return this._sheetMode === this.constructor.SHEET_MODES.EDIT
}
/** @override */
async _prepareContext() {
const context = {
fields: this.document.schema.fields,
systemFields: this.document.system.schema.fields,
actor: this.document,
system: this.document.system,
source: this.document.toObject(),
isEditMode: this.isEditMode,
isPlayMode: this.isPlayMode,
isEditable: this.isEditable
}
return context
}
/** @override */
_onRender(context, options) {
this.#dragDrop.forEach(d => d.bind(this.element))
const rollables = this.element.querySelectorAll(".rollable")
rollables.forEach(d => d.addEventListener("click", this._onRoll.bind(this)))
}
/**
* Handle rolling an attribute check.
* @param {PointerEvent} event - The click event.
*/
async _onRoll(event) {
if (this.isEditMode) return
const attributeId = event.currentTarget.dataset.attributeId
if (!attributeId) return
await this.document.rollAttribute(attributeId)
}
// #region Drag-and-Drop Workflow
/**
* Create drag-and-drop workflow handlers for this Application.
* @returns {DragDrop[]} An array of DragDrop handlers.
* @private
*/
#createDragDropHandlers() {
return this.options.dragDrop.map(d => {
d.permissions = {
dragstart: this._canDragStart.bind(this),
drop: this._canDragDrop.bind(this)
}
d.callbacks = {
dragstart: this._onDragStart.bind(this),
dragover: this._onDragOver.bind(this),
drop: this._onDrop.bind(this)
}
return new foundry.applications.ux.DragDrop.implementation(d)
})
}
/**
* Callback actions which occur when a dragged element is dropped on a target.
* @param {DragEvent} event - The originating DragEvent.
* @protected
*/
async _onDrop(event) {}
/**
* Define whether a user is able to begin a dragstart workflow for a given drag selector.
* @param {string} selector - The candidate HTML selector for dragging.
* @returns {boolean} Can the current user drag this selector?
* @protected
*/
_canDragStart(selector) {
return this.isEditable
}
/**
* Define whether a user is able to conclude a drag-and-drop workflow for a given drop selector.
* @param {string} selector - The candidate HTML selector for the drop target.
* @returns {boolean} Can the current user drop on this selector?
* @protected
*/
_canDragDrop(selector) {
return this.isEditable && this.document.isOwner
}
/**
* Callback actions which occur at the beginning of a drag start workflow.
* @param {DragEvent} event - The originating DragEvent.
* @protected
*/
_onDragStart(event) {
if ("link" in event.target.dataset) return
}
/**
* Callback actions which occur when a dragged element is over a drop target.
* @param {DragEvent} event - The originating DragEvent.
* @protected
*/
_onDragOver(event) {}
/**
* Drop an item onto the actor.
* @param {Item} item - The item being dropped.
*/
async _onDropItem(item) {
const itemData = item.toObject()
await this.document.createEmbeddedDocuments("Item", [itemData], { renderSheet: false })
}
// #endregion
// #region Actions
/**
* Handle toggling between Edit and Play mode.
* @param {Event} event - The initiating click event.
* @param {HTMLElement} target - The current target of the event listener.
*/
static #onToggleSheet(event, target) {
const modes = this.constructor.SHEET_MODES
this._sheetMode = this.isEditMode ? modes.PLAY : modes.EDIT
this.render()
}
/**
* Handle changing a Document's image.
* @param {PointerEvent} event - The originating click event.
* @param {HTMLElement} target - The capturing HTML element which defined a [data-action].
* @returns {Promise} The file picker promise.
* @private
*/
static async #onEditImage(event, target) {
const attr = target.dataset.edit
const current = foundry.utils.getProperty(this.document, attr)
const { img } = this.document.constructor.getDefaultArtwork?.(this.document.toObject()) ?? {}
const fp = new FilePicker({
current,
type: "image",
redirectToRoot: img ? [img] : [],
callback: path => {
this.document.update({ [attr]: path })
},
top: this.position.top + 40,
left: this.position.left + 10
})
return fp.browse()
}
/**
* Edit an existing item within the Actor.
* @param {PointerEvent} event - The originating click event.
* @param {HTMLElement} target - The capturing HTML element which defined a [data-action].
*/
static async #onItemEdit(event, target) {
const id = target.getAttribute("data-item-id")
const uuid = target.getAttribute("data-item-uuid")
let item = await fromUuid(uuid)
if (!item) item = this.document.items.get(id)
if (!item) return
item.sheet.render(true)
}
/**
* Delete an existing item within the Actor.
* @param {PointerEvent} event - The originating click event.
* @param {HTMLElement} target - The capturing HTML element which defined a [data-action].
*/
static async #onItemDelete(event, target) {
const itemUuid = target.getAttribute("data-item-uuid")
const item = await fromUuid(itemUuid)
await item.deleteDialog()
}
// #endregion
}
@@ -0,0 +1,185 @@
const { HandlebarsApplicationMixin } = foundry.applications.api
export default class AwEItemSheet extends HandlebarsApplicationMixin(foundry.applications.sheets.ItemSheetV2) {
/**
* Different sheet modes.
* @enum {number}
*/
static SHEET_MODES = { EDIT: 0, PLAY: 1 }
constructor(options = {}) {
super(options)
this.#dragDrop = this.#createDragDropHandlers()
}
#dragDrop
/** @override */
static DEFAULT_OPTIONS = {
classes: ["awemmy", "item"],
position: {
width: 600,
height: "auto"
},
form: {
submitOnChange: true
},
window: {
resizable: true
},
dragDrop: [{ dragSelector: "[data-drag]", dropSelector: null }],
actions: {
toggleSheet: AwEItemSheet.#onToggleSheet,
editImage: AwEItemSheet.#onEditImage
}
}
/**
* The current sheet mode.
* @type {number}
*/
_sheetMode = this.constructor.SHEET_MODES.PLAY
/**
* Is the sheet currently in 'Play' mode?
* @type {boolean}
*/
get isPlayMode() {
return this._sheetMode === this.constructor.SHEET_MODES.PLAY
}
/**
* Is the sheet currently in 'Edit' mode?
* @type {boolean}
*/
get isEditMode() {
return this._sheetMode === this.constructor.SHEET_MODES.EDIT
}
/** @override */
async _prepareContext() {
const context = await super._prepareContext()
context.fields = this.document.schema.fields
context.systemFields = this.document.system.schema.fields
context.item = this.document
context.system = this.document.system
context.source = this.document.toObject()
context.enrichedDescription = await foundry.applications.ux.TextEditor.implementation.enrichHTML(
this.document.system.description, { async: true }
)
context.isEditMode = this.isEditMode
context.isPlayMode = this.isPlayMode
context.isEditable = this.isEditable
return context
}
/** @override */
_onRender(context, options) {
super._onRender(context, options)
this.#dragDrop.forEach(d => d.bind(this.element))
}
// #region Drag-and-Drop Workflow
/**
* Create drag-and-drop workflow handlers for this Application.
* @returns {DragDrop[]} An array of DragDrop handlers.
* @private
*/
#createDragDropHandlers() {
return this.options.dragDrop.map(d => {
d.permissions = {
dragstart: this._canDragStart.bind(this),
drop: this._canDragDrop.bind(this)
}
d.callbacks = {
dragstart: this._onDragStart.bind(this),
dragover: this._onDragOver.bind(this),
drop: this._onDrop.bind(this)
}
return new foundry.applications.ux.DragDrop.implementation(d)
})
}
/**
* Define whether a user is able to begin a dragstart workflow for a given drag selector.
* @param {string} selector - The candidate HTML selector for dragging.
* @returns {boolean} Can the current user drag this selector?
* @protected
*/
_canDragStart(selector) {
return this.isEditable
}
/**
* Define whether a user is able to conclude a drag-and-drop workflow for a given drop selector.
* @param {string} selector - The candidate HTML selector for the drop target.
* @returns {boolean} Can the current user drop on this selector?
* @protected
*/
_canDragDrop(selector) {
return this.isEditable && this.document.isOwner
}
/**
* Callback actions which occur at the beginning of a drag start workflow.
* @param {DragEvent} event - The originating DragEvent.
* @protected
*/
_onDragStart(event) {
if ("link" in event.target.dataset) return
}
/**
* Callback actions which occur when a dragged element is over a drop target.
* @param {DragEvent} event - The originating DragEvent.
* @protected
*/
_onDragOver(event) {}
/**
* Callback actions which occur when a dragged element is dropped on a target.
* @param {DragEvent} event - The originating DragEvent.
* @protected
*/
async _onDrop(event) {}
// #endregion
// #region Actions
/**
* Handle toggling between Edit and Play mode.
* @param {Event} event - The initiating click event.
* @param {HTMLElement} target - The current target of the event listener.
*/
static #onToggleSheet(event, target) {
const modes = this.constructor.SHEET_MODES
this._sheetMode = this.isEditMode ? modes.PLAY : modes.EDIT
this.render()
}
/**
* Handle changing a Document's image.
* @param {PointerEvent} event - The originating click event.
* @param {HTMLElement} target - The capturing HTML element which defined a [data-action].
* @returns {Promise} The file picker promise.
* @private
*/
static async #onEditImage(event, target) {
const attr = target.dataset.edit
const current = foundry.utils.getProperty(this.document, attr)
const { img } = this.document.constructor.getDefaultArtwork?.(this.document.toObject()) ?? {}
const fp = new FilePicker({
current,
type: "image",
redirectToRoot: img ? [img] : [],
callback: path => {
this.document.update({ [attr]: path })
},
top: this.position.top + 40,
left: this.position.left + 10
})
return fp.browse()
}
// #endregion
}
@@ -0,0 +1,161 @@
import AwEActorSheet from "./base-actor-sheet.mjs"
export default class AwECharacterSheet extends AwEActorSheet {
/** @override */
static DEFAULT_OPTIONS = {
classes: ["character"],
position: {
width: 960,
height: 780
},
window: {
contentClasses: ["character-content"]
},
actions: {
createAbility: AwECharacterSheet.#onCreateAbility,
createWeapon: AwECharacterSheet.#onCreateWeapon,
createKit: AwECharacterSheet.#onCreateKit,
createEquipment: AwECharacterSheet.#onCreateEquipment,
flowPointsPlus: AwECharacterSheet.#onFlowPointsPlus,
flowPointsMinus: AwECharacterSheet.#onFlowPointsMinus
}
}
/** @override */
static PARTS = {
main: {
template: "systems/fvtt-adventures-with-emmy/templates/character-main.hbs"
},
tabs: {
template: "templates/generic/tab-navigation.hbs"
},
biography: {
template: "systems/fvtt-adventures-with-emmy/templates/character-biography.hbs"
},
equipment: {
template: "systems/fvtt-adventures-with-emmy/templates/character-equipment.hbs"
}
}
/** @override */
tabGroups = {
sheet: "main"
}
/**
* Prepare an array of form header tabs.
* @returns {Record<string, Partial<ApplicationTab>>} The tab objects.
*/
#getTabs() {
const tabs = {
main: { id: "main", group: "sheet", icon: "fa-solid fa-user", label: "AWEMMY.Sheet.Tab.Main" },
biography: { id: "biography", group: "sheet", icon: "fa-solid fa-book", label: "AWEMMY.Sheet.Tab.Biography" },
equipment: { id: "equipment", group: "sheet", icon: "fa-solid fa-backpack", label: "AWEMMY.Sheet.Tab.Equipment" }
}
for (const v of Object.values(tabs)) {
v.active = this.tabGroups[v.group] === v.id
v.cssClass = v.active ? "active" : ""
}
return tabs
}
/** @override */
async _prepareContext() {
const context = await super._prepareContext()
context.tabs = this.#getTabs()
return context
}
/** @override */
async _preparePartContext(partId, context) {
const doc = this.document
switch (partId) {
case "main":
context.tab = context.tabs.main
context.abilities = doc.itemTypes.ability
break
case "biography":
context.tab = context.tabs.biography
context.enrichedDescription = await foundry.applications.ux.TextEditor.implementation.enrichHTML(
doc.system.description, { async: true }
)
context.enrichedNotes = await foundry.applications.ux.TextEditor.implementation.enrichHTML(
doc.system.notes, { async: true }
)
break
case "equipment":
context.tab = context.tabs.equipment
context.kits = doc.itemTypes.kit
context.weapons = doc.itemTypes.weapon
context.equipments = doc.itemTypes.equipment
break
}
return context
}
/** @override */
async _onDrop(event) {
if (!this.isEditable || !this.isEditMode) return
const data = foundry.applications.ux.TextEditor.implementation.getDragEventData(event)
if (data.type === "Item") {
const item = await fromUuid(data.uuid)
return this._onDropItem(item)
}
}
/**
* Create a new ability item.
* @param {Event} event - The triggering event.
* @param {HTMLElement} target - The target element.
*/
static #onCreateAbility(event, target) {
this.document.createEmbeddedDocuments("Item", [{ name: "New Ability", type: "ability" }])
}
/**
* Create a new weapon item.
* @param {Event} event - The triggering event.
* @param {HTMLElement} target - The target element.
*/
static #onCreateWeapon(event, target) {
this.document.createEmbeddedDocuments("Item", [{ name: "New Weapon", type: "weapon" }])
}
/**
* Create a new kit item.
* @param {Event} event - The triggering event.
* @param {HTMLElement} target - The target element.
*/
static #onCreateKit(event, target) {
this.document.createEmbeddedDocuments("Item", [{ name: "New Kit", type: "kit" }])
}
/**
* Create a new equipment item.
* @param {Event} event - The triggering event.
* @param {HTMLElement} target - The target element.
*/
static #onCreateEquipment(event, target) {
this.document.createEmbeddedDocuments("Item", [{ name: "New Equipment", type: "equipment" }])
}
/**
* Increase flow points by 1.
* @param {Event} event - The triggering event.
* @param {HTMLElement} target - The target element.
*/
static #onFlowPointsPlus(event, target) {
const current = this.actor.system.flowPoints.value
this.actor.update({ "system.flowPoints.value": current + 1 })
}
/**
* Decrease flow points by 1.
* @param {Event} event - The triggering event.
* @param {HTMLElement} target - The target element.
*/
static #onFlowPointsMinus(event, target) {
const current = this.actor.system.flowPoints.value
this.actor.update({ "system.flowPoints.value": Math.max(0, current - 1) })
}
}
@@ -0,0 +1,31 @@
import AwEActorSheet from "./base-actor-sheet.mjs"
export default class AwECreatureSheet extends AwEActorSheet {
/** @override */
static DEFAULT_OPTIONS = {
classes: ["creature"],
position: {
width: 700,
height: "auto"
},
window: {
contentClasses: ["creature-content"]
}
}
/** @override */
static PARTS = {
main: {
template: "systems/fvtt-adventures-with-emmy/templates/creature-main.hbs"
}
}
/** @override */
async _prepareContext() {
const context = await super._prepareContext()
context.enrichedDescription = await foundry.applications.ux.TextEditor.implementation.enrichHTML(
this.document.system.description, { async: true }
)
return context
}
}
@@ -0,0 +1,17 @@
import AwEItemSheet from "./base-item-sheet.mjs"
export default class AwEEquipmentSheet extends AwEItemSheet {
/** @override */
static DEFAULT_OPTIONS = {
classes: ["equipment"],
position: { width: 620 },
window: { contentClasses: ["equipment-content"] }
}
/** @override */
static PARTS = {
main: {
template: "systems/fvtt-adventures-with-emmy/templates/equipment.hbs"
}
}
}
@@ -0,0 +1,17 @@
import AwEItemSheet from "./base-item-sheet.mjs"
export default class AwEFieldSheet extends AwEItemSheet {
/** @override */
static DEFAULT_OPTIONS = {
classes: ["field"],
position: { width: 620 },
window: { contentClasses: ["field-content"] }
}
/** @override */
static PARTS = {
main: {
template: "systems/fvtt-adventures-with-emmy/templates/field.hbs"
}
}
}
+17
View File
@@ -0,0 +1,17 @@
import AwEItemSheet from "./base-item-sheet.mjs"
export default class AwEKitSheet extends AwEItemSheet {
/** @override */
static DEFAULT_OPTIONS = {
classes: ["kit"],
position: { width: 620 },
window: { contentClasses: ["kit-content"] }
}
/** @override */
static PARTS = {
main: {
template: "systems/fvtt-adventures-with-emmy/templates/kit.hbs"
}
}
}
@@ -0,0 +1,17 @@
import AwEItemSheet from "./base-item-sheet.mjs"
export default class AwEWeaponSheet extends AwEItemSheet {
/** @override */
static DEFAULT_OPTIONS = {
classes: ["weapon"],
position: { width: 620 },
window: { contentClasses: ["weapon-content"] }
}
/** @override */
static PARTS = {
main: {
template: "systems/fvtt-adventures-with-emmy/templates/weapon.hbs"
}
}
}
+65
View File
@@ -0,0 +1,65 @@
export const SYSTEM_ID = "fvtt-adventures-with-emmy"
export const DEV_MODE = false
export const ATTRIBUTES = {
agility: { id: "agility", abbrev: "AGI", label: "AWEMMY.Attribute.Agility" },
fitness: { id: "fitness", abbrev: "FIT", label: "AWEMMY.Attribute.Fitness" },
awareness: { id: "awareness", abbrev: "AWA", label: "AWEMMY.Attribute.Awareness" },
influence: { id: "influence", abbrev: "INF", label: "AWEMMY.Attribute.Influence" }
}
export const CONDITIONS = {
edge: { id: "edge", label: "AWEMMY.Condition.Edge" },
hampered: { id: "hampered", label: "AWEMMY.Condition.Hampered" },
inhibited: { id: "inhibited", label: "AWEMMY.Condition.Inhibited" },
jumbled: { id: "jumbled", label: "AWEMMY.Condition.Jumbled" },
mishap: { id: "mishap", label: "AWEMMY.Condition.Mishap" },
prone: { id: "prone", label: "AWEMMY.Condition.Prone" },
quickened: { id: "quickened", label: "AWEMMY.Condition.Quickened" },
slowed: { id: "slowed", label: "AWEMMY.Condition.Slowed" },
vulnerable: { id: "vulnerable", label: "AWEMMY.Condition.Vulnerable" }
}
export const ABILITY_COST = {
"one": { id: "one", label: "Δ" },
"two": { id: "two", label: "ΔΔ" },
"three": { id: "three", label: "ΔΔΔ" },
"reaction": { id: "reaction", label: "↩" },
"free": { id: "free", label: "AWEMMY.Ability.Cost.Free" },
"none": { id: "none", label: "—" }
}
export const ABILITY_TYPE = {
"field": { id: "field", label: "AWEMMY.Ability.Type.Field" },
"archetype": { id: "archetype", label: "AWEMMY.Ability.Type.Archetype" },
"general": { id: "general", label: "AWEMMY.Ability.Type.General" },
"beginner": { id: "beginner", label: "AWEMMY.Ability.Type.Beginner" }
}
export const OUTCOME_LABELS = {
criticalSuccess: "AWEMMY.Roll.CriticalSuccess",
success: "AWEMMY.Roll.Success",
failure: "AWEMMY.Roll.Failure",
criticalFailure: "AWEMMY.Roll.CriticalFailure"
}
export const ASCII = `
_ _ _ _ _ _ _____
/ \\ __| |_ _____ _ __ | |_ _ _ _ __ ___ ___| | | | | | ____|_ __ ___ _ __ ___ _ _
/ _ \\ / _\` \\ \\ / / _ \\ '_ \\| __| | | | '__/ _ \\/ __| | | | | | _| | '_ \` _ \\| '_ \` _ \\| | | |
/ ___ \\ (_| |\\ V / __/ | | | |_| |_| | | | __/\\__ \\ |_| | |___| |___| | | | | | | | | | | |_| |
/_/ \\_\\__,_| \\_/ \\___|_| |_|\\__|\\__,_|_| \\___||___/\\___/|_____|_____|_| |_| |_|_| |_| |_|\\__, |
|___/
`
// Re-export all for convenience
export const SYSTEM = {
SYSTEM_ID,
DEV_MODE,
ATTRIBUTES,
CONDITIONS,
ABILITY_COST,
ABILITY_TYPE,
OUTCOME_LABELS,
ASCII
}
+4
View File
@@ -0,0 +1,4 @@
export { default as AwEActor } from "./actor.mjs"
export { default as AwEItem } from "./item.mjs"
export { default as AwERoll } from "./roll.mjs"
export { default as AwEChatMessage } from "./chat-message.mjs"
+70
View File
@@ -0,0 +1,70 @@
export default class AwEActor extends Actor {
/** @override */
prepareData() {
super.prepareData()
}
/** @override */
prepareBaseData() {}
/** @override */
prepareDerivedData() {
const actorData = this
this._prepareCharacterData(actorData)
this._prepareCreatureData(actorData)
}
/**
* Prepare character data.
* @param {object} actorData - The actor data.
*/
_prepareCharacterData(actorData) {
if (actorData.type !== "character") return
}
/**
* Prepare creature data.
* @param {object} actorData - The actor data.
*/
_prepareCreatureData(actorData) {
if (actorData.type !== "creature") return
}
/**
* Roll an attribute check.
* @param {string} attributeId - The attribute to roll.
* @param {object} options - Roll options.
* @returns {Promise<Roll>} The roll result.
*/
async rollAttribute(attributeId, options = {}) {
const attribute = this.system.attributes[attributeId]
if (!attribute) return null
const mod = attribute.mod ?? 0
const formula = `1d20 + ${mod}`
const roll = new Roll(formula)
await roll.evaluate()
// Determine outcome vs DC if provided
let outcome = null
if (options.dc !== undefined) {
const total = roll.total
const dc = options.dc
if (total >= dc + 10) outcome = "criticalSuccess"
else if (total >= dc) outcome = "success"
else if (total <= dc - 10) outcome = "criticalFailure"
else outcome = "failure"
}
// Send to chat
const attrLabel = attributeId.charAt(0).toUpperCase() + attributeId.slice(1)
const flavor = options.flavor || game.i18n.localize(`AWEMMY.Attribute.${attrLabel}`)
await roll.toMessage({
speaker: ChatMessage.getSpeaker({ actor: this }),
flavor,
rollMode: game.settings.get("core", "rollMode")
})
return { roll, outcome }
}
}
+7
View File
@@ -0,0 +1,7 @@
export default class AwEChatMessage extends ChatMessage {
/** @override */
async getHTML(...args) {
const html = await super.getHTML(...args)
return html
}
}
+6
View File
@@ -0,0 +1,6 @@
export default class AwEItem extends Item {
/** @override */
prepareData() {
super.prepareData()
}
}
+5
View File
@@ -0,0 +1,5 @@
export default class AwERoll extends Roll {
constructor(formula, data = {}, options = {}) {
super(formula, data, options)
}
}
+9
View File
@@ -0,0 +1,9 @@
export { default as AwECharacter } from "./character.mjs"
export { default as AwECreature } from "./creature.mjs"
export { default as AwEAbility } from "./ability.mjs"
export { default as AwEField } from "./field.mjs"
export { default as AwEArchetype } from "./archetype.mjs"
export { default as AwEBackground } from "./background.mjs"
export { default as AwEKit } from "./kit.mjs"
export { default as AwEWeapon } from "./weapon.mjs"
export { default as AwEEquipment } from "./equipment.mjs"
+28
View File
@@ -0,0 +1,28 @@
import { SYSTEM } from "../config/system.mjs"
export default class AwEAbility extends foundry.abstract.TypeDataModel {
static defineSchema() {
const fields = foundry.data.fields
const schema = {}
schema.description = new fields.HTMLField({ required: true, textSearch: true })
schema.abilityType = new fields.StringField({
required: true,
nullable: false,
initial: "field",
choices: Object.keys(SYSTEM.ABILITY_TYPE)
})
schema.cost = new fields.StringField({
required: true,
nullable: false,
initial: "one",
choices: Object.keys(SYSTEM.ABILITY_COST)
})
schema.frequency = new fields.StringField({ initial: "", required: false, nullable: true })
schema.requirements = new fields.StringField({ initial: "", required: false, nullable: true })
schema.trigger = new fields.StringField({ initial: "", required: false, nullable: true })
schema.traits = new fields.ArrayField(new fields.StringField())
return schema
}
}
+13
View File
@@ -0,0 +1,13 @@
export default class AwEArchetype extends foundry.abstract.TypeDataModel {
static defineSchema() {
const fields = foundry.data.fields
const schema = {}
schema.description = new fields.HTMLField({ required: true, textSearch: true })
schema.prerequisiteLevel = new fields.NumberField({
required: true, nullable: false, integer: true, initial: 2, min: 1
})
return schema
}
}
+11
View File
@@ -0,0 +1,11 @@
export default class AwEBackground extends foundry.abstract.TypeDataModel {
static defineSchema() {
const fields = foundry.data.fields
const schema = {}
schema.description = new fields.HTMLField({ required: true, textSearch: true })
schema.bonus = new fields.StringField({ initial: "", required: false, nullable: true })
return schema
}
}
+74
View File
@@ -0,0 +1,74 @@
import { SYSTEM } from "../config/system.mjs"
export default class AwECharacter extends foundry.abstract.TypeDataModel {
static defineSchema() {
const fields = foundry.data.fields
const requiredInteger = { required: true, nullable: false, integer: true }
const schema = {}
schema.description = new fields.HTMLField({ required: true, textSearch: true })
schema.notes = new fields.HTMLField({ required: true, textSearch: true })
// Identity
schema.pronouns = new fields.StringField({ initial: "", required: false, nullable: true })
schema.fieldName = new fields.StringField({ initial: "", required: false, nullable: true })
schema.specialization = new fields.StringField({ initial: "", required: false, nullable: true })
schema.archetypeName = new fields.StringField({ initial: "", required: false, nullable: true })
schema.backgroundName = new fields.StringField({ initial: "", required: false, nullable: true })
// Core stats
schema.level = new fields.NumberField({ ...requiredInteger, initial: 1, min: 1, max: 10 })
schema.stride = new fields.NumberField({ ...requiredInteger, initial: 5, min: 0 })
// Hit Points
schema.hp = new fields.SchemaField({
value: new fields.NumberField({ ...requiredInteger, initial: 10, min: 0 }),
max: new fields.NumberField({ ...requiredInteger, initial: 10, min: 0 }),
temp: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 })
})
// Flow Points
schema.flowPoints = new fields.SchemaField({
value: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }),
temp: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 })
})
// Attributes: agility, fitness, awareness, influence
// boostLevel: how many boosts applied (0-4)
// mod = level + boostLevel (computed in prepareDerivedData)
// dc = 10 + mod (computed)
// bonus: manual +/- bonus
const attributeField = () => new fields.SchemaField({
boostLevel: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0, max: 4 }),
bonus: new fields.NumberField({ required: true, nullable: false, integer: true, initial: 0 })
})
schema.attributes = new fields.SchemaField(
Object.values(SYSTEM.ATTRIBUTES).reduce((obj, attr) => {
obj[attr.id] = attributeField()
return obj
}, {})
)
return schema
}
/** @override */
prepareDerivedData() {
super.prepareDerivedData()
const level = this.level
for (const attrId of Object.keys(SYSTEM.ATTRIBUTES)) {
const attr = this.attributes[attrId]
attr.mod = level + attr.boostLevel + attr.bonus
attr.dc = 10 + attr.mod
}
// Compute max HP if not overridden
// Base HP = 10 + (level * 2) + fitness modifier
const fitnessMod = this.attributes.fitness.mod ?? 0
if (this.hp.max === 10) {
this.hp.max = 10 + (level * 2) + fitnessMod
}
}
}
+46
View File
@@ -0,0 +1,46 @@
export default class AwECreature extends foundry.abstract.TypeDataModel {
static defineSchema() {
const fields = foundry.data.fields
const requiredInteger = { required: true, nullable: false, integer: true }
const schema = {}
schema.description = new fields.HTMLField({ required: true, textSearch: true })
schema.level = new fields.NumberField({ ...requiredInteger, initial: 1, min: 1 })
schema.stride = new fields.NumberField({ ...requiredInteger, initial: 5, min: 0 })
schema.hp = new fields.SchemaField({
value: new fields.NumberField({ ...requiredInteger, initial: 10, min: 0 }),
max: new fields.NumberField({ ...requiredInteger, initial: 10, min: 0 })
})
// Raw attribute values (mod = value directly, no boosts)
schema.attributes = new fields.SchemaField({
agility: new fields.SchemaField({
mod: new fields.NumberField({ ...requiredInteger, initial: 2 }),
dc: new fields.NumberField({ ...requiredInteger, initial: 12 })
}),
fitness: new fields.SchemaField({
mod: new fields.NumberField({ ...requiredInteger, initial: 2 }),
dc: new fields.NumberField({ ...requiredInteger, initial: 12 })
}),
awareness: new fields.SchemaField({
mod: new fields.NumberField({ ...requiredInteger, initial: 2 }),
dc: new fields.NumberField({ ...requiredInteger, initial: 12 })
}),
influence: new fields.SchemaField({
mod: new fields.NumberField({ ...requiredInteger, initial: 2 }),
dc: new fields.NumberField({ ...requiredInteger, initial: 12 })
})
})
// Eureka Rubric
schema.eurekaClaims = new fields.StringField({ initial: "", required: false, nullable: true })
schema.eurekaEvidence = new fields.StringField({ initial: "", required: false, nullable: true })
schema.eurekaThreshold1 = new fields.StringField({ initial: "", required: false, nullable: true })
schema.eurekaThreshold2 = new fields.StringField({ initial: "", required: false, nullable: true })
schema.eurekaHints = new fields.StringField({ initial: "", required: false, nullable: true })
return schema
}
}
+13
View File
@@ -0,0 +1,13 @@
export default class AwEEquipment extends foundry.abstract.TypeDataModel {
static defineSchema() {
const fields = foundry.data.fields
const requiredInteger = { required: true, nullable: false, integer: true }
const schema = {}
schema.description = new fields.HTMLField({ required: true, textSearch: true })
schema.quantity = new fields.NumberField({ ...requiredInteger, initial: 1, min: 0 })
schema.weight = new fields.NumberField({ required: true, nullable: false, initial: 0, min: 0 })
return schema
}
}
+26
View File
@@ -0,0 +1,26 @@
import { SYSTEM } from "../config/system.mjs"
export default class AwEField extends foundry.abstract.TypeDataModel {
static defineSchema() {
const fields = foundry.data.fields
const schema = {}
schema.description = new fields.HTMLField({ required: true, textSearch: true })
schema.keyAttribute = new fields.StringField({
required: true,
nullable: false,
initial: "agility",
choices: Object.keys(SYSTEM.ATTRIBUTES)
})
schema.keyAttribute2 = new fields.StringField({
required: false,
nullable: true,
initial: null,
choices: [...Object.keys(SYSTEM.ATTRIBUTES), null]
})
schema.specializations = new fields.ArrayField(new fields.StringField())
schema.knowledgeBonus = new fields.StringField({ initial: "", required: false, nullable: true })
return schema
}
}
+16
View File
@@ -0,0 +1,16 @@
export default class AwEKit extends foundry.abstract.TypeDataModel {
static defineSchema() {
const fields = foundry.data.fields
const requiredInteger = { required: true, nullable: false, integer: true }
const schema = {}
schema.description = new fields.HTMLField({ required: true, textSearch: true })
schema.fieldName = new fields.StringField({ initial: "", required: false, nullable: true })
schema.charges = new fields.SchemaField({
value: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }),
max: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 })
})
return schema
}
}
+23
View File
@@ -0,0 +1,23 @@
import { SYSTEM } from "../config/system.mjs"
export default class AwEWeapon extends foundry.abstract.TypeDataModel {
static defineSchema() {
const fields = foundry.data.fields
const requiredInteger = { required: true, nullable: false, integer: true }
const schema = {}
schema.description = new fields.HTMLField({ required: true, textSearch: true })
schema.range = new fields.NumberField({ ...requiredInteger, initial: 1, min: 0 })
schema.damageFormula = new fields.StringField({ initial: "1d6", required: true, nullable: false })
schema.damageType = new fields.StringField({ initial: "physical", required: true, nullable: false })
schema.attackAttribute = new fields.StringField({
required: true,
nullable: false,
initial: "agility",
choices: Object.keys(SYSTEM.ATTRIBUTES)
})
schema.traits = new fields.ArrayField(new fields.StringField())
return schema
}
}