This commit is contained in:
2025-09-18 09:47:02 +02:00
parent 5892e6148d
commit e84c0127bb
4 changed files with 150 additions and 88 deletions
+21 -7
View File
@@ -10,8 +10,8 @@ class VoidshipSheet extends ActorSheet {
classes: ["wg-voidships", "sheet", "actor", "voidship"],
template: `modules/${VB_MOD}/templates/voidship-sheet.hbs`,
width: 720,
height: 620,
tabs: [{ navSelector: ".tabs", contentSelector: ".sheet-body", initial: "stats" }]
height: 680,
tabs: [{ navSelector: ".tabs", contentSelector: ".sheet-body", initial: "wg" }]
});
}
@@ -35,8 +35,8 @@ class VoidshipSheet extends ActorSheet {
space: Number(a.getFlag(VB_MOD, "base.space")) || 0,
power: Number(a.getFlag(VB_MOD, "base.power")) || 0
};
const mods = { armour:0, integrity:0, manoeuvre:0, detection:0, speed:0, space:0, power:0 };
const slots = { prow:0, dorsal:0, port:0, starboard:0, keel:0, other:0 };
const mods = { armour: 0, integrity: 0, manoeuvre: 0, detection: 0, speed: 0, space: 0, power: 0 };
const slots = { prow: 0, dorsal: 0, port: 0, starboard: 0, keel: 0, other: 0 };
const items = a?.items ?? [];
for (const it of items) {
const eq = (it.system?.equipped ?? true); // treat as mounted unless explicitly off
@@ -72,10 +72,23 @@ class VoidshipSheet extends ActorSheet {
return { base, mods, total, slots };
}
async getData(options={}) {
async getData(options = {}) {
const data = await super.getData(options);
data.isVoidship = this.isVoidship;
data.voidship = this._computeDerived();
const hull = this.actor.getFlag(VB_MOD, "hull") || {};
data.hull = {
class: hull.class || this.actor.name,
size: hull.size || "Cruiser",
slotsAllowed: hull.slots || { prow: 0, dorsal: 0, port: 0, starboard: 0, keel: 0 }
};
data.crew = this.actor.getFlag(VB_MOD, "crew") || {
command: 1, pilot: 1, sensors: 1, engineering: 2,
gunnery: 2, security: 2, flightDeck: 0, passengers: 0
};
data.rtRaw = this.actor.getFlag(VB_MOD, "rtRaw") || {};
// expose a minimal config (labels)
data.cfg = {
labels: {
@@ -91,6 +104,7 @@ class VoidshipSheet extends ActorSheet {
}
};
return data;
}
activateListeners(html) {
@@ -134,7 +148,7 @@ class VoidshipSheet extends ActorSheet {
"base.space": get("space"),
"base.power": get("power")
};
for (const [k,v] of Object.entries(patch)) await this.actor.setFlag(VB_MOD, k, v);
for (const [k, v] of Object.entries(patch)) await this.actor.setFlag(VB_MOD, k, v);
this.render(true);
}
},
@@ -155,7 +169,7 @@ Hooks.once("init", () => {
});
// Optional: a convenient factory on game namespace
game.wgVoidships = game.wgVoidships || {};
game.wgVoidships.createVoidship = async function(name="New Voidship") {
game.wgVoidships.createVoidship = async function (name = "New Voidship") {
const actor = await Actor.create({ name, type: "vehicle", folder: null });
await actor.setFlag(VB_MOD, "isVoidship", true);
ui.notifications.info(`Voidship created: ${name}`);