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
+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)
}
}