Fix in creature+actor sheet
This commit is contained in:
@@ -20,7 +20,11 @@ export default class AwECreatureSheet extends AwEActorSheet {
|
||||
createKit: AwECreatureSheet.#onCreateKit,
|
||||
createEquipment: AwECreatureSheet.#onCreateEquipment,
|
||||
rollWeapon: AwECreatureSheet.#onRollWeapon,
|
||||
rollDamage: AwECreatureSheet.#onRollDamage
|
||||
rollDamage: AwECreatureSheet.#onRollDamage,
|
||||
useAbility: AwECreatureSheet.#onUseAbility,
|
||||
toggleCondition: AwECreatureSheet.#onToggleCondition,
|
||||
addTrait: AwECreatureSheet.#onAddTrait,
|
||||
removeTrait: AwECreatureSheet.#onRemoveTrait
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,7 +90,8 @@ export default class AwECreatureSheet extends AwEActorSheet {
|
||||
name: item.name,
|
||||
img: item.img,
|
||||
system: item.system,
|
||||
costLabel: game.i18n.localize(SYSTEM.ABILITY_COST[item.system.cost]?.label ?? item.system.cost)
|
||||
costLabel: game.i18n.localize(SYSTEM.ABILITY_COST[item.system.cost]?.label ?? item.system.cost),
|
||||
usedToday: item.system.usedToday
|
||||
}))
|
||||
context.skills = this.document.itemTypes.skill.map(item => ({
|
||||
id: item.id,
|
||||
@@ -102,6 +107,19 @@ export default class AwECreatureSheet extends AwEActorSheet {
|
||||
img: item.img,
|
||||
system: item.system
|
||||
}))
|
||||
const doc = this.document
|
||||
context.conditions = Object.values(SYSTEM.CONDITIONS).map(c => ({
|
||||
...c,
|
||||
label: game.i18n.localize(c.label),
|
||||
img: `systems/fvtt-adventures-with-emmy/assets/conditions/${c.id}.svg`,
|
||||
active: doc.statuses.has(c.id)
|
||||
}))
|
||||
context.inhibitedActive = doc.statuses.has("inhibited")
|
||||
context.vulnerableActive = doc.statuses.has("vulnerable")
|
||||
context.inhibitedPenalty = doc.system.inhibitedPenalty
|
||||
context.vulnerablePenalty = doc.system.vulnerablePenalty
|
||||
context.hasConditionPenalties = context.inhibitedActive || context.vulnerableActive
|
||||
context.traitSuggestions = SYSTEM.TRAITS
|
||||
break
|
||||
case "inventory":
|
||||
context.tab = context.tabs.inventory
|
||||
@@ -135,6 +153,20 @@ export default class AwECreatureSheet extends AwEActorSheet {
|
||||
return super._onDropItem(item)
|
||||
}
|
||||
|
||||
/** @override */
|
||||
_onRender(context, options) {
|
||||
super._onRender(context, options)
|
||||
this.element.querySelectorAll("input.new-tag[data-action]").forEach(input => {
|
||||
input.addEventListener("keydown", event => {
|
||||
if (event.key !== "Enter") return
|
||||
event.preventDefault()
|
||||
const actionName = input.dataset.action
|
||||
const handler = this.options.actions?.[actionName]
|
||||
if (handler) handler.call(this, event, input)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
static #onCreateAbility(event, target) {
|
||||
const type = "ability"
|
||||
this.document.createEmbeddedDocuments("Item", [{ name: CONFIG.Item.documentClass.defaultName({ type }), type }])
|
||||
@@ -165,6 +197,16 @@ export default class AwECreatureSheet extends AwEActorSheet {
|
||||
this.document.createEmbeddedDocuments("Item", [{ name: CONFIG.Item.documentClass.defaultName({ type }), type }])
|
||||
}
|
||||
|
||||
static async #onUseAbility(event, target) {
|
||||
const itemId = target.closest("[data-item-id]")?.dataset.itemId
|
||||
await this.document.useAbility(itemId)
|
||||
}
|
||||
|
||||
static async #onToggleCondition(event, target) {
|
||||
const conditionId = target.dataset.conditionId
|
||||
await this.document.toggleStatusEffect(conditionId)
|
||||
}
|
||||
|
||||
static async #onRollWeapon(event, target) {
|
||||
const itemId = target.closest("[data-item-id]")?.dataset.itemId
|
||||
const item = this.document.items.get(itemId)
|
||||
@@ -178,4 +220,19 @@ export default class AwECreatureSheet extends AwEActorSheet {
|
||||
if (!item) return
|
||||
await this.document.rollDamage(item)
|
||||
}
|
||||
|
||||
static async #onAddTrait(event, target) {
|
||||
const value = target.value.trim()
|
||||
if (!value) return
|
||||
const current = foundry.utils.getProperty(this.document, "system.traits") ?? []
|
||||
await this.document.update({ "system.traits": [...current, value] })
|
||||
target.value = ""
|
||||
}
|
||||
|
||||
static async #onRemoveTrait(event, target) {
|
||||
const index = Number(target.dataset.index)
|
||||
const current = [...(foundry.utils.getProperty(this.document, "system.traits") ?? [])]
|
||||
current.splice(index, 1)
|
||||
await this.document.update({ "system.traits": current })
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,8 +84,8 @@ export default class AwERoll extends Roll {
|
||||
Object.entries(CONFIG.Dice.rollModes).map(([k, v]) => [k, game.i18n.localize(v.label ?? v)])
|
||||
)
|
||||
|
||||
// Bonus choices: -5 to +5
|
||||
const bonusChoices = Array.from({length: 11}, (_, i) => i - 5)
|
||||
// Bonus choices: -10 to +10
|
||||
const bonusChoices = Array.from({length: 21}, (_, i) => i - 10)
|
||||
.map(v => ({ value: v, label: v > 0 ? `+${v}` : String(v), selected: v === 0 }))
|
||||
|
||||
// DC choices: blank + 10..30
|
||||
|
||||
@@ -51,6 +51,13 @@ export default class AwECharacter extends foundry.abstract.TypeDataModel {
|
||||
}, {})
|
||||
)
|
||||
|
||||
schema.keyAttribute = new fields.StringField({
|
||||
required: true,
|
||||
nullable: false,
|
||||
initial: "agility",
|
||||
choices: Object.fromEntries(Object.values(SYSTEM.ATTRIBUTES).map(a => [a.id, a.label]))
|
||||
})
|
||||
|
||||
// Condition penalty magnitudes (used when the respective condition is active)
|
||||
schema.inhibitedPenalty = new fields.NumberField({ required: true, nullable: false, integer: true, initial: 2, min: 0 })
|
||||
schema.vulnerablePenalty = new fields.NumberField({ required: true, nullable: false, integer: true, initial: 2, min: 0 })
|
||||
@@ -70,5 +77,8 @@ export default class AwECharacter extends foundry.abstract.TypeDataModel {
|
||||
const bonusPart = attr.bonus !== 0 ? ` + Bonus ${attr.bonus >= 0 ? '+' : ''}${attr.bonus}` : ''
|
||||
attr.modBreakdown = `Level ${level} + Boosts ${attr.boostLevel}${bonusPart} = ${attr.mod >= 0 ? '+' : ''}${attr.mod}`
|
||||
}
|
||||
|
||||
this.hp.max = (10 * level) + this.attributes.fitness.mod
|
||||
this.hp.value = Math.min(this.hp.value, this.hp.max)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,6 +34,10 @@ export default class AwECreature extends foundry.abstract.TypeDataModel {
|
||||
})
|
||||
})
|
||||
|
||||
schema.traits = new fields.ArrayField(new fields.StringField())
|
||||
schema.inhibitedPenalty = new fields.NumberField({ required: true, nullable: false, integer: true, initial: 2, min: 0 })
|
||||
schema.vulnerablePenalty = new fields.NumberField({ required: true, nullable: false, integer: true, initial: 2, min: 0 })
|
||||
|
||||
// Eureka Rubric
|
||||
schema.eurekaClaims = new fields.StringField({ initial: "", required: false, nullable: true })
|
||||
schema.eurekaEvidence = new fields.StringField({ initial: "", required: false, nullable: true })
|
||||
|
||||
Reference in New Issue
Block a user