Various fixes/update based on first tests feedback
This commit is contained in:
+19
-21
@@ -146,21 +146,15 @@ export default class AwEActor extends Actor {
|
||||
}
|
||||
|
||||
/**
|
||||
* Use a kit item: decrement charges and post a chat message.
|
||||
* Use a kit item: post a chat message.
|
||||
* @param {string} kitId - The kit item ID.
|
||||
*/
|
||||
async useKit(kitId) {
|
||||
const item = this.items.get(kitId)
|
||||
if (!item) return
|
||||
const charges = item.system.charges
|
||||
if (charges.value <= 0) {
|
||||
ui.notifications.warn(game.i18n.format("AWEMMY.Kit.Depleted", { name: item.name }))
|
||||
return
|
||||
}
|
||||
await item.update({ "system.charges.value": charges.value - 1 })
|
||||
await ChatMessage.create({
|
||||
speaker: ChatMessage.getSpeaker({ actor: this }),
|
||||
content: `<p>${game.i18n.format("AWEMMY.Kit.Used", { name: item.name, value: charges.value - 1, max: charges.max })}</p>`
|
||||
content: `<p>${game.i18n.format("AWEMMY.Kit.Used", { name: item.name })}</p>`
|
||||
})
|
||||
}
|
||||
|
||||
@@ -173,7 +167,8 @@ export default class AwEActor extends Actor {
|
||||
if (!item) return
|
||||
const sys = item.system
|
||||
|
||||
if (sys.usedToday) {
|
||||
const isDaily = sys.isDaily
|
||||
if (isDaily && sys.usedToday) {
|
||||
ui.notifications.warn(game.i18n.format("AWEMMY.Ability.AlreadyUsed", { name: item.name }))
|
||||
return
|
||||
}
|
||||
@@ -187,7 +182,6 @@ export default class AwEActor extends Actor {
|
||||
await this.update({ "system.flowPoints.value": fp - sys.flowPointCost })
|
||||
}
|
||||
|
||||
const isDaily = sys.frequency?.toLowerCase().includes("day")
|
||||
if (isDaily) await item.update({ "system.usedToday": true })
|
||||
|
||||
const abilityTypeLabel = game.i18n.localize(SYSTEM.ABILITY_TYPE[sys.abilityType]?.label ?? sys.abilityType)
|
||||
@@ -212,7 +206,18 @@ export default class AwEActor extends Actor {
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform a long rest: restore HP, reset daily abilities, refill kits, post chat card.
|
||||
* Reset all once-per-day abilities (usedToday → false).
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async resetDailyAbilities() {
|
||||
const dailyAbilities = this.itemTypes.ability.filter(i => i.system.usedToday)
|
||||
if (!dailyAbilities.length) return 0
|
||||
await this.updateEmbeddedDocuments("Item", dailyAbilities.map(i => ({ _id: i.id, "system.usedToday": false })))
|
||||
return dailyAbilities.length
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform a long rest: restore HP, reset daily abilities, post chat card.
|
||||
* No confirmation dialog — caller is responsible for confirming if needed.
|
||||
*/
|
||||
async longRest() {
|
||||
@@ -227,16 +232,9 @@ export default class AwEActor extends Actor {
|
||||
}
|
||||
if (Object.keys(updates).length > 0) await this.update(updates)
|
||||
|
||||
const dailyAbilities = this.itemTypes.ability.filter(i => i.system.usedToday)
|
||||
if (dailyAbilities.length) {
|
||||
await this.updateEmbeddedDocuments("Item", dailyAbilities.map(i => ({ _id: i.id, "system.usedToday": false })))
|
||||
summary.push(game.i18n.format("AWEMMY.Rest.AbilitiesReset", { count: dailyAbilities.length }))
|
||||
}
|
||||
|
||||
const depleted = this.itemTypes.kit.filter(i => i.system.charges.value < i.system.charges.max)
|
||||
if (depleted.length) {
|
||||
await this.updateEmbeddedDocuments("Item", depleted.map(i => ({ _id: i.id, "system.charges.value": i.system.charges.max })))
|
||||
summary.push(game.i18n.format("AWEMMY.Rest.KitsReplenished", { count: depleted.length }))
|
||||
const resetCount = await this.resetDailyAbilities()
|
||||
if (resetCount > 0) {
|
||||
summary.push(game.i18n.format("AWEMMY.Rest.AbilitiesReset", { count: resetCount }))
|
||||
}
|
||||
|
||||
const bulletList = summary.map(s => `<li>${s}</li>`).join("")
|
||||
|
||||
Reference in New Issue
Block a user