Add support for investigator cards

This commit is contained in:
Adam Goldsmith 2022-12-04 19:46:14 -05:00
parent d79ba152b0
commit 73e78c7a02
1 changed files with 53 additions and 5 deletions

View File

@ -47,6 +47,11 @@ function renameSlot(slot) {
}
}
// TODO: very incomplete
const double_sided = [
"AHLCG-Investigator-Default",
];
const tag_replacements = {
"<gua>": "[guardian]",
"<see>": "[seeker]",
@ -249,6 +254,36 @@ function build_card(component, pack_code, cycle_prefix, copies) {
}
}
function investigator() {
let back_text = Array(8).fill()
.map((_, i) => {
let index = (i + 1);
let name = substitute_tags(component.settings.get("Text" + index + "NameBack"));
let text = substitute_tags(component.settings.get("Text" + index + "Back"));
if (text) {
return "<b>" + name + "</b>: " + text;
} else {
return false;
}
})
.filter(x => x)
.join("\n");
return {
back_flavor: substitute_tags(component.settings.get('InvStoryBack')),
back_text: back_text,
deck_options: ["FIXME"], // TODO
deck_requirements: "FIXME", // TODO
double_sided: true,
is_unique: true,
skill_agility: int_or_null(component.settings.get('Agility')),
skill_intellect: int_or_null(component.settings.get('Intellect')),
skill_combat: int_or_null(component.settings.get('Combat')),
skill_willpower: int_or_null(component.settings.get('Willpower')),
};
}
function treachery_subtype() {
switch (String(component.settings.get('Subtype'))) {
// TODO: should "StoryWeakness" be different?
@ -326,6 +361,15 @@ function build_card(component, pack_code, cycle_prefix, copies) {
health_and_sanity(),
slots()
));
case "AHLCG-Investigator-Default":
return order_by_keys(Object.assign(
{ type_code: "investigator", },
common_data(),
faction(),
subtitle(),
health_and_sanity(),
investigator(),
));
case "AHLCG-WeaknessEnemy-Default":
return order_by_keys(Object.assign(
{ type_code: "enemy", },
@ -344,18 +388,18 @@ function build_card(component, pack_code, cycle_prefix, copies) {
}
}
function exportCard(component, file) {
function exportCard(component, file, face) {
try {
// create the sheets that will paint the faces of the component
let sheets = component.createDefaultSheets();
if (sheets == null) return;
// export front face
let image = sheets[0].paint(arkham.sheet.RenderTarget.EXPORT, RESOLUTION);
// export face
let image = sheets[face].paint(arkham.sheet.RenderTarget.EXPORT, RESOLUTION);
ImageUtils.write(image, file, FORMAT, -1, false, RESOLUTION);
} catch (ex) {
println(ex);
println('Error while making image for ' + component.getName() + ', skipping file');
println('Error while making image for ' + component.getName() + ' face ' + face + ', skipping file');
Error.handleUncaught(ex);
}
}
@ -467,7 +511,11 @@ function run() {
if (!target_file.exists() || child.file.lastModified() > target_file.lastModified()) {
printf("Image for '%s' is out of date, rebuilding...\n", child);
export_dir.mkdir();
exportCard(component, target_file);
exportCard(component, target_file, 0);
if (double_sided.includes(String(component.getFrontTemplateKey()))) {
let back_target_file = new File(export_dir, card_data.code + 'b.' + FORMAT);
exportCard(component, back_target_file, 1);
}
}
} catch (ex) {
println(ex);