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",
|
||||
};
|
||||
|
||||
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),
|
||||
// TODO: handle None/X
|
||||
cost: parseInt(Component.settings.get('ResourceCost')) || null,
|
||||
cost: int_or_null(Component.settings.get('ResourceCost')),
|
||||
deck_limit: 2, // TODO: could be derived?
|
||||
faction_code: String(Component.settings.get('CardClass')).toLowerCase(),
|
||||
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')),
|
||||
is_unique: Component.settings.getBoolean('Unique'),
|
||||
name: substitute_tags(String(Component.getName())),
|
||||
pack_code: pack_code,
|
||||
position: parseInt(Component.settings.get('CollectionNumber')) || null,
|
||||
position: int_or_null(Component.settings.get('CollectionNumber')),
|
||||
quantity: 2, // TODO
|
||||
//restrictions: null, // TODO
|
||||
sanity: parseInt(Component.settings.get('Sanity')) || null,
|
||||
sanity: int_or_null(Component.settings.get('Sanity')),
|
||||
skill_agility: skills["Agility"],
|
||||
skill_combat: skills["Combat"],
|
||||
skill_intellect: skills["Intellect"],
|
||||
@ -111,7 +122,7 @@ var card_data = {
|
||||
Component.settings.get('Keywords') + '\n' + Component.settings.get('Rules'))),
|
||||
traits: substitute_tags(String(Component.settings.get('Traits'))),
|
||||
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');
|
||||
|
Loading…
Reference in New Issue
Block a user