// TODO: should be defined in strange eons somewhere const pack_code = "420"; var code = pack_code + Component.settings.get('CollectionNumber'); var skills = { Agility: 0, Intellect: 0, Combat: 0, Willpower: 0, Wild: 0, None: 0, }; for (var i = 1; i<=6; i++) { skills[Component.settings.get('Skill' + i)] += 1; } function renameSlot(slot) { if (slot.startsWith('1 ')) { return slot.slice(2); } else if (slot.startsWith('2 ')) { return slot.slice(2) + ' x2'; } else { return slot; } } var slot = renameSlot(Component.settings.get('Slot')); if (Component.settings.get('Slot2') != 'None') { slot += '. ' + renameSlot(Component.settings.get('Slot2')); } var card_name = Component.getName(); if (Component.settings.get('Subtitle') != '') { card_name += ': ' + Component.settings.get('Subtitle'); } const tag_replacements = { "": String(Component.getName()), "": "[guardian]", "": "[seeker]", "": "[rogue]", "": "[mystic]", "": "[survivor]", "": "[will]", "": "[lore]", "": "[strength]", "": "[agility]", "": "[wild]", "": "[skull]", "": "[cultist]", "": "[tablet]", "": "[elder_thing]", "": "[bless]", "": "[curse]", "": "[eldersign]", "": "[auto_fail]", "": "[action]", "": "[free]", "": "[reaction]", "": "forced", "": "Haunted", "": "Objective", "": "Patrol", "": "Revelation", "": "{Unique}", // TODO "": "[per_investigator]", "": "- ", "": "{Square}", // TODO // TODO "": "", // Tab spacing for bullet sections "": "", // Trait "": "", "": "", // Horizontal spacer "": "", // Large vertical spacer "": "", // Vertical spacer "": "", // Small vertical spacer }; function substitute_tags(str) { for (tag in tag_replacements) { str = str.replace(tag, tag_replacements[tag]); } return str; } // TODO: handle investigator cards const card_types = { "AHLCG-Event-Default": "event", "AHLCG-Skill-Default": "skill", "AHLCG-Asset-Default": "asset", // TODO: actually handle enemy weaknesses "AHLCG-WeaknessEnemy-Default": "enemy", "AHLCG-WeaknessTreachery-Default": "treachery", }; var card_data = { agility: skills["Agility"], code: String(code), // TODO: handle None/X cost: parseInt(Component.settings.get('ResourceCost')) || null, // TODO: could be derived? deck_limit: 2, faction_code: String(Component.settings.get('CardClass')).toLowerCase(), flavor: substitute_tags(String(Component.settings.get('Flavor'))), health: parseInt(Component.settings.get('Stamina')) || null, illustrator: String(Component.settings.get('Artist')), is_unique: Component.settings.getBoolean('Unique'), lore: skills["Intellect"], name: substitute_tags(String(card_name)), pack_code: pack_code, position: parseInt(Component.settings.get('CollectionNumber')) || null, // TODO quantity: 2, // TODO restrictions: null, sanity: parseInt(Component.settings.get('Sanity')) || null, slot: String(slot), strength: skills["Combat"], text: substitute_tags(String(Component.settings.get('Rules'))), traits: substitute_tags(String(Component.settings.get('Traits'))), type_code: card_types[Component.getFrontTemplateKey()], wild: skills["Wild"], will: skills["Willpower"], }; if (Component.settings.get('CardClass2') != 'None') { card_data.faction2_code = String(Component.settings.get('CardClass2')).toLowerCase(); } if (card_types[Component.getFrontTemplateKey()] == 'enemy') { // TODO: "weakness" or "basicweakness" card_data.subtype_code = "basicweakness"; } println(JSON.stringify(card_data, null, 4));