SE3-ArkhamDBExporter/strange_eons_to_arkhamdb.js

140 lines
4.0 KiB
JavaScript
Raw Normal View History

2021-09-07 22:53:27 -04:00
// 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'));
}
const tag_replacements = {
"<fullname>": String(Component.getName()),
"<gua>": "[guardian]",
"<see>": "[seeker]",
"<rog>": "[rogue]",
"<mys>": "[mystic]",
"<sur>": "[survivor]",
2021-09-08 12:42:00 -04:00
"<wil>": "[willpower]",
"<int>": "[intellect]",
"<com>": "[combat]",
"<agi>": "[agility]",
"<wild>": "[wild]",
"<sku>": "[skull]",
"<cul>": "[cultist]",
"<tab>": "[tablet]",
"<mon>": "[elder_thing]",
"<ble>": "[bless]",
"<cur>": "[curse]",
"<eld>": "[eldersign]",
"<ten>": "[auto_fail]",
"<act>": "[action]",
"<fre>": "[free]",
"<rea>": "[reaction]",
"<for>": "<b>forced</b>",
"<hau>": "<b>Haunted</b>",
"<obj>": "<b>Objective</b>",
"<pat>": "Patrol",
"<rev>": "<b>Revelation</b>",
"<uni>": "{Unique}", // TODO
"<per>": "[per_investigator]",
"<bul>": "- ",
"<squ>": "{Square}", // TODO
// TODO
"<bultab>": "", // Tab spacing for bullet sections
"<t>": "<b><i>", // Trait
"</t>": "</i></b>",
"<hs>": "", // Horizontal spacer
"<lvs>": "", // Large vertical spacer
"<vs>": "", // Vertical spacer
"<svs>": "", // Small vertical spacer
};
function substitute_tags(str) {
for (tag in tag_replacements) {
str = str.replace(tag, tag_replacements[tag]);
}
return str;
}
2021-09-07 22:53:27 -04:00
// 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 = {
code: String(code),
2021-09-07 23:22:15 -04:00
// TODO: handle None/X
cost: parseInt(Component.settings.get('ResourceCost')) || null,
2021-09-07 23:35:32 -04:00
deck_limit: 2, // TODO: could be derived?
2021-09-07 22:53:27 -04:00
faction_code: String(Component.settings.get('CardClass')).toLowerCase(),
flavor: substitute_tags(String(Component.settings.get('Flavor'))),
2021-09-07 22:53:27 -04:00
health: parseInt(Component.settings.get('Stamina')) || null,
illustrator: String(Component.settings.get('Artist')),
is_unique: Component.settings.getBoolean('Unique'),
name: substitute_tags(String(Component.getName())),
2021-09-07 22:53:27 -04:00
pack_code: pack_code,
position: parseInt(Component.settings.get('CollectionNumber')) || null,
2021-09-07 23:35:32 -04:00
quantity: 2, // TODO
//restrictions: null, // TODO
2021-09-07 22:53:27 -04:00
sanity: parseInt(Component.settings.get('Sanity')) || null,
2021-09-08 12:42:00 -04:00
skill_agility: skills["Agility"],
skill_combat: skills["Combat"],
skill_intellect: skills["Intellect"],
skill_wild: skills["Wild"],
skill_willpower: skills["Willpower"],
2021-09-07 22:53:27 -04:00
slot: String(slot),
// TODO: should also handle "Victory" field
2021-09-07 23:35:09 -04:00
text: substitute_tags(String(
Component.settings.get('Keywords') + '\n' + Component.settings.get('Rules'))),
traits: substitute_tags(String(Component.settings.get('Traits'))),
2021-09-07 22:53:27 -04:00
type_code: card_types[Component.getFrontTemplateKey()],
xp: parseInt(Component.settings.get('Level')) || null,
2021-09-07 22:53:27 -04:00
};
var subtitle = Component.settings.get('Subtitle');
if (subtitle && subtitle != '') {
card_data.subname = subtitle;
}
if (Component.settings.get('CardClass2') != 'None') {
card_data.faction2_code = String(Component.settings.get('CardClass2')).toLowerCase();
}
2021-09-07 22:53:27 -04:00
if (card_types[Component.getFrontTemplateKey()] == 'enemy') {
// TODO: "weakness" or "basicweakness"
card_data.subtype_code = "basicweakness";
}
2021-09-07 23:35:09 -04:00
// TODO: parse out some keywords into their own fields
2021-09-07 22:53:27 -04:00
println(JSON.stringify(card_data, null, 4));