Skip to content
Snippets Groups Projects
Commit 483f31e9 authored by dsoloha's avatar dsoloha
Browse files

Merge branch 'pregmod-master' of https://gitgud.io/pregmodfan/fc-pregmod into dcoded-dev

parents 5a92d77a 891d829c
No related branches found
No related tags found
No related merge requests found
...@@ -297,3 +297,30 @@ App.Utils.topologicalSort = function(keys, edges) { ...@@ -297,3 +297,30 @@ App.Utils.topologicalSort = function(keys, edges) {
return sorted; return sorted;
}; };
window.getBestSlaves = function({part, count=3, smallest=false, filter=null}={}){
if(!_.isFunction(part)) {
const partName = part;
part = (slave)=>slave[partName];
}
const sortMethod = smallest ? (left, right) => left.value - right.value : (left, right) => right.value - left.value;
if(filter == null) {
filter = ()=>true;
}
return V.slaves.map((slave, index)=>({slave, index}))
.filter(slaveInfo=>filter(slaveInfo.slave))
.map(slaveInfo=>{ slaveInfo.value = part(slaveInfo.slave); return slaveInfo; })
.sort(sortMethod)
.slice(0, count);
};
window.getBestSlavesIndices= function(info) {
return getBestSlaves(info).map(slaveInfo => slaveInfo.index);
};
/*
//Example
getBestSlaves({part:"butt", count: 5});
getBestSlaves({part:"boobs"});//defaults to top 3
getBestSlaves({part:"dick", smallest:true, filter:(slave)=>slave.dick > 0});//defaults to top 3
getBestSlaves({part:slave=>slave.intelligence+slave.intelligenceImplant});
*/
This diff is collapsed.
:: Underperforming Slaves [nobr]
<<set $nextButton = "Back", $nextLink = "Buy Slaves", $returnTo = "Buy Slaves", $showEncyclopedia = 1>>
<p>
<div>
<<= properMaster()>>, while many of your slaves work hard to earn ¤ each week, some succeed more than others. As a trader in slaves, you may appreciate the opportunity that comes when a particularly valuable slave didn't earn very much last week. Or perhaps you just want the chance to tweak these problem slaves and train them to be better? The choice is yours.
</div>
<div>
<<if ($slaveCostFactor > 1.1)>>
Since there is a bull market for slaves, @@.green;this is a great time to sell.@@
<<elseif ($slaveCostFactor > 1)>>
Since the slave market is bullish; @@.green;this is a pretty good time to sell.@@
<<elseif ($slaveCostFactor < 0.9)>>
Since there is a bear market for slaves, @@.red;this is a poor time to sell.@@
<<elseif ($slaveCostFactor < 1)>>
Since the slave market is bearish; @@.red;this is a terrible time to sell.@@
<<else>>
Since the slave market is stable; @@.yellow;prices are average.@@
<</if>>
</div>
</p>
<<run App.UI.tabbar.handlePreSelectedTab($tabChoice.Options)>>
<button class="tablinks" onclick="App.UI.tabbar.openTab(event, 'highSale')" id="tab highSale">Worth much but earning little</button>
<button class="tablinks" onclick="App.UI.tabbar.openTab(event, 'expensive')" id="tab expensive">Costing vs earning</button>
<div id="highSale" class="tabcontent">
<div class="content">
<div style="font-style:italic">
Take the rough value of a slave and divide it by how much they made overall last week. This will tell you how many weeks it might take them to earn the same amount you'd get for selling them right now.
</div>
<<print App.UI.SlaveList.render.listMarkup(
getBestSlavesIndices(
{
part:(slave)=>(slaveCost(slave) / (slave.lastWeeksCashIncome - getSlaveCost(slave))),
smallest:false,
count: 7,
filter:(slave)=>(
["get milked", "work in the dairy", "whore", "work in the brothel", "work a glory hole", "be confined in the arcade"].includes(slave.assignment)
&& ((slave.weekAcquired + 1) < V.week)
&& slave.lastWeeksCashIncome
)
}
),
[],
App.UI.SlaveList.SlaveInteract.stdInteract,
(slave)=>$(document.createDocumentFragment()).append(
`Worth ${cashFormatColor(slaveCost(slave))} / Nets ${cashFormatColor(slave.lastWeeksCashIncome - getSlaveCost(slave))} a week = ${(Math.trunc(slaveCost(slave) / (slave.lastWeeksCashIncome - getSlaveCost(slave))))} weeks`
).get(0)
)>>
</div>
</div>
<div id="expensive" class="tabcontent">
<div class="content">
<div style="font-style:italic">
This list looks for moochers by weighing their weekly income against the weekly cost of providing for them.
</div>
<<print App.UI.SlaveList.render.listMarkup(
getBestSlavesIndices(
{
part:(slave)=>(slave.lastWeeksCashIncome - getSlaveCost(slave)),
smallest:true,
count: 7,
filter:(slave)=>(
["get milked", "work in the dairy", "whore", "work in the brothel", "work a glory hole", "be confined in the arcade"].includes(slave.assignment)
&& ((slave.weekAcquired + 1) < V.week)
&& slave.lastWeeksCashIncome
)
}
),
[],
App.UI.SlaveList.SlaveInteract.stdInteract,
(slave)=>$(document.createDocumentFragment()).append(
`${cashFormatColor(Math.trunc(slave.lastWeeksCashIncome - getSlaveCost(slave)))} net last week`
).get(0)
)>>
</div>
</div>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment