Improve handling of integers, including values of 'X'
This commit is contained in:
parent
5e25b42e2a
commit
25b4628348
@ -85,22 +85,33 @@ const card_types = {
|
|||||||
"AHLCG-WeaknessTreachery-Default": "treachery",
|
"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 = {
|
var card_data = {
|
||||||
code: String(code),
|
code: String(code),
|
||||||
// TODO: handle None/X
|
cost: int_or_null(Component.settings.get('ResourceCost')),
|
||||||
cost: parseInt(Component.settings.get('ResourceCost')) || null,
|
|
||||||
deck_limit: 2, // TODO: could be derived?
|
deck_limit: 2, // TODO: could be derived?
|
||||||
faction_code: String(Component.settings.get('CardClass')).toLowerCase(),
|
faction_code: String(Component.settings.get('CardClass')).toLowerCase(),
|
||||||
flavor: substitute_tags(String(Component.settings.get('Flavor'))),
|
flavor: substitute_tags(String(Component.settings.get('Flavor'))),
|
||||||
health: parseInt(Component.settings.get('Stamina')) || null,
|
health: int_or_null(Component.settings.get('Stamina')),
|
||||||
illustrator: String(Component.settings.get('Artist')),
|
illustrator: String(Component.settings.get('Artist')),
|
||||||
is_unique: Component.settings.getBoolean('Unique'),
|
is_unique: Component.settings.getBoolean('Unique'),
|
||||||
name: substitute_tags(String(Component.getName())),
|
name: substitute_tags(String(Component.getName())),
|
||||||
pack_code: pack_code,
|
pack_code: pack_code,
|
||||||
position: parseInt(Component.settings.get('CollectionNumber')) || null,
|
position: int_or_null(Component.settings.get('CollectionNumber')),
|
||||||
quantity: 2, // TODO
|
quantity: 2, // TODO
|
||||||
//restrictions: null, // TODO
|
//restrictions: null, // TODO
|
||||||
sanity: parseInt(Component.settings.get('Sanity')) || null,
|
sanity: int_or_null(Component.settings.get('Sanity')),
|
||||||
skill_agility: skills["Agility"],
|
skill_agility: skills["Agility"],
|
||||||
skill_combat: skills["Combat"],
|
skill_combat: skills["Combat"],
|
||||||
skill_intellect: skills["Intellect"],
|
skill_intellect: skills["Intellect"],
|
||||||
@ -111,7 +122,7 @@ var card_data = {
|
|||||||
Component.settings.get('Keywords') + '\n' + Component.settings.get('Rules'))),
|
Component.settings.get('Keywords') + '\n' + Component.settings.get('Rules'))),
|
||||||
traits: substitute_tags(String(Component.settings.get('Traits'))),
|
traits: substitute_tags(String(Component.settings.get('Traits'))),
|
||||||
type_code: card_types[Component.getFrontTemplateKey()],
|
type_code: card_types[Component.getFrontTemplateKey()],
|
||||||
xp: parseInt(Component.settings.get('Level')) || null,
|
xp: int_or_null(Component.settings.get('Level')),
|
||||||
};
|
};
|
||||||
|
|
||||||
var raw_slot = Component.settings.get('Slot');
|
var raw_slot = Component.settings.get('Slot');
|
||||||
|
Loading…
Reference in New Issue
Block a user