diff --git a/src/js/salon.js b/src/js/salon.js index 58da243baba434a9fa8c33812bcc97bd870faac1..51256ca708d52b5c2ef0ac33218b68e94bf3736c 100644 --- a/src/js/salon.js +++ b/src/js/salon.js @@ -334,6 +334,7 @@ App.Medicine.Salon.hair = function(slave, {primaryHairColor = 0, secondaryHairCo } else { frag.append(wigDye()); } + frag.append(wigLength()); } return jQuery("#salonHair").empty().append(frag); @@ -453,7 +454,6 @@ App.Medicine.Salon.hair = function(slave, {primaryHairColor = 0, secondaryHairCo if (newVal.hasOwnProperty("hLength")) { slave.hLength = newVal.hLength; } - console.log(newVal); apply(); }; const oldHLength = (V.showInches === 2) ? Math.round(slave.hLength/2.54) : slave.hLength; @@ -567,6 +567,104 @@ App.Medicine.Salon.hair = function(slave, {primaryHairColor = 0, secondaryHairCo return frag; } + function wigLength() { + const frag = new DocumentFragment(); + let div = document.createElement("div"); + if (slave.hStyle === "bald") { + div.append(`${He} is not wearing a wig.`); + frag.append(div); + return frag; + } + const array = []; + for (const number of [10, 30, 60, 90, 120, 150]) { + const obj = {}; + obj.title = lengthToEitherUnit(number); + obj.hLength = number; + } + let method = (newVal) => { + slave.hLength = newVal.hLength; + apply(); + }; + const oldHLength = (V.showInches === 2) ? Math.round(slave.hLength/2.54) : slave.hLength; + App.UI.DOM.appendNewElement("span", div, `Cut or lengthen ${his} hair:`, "choices"); + div.append(createList(array, method)); + div.append(" | Custom length: "); + div.append( + App.UI.DOM.makeTextBox( + oldHLength, + v => { + v = Math.max(v, 0); // Positive hair length only + // If they entered "inches," convert + if (V.showInches === 2) { + v = Math.round(v*2.54); + } + slave.hLength = v; + cashX(forceNeg(V.modCost), "slaveMod", slave); + apply(); + }, + true + ) + ); + if (V.showInches === 1) { + div.append(`cm (${cmToInchString(slave.hLength)})`); + } else if (V.showInches === 2) { + div.append(`inches`); + } + + frag.append(div); + + return frag; + } + + function hairStyle() { + const frag = new DocumentFragment(); + let p; + let div; + let span; + let method; + div = document.createElement("div"); + if (slave.hStyle !== "shaved") { + div.append(`${His} ${slave.hStyle} hair is ${lengthToEitherUnit(slave.hLength)} long. `); + } else { + div.append(`${His} hair is shaved smooth. `); + } + App.UI.DOM.appendNewElement("span", div, `General hairstyles will conform to hair length and clothing choices.`, "note"); + frag.append(div); + + // Normal styles + div = document.createElement("div"); + div.classList.add("choices"); + method = (newVal) => { + slave.hStyle = newVal.value; + cashX(forceNeg(V.modCost), "slaveMod", slave); + apply(); + }; + if (slave.hLength > 1) { + div.append(`Style ${his} hair:`); + div.append(createList(App.Medicine.Modification.hairStyles.Normal, method)); + } else { + App.UI.DOM.appendNewElement("span", div, `${His} hair is too short to style meaningfully`, "note"); + } + frag.append(div); + + // Short styles, includes cutting + div = document.createElement("div"); + div.classList.add("choices"); + method = (newVal) => { + slave.hStyle = newVal.value; + slave.hLength = newVal.hLength; + cashX(forceNeg(V.modCost), "slaveMod", slave); + apply(); + }; + if (slave.hLength > 1) { + div.append(`Cut and style ${his} hair:`); + div.append(createList(App.Medicine.Modification.hairStyles.Cut, method)); + } + frag.append(div); + + return frag; + } + function createList(array, method) { const links = []; for (const item of array) {