Trimps / bug-tracker

Trimps Bugs and Suggestions
GNU General Public License v2.0
1 stars 0 forks source link

autojobs ignore scientist buyMax setting on scientist unlock #248

Open namedots opened 1 year ago

namedots commented 1 year ago

Describe the bug well, title. specifically when scientist (and miner, probably) is unlocked, as this has a separate code path (why? idk)

I'm submitting my save file which does this a couple seconds after unpausing - autojobs limit is set to 5 but it'll typically hire 66. I've also seen 48 hires though, and I must say that I'm a little bothered by that this isn't deterministic.

blahh.txt

and then as to the cause - main.js:

function autoBalanceJob(which) {
  //Fired when miners and scientists are unlocked and maybe other places later, requires autoJobs
  var setting = getAutoJobsSetting();
  if (!setting || !setting.enabled || !bwRewardUnlocked("AutoJobs")) return;
  if (!setting[which] || !setting[which].enabled || !setting.Farmer || !setting.Farmer.enabled || setting.Farmer.ratio == 0) return;
  var want = game.jobs.Farmer.owned * (setting[which].ratio / setting.Farmer.ratio);
  want = Math.floor(want);

  if (setting.buyMax)
    want = Math.max(want, setting.buyMax);  // <--------------- should be Math.min

  var trimps = game.resources.trimps;
  var breedCount = (trimps.owned - trimps.employed > 2) ? Math.floor(trimps.owned - trimps.employed) : 0;
  var workspaces = game.workspaces;
  if (breedCount < workspaces) workspaces = breedCount;
  if (workspaces < want) want = workspaces;
  autoBuyJob(which, true, want);
}

I also have to wonder why Farmer settings are used the way they are, and why only Farmer and not also LumberJack/Miner, and, does this function need to trigger at all when unlocking scientists, why not simply wait for autojobs to trigger by itself in a little while?