diff --git a/src/interaction/prostheticConfig.tw b/src/interaction/prostheticConfig.tw index e44f47ea79b77bbb7ccabbac51730ea837bd952d..8a68dbe21a99b923a830f662d4882e026c8c74ad 100644 --- a/src/interaction/prostheticConfig.tw +++ b/src/interaction/prostheticConfig.tw @@ -115,7 +115,7 @@ This room is lined with shelves and cabinets; it could be easily mistaken for a </p> <p class="indent"> - $He has <<print App.Desc.eyesColor(getSlave($AS))>>. To change $his eye color visit the [[auto salon|Salon][$primaryTailColor = "", $secondaryTailColor = ""]]. + $He has <<print App.Desc.eyesColor(getSlave($AS))>>. To change $his eye color visit the [[auto salon|Salon]]. </p> <</if>> diff --git a/src/interaction/slaveInteract.js b/src/interaction/slaveInteract.js index 8e0030d63bbea9aba451c60070997d2107c71b48..c69d9adbe2cf3e348d7b54882e4d5b8e155d43b7 100644 --- a/src/interaction/slaveInteract.js +++ b/src/interaction/slaveInteract.js @@ -61,8 +61,6 @@ App.UI.SlaveInteract.modify = function(slave) { makeRoomLink(el, "Auto salon", "Salon", ' Modify hair (color, length, style), nails, and even skin color.', () => { V.activeSlave = slave; - V.primaryTailColor = ""; - V.secondaryTailColor = ""; } ); diff --git a/src/js/salon.js b/src/js/salon.js index d8e3d69716ee4ff5598bca4a9ca5d84f893b3cd9..4069c507d753be823befbfcb7ebdd2f69d627b6f 100644 --- a/src/js/salon.js +++ b/src/js/salon.js @@ -322,7 +322,7 @@ App.Medicine.Salon.ears = function(slave, {primaryEarColor = 0, secondaryEarColo * @param {string} [params.secondaryHairColor] * @returns {node} */ -App.Medicine.Salon.hair = function(slave, {primaryHairColor = 0, secondaryHairColor = "", primaryTailColor = 0, secondaryTailColor = ""} = {}) { +App.Medicine.Salon.hair = function(slave, {primaryHairColor = 0, secondaryHairColor = ""} = {}) { const frag = new DocumentFragment(); let updatePrimary = (newVal) => { primaryHairColor = newVal.value; apply(); }; let updateSecondary = (newVal) => { secondaryHairColor = newVal.value; apply(); }; @@ -343,7 +343,6 @@ App.Medicine.Salon.hair = function(slave, {primaryHairColor = 0, secondaryHairCo frag.append(wigStyle()); frag.append(wigLength()); } - frag.append(tailDye()); return jQuery("#salonHair").empty().append(frag); function hairDye() { @@ -465,7 +464,7 @@ App.Medicine.Salon.hair = function(slave, {primaryHairColor = 0, secondaryHairCo } apply(); }; - const oldHLength = (V.showInches === 2) ? Math.round(slave.hLength/2.54) : slave.hLength; + const oldHLength = (V.showInches === 2) ? Math.round(slave.hLength / 2.54) : slave.hLength; App.UI.DOM.appendNewElement("span", div, `Cut or lengthen ${his} hair:`); div.append(createList(App.Medicine.Modification.hairStyles.Length, method)); @@ -477,7 +476,7 @@ App.Medicine.Salon.hair = function(slave, {primaryHairColor = 0, secondaryHairCo v = Math.max(v, 0); // Positive hair length only // If they entered "inches," convert if (V.showInches === 2) { - v = Math.round(v*2.54); + v = Math.round(v * 2.54); } slave.hLength = v; cashX(forceNeg(V.modCost), "slaveMod", slave); @@ -593,7 +592,7 @@ App.Medicine.Salon.hair = function(slave, {primaryHairColor = 0, secondaryHairCo slave.hLength = newVal.hLength; apply(); }; - const oldHLength = (V.showInches === 2) ? Math.round(slave.hLength/2.54) : slave.hLength; + const oldHLength = (V.showInches === 2) ? Math.round(slave.hLength / 2.54) : slave.hLength; App.UI.DOM.appendNewElement("span", div, `Set wig length to:`, "choices"); div.append(createList(array, method)); div.append(" | Custom length: "); @@ -604,7 +603,7 @@ App.Medicine.Salon.hair = function(slave, {primaryHairColor = 0, secondaryHairCo v = Math.max(v, 10); // Wigs must be at least 10 cm // If they entered "inches," convert if (V.showInches === 2) { - v = Math.round(v*2.54); + v = Math.round(v * 2.54); } slave.hLength = v; cashX(forceNeg(V.modCost), "slaveMod", slave); @@ -653,13 +652,59 @@ App.Medicine.Salon.hair = function(slave, {primaryHairColor = 0, secondaryHairCo return frag; } + function createList(array, method) { + const links = []; + for (const item of array) { + if (item.hasOwnProperty("requirements")) { + if (item.requirements(slave) === false) { + continue; + } + } + const title = item.title || capFirstChar(item.value); + links.push( + App.UI.DOM.link( + title, + () => method(item) + ) + ); + } + return App.UI.DOM.generateLinksStrip(links); + } + + function apply() { + App.Art.refreshSlaveArt(slave, 3, "artFrame"); + App.Medicine.Salon.hair( + slave, + { + primaryHairColor: primaryHairColor, + secondaryHairColor: secondaryHairColor, + } + ); + } +}; + +/** + * Update hair in salon + * @param {App.Entity.SlaveState} slave + * @param {object} params + * @param {number|string} [params.primaryTailColor] + * @param {string} [params.secondaryTailColor] + * @returns {node} + */ +App.Medicine.Salon.tail = function(slave, {primaryTailColor = 0, secondaryTailColor = ""} = {}) { + const frag = new DocumentFragment(); + let updatePrimary = (newVal) => { primaryTailColor = newVal.value; apply(); }; + let updateSecondary = (newVal) => { secondaryTailColor = newVal.value; apply(); }; + const {His, his} = getPronouns(slave); + + if (slave.tail !== "none") { + frag.append(tailDye()); + } + + return jQuery("#salonTail").empty().append(frag); + function tailDye() { const frag = new DocumentFragment(); - if (slave.tail === "none") { - return frag; - } - let updatePrimary = (newVal) => { primaryTailColor = newVal.value; apply(); }; - let updateSecondary = (newVal) => { secondaryTailColor = newVal.value; apply(); }; let div; let p; frag.append(`${His} tail is ${slave.tailColor}.`); @@ -707,7 +752,7 @@ App.Medicine.Salon.hair = function(slave, {primaryHairColor = 0, secondaryHairCo slave.tailColor = (primaryTailColor + secondaryTailColor); App.Art.refreshSlaveArt(slave, 3, "artFrame"); cashX(forceNeg(V.modCost), "slaveMod", slave); - App.Medicine.Salon.hair(slave); // discard selections after locking them in. + App.Medicine.Salon.tail(slave); // discard selections after locking them in. } ) ); @@ -738,11 +783,9 @@ App.Medicine.Salon.hair = function(slave, {primaryHairColor = 0, secondaryHairCo function apply() { App.Art.refreshSlaveArt(slave, 3, "artFrame"); - App.Medicine.Salon.hair( + App.Medicine.Salon.tail( slave, { - primaryHairColor: primaryHairColor, - secondaryHairColor: secondaryHairColor, primaryTailColor: primaryTailColor, secondaryTailColor: secondaryTailColor, } diff --git a/src/uncategorized/salon.tw b/src/uncategorized/salon.tw index 8f92721d5448b2f3dbf03ec38ceecb13b7d9c512..2d0ef9efd71a2d4bd67968bdb7d759e3af25611a 100644 --- a/src/uncategorized/salon.tw +++ b/src/uncategorized/salon.tw @@ -286,71 +286,10 @@ | [[Tiger Stripes|Salon][getSlave($AS).skin = "tiger striped",cashX(forceNeg($modCost), "slaveMod", getSlave($AS))]] </div> -<<if getSlave($AS).tail != "none">> - $His tail is <<= getSlave($AS).tailColor>>. - <<if getSlave($AS).tailColor != getSlave($AS).hColor>> - [[Match current hair|Salon][getSlave($AS).tailColor = getSlave($AS).hColor]] or <span class="note">choose a new one:</span> - <<else>> - <span class="note">Choose a dye color before dyeing $his tail:</span> - <</if>> - <div class="choices"> - Colors: - [[Auburn|Salon][$primaryTailColor = "auburn"]] - | [[Black|Salon][$primaryTailColor = "black"]] - | [[Blazing Red|Salon][$primaryTailColor = "blazing red"]] - | [[Blonde|Salon][$primaryTailColor = "blonde"]] - | [[Blue-Violet|Salon][$primaryTailColor = "blue-violet"]] - | [[Blue|Salon][$primaryTailColor = "blue"]] - | [[Brown|Salon][$primaryTailColor = "brown"]] - | [[Burgundy|Salon][$primaryTailColor = "burgundy"]] - | [[Chestnut|Salon][$primaryTailColor = "chestnut"]] - | [[Chocolate|Salon][$primaryTailColor = "chocolate brown"]] - | [[Copper|Salon][$primaryTailColor = "copper"]] - | [[Dark Blue|Salon][$primaryTailColor = "dark blue"]] - | [[Dark Brown|Salon][$primaryTailColor = "dark brown"]] - | [[Dark Orchid|Salon][$primaryTailColor = "dark orchid"]] - | [[Deep Red|Salon][$primaryTailColor = "deep red"]] - | [[Ginger|Salon][$primaryTailColor = "ginger"]] - | [[Golden|Salon][$primaryTailColor = "golden"]] - | [[Green-yellow|Salon][$primaryTailColor = "green-yellow"]] - | [[Green|Salon][$primaryTailColor = "green"]] - | [[Grey|Salon][$primaryTailColor = "grey"]] - | [[Hazel|Salon][$primaryTailColor = "hazel"]] - | [[Jet Black|Salon][$primaryTailColor = "jet black"]] - | [[Neon Blue|Salon][$primaryTailColor = "neon blue"]] - | [[Neon Green|Salon][$primaryTailColor = "neon green"]] - | [[Neon Pink|Salon][$primaryTailColor = "neon pink"]] - | [[Pink|Salon][$primaryTailColor = "pink"]] - | [[Platinum Blonde|Salon][$primaryTailColor = "platinum blonde"]] - | [[Purple|Salon][$primaryTailColor = "purple"]] - | [[Red|Salon][$primaryTailColor = "red"]] - | [[Sea Green|Salon][$primaryTailColor = "sea green"]] - | [[Silver|Salon][$primaryTailColor = "silver"]] - | [[Strawberry-Blonde|Salon][$primaryTailColor = "strawberry-blonde"]] - | [[White|Salon][$primaryTailColor = "white"]] - </div> - - <div class="choices"> - Highlights: - [[None|Salon][$secondaryTailColor = ""]] - | [[Black|Salon][$secondaryTailColor = " with black highlights"]] - | [[Blazing Red|Salon][$secondaryTailColor = " with blazing red highlights"]] - | [[Blonde|Salon][$secondaryTailColor = " with blonde highlights"]] - | [[Grey|Salon][$secondaryTailColor = " with grey highlights"]] - | [[Neon Blue|Salon][$secondaryTailColor = " with neon blue highlights"]] - | [[Neon Green|Salon][$secondaryTailColor = " with neon green highlights"]] - | [[Neon Pink|Salon][$secondaryTailColor = " with neon pink highlights"]] - | [[Rainbow|Salon][$secondaryTailColor = " with rainbow highlights"]] - | [[Silver|Salon][$secondaryTailColor = " with silver highlights"]] - | [[White|Salon][$secondaryTailColor = " with white highlights"]] - </div> - - <<if $primaryTailColor != 0>> - <div class="choices"> - [["Dye " + $his + " tail"|Salon][getSlave($AS).tailColor = ($primaryTailColor + $secondaryTailColor),cashX(forceNeg($modCost), "slaveMod", getSlave($AS)), $primaryTailColor = 0, $secondaryTailColor = ""]] $primaryTailColor $secondaryTailColor now? - </div> - <</if>> -<</if>> +<p id="salonTail"></p> +<script> + App.Medicine.Salon.tail(getSlave(V.AS)); +</script> /* MARKS */ <div>