diff --git a/adventures-with-emmy.mjs b/adventures-with-emmy.mjs index 9ff70d3..7f54d61 100644 --- a/adventures-with-emmy.mjs +++ b/adventures-with-emmy.mjs @@ -66,6 +66,7 @@ Hooks.once("init", function () { CONFIG.ChatMessage.documentClass = documents.AwEChatMessage CONFIG.Dice.rolls.push(documents.AwERoll) + CONFIG.Combatant.documentClass = documents.AwECombatant // Handlebars helpers Handlebars.registerHelper("abs", (value) => Math.abs(value ?? 0)) diff --git a/module/applications/sheets/base-item-sheet.mjs b/module/applications/sheets/base-item-sheet.mjs index 60637ed..e6e44ec 100644 --- a/module/applications/sheets/base-item-sheet.mjs +++ b/module/applications/sheets/base-item-sheet.mjs @@ -1,3 +1,5 @@ +import { SYSTEM } from "../../config/system.mjs" + const { HandlebarsApplicationMixin } = foundry.applications.api export default class AwEItemSheet extends HandlebarsApplicationMixin(foundry.applications.sheets.ItemSheetV2) { @@ -72,6 +74,7 @@ export default class AwEItemSheet extends HandlebarsApplicationMixin(foundry.app context.isEditMode = this.isEditMode context.isPlayMode = this.isPlayMode context.isEditable = this.isEditable + context.traitSuggestions = SYSTEM.TRAITS return context } diff --git a/module/config/system.mjs b/module/config/system.mjs index 97468cd..4db246c 100644 --- a/module/config/system.mjs +++ b/module/config/system.mjs @@ -52,6 +52,25 @@ export const ASCII = ` |___/ ` +/** Default trait list extracted from the core rulebook. Open-ended: custom traits are always allowed. */ +export const TRAITS = [ + // Action traits + "attack", "discovered", "flow", "hypothesis", "intensive", "kit", "linguistic", + "manipulate", "review", "traversal", "velocity", + // Damage types + "acid", "bludgeoning", "cold", "electricity", "fire", "force", "mental", + "piercing", "poison", "slashing", "sonic", + // Mathematician / math traits + "electromagnetic", "geometry", "gravity", "numerical", "paradox", "probability", + // Special/narrative traits + "animal", "archetype", "aura", "auditory", "awarded", "axiom", + "design", "extradimensional", "fabricate", "gremlin", + "interdisciplinary", "large", "mishap", "number", + "plant", "prototype", "singular", "small", "teleportation", + // Field/class traits + "biologist", "chemist", "engineer", "mathematician", "physicist", +] + // Re-export all for convenience export const SYSTEM = { SYSTEM_ID, @@ -61,5 +80,6 @@ export const SYSTEM = { ABILITY_COST, ABILITY_TYPE, OUTCOME_LABELS, + TRAITS, ASCII } diff --git a/module/documents/_module.mjs b/module/documents/_module.mjs index 1e6febc..52f1ce1 100644 --- a/module/documents/_module.mjs +++ b/module/documents/_module.mjs @@ -2,3 +2,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" +export { default as AwECombatant } from "./combatant.mjs" diff --git a/module/documents/combatant.mjs b/module/documents/combatant.mjs new file mode 100644 index 0000000..b492196 --- /dev/null +++ b/module/documents/combatant.mjs @@ -0,0 +1,18 @@ +export default class AwECombatant extends Combatant { + /** + * Initiative = 1d20 + highest attribute modifier. + * @override + */ + getInitiativeRoll(formula) { + const actor = this.actor + if (!actor) return super.getInitiativeRoll(formula) + + const attrs = actor.system?.attributes ?? {} + const mods = ["agility", "awareness", "fitness", "influence"] + .map(k => attrs[k]?.mod ?? 0) + const highest = Math.max(...mods) + + const rollFormula = highest >= 0 ? `1d20 + ${highest}` : `1d20 - ${Math.abs(highest)}` + return Roll.create(rollFormula) + } +} diff --git a/templates/ability.hbs b/templates/ability.hbs index 81913eb..b31f286 100644 --- a/templates/ability.hbs +++ b/templates/ability.hbs @@ -37,7 +37,12 @@ {{#each system.traits}} {{this}} × {{/each}} - + + + {{#each traitSuggestions}} diff --git a/templates/weapon.hbs b/templates/weapon.hbs index bc874f1..1163052 100644 --- a/templates/weapon.hbs +++ b/templates/weapon.hbs @@ -32,7 +32,12 @@ {{#each system.traits}} {{this}} × {{/each}} - + + + {{#each traitSuggestions}}