2021-09-07 22:53:27 -04:00
|
|
|
// TODO: should be defined in strange eons somewhere
|
|
|
|
const pack_code = "420";
|
|
|
|
|
|
|
|
function renameSlot(slot) {
|
|
|
|
if (slot.startsWith('1 ')) {
|
|
|
|
return slot.slice(2);
|
|
|
|
}
|
|
|
|
else if (slot.startsWith('2 ')) {
|
|
|
|
return slot.slice(2) + ' x2';
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return slot;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-09-07 23:23:28 -04:00
|
|
|
const tag_replacements = {
|
|
|
|
"<gua>": "[guardian]",
|
|
|
|
"<see>": "[seeker]",
|
|
|
|
"<rog>": "[rogue]",
|
|
|
|
"<mys>": "[mystic]",
|
|
|
|
"<sur>": "[survivor]",
|
2021-09-08 12:42:00 -04:00
|
|
|
"<wil>": "[willpower]",
|
|
|
|
"<int>": "[intellect]",
|
|
|
|
"<com>": "[combat]",
|
2021-09-07 23:23:28 -04:00
|
|
|
"<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
|
|
|
|
};
|
|
|
|
|
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",
|
|
|
|
};
|
|
|
|
|
2021-09-08 13:16:38 -04:00
|
|
|
function int_or_null(inp) {
|
|
|
|
if (inp == 'None') {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
else if (inp == 'X') {
|
|
|
|
return -2;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return parseInt(inp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-09-08 14:22:37 -04:00
|
|
|
function build_card(component) {
|
|
|
|
function substitute_tags(str) {
|
|
|
|
str = str.replace("<fullname>", String(component.getName()));
|
2021-09-07 22:53:27 -04:00
|
|
|
|
2021-09-08 14:22:37 -04:00
|
|
|
for (tag in tag_replacements) {
|
|
|
|
str = str.replace(tag, tag_replacements[tag]);
|
|
|
|
}
|
|
|
|
return str;
|
|
|
|
}
|
|
|
|
|
|
|
|
var code = pack_code + component.settings.get('CollectionNumber');
|
2021-09-08 13:26:17 -04:00
|
|
|
|
2021-09-08 14:22:37 -04:00
|
|
|
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')),
|
|
|
|
// 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')),
|
|
|
|
};
|
2021-09-08 13:03:02 -04:00
|
|
|
|
2021-09-08 14:40:20 -04:00
|
|
|
var skills = {
|
|
|
|
Agility: 0,
|
|
|
|
Intellect: 0,
|
|
|
|
Combat: 0,
|
|
|
|
Willpower: 0,
|
|
|
|
Wild: 0,
|
|
|
|
};
|
|
|
|
for (var i = 1; i<=6; i++) {
|
|
|
|
var skill_icon = component.settings.get('Skill' + i);
|
|
|
|
if (skill_icon in skills) {
|
|
|
|
skills[skill_icon] += 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (var skill in skills) {
|
|
|
|
if (skills[skill] > 0) {
|
|
|
|
card_data["skill_" + skill.toLowerCase()] = skills[skill];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-09-08 14:22:37 -04:00
|
|
|
var raw_cost = component.settings.get('ResourceCost');
|
|
|
|
if (raw_cost) {
|
|
|
|
card_data.cost = int_or_null(raw_cost);
|
|
|
|
}
|
2021-09-07 23:22:39 -04:00
|
|
|
|
2021-09-08 14:22:37 -04:00
|
|
|
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 != '') {
|
2021-09-08 14:46:26 -04:00
|
|
|
card_data.subname = String(subtitle);
|
2021-09-08 14:22:37 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
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";
|
|
|
|
}
|
2021-09-07 22:53:27 -04:00
|
|
|
|
2021-09-08 14:22:37 -04:00
|
|
|
// TODO: parse out some keywords into their own fields
|
2021-09-07 22:53:27 -04:00
|
|
|
|
2021-09-08 14:22:37 -04:00
|
|
|
return card_data;
|
|
|
|
}
|
|
|
|
|
|
|
|
var cards = [];
|
|
|
|
var member_iter = Eons.getOpenProject().iterator();
|
|
|
|
while (member_iter.hasNext()) {
|
|
|
|
var member = member_iter.next();
|
|
|
|
var component = ResourceKit.getGameComponentFromFile(member.getFile());
|
|
|
|
var card_data = build_card(component);
|
|
|
|
cards.push(card_data);
|
|
|
|
}
|
|
|
|
println(JSON.stringify(cards, null, 4));
|