Fix as per CSV sheet tracking + creature explanation
Release Creation / build (release) Successful in 46s

This commit is contained in:
2026-05-17 18:01:35 +02:00
parent 374854cc8b
commit 1b10a77748
4 changed files with 140 additions and 14 deletions
+7 -4
View File
@@ -309,6 +309,9 @@
"Specialty": "Specialty",
"AdventuringBehavior": "Adventuring Behavior",
"CombatBehavior": "Combat Behavior",
"RollBehavior": "Roll Behavior",
"NoTableLinked": "No behavior table is linked.",
"TableNotFound": "The linked behavior table could not be found.",
"FIELDS": {
"abilities": {
"label": "Abilities",
@@ -358,11 +361,11 @@
"specialtyText": {
"label": "Specialty"
},
"adventuringBehavior": {
"label": "Adventuring Behavior"
"adventuringBehaviorUuid": {
"label": "Adventuring Behavior Table"
},
"combatBehavior": {
"label": "Combat Behavior"
"combatBehaviorUuid": {
"label": "Combat Behavior Table"
},
"upkeep": {
"label": "Upkeep"
@@ -7,9 +7,84 @@ export default class MGNECompanionSheet extends MGNEActorSheet {
width: 820,
height: 700,
},
actions: {
rollAdventuringBehavior: MGNECompanionSheet.prototype._rollAdventuringBehavior,
clearAdventuringBehavior: MGNECompanionSheet.prototype._clearAdventuringBehavior,
openAdventuringBehavior: MGNECompanionSheet.prototype._openAdventuringBehavior,
rollCombatBehavior: MGNECompanionSheet.prototype._rollCombatBehavior,
clearCombatBehavior: MGNECompanionSheet.prototype._clearCombatBehavior,
openCombatBehavior: MGNECompanionSheet.prototype._openCombatBehavior,
},
}
static PARTS = {
main: { template: "systems/fvtt-machine-gods-noxian-expanse/templates/companion-main.hbs" },
}
async _prepareContext() {
const context = await super._prepareContext()
const resolveTable = async (uuid) => {
if (!uuid) return null
const table = await fromUuid(uuid).catch(() => null)
return table ? { name: table.name, uuid } : null
}
context.adventuringTable = await resolveTable(this.document.system.adventuringBehaviorUuid)
context.combatTable = await resolveTable(this.document.system.combatBehaviorUuid)
return context
}
async _onDrop(event) {
const data = foundry.applications.ux.TextEditor.implementation.getDragEventData(event)
if (data?.type === "RollTable") {
const table = await fromUuid(data.uuid)
if (!table) return super._onDrop(event)
// Determine drop target by proximity to each section
const target = event.target.closest("[data-behavior-slot]")
const slot = target?.dataset.behaviorSlot
if (slot === "adventuring") {
await this.document.update({ "system.adventuringBehaviorUuid": data.uuid })
return
}
if (slot === "combat") {
await this.document.update({ "system.combatBehaviorUuid": data.uuid })
return
}
// Fallback: first empty slot, then adventuring
const sys = this.document.system
if (!sys.adventuringBehaviorUuid) {
await this.document.update({ "system.adventuringBehaviorUuid": data.uuid })
} else {
await this.document.update({ "system.combatBehaviorUuid": data.uuid })
}
return
}
return super._onDrop(event)
}
async _rollAdventuringBehavior() { await this._rollTable("adventuringBehaviorUuid") }
async _clearAdventuringBehavior() { await this.document.update({ "system.adventuringBehaviorUuid": "" }) }
async _openAdventuringBehavior() { await this._openTable("adventuringBehaviorUuid") }
async _rollCombatBehavior() { await this._rollTable("combatBehaviorUuid") }
async _clearCombatBehavior() { await this.document.update({ "system.combatBehaviorUuid": "" }) }
async _openCombatBehavior() { await this._openTable("combatBehaviorUuid") }
async _rollTable(uuidField) {
const uuid = this.document.system[uuidField]
if (!uuid) return ui.notifications.warn(game.i18n.localize("MGNE.Companion.NoTableLinked"))
const table = await fromUuid(uuid).catch(() => null)
if (!table) return ui.notifications.warn(game.i18n.localize("MGNE.Companion.TableNotFound"))
await table.draw()
}
async _openTable(uuidField) {
const uuid = this.document.system[uuidField]
if (!uuid) return
const table = await fromUuid(uuid).catch(() => null)
if (table) table.sheet.render(true)
}
}
+10 -2
View File
@@ -18,8 +18,8 @@ export default class MGNECompanion extends foundry.abstract.TypeDataModel {
valueText: stringField(""),
traitText: stringField(""),
specialtyText: stringField(""),
adventuringBehavior: htmlField(""),
combatBehavior: htmlField(""),
adventuringBehaviorUuid: stringField(""),
combatBehaviorUuid: stringField(""),
upkeep: stringField("3d10c per full rest"),
description: htmlField(""),
notes: htmlField(""),
@@ -28,4 +28,12 @@ export default class MGNECompanion extends foundry.abstract.TypeDataModel {
/** @override */
static LOCALIZATION_PREFIXES = ["MGNE.Companion"]
/** @override */
static migrateData(source) {
// Remove old html behavior fields if present
if ("adventuringBehavior" in source) delete source.adventuringBehavior
if ("combatBehavior" in source) delete source.combatBehavior
return super.migrateData(source)
}
}
+48 -8
View File
@@ -81,21 +81,61 @@
</div>
<div class="grid two">
<div class="inventory-section">
<!-- Adventuring Behavior Table -->
<div class="inventory-section creature-action-table-section">
<div class="inventory-header">
<h3>{{localize "MGNE.Companion.AdventuringBehavior"}}</h3>
{{#if adventuringTable}}
<div class="action-table-buttons">
<button type="button" data-action="rollAdventuringBehavior" class="rollable" data-tooltip="{{localize "MGNE.Companion.RollBehavior"}}">
<i class="fa-solid fa-dice-d20"></i> {{localize "MGNE.Companion.RollBehavior"}}
</button>
<button type="button" data-action="openAdventuringBehavior" data-tooltip="{{localize "MGNE.Creature.OpenTable"}}">
<i class="fa-solid fa-table-list"></i> {{localize "MGNE.Creature.OpenTable"}}
</button>
<button type="button" data-action="clearAdventuringBehavior" data-tooltip="{{localize "MGNE.Creature.ClearTable"}}">
<i class="fa-solid fa-xmark"></i>
</button>
</div>
{{/if}}
</div>
<div class="action-table-drop-zone {{#unless adventuringTable}}drop-hint{{/unless}}" data-behavior-slot="adventuring">
{{#if adventuringTable}}
<i class="fa-solid fa-table-list"></i>
<span class="action-table-name">{{adventuringTable.name}}</span>
{{else}}
<i class="fa-solid fa-cloud-arrow-down"></i>
<span>{{localize "MGNE.Creature.DropTableHint"}}</span>
{{/if}}
</div>
<fieldset>
{{formInput systemFields.adventuringBehavior enriched=(lookup enrichedFields "adventuringBehavior") value=system.adventuringBehavior name="system.adventuringBehavior" toggled=true}}
</fieldset>
</div>
<div class="inventory-section">
<!-- Combat Behavior Table -->
<div class="inventory-section creature-action-table-section">
<div class="inventory-header">
<h3>{{localize "MGNE.Companion.CombatBehavior"}}</h3>
{{#if combatTable}}
<div class="action-table-buttons">
<button type="button" data-action="rollCombatBehavior" class="rollable" data-tooltip="{{localize "MGNE.Companion.RollBehavior"}}">
<i class="fa-solid fa-dice-d20"></i> {{localize "MGNE.Companion.RollBehavior"}}
</button>
<button type="button" data-action="openCombatBehavior" data-tooltip="{{localize "MGNE.Creature.OpenTable"}}">
<i class="fa-solid fa-table-list"></i> {{localize "MGNE.Creature.OpenTable"}}
</button>
<button type="button" data-action="clearCombatBehavior" data-tooltip="{{localize "MGNE.Creature.ClearTable"}}">
<i class="fa-solid fa-xmark"></i>
</button>
</div>
{{/if}}
</div>
<div class="action-table-drop-zone {{#unless combatTable}}drop-hint{{/unless}}" data-behavior-slot="combat">
{{#if combatTable}}
<i class="fa-solid fa-table-list"></i>
<span class="action-table-name">{{combatTable.name}}</span>
{{else}}
<i class="fa-solid fa-cloud-arrow-down"></i>
<span>{{localize "MGNE.Creature.DropTableHint"}}</span>
{{/if}}
</div>
<fieldset>
{{formInput systemFields.combatBehavior enriched=(lookup enrichedFields "combatBehavior") value=system.combatBehavior name="system.combatBehavior" toggled=true}}
</fieldset>
</div>
</div>