// 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; } } const tag_replacements = { "": String(Component.getName()), "": "[guardian]", "": "[seeker]", "": "[rogue]", "": "[mystic]", "": "[survivor]", "": "[willpower]", "": "[intellect]", "": "[combat]", "": "[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", }; function int_or_null(inp) { if (inp == 'None') { return null; } else if (inp == 'X') { return -2; } else { return parseInt(inp); } } var card_data = { code: String(code), deck_limit: 2, // TODO: could be derived? faction_code: String(Component.settings.get('CardClass')).toLowerCase(), flavor: substitute_tags(String(Component.settings.get('Flavor'))), health: int_or_null(Component.settings.get('Stamina')), illustrator: String(Component.settings.get('Artist')), is_unique: Component.settings.getBoolean('Unique'), name: substitute_tags(String(Component.getName())), pack_code: pack_code, position: int_or_null(Component.settings.get('CollectionNumber')), quantity: 2, // TODO //restrictions: null, // TODO sanity: int_or_null(Component.settings.get('Sanity')), skill_agility: skills["Agility"], skill_combat: skills["Combat"], skill_intellect: skills["Intellect"], skill_wild: skills["Wild"], skill_willpower: skills["Willpower"], // TODO: should also handle "Victory" field text: substitute_tags(String( Component.settings.get('Keywords') + '\n' + Component.settings.get('Rules'))), traits: substitute_tags(String(Component.settings.get('Traits'))), type_code: card_types[Component.getFrontTemplateKey()], xp: int_or_null(Component.settings.get('Level')), }; var raw_cost = Component.settings.get('ResourceCost'); if (raw_cost) { card_data.cost = int_or_null(raw_cost); } var raw_slot = Component.settings.get('Slot'); if (raw_slot) { card_data.slot = renameSlot(String(raw_slot)); var raw_slot2 = Component.settings.get('Slot2'); if (raw_slot2 && raw_slot2 != 'None') { card_data.slot += '. ' + renameSlot(raw_slot2); } } var subtitle = Component.settings.get('Subtitle'); if (subtitle && subtitle != '') { card_data.subname = subtitle; } var faction2 = Component.settings.get('CardClass2'); if (faction2 && faction2 != '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"; } // TODO: parse out some keywords into their own fields println(JSON.stringify(card_data, null, 4));