Skip to content

Commit

Permalink
scale?
Browse files Browse the repository at this point in the history
  • Loading branch information
IG2WTC committed Aug 4, 2024
1 parent 257e174 commit df4efb8
Showing 1 changed file with 69 additions and 7 deletions.
76 changes: 69 additions & 7 deletions js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ function profit(crop) {

var jarCycles = 0;
if (options.equipment > 0) {
if (produce == 1 || produce == 2) {
if (produce == 1) {
//cropsLeft += Math.max(0, itemsMade - options.equipment) * crop.harvests;
//itemsMade = Math.min(options.equipment, itemsMade) * crop.harvests;
if (crop.growth.regrow == 0) {
Expand All @@ -438,6 +438,30 @@ function profit(crop) {
cropsLeft += Math.max(total_crops - usableCrops, 0);
}
}
if (produce == 2) {

if (crop.growth.regrow == 0) {
jarCycles = Math.max(Math.floor((crop.growth.initial * (crop.harvests - 1)) + (options.days - crop.growth.initial * crop.harvests - 1) / 3), 0);
}
else {
jarCycles = Math.max(Math.floor((crop.growth.regrow * (crop.harvests - 1)) + (options.days - crop.growth.initial - crop.growth.regrow * (crop.harvests - 1) - 1)), 0);
}
usableCrops = Math.max(
Math.floor(total_harvest * (crop.harvests - 1)) +
Math.min(Math.floor(crop.growth.regrow > 0 ? (options.days - crop.growth.initial - crop.growth.regrow * (crop.harvests - 1) - 1) / 3 :
(options.days - crop.growth.initial * crop.harvests - 1) / 3) * num_planted, num_planted * crop.harvests)
, 0);
var maxJarProcesses = (jarCycles * options.equipment);
itemsMade = Math.min(maxJarProcesses, usableCrops //- total_harvest
);

if (usableCrops > maxJarProcesses) {
cropsLeft += total_crops - maxJarProcesses;
}
else{
cropsLeft += Math.max(total_crops - usableCrops, 0);
}
}
if (produce == 4 && !options.byHarvest) {
cropsLeft += Math.max(0, itemsMade - options.equipment) * 5;
itemsMade = Math.min(options.equipment, itemsMade);
Expand Down Expand Up @@ -716,43 +740,81 @@ function updateScaleY() {
* @return The new scale.
*/
function updateScaleAxis() {

return d3.scale.linear()

.domain([
-d3.max(cropList, function(d) {

d3.min(cropList, function(d) {

if (d.drawProfit >= 0) {

return (~~((d.drawProfit + 99) / 100) * 100);

}

else {

var profit = d.drawProfit;

if (options.buySeed) {

if (d.seedLoss < profit)

profit = d.drawSeedLoss;

}

if (options.buyFert) {

if (d.fertLoss < profit)

profit = d.drawFertLoss;

}

return (~~((-profit + 99) / 100) * 100);

}

}),

d3.max(cropList, function(d) {
if (d.drawProfit >= 0) {
return (~~((d.drawProfit + 99) / 100) * 100);

if (d.drawProfit < 0) {

return (~~((d.drawProfit - 99) / 100) * 100);

}

else {

var profit = d.drawProfit;

if (options.buySeed) {
if (d.seedLoss < profit)

if (d.seedLoss > profit)

profit = d.drawSeedLoss;

}

if (options.buyFert) {
if (d.fertLoss < profit)

if (d.fertLoss > profit)

profit = d.drawFertLoss;

}
return (~~((-profit + 99) / 100) * 100);

return (~~((-profit - 99) / 100) * 100);

}

})])

.range([height*2, 0]);

}

/*
Expand Down

0 comments on commit df4efb8

Please sign in to comment.