Oh hey there's a channel for Lancer development! My group recently started playing a game, and I

Oh hey there's a channel for Lancer development!
My group recently started playing a game, and I immediately built a "eunos-lancer-hacks" module (as is my way, lol). The first part of it is incorporating the Bonds system into the pilot sheet under another tab, which I do with an override of LancerActor.importCC in a subclass that I then assign to CONFIG.Actor.documentClass:
import C from "../core/constants";

export default function OverrideLancerActor(lancerActorClass: typeof LancerActor) {

return class EunosLancerActor extends lancerActorClass {

static Initialize() {
// Register the new actor class
CONFIG.Actor.documentClass = this;
}

parseBondPowersDownload(bond, bondPowers) {
const getMapKey = (power) => power.name.replace(/[^A-Za-z]/g, "");

return Object.fromEntries(bondPowers
.map((power) => {
const powerKey = getMapKey(power);
const powerBond = C.bondPowersMap[powerKey];
const powerData = C.bondPowers[powerBond].find((bPower) => getMapKey(bPower) === powerKey);
powerData.key = powerKey;
powerData.isVeteran = powerData.bond !== bond;
return [powerKey, powerData];
}));
}

get fData() { return this.flags["eunos-lancer-hacks"] ?? {}; }

override async importCC(data: PackedPilotData, clearFirst = false) {
if (!data || this.type !== "pilot") { return; }
await super.importCC(data, clearFirst);

// Extract relevant data from retrieved Comp/Con data object
const {bondId, bondPowers, burdens, clocks, bondAnswers, minorIdeal, stress, xp} = data;
// Convert bondId to bond
const bond = bondId.split(/-/).pop();

// Prepare new flag update data
const bondFlagData = Object.fromEntries(
Object.entries({
bond,
bondPowers: this.parseBondPowersDownload(bond, bondPowers),
bondAnswers: {
a: this.fData.bondAnswers?.a ?? bondAnswers[0],
b: this.fData.bondAnswers?.b ?? bondAnswers[1]
},
minorIdeal: this.fData.minorIdeal ?? minorIdeal,
pilot_xp: {
value: this.fData.pilot_xp?.value ?? xp,
max: this.fData.pilot_xp?.max ?? 8
},
pilot_stress: {
value: this.fData.pilot_stress?.value ?? stress,
max: this.fData.pilot_stress?.max ?? 8
}
}).map(([key, value]) => [`flags.eunos-lancer-hacks.${key}`, value])
);

// Write bond-related data to module flags
await this.update(bondFlagData);
}
}
}
import C from "../core/constants";

export default function OverrideLancerActor(lancerActorClass: typeof LancerActor) {

return class EunosLancerActor extends lancerActorClass {

static Initialize() {
// Register the new actor class
CONFIG.Actor.documentClass = this;
}

parseBondPowersDownload(bond, bondPowers) {
const getMapKey = (power) => power.name.replace(/[^A-Za-z]/g, "");

return Object.fromEntries(bondPowers
.map((power) => {
const powerKey = getMapKey(power);
const powerBond = C.bondPowersMap[powerKey];
const powerData = C.bondPowers[powerBond].find((bPower) => getMapKey(bPower) === powerKey);
powerData.key = powerKey;
powerData.isVeteran = powerData.bond !== bond;
return [powerKey, powerData];
}));
}

get fData() { return this.flags["eunos-lancer-hacks"] ?? {}; }

override async importCC(data: PackedPilotData, clearFirst = false) {
if (!data || this.type !== "pilot") { return; }
await super.importCC(data, clearFirst);

// Extract relevant data from retrieved Comp/Con data object
const {bondId, bondPowers, burdens, clocks, bondAnswers, minorIdeal, stress, xp} = data;
// Convert bondId to bond
const bond = bondId.split(/-/).pop();

// Prepare new flag update data
const bondFlagData = Object.fromEntries(
Object.entries({
bond,
bondPowers: this.parseBondPowersDownload(bond, bondPowers),
bondAnswers: {
a: this.fData.bondAnswers?.a ?? bondAnswers[0],
b: this.fData.bondAnswers?.b ?? bondAnswers[1]
},
minorIdeal: this.fData.minorIdeal ?? minorIdeal,
pilot_xp: {
value: this.fData.pilot_xp?.value ?? xp,
max: this.fData.pilot_xp?.max ?? 8
},
pilot_stress: {
value: this.fData.pilot_stress?.value ?? stress,
max: this.fData.pilot_stress?.max ?? 8
}
}).map(([key, value]) => [`flags.eunos-lancer-hacks.${key}`, value])
);

// Write bond-related data to module flags
await this.update(bondFlagData);
}
}
}
First question: Do you foresee any issues with my override of LancerActor in this way? (I can't think of any, but Lancer is a complex system and I'm a moderately-skilled coder at best). Second question: Is this something you might be interested in incorporating into the system proper, once I have it all finished?
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?