Add initiative rolls
This commit is contained in:
@@ -66,6 +66,7 @@ Hooks.once("init", function () {
|
|||||||
|
|
||||||
CONFIG.ChatMessage.documentClass = documents.AwEChatMessage
|
CONFIG.ChatMessage.documentClass = documents.AwEChatMessage
|
||||||
CONFIG.Dice.rolls.push(documents.AwERoll)
|
CONFIG.Dice.rolls.push(documents.AwERoll)
|
||||||
|
CONFIG.Combatant.documentClass = documents.AwECombatant
|
||||||
|
|
||||||
// Handlebars helpers
|
// Handlebars helpers
|
||||||
Handlebars.registerHelper("abs", (value) => Math.abs(value ?? 0))
|
Handlebars.registerHelper("abs", (value) => Math.abs(value ?? 0))
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import { SYSTEM } from "../../config/system.mjs"
|
||||||
|
|
||||||
const { HandlebarsApplicationMixin } = foundry.applications.api
|
const { HandlebarsApplicationMixin } = foundry.applications.api
|
||||||
|
|
||||||
export default class AwEItemSheet extends HandlebarsApplicationMixin(foundry.applications.sheets.ItemSheetV2) {
|
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.isEditMode = this.isEditMode
|
||||||
context.isPlayMode = this.isPlayMode
|
context.isPlayMode = this.isPlayMode
|
||||||
context.isEditable = this.isEditable
|
context.isEditable = this.isEditable
|
||||||
|
context.traitSuggestions = SYSTEM.TRAITS
|
||||||
return context
|
return context
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
// Re-export all for convenience
|
||||||
export const SYSTEM = {
|
export const SYSTEM = {
|
||||||
SYSTEM_ID,
|
SYSTEM_ID,
|
||||||
@@ -61,5 +80,6 @@ export const SYSTEM = {
|
|||||||
ABILITY_COST,
|
ABILITY_COST,
|
||||||
ABILITY_TYPE,
|
ABILITY_TYPE,
|
||||||
OUTCOME_LABELS,
|
OUTCOME_LABELS,
|
||||||
|
TRAITS,
|
||||||
ASCII
|
ASCII
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,3 +2,4 @@ export { default as AwEActor } from "./actor.mjs"
|
|||||||
export { default as AwEItem } from "./item.mjs"
|
export { default as AwEItem } from "./item.mjs"
|
||||||
export { default as AwERoll } from "./roll.mjs"
|
export { default as AwERoll } from "./roll.mjs"
|
||||||
export { default as AwEChatMessage } from "./chat-message.mjs"
|
export { default as AwEChatMessage } from "./chat-message.mjs"
|
||||||
|
export { default as AwECombatant } from "./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)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -37,7 +37,12 @@
|
|||||||
{{#each system.traits}}
|
{{#each system.traits}}
|
||||||
<span class="tag">{{this}} <a data-action="removeTrait" data-index="{{@index}}">×</a></span>
|
<span class="tag">{{this}} <a data-action="removeTrait" data-index="{{@index}}">×</a></span>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
<input type="text" class="new-tag" data-action="addTrait" placeholder="{{localize 'AWEMMY.Ability.AddTrait'}}" />
|
<input type="text" class="new-tag" data-action="addTrait"
|
||||||
|
list="awemmy-trait-suggestions"
|
||||||
|
placeholder="{{localize 'AWEMMY.Ability.AddTrait'}}" />
|
||||||
|
<datalist id="awemmy-trait-suggestions">
|
||||||
|
{{#each traitSuggestions}}<option value="{{this}}">{{/each}}
|
||||||
|
</datalist>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,12 @@
|
|||||||
{{#each system.traits}}
|
{{#each system.traits}}
|
||||||
<span class="tag">{{this}} <a data-action="removeTrait" data-index="{{@index}}">×</a></span>
|
<span class="tag">{{this}} <a data-action="removeTrait" data-index="{{@index}}">×</a></span>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
<input type="text" class="new-tag" data-action="addTrait" placeholder="{{localize 'AWEMMY.Ability.AddTrait'}}" />
|
<input type="text" class="new-tag" data-action="addTrait"
|
||||||
|
list="awemmy-trait-suggestions"
|
||||||
|
placeholder="{{localize 'AWEMMY.Ability.AddTrait'}}" />
|
||||||
|
<datalist id="awemmy-trait-suggestions">
|
||||||
|
{{#each traitSuggestions}}<option value="{{this}}">{{/each}}
|
||||||
|
</datalist>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user