diff --git a/src/markets/specificMarkets/customSlaveMarket.js b/src/markets/specificMarkets/customSlaveMarket.js index 5665961f3cfe8572a11d76b6ec52083a2f7327dc..2c5361803428088f3595ef57606f7fc7e011e27f 100644 --- a/src/markets/specificMarkets/customSlaveMarket.js +++ b/src/markets/specificMarkets/customSlaveMarket.js @@ -40,12 +40,32 @@ App.Markets["Custom Slave"] = function() { // Lower age should be the previous number in the array, +1 ageText = `${(ages[highIndex-1])+1}-${ages[highIndex]}`; } - el.append(`${ageText} years old.`); + el.append(`${ageText} years old. `); // Choices - for (const high in ages) { + const select = document.createElement("select"); + for (let i = 0; i < ages.length; i++) { + const high = ages[i]; + const low = ages[i-1] || (ages[i] - 1); // First element of array has nothing before it, obviously, so display low as one less than high. + if (low < V.minimumSlaveAge) { + continue; + } else if (high > V.retirementAge) { + const option = document.createElement("option"); + option.text = `${low+1}+`; + option.value = low+1; + select.append(option); + break; + } + const option = document.createElement("option"); + option.text = `${low}-${high}`; + option.value = high; + select.append(option); } + select.onchange = () => { + slave.age = Number(select.options[select.selectedIndex].value); + } + el.append(select); return el; }