diff --git a/src/js/descriptionWidgets.js b/src/js/descriptionWidgets.js index 7eb1a694eba4a235f3f7d3a2f556405ee7c40321..ab97fcf10c600f9e0f3746222fb4d9f435a45d8b 100644 --- a/src/js/descriptionWidgets.js +++ b/src/js/descriptionWidgets.js @@ -315,6 +315,7 @@ App.Desc.ageAndHealth = function(slave) { let woman = pronouns.woman; let He = capFirstChar(he); let His = capFirstChar(his); + let array; /* eslint-enable */ let age; let birthday = ""; @@ -346,49 +347,46 @@ App.Desc.ageAndHealth = function(slave) { if (H.shortDamage !== 0 || H.longDamage !== 0 || H.condition < 0) { r += ` Upon closer inspection you note that ${he}`; + array = []; if (H.shortDamage >= 100) { - r += ` looks <span class="red">absolutely brutalized</span> and will never be quite the way ${he} was`; + array.push(`looks <span class="red">absolutely brutalized</span> and will never be quite the way ${he} was`); } else if (H.shortDamage >= 70) { - r += ` is <span class="red">gravely injured</span> with assured lasting effects`; + array.push(`is <span class="red">gravely injured</span> with assured lasting effects`); } else if (H.shortDamage >= 40) { - r += ` is <span class="red">seriouly injured</span> with some lasting effects`; + array.push(`is <span class="red">seriouly injured</span> with some lasting effects`); } else if (H.shortDamage >= 20) { - r += ` is <span class="orange">injured</span>`; + array.push(`is <span class="orange">injured</span>`); } else if (H.shortDamage > 0) { - r += ` seems to have suffered a <span class="yellow">minor injury</span> recently`; - } - - if (H.shortDamage !== 0 && H.longDamage !== 0 && H.condition < 0) { - r += `,`; - } else if ((H.shortDamage !== 0 && H.longDamage !== 0) || (H.shortDamage !== 0 && H.condition < 0)) { - r += ` and`; + array.push(`seems to have suffered a <span class="yellow">minor injury</span> recently`); } if (H.longDamage >= 70) { - r += ` is suffering heavily under accumulated <span class="red">permanent health problems</span>`; + array.push(`is suffering heavily under accumulated <span class="red">permanent health problems</span>`); } else if (H.longDamage >= 40) { - r += ` has some clear <span class="red">permanent health issues</span>`; + array.push(`has some clear <span class="red">permanent health issues</span>`); } else if (H.longDamage >= 20) { - r += ` shows signs of <span class="orange">lasting health problems</span>`; + array.push(`shows signs of <span class="orange">lasting health problems</span>`); } else if (H.longDamage > 0) { - r += ` carries some <span class="yellow">minor niggles</span>`; - } - - if ((H.shortDamage !== 0 || H.longDamage !== 0) && H.condition < 0) { - r += ` and`; + array.push(`carries some <span class="yellow">minor niggles</span>`); } if (H.condition < -80 && H.shortDamage !== 0 && H.longDamage !== 0) { - r += ` has been treated so badly ${he} <span class="red">is close to the brink</span>`; + array.push(`has been treated so badly ${he} <span class="red">is close to the brink</span>`); } else if (H.condition < -50) { - r += ` appears to be in <span class="red">terrible condition</span>`; + array.push(`appears to be in <span class="red">terrible condition</span>`); } else if (H.condition < -20) { - r += ` appears to be in <span class="orange">poor condition</span>`; + array.push(`appears to be in <span class="orange">poor condition</span>`); } else if (H.condition < 0) { - r += ' could be in <span class="yellow">better condition</span>'; + array.push('could be in <span class="yellow">better condition</span>'); } - r += `.`; + if (array.length === 3) { + r += (` ${array[0]}, ${array[1]} and ${array[2]}.`); + } else if (array.length === 2) { + r += (` ${array[0]} and ${array[1]}.`); + } else if (array.length === 1) { + r += (` ${array[0]}.`); + } } if (H.tired > 30) {