IMplémentation de la ajorité des remarques de Nepherius
This commit is contained in:
@@ -29,6 +29,7 @@ export default class CelestopolActorSheet extends HandlebarsApplicationMixin(fou
|
||||
trackBox: CelestopolActorSheet.#onTrackBox,
|
||||
skillLevel: CelestopolActorSheet.#onSkillLevel,
|
||||
factionLevel: CelestopolActorSheet.#onFactionLevel,
|
||||
toggleArmure: CelestopolActorSheet.#onToggleArmure,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -173,12 +174,21 @@ export default class CelestopolActorSheet extends HandlebarsApplicationMixin(fou
|
||||
}
|
||||
|
||||
/** Met à jour le score d'une faction par clic sur un point. */
|
||||
static async #onToggleArmure(_event, target) {
|
||||
const uuid = target.closest('[data-item-uuid]')?.dataset.itemUuid
|
||||
if (!uuid) return
|
||||
const item = await fromUuid(uuid)
|
||||
if (item?.type === "armure") await item.update({ "system.equipped": !item.system.equipped })
|
||||
}
|
||||
|
||||
static #onFactionLevel(_event, target) {
|
||||
if (!this.isEditable) return
|
||||
const factionId = target.dataset.faction
|
||||
const index = parseInt(target.dataset.index)
|
||||
const index = parseInt(target.dataset.index) // 0-8
|
||||
const newValue = index - 4 // -4 à +4
|
||||
const current = this.document.system.factions[factionId]?.value ?? 0
|
||||
const newValue = (index <= current) ? index - 1 : index
|
||||
this.document.update({ [`system.factions.${factionId}.value`]: Math.max(0, newValue) })
|
||||
// Cliquer sur le dot actif (sauf neutre) remet à 0
|
||||
const finalValue = (newValue === current && newValue !== 0) ? 0 : newValue
|
||||
this.document.update({ [`system.factions.${factionId}.value`]: finalValue })
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ export default class CelestopolCharacterSheet extends CelestopolActorSheet {
|
||||
resetAnomalyUses: CelestopolCharacterSheet.#onResetAnomalyUses,
|
||||
depenseXp: CelestopolCharacterSheet.#onDepenseXp,
|
||||
supprimerXpLog: CelestopolCharacterSheet.#onSupprimerXpLog,
|
||||
rollMoonDie: CelestopolCharacterSheet.#onRollMoonDie,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -93,15 +94,46 @@ export default class CelestopolCharacterSheet extends CelestopolActorSheet {
|
||||
|
||||
case "factions":
|
||||
context.tab = context.tabs.factions
|
||||
context.factionRows = Object.entries(SYSTEM.FACTIONS).map(([id, fDef]) => {
|
||||
const val = this.document.system.factions[id]?.value ?? 0
|
||||
return {
|
||||
id,
|
||||
label: fDef.label,
|
||||
value: val,
|
||||
valueStr: val > 0 ? `+${val}` : `${val}`,
|
||||
dots: Array.from({ length: 9 }, (_, i) => ({
|
||||
index: i,
|
||||
filled: i <= val + 4,
|
||||
type: i < 4 ? "neg" : i === 4 ? "neutral" : "pos",
|
||||
})),
|
||||
}
|
||||
})
|
||||
context.factionCustom = ["perso1", "perso2"].map(id => {
|
||||
const f = this.document.system.factions[id]
|
||||
const val = f?.value ?? 0
|
||||
return {
|
||||
id,
|
||||
label: f?.label ?? "",
|
||||
value: val,
|
||||
valueStr: val > 0 ? `+${val}` : `${val}`,
|
||||
dots: Array.from({ length: 9 }, (_, i) => ({
|
||||
index: i,
|
||||
filled: i <= val + 4,
|
||||
type: i < 4 ? "neg" : i === 4 ? "neutral" : "pos",
|
||||
})),
|
||||
}
|
||||
})
|
||||
break
|
||||
|
||||
case "biography":
|
||||
context.tab = context.tabs.biography
|
||||
context.xpLogEmpty = (doc.system.xp?.log?.length ?? 0) === 0
|
||||
context.enrichedDescription = await foundry.applications.ux.TextEditor.implementation.enrichHTML(
|
||||
doc.system.description, { async: true })
|
||||
context.enrichedDescriptionPhysique = await foundry.applications.ux.TextEditor.implementation.enrichHTML(
|
||||
doc.system.descriptionPhysique, { relativeTo: this.document })
|
||||
context.enrichedDescriptionPsychologique = await foundry.applications.ux.TextEditor.implementation.enrichHTML(
|
||||
doc.system.descriptionPsychologique, { relativeTo: this.document })
|
||||
context.enrichedNotes = await foundry.applications.ux.TextEditor.implementation.enrichHTML(
|
||||
doc.system.notes, { async: true })
|
||||
doc.system.notes, { relativeTo: this.document })
|
||||
break
|
||||
|
||||
case "equipement":
|
||||
@@ -235,4 +267,10 @@ export default class CelestopolCharacterSheet extends CelestopolActorSheet {
|
||||
"system.xp.log": log,
|
||||
})
|
||||
}
|
||||
|
||||
/** Lance le Dé de la Lune de façon autonome depuis le header de la fiche. */
|
||||
static async #onRollMoonDie() {
|
||||
const { CelestopolRoll } = await import("../../documents/roll.mjs")
|
||||
await CelestopolRoll.rollMoonStandalone(this.document)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,24 +5,34 @@ export default class CelestopolNPCSheet extends CelestopolActorSheet {
|
||||
/** @override */
|
||||
static DEFAULT_OPTIONS = {
|
||||
classes: ["npc"],
|
||||
position: { width: 760, height: 600 },
|
||||
position: { width: 780, height: 640 },
|
||||
window: { contentClasses: ["npc-content"] },
|
||||
actions: {
|
||||
createAspect: CelestopolNPCSheet.#onCreateAspect,
|
||||
createWeapon: CelestopolNPCSheet.#onCreateWeapon,
|
||||
createArmure: CelestopolNPCSheet.#onCreateArmure,
|
||||
rollMoonDie: CelestopolNPCSheet.#onRollMoonDie,
|
||||
},
|
||||
}
|
||||
|
||||
/** @override */
|
||||
static PARTS = {
|
||||
main: { template: "systems/fvtt-celestopol/templates/npc-main.hbs" },
|
||||
tabs: { template: "templates/generic/tab-navigation.hbs" },
|
||||
competences:{ template: "systems/fvtt-celestopol/templates/npc-competences.hbs" },
|
||||
blessures: { template: "systems/fvtt-celestopol/templates/npc-blessures.hbs" },
|
||||
main: { template: "systems/fvtt-celestopol/templates/npc-main.hbs" },
|
||||
tabs: { template: "templates/generic/tab-navigation.hbs" },
|
||||
competences: { template: "systems/fvtt-celestopol/templates/npc-competences.hbs" },
|
||||
blessures: { template: "systems/fvtt-celestopol/templates/npc-blessures.hbs" },
|
||||
equipement: { template: "systems/fvtt-celestopol/templates/npc-equipement.hbs" },
|
||||
biographie: { template: "systems/fvtt-celestopol/templates/npc-biographie.hbs" },
|
||||
}
|
||||
|
||||
tabGroups = { sheet: "competences" }
|
||||
|
||||
#getTabs() {
|
||||
const tabs = {
|
||||
competences:{ id: "competences", group: "sheet", icon: "fa-solid fa-dice-d6", label: "CELESTOPOL.Tab.competences" },
|
||||
blessures: { id: "blessures", group: "sheet", icon: "fa-solid fa-heart-crack", label: "CELESTOPOL.Tab.blessures" },
|
||||
competences: { id: "competences", group: "sheet", icon: "fa-solid fa-dice-d6", label: "CELESTOPOL.Tab.competences" },
|
||||
blessures: { id: "blessures", group: "sheet", icon: "fa-solid fa-heart-crack", label: "CELESTOPOL.Tab.blessures" },
|
||||
equipement: { id: "equipement", group: "sheet", icon: "fa-solid fa-shield-halved",label: "CELESTOPOL.Tab.equipement" },
|
||||
biographie: { id: "biographie", group: "sheet", icon: "fa-solid fa-book-open", label: "CELESTOPOL.Tab.biographie" },
|
||||
}
|
||||
for (const v of Object.values(tabs)) {
|
||||
v.active = this.tabGroups[v.group] === v.id
|
||||
@@ -33,12 +43,29 @@ export default class CelestopolNPCSheet extends CelestopolActorSheet {
|
||||
|
||||
/** @override */
|
||||
async _prepareContext() {
|
||||
const context = await super._prepareContext()
|
||||
context.tabs = this.#getTabs()
|
||||
context.stats = SYSTEM.STATS
|
||||
context.skills = SYSTEM.SKILLS
|
||||
context.anomalyTypes = SYSTEM.ANOMALY_TYPES
|
||||
context.woundLevels = SYSTEM.WOUND_LEVELS
|
||||
const context = await super._prepareContext()
|
||||
context.tabs = this.#getTabs()
|
||||
context.stats = SYSTEM.STATS
|
||||
context.anomalyTypes = SYSTEM.ANOMALY_TYPES
|
||||
context.woundLevels = SYSTEM.WOUND_LEVELS
|
||||
context.npcTypes = SYSTEM.NPC_TYPES
|
||||
context.factions = SYSTEM.FACTIONS
|
||||
context.antagonisteStats = SYSTEM.ANTAGONISTE_STATS
|
||||
|
||||
const sys = this.document.system
|
||||
context.aspects = this.document.itemTypes.aspect ?? []
|
||||
context.weapons = this.document.itemTypes.weapon ?? []
|
||||
context.armures = this.document.itemTypes.armure ?? []
|
||||
context.armorMalus = sys.armorMalus ?? 0
|
||||
|
||||
// Label effectif de chaque domaine selon le type de PNJ
|
||||
const isAntagoniste = sys.npcType === "antagoniste"
|
||||
context.domainLabels = {
|
||||
ame: isAntagoniste ? "CELESTOPOL.NPC.emprise" : "CELESTOPOL.Stat.ame",
|
||||
corps: isAntagoniste ? "CELESTOPOL.NPC.peril" : "CELESTOPOL.Stat.corps",
|
||||
coeur: isAntagoniste ? "CELESTOPOL.NPC.menace" : "CELESTOPOL.Stat.coeur",
|
||||
esprit: isAntagoniste ? "CELESTOPOL.NPC.danger" : "CELESTOPOL.Stat.esprit",
|
||||
}
|
||||
return context
|
||||
}
|
||||
|
||||
@@ -48,11 +75,59 @@ export default class CelestopolNPCSheet extends CelestopolActorSheet {
|
||||
switch (partId) {
|
||||
case "competences":
|
||||
context.tab = context.tabs.competences
|
||||
// Enrichissement des aspects
|
||||
context.enrichedAspects = await Promise.all(
|
||||
(context.aspects ?? []).map(async a => ({
|
||||
item: a,
|
||||
enrichedDesc: await foundry.applications.ux.TextEditor.implementation.enrichHTML(
|
||||
a.system.description, { relativeTo: this.document }
|
||||
),
|
||||
}))
|
||||
)
|
||||
break
|
||||
case "blessures":
|
||||
context.tab = context.tabs.blessures
|
||||
context.enrichedNotes = await foundry.applications.ux.TextEditor.implementation.enrichHTML(
|
||||
context.system.notes, { relativeTo: this.document }
|
||||
)
|
||||
break
|
||||
case "equipement":
|
||||
context.tab = context.tabs.equipement
|
||||
break
|
||||
case "biographie":
|
||||
context.tab = context.tabs.biographie
|
||||
context.enrichedHistoire = await foundry.applications.ux.TextEditor.implementation.enrichHTML(
|
||||
context.system.histoire, { relativeTo: this.document }
|
||||
)
|
||||
context.enrichedDescriptionPhysique = await foundry.applications.ux.TextEditor.implementation.enrichHTML(
|
||||
context.system.descriptionPhysique, { relativeTo: this.document }
|
||||
)
|
||||
break
|
||||
}
|
||||
return context
|
||||
}
|
||||
|
||||
static async #onCreateAspect() {
|
||||
await this.document.createEmbeddedDocuments("Item", [{
|
||||
name: game.i18n.localize("CELESTOPOL.Item.newAspect"), type: "aspect",
|
||||
}])
|
||||
}
|
||||
|
||||
static async #onCreateWeapon() {
|
||||
await this.document.createEmbeddedDocuments("Item", [{
|
||||
name: game.i18n.localize("TYPES.Item.weapon"), type: "weapon",
|
||||
}])
|
||||
}
|
||||
|
||||
static async #onCreateArmure() {
|
||||
await this.document.createEmbeddedDocuments("Item", [{
|
||||
name: game.i18n.localize("TYPES.Item.armure"), type: "armure",
|
||||
}])
|
||||
}
|
||||
|
||||
/** Lance le Dé de la Lune de façon autonome depuis le header de la fiche PNJ. */
|
||||
static async #onRollMoonDie() {
|
||||
const { CelestopolRoll } = await import("../../documents/roll.mjs")
|
||||
await CelestopolRoll.rollMoonStandalone(this.document)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user