Fix as per CSV sheet tracking + creature explanation
Release Creation / build (release) Successful in 46s
Release Creation / build (release) Successful in 46s
This commit is contained in:
+7
-4
@@ -309,6 +309,9 @@
|
|||||||
"Specialty": "Specialty",
|
"Specialty": "Specialty",
|
||||||
"AdventuringBehavior": "Adventuring Behavior",
|
"AdventuringBehavior": "Adventuring Behavior",
|
||||||
"CombatBehavior": "Combat Behavior",
|
"CombatBehavior": "Combat Behavior",
|
||||||
|
"RollBehavior": "Roll Behavior",
|
||||||
|
"NoTableLinked": "No behavior table is linked.",
|
||||||
|
"TableNotFound": "The linked behavior table could not be found.",
|
||||||
"FIELDS": {
|
"FIELDS": {
|
||||||
"abilities": {
|
"abilities": {
|
||||||
"label": "Abilities",
|
"label": "Abilities",
|
||||||
@@ -358,11 +361,11 @@
|
|||||||
"specialtyText": {
|
"specialtyText": {
|
||||||
"label": "Specialty"
|
"label": "Specialty"
|
||||||
},
|
},
|
||||||
"adventuringBehavior": {
|
"adventuringBehaviorUuid": {
|
||||||
"label": "Adventuring Behavior"
|
"label": "Adventuring Behavior Table"
|
||||||
},
|
},
|
||||||
"combatBehavior": {
|
"combatBehaviorUuid": {
|
||||||
"label": "Combat Behavior"
|
"label": "Combat Behavior Table"
|
||||||
},
|
},
|
||||||
"upkeep": {
|
"upkeep": {
|
||||||
"label": "Upkeep"
|
"label": "Upkeep"
|
||||||
|
|||||||
@@ -7,9 +7,84 @@ export default class MGNECompanionSheet extends MGNEActorSheet {
|
|||||||
width: 820,
|
width: 820,
|
||||||
height: 700,
|
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 = {
|
static PARTS = {
|
||||||
main: { template: "systems/fvtt-machine-gods-noxian-expanse/templates/companion-main.hbs" },
|
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)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,8 +18,8 @@ export default class MGNECompanion extends foundry.abstract.TypeDataModel {
|
|||||||
valueText: stringField(""),
|
valueText: stringField(""),
|
||||||
traitText: stringField(""),
|
traitText: stringField(""),
|
||||||
specialtyText: stringField(""),
|
specialtyText: stringField(""),
|
||||||
adventuringBehavior: htmlField(""),
|
adventuringBehaviorUuid: stringField(""),
|
||||||
combatBehavior: htmlField(""),
|
combatBehaviorUuid: stringField(""),
|
||||||
upkeep: stringField("3d10c per full rest"),
|
upkeep: stringField("3d10c per full rest"),
|
||||||
description: htmlField(""),
|
description: htmlField(""),
|
||||||
notes: htmlField(""),
|
notes: htmlField(""),
|
||||||
@@ -28,4 +28,12 @@ export default class MGNECompanion extends foundry.abstract.TypeDataModel {
|
|||||||
|
|
||||||
/** @override */
|
/** @override */
|
||||||
static LOCALIZATION_PREFIXES = ["MGNE.Companion"]
|
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)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -81,21 +81,61 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="grid two">
|
<div class="grid two">
|
||||||
<div class="inventory-section">
|
<!-- Adventuring Behavior Table -->
|
||||||
|
<div class="inventory-section creature-action-table-section">
|
||||||
<div class="inventory-header">
|
<div class="inventory-header">
|
||||||
<h3>{{localize "MGNE.Companion.AdventuringBehavior"}}</h3>
|
<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>
|
</div>
|
||||||
<fieldset>
|
{{/if}}
|
||||||
{{formInput systemFields.adventuringBehavior enriched=(lookup enrichedFields "adventuringBehavior") value=system.adventuringBehavior name="system.adventuringBehavior" toggled=true}}
|
|
||||||
</fieldset>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="inventory-section">
|
<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>
|
||||||
|
</div>
|
||||||
|
<!-- Combat Behavior Table -->
|
||||||
|
<div class="inventory-section creature-action-table-section">
|
||||||
<div class="inventory-header">
|
<div class="inventory-header">
|
||||||
<h3>{{localize "MGNE.Companion.CombatBehavior"}}</h3>
|
<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>
|
</div>
|
||||||
<fieldset>
|
|
||||||
{{formInput systemFields.combatBehavior enriched=(lookup enrichedFields "combatBehavior") value=system.combatBehavior name="system.combatBehavior" toggled=true}}
|
|
||||||
</fieldset>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user