Fixes and enhancements, from issue list
This commit is contained in:
@@ -56,10 +56,11 @@ export function injectFreeRollBar(_chatLog, html) {
|
||||
rollFree(pool, color, explode5)
|
||||
})
|
||||
|
||||
// Insert between .chat-scroll and .chat-form
|
||||
// Insert before the chat form — use chatForm.parentElement for AppV2 compatibility
|
||||
// (in v13 parts are nested inside the app element, not direct children)
|
||||
const chatForm = html.querySelector(".chat-form")
|
||||
if (chatForm) {
|
||||
html.insertBefore(bar, chatForm)
|
||||
chatForm.parentElement.insertBefore(bar, chatForm)
|
||||
} else {
|
||||
html.appendChild(bar)
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ export default class OathHammerCharacterSheet extends OathHammerActorSheet {
|
||||
rollInitiative: OathHammerCharacterSheet.#onRollInitiative,
|
||||
adjustQty: OathHammerCharacterSheet.#onAdjustQty,
|
||||
adjustCurrency: OathHammerCharacterSheet.#onAdjustCurrency,
|
||||
adjustStress: OathHammerCharacterSheet.#onAdjustStress,
|
||||
adjustLuck: OathHammerCharacterSheet.#onAdjustLuck,
|
||||
clearStress: OathHammerCharacterSheet.#onClearStress,
|
||||
},
|
||||
}
|
||||
@@ -410,6 +410,13 @@ export default class OathHammerCharacterSheet extends OathHammerActorSheet {
|
||||
await this.document.update({ [field]: Math.max(0, current + delta) })
|
||||
}
|
||||
|
||||
static async #onAdjustLuck(event, target) {
|
||||
const delta = parseInt(target.dataset.delta, 10)
|
||||
const current = this.document.system.luck.value ?? 0
|
||||
// No upper cap — luck can exceed max (e.g. from blessings/bonuses)
|
||||
await this.document.update({ "system.luck.value": Math.max(0, current + delta) })
|
||||
}
|
||||
|
||||
static async #onAdjustStress(event, target) {
|
||||
const delta = parseInt(target.dataset.delta, 10)
|
||||
const current = this.document.system.arcaneStress.value ?? 0
|
||||
|
||||
@@ -172,6 +172,7 @@ export default class OathHammerNPCSheet extends OathHammerActorSheet {
|
||||
colorType: attack.system.colorDiceType,
|
||||
threshold: attack.system.threshold,
|
||||
bonusOptions,
|
||||
showExplodeOn5: true,
|
||||
colorChoices: Object.fromEntries(
|
||||
Object.entries(SYSTEM.DICE_COLOR_TYPES).map(([k, v]) => [k, game.i18n.localize(v)])
|
||||
),
|
||||
@@ -194,6 +195,7 @@ export default class OathHammerNPCSheet extends OathHammerActorSheet {
|
||||
|
||||
await rollNPCAttackDamage(this.document, attack, {
|
||||
bonus: parseInt(getValue("bonus")) || 0,
|
||||
explodeOn5: getValue("explodeOn5") === "true",
|
||||
visibility: getValue("visibility"),
|
||||
})
|
||||
}
|
||||
@@ -228,6 +230,7 @@ export default class OathHammerNPCSheet extends OathHammerActorSheet {
|
||||
itemName: spell.name, itemImg: spell.img,
|
||||
dv: spell.system.difficultyValue,
|
||||
poolOptions, bonusOptions, colorChoices, showColor: true,
|
||||
showExplodeOn5: true,
|
||||
rollModes: foundry.utils.duplicate(CONFIG.Dice.rollModes),
|
||||
visibility: game.settings.get("core", "rollMode"),
|
||||
}
|
||||
@@ -249,6 +252,7 @@ export default class OathHammerNPCSheet extends OathHammerActorSheet {
|
||||
dicePool: parseInt(getValue("dicePool")) || 3,
|
||||
bonus: parseInt(getValue("bonus")) || 0,
|
||||
colorOverride: getValue("colorOverride") || null,
|
||||
explodeOn5: getValue("explodeOn5") === "true",
|
||||
visibility: getValue("visibility"),
|
||||
})
|
||||
}
|
||||
@@ -272,6 +276,7 @@ export default class OathHammerNPCSheet extends OathHammerActorSheet {
|
||||
itemName: miracle.name, itemImg: miracle.img,
|
||||
dv: null, showColor: false,
|
||||
poolOptions, bonusOptions,
|
||||
showExplodeOn5: true,
|
||||
rollModes: foundry.utils.duplicate(CONFIG.Dice.rollModes),
|
||||
visibility: game.settings.get("core", "rollMode"),
|
||||
}
|
||||
@@ -292,6 +297,7 @@ export default class OathHammerNPCSheet extends OathHammerActorSheet {
|
||||
await rollNPCMiracle(this.document, miracle, {
|
||||
dicePool: parseInt(getValue("dicePool")) || 3,
|
||||
bonus: parseInt(getValue("bonus")) || 0,
|
||||
explodeOn5: getValue("explodeOn5") === "true",
|
||||
visibility: getValue("visibility"),
|
||||
})
|
||||
}
|
||||
@@ -323,6 +329,7 @@ export default class OathHammerNPCSheet extends OathHammerActorSheet {
|
||||
threshold,
|
||||
bonusOptions,
|
||||
colorChoices,
|
||||
showExplodeOn5: true,
|
||||
rollModes: foundry.utils.duplicate(CONFIG.Dice.rollModes),
|
||||
visibility: game.settings.get("core", "rollMode"),
|
||||
}
|
||||
@@ -343,6 +350,7 @@ export default class OathHammerNPCSheet extends OathHammerActorSheet {
|
||||
await rollNPCArmor(actor, {
|
||||
bonus: parseInt(getValue("bonus")) || 0,
|
||||
colorOverride: getValue("colorOverride") || null,
|
||||
explodeOn5: getValue("explodeOn5") === "true",
|
||||
visibility: getValue("visibility"),
|
||||
})
|
||||
}
|
||||
@@ -381,6 +389,7 @@ export default class OathHammerNPCSheet extends OathHammerActorSheet {
|
||||
threshold: item.system.threshold,
|
||||
bonusOptions,
|
||||
colorChoices,
|
||||
showExplodeOn5: true,
|
||||
rollModes: foundry.utils.duplicate(CONFIG.Dice.rollModes),
|
||||
visibility: game.settings.get("core", "rollMode"),
|
||||
}
|
||||
@@ -401,6 +410,7 @@ export default class OathHammerNPCSheet extends OathHammerActorSheet {
|
||||
await rollNPCSkill(this.document, item, {
|
||||
bonus: parseInt(getValue("bonus")) || 0,
|
||||
colorOverride: getValue("colorOverride") || null,
|
||||
explodeOn5: getValue("explodeOn5") === "true",
|
||||
visibility: getValue("visibility"),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -10,9 +10,10 @@ export default class OathHammerPartySheet extends OathHammerActorSheet {
|
||||
window: { contentClasses: ["party-content"] },
|
||||
actions: {
|
||||
openMember: OathHammerPartySheet.#onOpenMember,
|
||||
removeMember: OathHammerPartySheet.#onRemoveMember,
|
||||
moveMemberUp: OathHammerPartySheet.#onMoveMemberUp,
|
||||
moveMemberDown: OathHammerPartySheet.#onMoveMemberDown,
|
||||
removeMember: OathHammerPartySheet.#onRemoveMember,
|
||||
moveMemberUp: OathHammerPartySheet.#onMoveMemberUp,
|
||||
moveMemberDown: OathHammerPartySheet.#onMoveMemberDown,
|
||||
toggleCarriesLight: OathHammerPartySheet.#onToggleCarriesLight,
|
||||
adjustCurrency: OathHammerPartySheet.#onAdjustCurrency,
|
||||
adjustQty: OathHammerPartySheet.#onAdjustQty,
|
||||
},
|
||||
@@ -53,28 +54,41 @@ export default class OathHammerPartySheet extends OathHammerActorSheet {
|
||||
async _preparePartContext(partId, context) {
|
||||
const doc = this.document
|
||||
switch (partId) {
|
||||
case "main":
|
||||
case "main": {
|
||||
const lootItems = doc.items.contents.filter(i => ALLOWED_LOOT_TYPES.has(i.type))
|
||||
context.currentSlots = lootItems.reduce((sum, i) => {
|
||||
const slots = i.system.slots ?? 0
|
||||
const qty = i.system.quantity ?? 1
|
||||
return sum + slots * qty
|
||||
}, 0)
|
||||
break
|
||||
}
|
||||
|
||||
case "members": {
|
||||
context.tab = context.tabs.members
|
||||
const refs = doc.system.memberRefs ?? []
|
||||
context.members = refs.map((id, idx) => {
|
||||
const actor = game.actors?.get(id)
|
||||
context.members = refs.map((ref, idx) => {
|
||||
const actor = game.actors?.get(ref.id)
|
||||
if (!actor) return null
|
||||
const sys = actor.system
|
||||
const classItem = actor.items?.find(i => i.type === "class")
|
||||
const isNpc = actor.type === "npc"
|
||||
const classItem = !isNpc ? actor.items?.find(i => i.type === "class") : null
|
||||
return {
|
||||
id: actor.id,
|
||||
name: actor.name,
|
||||
img: actor.img,
|
||||
id: actor.id,
|
||||
name: actor.name,
|
||||
img: actor.img,
|
||||
type: actor.type,
|
||||
idx,
|
||||
position: idx + 1,
|
||||
isFirst: idx === 0,
|
||||
isLast: idx === refs.length - 1,
|
||||
classLabel: classItem?.name ?? "—",
|
||||
level: sys.level ?? "—",
|
||||
grit: sys.grit ? `${sys.grit.value}/${sys.grit.max}` : "—",
|
||||
position: idx + 1,
|
||||
isFirst: idx === 0,
|
||||
isLast: idx === refs.length - 1,
|
||||
carriesLight: ref.carriesLight ?? false,
|
||||
classLabel: isNpc
|
||||
? game.i18n.localize(`OATHHAMMER.NpcSubtype.${sys.subtype === "creature" ? "Creature" : "Npc"}`)
|
||||
: (classItem?.name ?? "—"),
|
||||
lineage: !isNpc ? (sys.lineage?.name || "—") : "—",
|
||||
current: !isNpc ? (sys.experience?.current ?? "—") : "—",
|
||||
grit: sys.grit ? `${sys.grit.value}/${sys.grit.max}` : "—",
|
||||
}
|
||||
}).filter(Boolean)
|
||||
break
|
||||
@@ -109,10 +123,10 @@ export default class OathHammerPartySheet extends OathHammerActorSheet {
|
||||
|
||||
if (data.type === "Actor") {
|
||||
const actor = await fromUuid(data.uuid)
|
||||
if (!actor || actor.type !== "character") return
|
||||
if (!actor || !["character", "npc"].includes(actor.type)) return
|
||||
const refs = foundry.utils.deepClone(this.document.system.memberRefs ?? [])
|
||||
if (refs.includes(actor.id)) return
|
||||
refs.push(actor.id)
|
||||
if (refs.some(r => r.id === actor.id)) return
|
||||
refs.push({ id: actor.id, carriesLight: false })
|
||||
return this.document.update({ "system.memberRefs": refs })
|
||||
}
|
||||
|
||||
@@ -132,7 +146,7 @@ export default class OathHammerPartySheet extends OathHammerActorSheet {
|
||||
|
||||
static async #onRemoveMember(event, target) {
|
||||
const id = target.dataset.actorId
|
||||
const refs = (this.document.system.memberRefs ?? []).filter(r => r !== id)
|
||||
const refs = (this.document.system.memberRefs ?? []).filter(r => r.id !== id)
|
||||
await this.document.update({ "system.memberRefs": refs })
|
||||
}
|
||||
|
||||
@@ -152,6 +166,14 @@ export default class OathHammerPartySheet extends OathHammerActorSheet {
|
||||
await this.document.update({ "system.memberRefs": refs })
|
||||
}
|
||||
|
||||
static async #onToggleCarriesLight(event, target) {
|
||||
const idx = parseInt(target.dataset.idx, 10)
|
||||
const refs = foundry.utils.deepClone(this.document.system.memberRefs ?? [])
|
||||
if (!refs[idx]) return
|
||||
refs[idx].carriesLight = !refs[idx].carriesLight
|
||||
await this.document.update({ "system.memberRefs": refs })
|
||||
}
|
||||
|
||||
static async #onAdjustCurrency(event, target) {
|
||||
const field = target.dataset.field
|
||||
const delta = parseInt(target.dataset.delta, 10)
|
||||
|
||||
@@ -56,6 +56,9 @@ export default class OathHammerRegimentSheet extends OathHammerActorSheet {
|
||||
context.colorChoices = Object.fromEntries(
|
||||
Object.entries(SYSTEM.DICE_COLOR_TYPES).map(([k, v]) => [k, game.i18n.localize(v)])
|
||||
)
|
||||
context.traitTypeLabels = Object.fromEntries(
|
||||
Object.entries(SYSTEM.TRAIT_TYPE_CHOICES).map(([k, v]) => [k, v])
|
||||
)
|
||||
// Resolve leader actor
|
||||
const leaderUuid = this.document.system.leaderUuid
|
||||
if (leaderUuid) {
|
||||
@@ -75,7 +78,7 @@ export default class OathHammerRegimentSheet extends OathHammerActorSheet {
|
||||
break
|
||||
case "skills":
|
||||
context.tab = context.tabs.skills
|
||||
context.skills = doc.itemTypes.skillnpc ?? []
|
||||
context.skills = (doc.itemTypes.skillnpc ?? []).slice().sort((a, b) => a.name.localeCompare(b.name))
|
||||
break
|
||||
case "combat":
|
||||
context.tab = context.tabs.combat
|
||||
@@ -141,6 +144,9 @@ export default class OathHammerRegimentSheet extends OathHammerActorSheet {
|
||||
const doc = this.document
|
||||
const armorDice = doc.system.armorDice
|
||||
if (!armorDice?.value) return ui.notifications.info("No armor dice to roll.")
|
||||
const colorType = armorDice.colorDiceType || "white"
|
||||
const threshold = colorType === "black" ? 2 : colorType === "red" ? 3 : 4
|
||||
const colorEmoji = colorType === "black" ? "⬛" : colorType === "red" ? "🔴" : "⬜"
|
||||
const bonusOptions = Array.from({ length: 13 }, (_, i) => {
|
||||
const v = i - 6
|
||||
return { value: v, label: v > 0 ? `+${v}` : String(v), selected: v === 0 }
|
||||
@@ -149,9 +155,10 @@ export default class OathHammerRegimentSheet extends OathHammerActorSheet {
|
||||
"systems/fvtt-oath-hammer/templates/npc-skill-dialog.hbs",
|
||||
{
|
||||
skillName: game.i18n.localize("OATHHAMMER.Label.ArmorDice"),
|
||||
skillImg: doc.img, basePool: armorDice.value, bonusOptions,
|
||||
skillImg: doc.img, dicePool: armorDice.value,
|
||||
colorType, colorEmoji, threshold, bonusOptions,
|
||||
colorChoices: { white: "⬜ White (4+)", red: "🔴 Red (3+)", black: "⬛ Black (2+)" },
|
||||
selectedColor: armorDice.colorDiceType,
|
||||
showExplodeOn5: true,
|
||||
rollModes: foundry.utils.duplicate(CONFIG.Dice.rollModes),
|
||||
visibility: game.settings.get("core", "rollMode")
|
||||
}
|
||||
@@ -165,15 +172,19 @@ export default class OathHammerRegimentSheet extends OathHammerActorSheet {
|
||||
const form = new DOMParser().parseFromString(result, "text/html")
|
||||
const getValue = n => form.querySelector(`[name="${n}"]`)?.value
|
||||
await rollNPCArmor(doc, {
|
||||
bonus: parseInt(getValue("bonus")) || 0,
|
||||
bonus: parseInt(getValue("bonus")) || 0,
|
||||
colorOverride: getValue("colorOverride") || null,
|
||||
visibility: getValue("visibility"),
|
||||
explodeOn5: getValue("explodeOn5") === "true",
|
||||
visibility: getValue("visibility"),
|
||||
})
|
||||
}
|
||||
|
||||
static async #onRollSkillNPC(event, target) {
|
||||
const skill = this.document.items.get(target.dataset.itemId)
|
||||
if (!skill) return
|
||||
const colorType = skill.system.colorDiceType || "white"
|
||||
const threshold = colorType === "black" ? 2 : colorType === "red" ? 3 : 4
|
||||
const colorEmoji = colorType === "black" ? "⬛" : colorType === "red" ? "🔴" : "⬜"
|
||||
const bonusOptions = Array.from({ length: 13 }, (_, i) => {
|
||||
const v = i - 6
|
||||
return { value: v, label: v > 0 ? `+${v}` : String(v), selected: v === 0 }
|
||||
@@ -181,9 +192,10 @@ export default class OathHammerRegimentSheet extends OathHammerActorSheet {
|
||||
const content = await foundry.applications.handlebars.renderTemplate(
|
||||
"systems/fvtt-oath-hammer/templates/npc-skill-dialog.hbs",
|
||||
{
|
||||
skillName: skill.name, skillImg: skill.img, basePool: skill.system.dicePool, bonusOptions,
|
||||
skillName: skill.name, skillImg: skill.img, dicePool: skill.system.dicePool,
|
||||
colorType, colorEmoji, threshold, bonusOptions,
|
||||
colorChoices: { white: "⬜ White (4+)", red: "🔴 Red (3+)", black: "⬛ Black (2+)" },
|
||||
selectedColor: skill.system.colorDiceType,
|
||||
showExplodeOn5: true,
|
||||
rollModes: foundry.utils.duplicate(CONFIG.Dice.rollModes),
|
||||
visibility: game.settings.get("core", "rollMode")
|
||||
}
|
||||
@@ -197,9 +209,10 @@ export default class OathHammerRegimentSheet extends OathHammerActorSheet {
|
||||
const form = new DOMParser().parseFromString(result, "text/html")
|
||||
const getValue = n => form.querySelector(`[name="${n}"]`)?.value
|
||||
await rollNPCSkill(this.document, skill, {
|
||||
bonus: parseInt(getValue("bonus")) || 0,
|
||||
bonus: parseInt(getValue("bonus")) || 0,
|
||||
colorOverride: getValue("colorOverride") || null,
|
||||
visibility: getValue("visibility"),
|
||||
explodeOn5: getValue("explodeOn5") === "true",
|
||||
visibility: getValue("visibility"),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -212,6 +225,9 @@ export default class OathHammerRegimentSheet extends OathHammerActorSheet {
|
||||
static async #onRollNpcAttack(event, target) {
|
||||
const attack = this.document.items.get(target.dataset.itemId)
|
||||
if (!attack) return
|
||||
const colorType = attack.system.colorDiceType || "white"
|
||||
const threshold = colorType === "black" ? 2 : colorType === "red" ? 3 : 4
|
||||
const colorEmoji = colorType === "black" ? "⬛" : colorType === "red" ? "🔴" : "⬜"
|
||||
const bonusOptions = Array.from({ length: 13 }, (_, i) => {
|
||||
const v = i - 6
|
||||
return { value: v, label: v > 0 ? `+${v}` : String(v), selected: v === 0 }
|
||||
@@ -219,9 +235,11 @@ export default class OathHammerRegimentSheet extends OathHammerActorSheet {
|
||||
const content = await foundry.applications.handlebars.renderTemplate(
|
||||
"systems/fvtt-oath-hammer/templates/npc-skill-dialog.hbs",
|
||||
{
|
||||
skillName: attack.name, skillImg: attack.img, basePool: attack.system.damageDice, bonusOptions,
|
||||
skillName: attack.name, skillImg: attack.img,
|
||||
dicePool: attack.system.damageDice,
|
||||
colorType, colorEmoji, threshold, bonusOptions,
|
||||
showExplodeOn5: true,
|
||||
colorChoices: { white: "⬜ White (4+)", red: "🔴 Red (3+)", black: "⬛ Black (2+)" },
|
||||
selectedColor: attack.system.colorDiceType,
|
||||
rollModes: foundry.utils.duplicate(CONFIG.Dice.rollModes),
|
||||
visibility: game.settings.get("core", "rollMode")
|
||||
}
|
||||
@@ -235,9 +253,10 @@ export default class OathHammerRegimentSheet extends OathHammerActorSheet {
|
||||
const form = new DOMParser().parseFromString(result, "text/html")
|
||||
const getValue = n => form.querySelector(`[name="${n}"]`)?.value
|
||||
await rollNPCAttackDamage(this.document, attack, {
|
||||
bonus: parseInt(getValue("bonus")) || 0,
|
||||
bonus: parseInt(getValue("bonus")) || 0,
|
||||
colorOverride: getValue("colorOverride") || null,
|
||||
visibility: getValue("visibility"),
|
||||
explodeOn5: getValue("explodeOn5") === "true",
|
||||
visibility: getValue("visibility"),
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user