diff --git a/src/js/slaveCostJS.js b/src/js/slaveCostJS.js index eba9c24062e23ba3f48031ae9ecd8f7f56ce31c4..8f805e46b4d573872fbadbd14117a392ee54036d 100644 --- a/src/js/slaveCostJS.js +++ b/src/js/slaveCostJS.js @@ -1691,6 +1691,7 @@ globalThis.FResultArray = (function() { let incestBonus; /** * @param {App.Entity.SlaveState} slave + * @param {number} [forSale=0] set to 1 if the value should not consider co-assignment and other temporary factors * @returns {{text:string, value:number}[]} */ function FResult(slave, forSale = 0) { @@ -1751,6 +1752,7 @@ globalThis.FResultArray = (function() { adjustFResult(`Rounding off: Slave value cannot be less than 2`, 2 - result); } } + return retval; } @@ -2116,22 +2118,38 @@ globalThis.FResultArray = (function() { return FResult; })(); -globalThis.FResult = function(s) { - let FResult = FResultArray(s).reduce((result, {value}) => result + value, 0); + +/** Calculate the sexual value (FResult) of the slave + * @param {App.Entity.SlaveState} s + * @param {number} [forSale=0] set to 1 to ignore co-assignment and other temporary factors + * @returns {number} + */ +globalThis.FResult = function(s, forSale=0) { + let FResult = FResultArray(s, forSale).reduce((result, {value}) => result + value, 0); FResult = Math.trunc(FResult); return FResult; }; -globalThis.FResultTooltip = function(slave) { - // Make a link. Text should be slave'slave FResult. Clicking the link will display detailed info about that beauty where the link used to be +/** Show an itemized breakdown of the sexual value (FResult) of the slave + * @param {App.Entity.SlaveState} slave + * @param {number} [forSale=0] set to 1 to ignore co-assignment and other temporary factors + * @returns {HTMLElement} + */ +globalThis.FResultTooltip = function(slave, forSale=0) { + // Make a link. Text should be slave's FResult. Clicking the link will display detailed info about that beauty where the link used to be if (V.cheatMode || V.debugMode) { - return jQuery('#FResultTooltip').empty().append(FResultDisplay(slave)); + return jQuery('#FResultTooltip').empty().append(FResultDisplay(slave, forSale))[0]; } else { - return FResultDisplay(slave); + return FResultDisplay(slave, forSale); } - // Upon the link being clicked, set up some links to sort the info and a span to show it in - function FResultDisplay(slave) { + + /** Upon the link being clicked, set up some links to sort the info and a span to show it in + * @param {App.Entity.SlaveState} slave + * @param {number} forSale + * @returns {HTMLElement} + */ + function FResultDisplay(slave, forSale) { let criteria = "value"; let direction = "descending"; @@ -2145,29 +2163,33 @@ globalThis.FResultTooltip = function(slave) { el.appendChild(document.createTextNode(`Sort by: `)); el.appendChild(App.UI.DOM.generateLinksStrip([ - App.UI.DOM.link("Text", () => { criteria = "text"; jQuery('#cheatFResultContents').empty().append(FResultFrame(slave)); }, []), - App.UI.DOM.link("Value", () => { criteria = "value"; jQuery('#cheatFResultContents').empty().append(FResultFrame(slave)); }, []), - App.UI.DOM.link("Ascending", () => { direction = "ascending"; jQuery('#cheatFResultContents').empty().append(FResultFrame(slave)); }, []), - App.UI.DOM.link("Descending", () => { direction = "descending"; jQuery('#cheatFResultContents').empty().append(FResultFrame(slave)); }, []) + App.UI.DOM.link("Text", () => { criteria = "text"; jQuery('#cheatFResultContents').empty().append(FResultFrame(slave, forSale)); }, []), + App.UI.DOM.link("Value", () => { criteria = "value"; jQuery('#cheatFResultContents').empty().append(FResultFrame(slave, forSale)); }, []), + App.UI.DOM.link("Ascending", () => { direction = "ascending"; jQuery('#cheatFResultContents').empty().append(FResultFrame(slave, forSale)); }, []), + App.UI.DOM.link("Descending", () => { direction = "descending"; jQuery('#cheatFResultContents').empty().append(FResultFrame(slave, forSale)); }, []) ])); let cheatFResultContents = document.createElement('div'); cheatFResultContents.id = "cheatFResultContents"; cheatFResultContents.className = "clear-formatting"; - cheatFResultContents.appendChild(FResultFrame(slave)); + cheatFResultContents.appendChild(FResultFrame(slave, forSale)); el.appendChild(cheatFResultContents); span.appendChild(el); return span; - // Set up the frame that contains the info, returns dom node - function FResultFrame(slave) { + /** Set up the frame that contains the info + * @param {App.Entity.SlaveState} slave + * @param {number} forSale + * @returns {DocumentFragment} + */ + function FResultFrame(slave, forSale) { let el = document.createDocumentFragment(); let fResultArray; if ((criteria === "text" && direction === "descending") || (criteria === "value" && direction === "ascending")) { - fResultArray = FResultArray(slave).sort((a, b) => (a[criteria] > b[criteria]) ? 1 : -1); + fResultArray = FResultArray(slave, forSale).sort((a, b) => (a[criteria] > b[criteria]) ? 1 : -1); } else { - fResultArray = FResultArray(slave).sort((a, b) => (a[criteria] < b[criteria]) ? 1 : -1); + fResultArray = FResultArray(slave, forSale).sort((a, b) => (a[criteria] < b[criteria]) ? 1 : -1); } let domLine; @@ -2197,12 +2219,12 @@ globalThis.FResultTooltip = function(slave) { } } - function hide(slave) { - return App.UI.DOM.link(FResult(slave), () => { jQuery('#FResultTooltip').empty().append(show(slave)); }, []); + function hide(slave, forSale) { + return App.UI.DOM.link(FResult(slave, forSale), () => { jQuery('#FResultTooltip').empty().append(show(slave, forSale)); }, []); } - function show(slave) { - return App.UI.DOM.link(FResult(slave), () => { jQuery('#FResultTooltip').empty().append(FResultDisplay(slave)); }, []); + function show(slave, forSale) { + return App.UI.DOM.link(FResult(slave, forSale), () => { jQuery('#FResultTooltip').empty().append(FResultDisplay(slave, forSale)); }, []); } }; @@ -2238,7 +2260,7 @@ globalThis.slaveCostBeauty = (function() { function slaveCost(slave, isStartingSlave, followLaws) { arcology = V.arcologies[0]; multiplier = V.slaveCostFactor; - cost = Beauty(slave) * FResult(slave); + cost = Beauty(slave) * FResult(slave, 1); calcGenitalsCost(slave); calcDevotionTrustCost(slave); diff --git a/src/npc/descriptions/longSlave.js b/src/npc/descriptions/longSlave.js index 33ca73fbce8f573a27ed0bc34890604b54a7fa81..38fb1a8558e60fda9033753b3ef5fc60530b76f2 100644 --- a/src/npc/descriptions/longSlave.js +++ b/src/npc/descriptions/longSlave.js @@ -372,7 +372,7 @@ App.Desc.longSlave = function(slave = V.activeSlave, {market = 0, eventDescripti if (V.cheatMode || V.debugMode) { span2.appendChild( App.UI.DOM.link( - FResult(slave), + FResult(slave, market ? 1 : 0), () => { FResultTooltip(slave); },