From 908c6a8ba15334b127848fd7182a40fb49bb6c9a Mon Sep 17 00:00:00 2001 From: Adam Goldsmith Date: Sun, 5 Jun 2022 22:34:31 -0400 Subject: [PATCH] Hackily add some metadata for Arkham Horror LCG SCED deckbuilder --- resources/ttsdeck/Card.js | 19 +++++++++++++++++-- resources/ttsdeck/plugin.js | 7 ++++++- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/resources/ttsdeck/Card.js b/resources/ttsdeck/Card.js index dc03c92..7449ac4 100644 --- a/resources/ttsdeck/Card.js +++ b/resources/ttsdeck/Card.js @@ -1,7 +1,8 @@ useLibrary("project"); -function Card(member, copies_list) { +function Card(member, arkhamdb_cycle_prefix, copies_list) { this.member = member; + this.arkhamdb_cycle_prefix = arkhamdb_cycle_prefix; this.copies_list = copies_list; this.component = ResourceKit.getGameComponentFromFile(member.file); @@ -62,7 +63,7 @@ Card.prototype.copyCount = function copyCount() { }; Card.prototype.makeJSON = function makeJSON(card_id, description) { - return { + let card = { Name: "Card", Transform: { posX: 0, @@ -91,6 +92,20 @@ Card.prototype.makeJSON = function makeJSON(card_id, description) { Tooltip: true, SidewaysCard: false, }; + + // TODO: could also do other fields, like "uses" + // Hack for AHLCG SCED deckbuilder + if (this.arkhamdb_cycle_prefix) { + let arkhamdb_id = + this.arkhamdb_cycle_prefix + + String(this.component.settings.get("CollectionNumber")).padStart(3, "0"); + + card.GMNotes = JSON.stringify({ + id: arkhamdb_id, + }); + } + + return card; }; module.exports = Card; diff --git a/resources/ttsdeck/plugin.js b/resources/ttsdeck/plugin.js index 1342866..47a8506 100644 --- a/resources/ttsdeck/plugin.js +++ b/resources/ttsdeck/plugin.js @@ -95,6 +95,9 @@ function run() { task_settings.set("tts_image_resolution", image_resolution); deck_task.writeTaskSettings(); + // If used with arkhamdb, get cycle prefix from settings + const arkhamdb_cycle_prefix = task_settings.get("arkhamdb_cycle_prefix"); + Eons.setWaitCursor(true); try { Thread.busyWindow( @@ -103,6 +106,7 @@ function run() { busy_props, image_format, image_resolution, + arkhamdb_cycle_prefix, deck_task ), "Setting up...", @@ -118,6 +122,7 @@ function run() { busy_props, image_format, image_resolution, + arkhamdb_cycle_prefix, member ) { let copies_list; @@ -135,7 +140,7 @@ function run() { const cards = children .map((child) => { if (ProjectUtilities.matchExtension(child, "eon")) { - let card = new Card(child, copies_list); + let card = new Card(child, arkhamdb_cycle_prefix, copies_list); if (card.component.isDeckLayoutSupported()) { return card; }