Switch from var to let/const, as appropriate

This commit is contained in:
Adam Goldsmith 2021-09-13 17:39:11 -04:00
parent 642cdeb40a
commit fff366770a

View File

@ -90,15 +90,15 @@ function build_card(component) {
str = str.trim(); str = str.trim();
str = replaceAll(str, "<fullname>", String(component.getName())); str = replaceAll(str, "<fullname>", String(component.getName()));
for (var tag in tag_replacements) { for (let tag in tag_replacements) {
str = replaceAll(str, tag, tag_replacements[tag]); str = replaceAll(str, tag, tag_replacements[tag]);
} }
return str; return str;
} }
var code = cycle_prefix + leftPad(String(component.settings.get('CollectionNumber')), 3, '0'); const code = cycle_prefix + leftPad(String(component.settings.get('CollectionNumber')), 3, '0');
var card_data = { const card_data = {
code: String(code), code: String(code),
deck_limit: 2, // TODO: could be derived? deck_limit: 2, // TODO: could be derived?
flavor: substitute_tags(String(component.settings.get('Flavor'))), flavor: substitute_tags(String(component.settings.get('Flavor'))),
@ -117,54 +117,54 @@ function build_card(component) {
xp: int_or_null(component.settings.get('Level')), xp: int_or_null(component.settings.get('Level')),
}; };
var raw_health = component.settings.get('Stamina'); const raw_health = component.settings.get('Stamina');
if (raw_health && raw_health != 'None' && raw_health != '-') { if (raw_health && raw_health != 'None' && raw_health != '-') {
card_data.health = int_or_null(raw_health); card_data.health = int_or_null(raw_health);
} }
var raw_sanity = component.settings.get('Sanity'); const raw_sanity = component.settings.get('Sanity');
if (raw_sanity && raw_sanity != 'None' && raw_sanity != '-') { if (raw_sanity && raw_sanity != 'None' && raw_sanity != '-') {
card_data.sanity = int_or_null(raw_sanity); card_data.sanity = int_or_null(raw_sanity);
} }
var skills = { const skills = {
Agility: 0, Agility: 0,
Intellect: 0, Intellect: 0,
Combat: 0, Combat: 0,
Willpower: 0, Willpower: 0,
Wild: 0, Wild: 0,
}; };
for (var i = 1; i<=6; i++) { for (let i = 1; i<=6; i++) {
var skill_icon = component.settings.get('Skill' + i); const skill_icon = component.settings.get('Skill' + i);
if (skill_icon in skills) { if (skill_icon in skills) {
skills[skill_icon] += 1; skills[skill_icon] += 1;
} }
} }
for (var skill in skills) { for (let skill in skills) {
if (skills[skill] > 0) { if (skills[skill] > 0) {
card_data["skill_" + skill.toLowerCase()] = skills[skill]; card_data["skill_" + skill.toLowerCase()] = skills[skill];
} }
} }
var raw_cost = component.settings.get('ResourceCost'); const raw_cost = component.settings.get('ResourceCost');
if (raw_cost) { if (raw_cost) {
card_data.cost = int_or_null(raw_cost); card_data.cost = int_or_null(raw_cost);
} }
var raw_slot = component.settings.get('Slot'); const raw_slot = component.settings.get('Slot');
if (raw_slot && raw_slot != 'None') { if (raw_slot && raw_slot != 'None') {
card_data.slot = renameSlot(String(raw_slot)); card_data.slot = renameSlot(String(raw_slot));
var raw_slot2 = component.settings.get('Slot2'); const raw_slot2 = component.settings.get('Slot2');
if (raw_slot2 && raw_slot2 != 'None') { if (raw_slot2 && raw_slot2 != 'None') {
card_data.slot += '. ' + renameSlot(String(raw_slot2)); card_data.slot += '. ' + renameSlot(String(raw_slot2));
} }
} }
var subtitle = component.settings.get('Subtitle'); const subtitle = component.settings.get('Subtitle');
if (subtitle && subtitle != '') { if (subtitle && subtitle != '') {
card_data.subname = String(subtitle); card_data.subname = String(subtitle);
} }
var faction = component.settings.get('CardClass'); const faction = component.settings.get('CardClass');
if (faction) { if (faction) {
if (faction == 'Weakness') { if (faction == 'Weakness') {
card_data.subtype_code = "weakness"; card_data.subtype_code = "weakness";
@ -174,7 +174,7 @@ function build_card(component) {
} }
else { else {
card_data.faction_code = String(faction).toLowerCase(); card_data.faction_code = String(faction).toLowerCase();
var faction2 = component.settings.get('CardClass2'); const faction2 = component.settings.get('CardClass2');
if (faction2 && faction2 != 'None') { if (faction2 && faction2 != 'None') {
card_data.faction2_code = String(faction2).toLowerCase(); card_data.faction2_code = String(faction2).toLowerCase();
} }
@ -200,13 +200,13 @@ function build_card(component) {
return ordered_card_data; return ordered_card_data;
} }
var cards = []; const cards = [];
var member_iter = Eons.getOpenProject().iterator(); const member_iter = Eons.getOpenProject().iterator();
while (member_iter.hasNext()) { while (member_iter.hasNext()) {
var member = member_iter.next(); const member = member_iter.next();
printf("Generating JSON for '%s'...\n", member); printf("Generating JSON for '%s'...\n", member);
var component = ResourceKit.getGameComponentFromFile(member.getFile()); const component = ResourceKit.getGameComponentFromFile(member.getFile());
var card_data = build_card(component); const card_data = build_card(component);
cards.push(card_data); cards.push(card_data);
} }