-
Notifications
You must be signed in to change notification settings - Fork 400
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New AI Apoc feat Existential Risk #974
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple of suggestions, but this seems otherwise neat.
Hasta la vista.
let aiApocRaceCount = 0; | ||
|
||
Object.keys(global.stats.synth).forEach(race => { | ||
aiApocRaceCount++; | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Much simpler to go for
const aiApocRaceCount = Object.keys(global.stats.synth).length;
let checked = `<div class="flexed wide">`; | ||
let avcounter = 0; | ||
Object.keys(races).sort((a,b) => races[a].name.localeCompare(races[b].name)).forEach(function (key){ | ||
if (key !== 'protoplasm' && key !== 'nano' && key !== 'synth' && key !== 'junker'){ | ||
avcounter++; | ||
if (global.stats.synth[key]){ | ||
checked = checked + `<span class="wide iclr${global.stats.synth[key]}">${races[key].name}</span>`; | ||
} | ||
else { | ||
checked = checked + `<span class="wide has-text-danger">${races[key].name}</span>`; | ||
} | ||
} | ||
}); | ||
checked = checked + `</div>`; | ||
popover(`f-${feat}`,$(`<div class="wide has-text-label">${feats[feat].desc}</div><div>${loc(`wiki_feat_${feat}`)}</div>${checked}${flair}`),{ | ||
wide: true | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This avoids creating the string through concatenation, and instead uses string templates
const noExistentialRisk = ['protoplasm', 'nano', 'synth', 'junker'];
const existentialProgress = `<div class="flexed wide">${
Object.keys(races)
.filter( (race) => !noExistentialRisk.includes(race) )
.map( (race) => ({ name: races[race].name, achieve: global.stats.synth[key] }) )
.sort( (a, b) => a.name.localeCompare(b.name) )
.map( (race) => `<span class="wide ${
race.achieve ? `iclr${race.achieve}` : 'has-text-danger'
}">${race.name}</span>` )
.join('')
}</div>`;
popover(`f-${feat}`,$(`<div class="wide has-text-label">${feats[feat].desc}</div><div>${loc(`wiki_feat_${feat}`)}</div>${existentialProgress}${flair}`),{
wide: true
});
Mostly I wanted to be able to track them, the feat is just icing on top :) Happy to take suggestions on icon, flavor text, etc