loathers / garbage-collector

Script for farming meat (and garbage) in 2003 web RPG Kingdom of Loathing
24 stars 59 forks source link

cannot call maxBy on an empty Array #1772

Closed danbeardan closed 7 months ago

danbeardan commented 9 months ago

Ran Garbo after a CS loop and received this error:

JavaScript exception: Error: Cannot call maxBy on an empty array! (file:/E:/KOLMafia/scripts/garbage-collector/garbo.js#25167)

slik_20231213.txt

giu-scopely commented 8 months ago

I am receiving this as well constantly today, at first garbo was running 1 turn, then gives this error... now it says it will fight a Kramco goblin and then gives this error before that:

JavaScript exception: Error: Cannot call maxBy on an empty array! (file:/D:/Loathing/Kol/scripts/garbage-collector/garbo.js#25167) at file:/D:/Loathing/Kol/scripts/garbage-collector/garbo.js:25167 (f) at file:/D:/Loathing/Kol/scripts/garbage-collector/garbo.js:25269 (freefightFactory) at file:/D:/Loathing/Kol/scripts/garbage-collector/garbo.js:25536 (bestWander) at file:/D:/Loathing/Kol/scripts/garbage-collector/garbo.js:25567 (wanderWhere) at file:/D:/Loathing/Kol/scripts/garbage-collector/garbo.js:25573 (wanderWhere) at file:/D:/Loathing/Kol/scripts/garbage-collector/garbo.js:25573 (wanderWhere) at file:/D:/Loathing/Kol/scripts/garbage-collector/garbo.js:25573 (wanderWhere) at file:/D:/Loathing/Kol/scripts/garbage-collector/garbo.js:25731 (getTarget) at file:/D:/Loathing/Kol/scripts/garbage-collector/garbo.js:25737 (getChoices) at file:/D:/Loathing/Kol/scripts/garbage-collector/garbo.js:41445 at file:/D:/Loathing/Kol/scripts/garbage-collector/garbo.js:1107 (undelay) at file:/D:/Loathing/Kol/scripts/garbage-collector/garbo.js:29080 (setChoices) at file:/D:/Loathing/Kol/scripts/garbage-collector/garbo.js:28924 (execute) at file:/D:/Loathing/Kol/scripts/garbage-collector/garbo.js:47531 (execute) at file:/D:/Loathing/Kol/scripts/garbage-collector/garbo.js:28857 (run) at file:/D:/Loathing/Kol/scripts/garbage-collector/garbo.js:47588 (runGarboTasks) at file:/D:/Loathing/Kol/scripts/garbage-collector/garbo.js:47594 (runGarboQuests) at file:/D:/Loathing/Kol/scripts/garbage-collector/garbo.js:43555 (freeFights) at file:/D:/Loathing/Kol/scripts/garbage-collector/garbo.js:48040 at file:/D:/Loathing/Kol/scripts/garbage-collector/garbo.js:39771 (withClan) at file:/D:/Loathing/Kol/scripts/garbage-collector/garbo.js:39765 (withVIPClan) at file:/D:/Loathing/Kol/scripts/garbage-collector/garbo.js:48021 at file:/D:/Loathing/Kol/scripts/garbage-collector/garbo.js:39750 (withStash) at file:/D:/Loathing/Kol/scripts/garbage-collector/garbo.js:48020 (main)

pstalcup commented 8 months ago

This error seems to have to do with having very few zones available. I am surprised we have not hit this before, given there wasn't a new release of garbo since 2 days ago. I have a PR that should fix this. In the meantime, you could try unlocking additional zones by unlocking your guild and opening the woods (since you are in CS), as well as doing parts of the spookyraven quest.

giu-scopely commented 8 months ago

Btw, the few zones is definitely not my case, I have been on aftercore for a long time and I came out of fall of the dinosaurs, not CS, and I get the same error. My fix to it was just running the kramco fight myself and now the script is going smoothly.

ddekok commented 8 months ago

Had the same issues yesterday as well, also with a kramco. Also resolved it by forcing the kramco fight and everything worked fine afterwards

Script was also processing shadow rifts (that was last location) so wondered if it got caught with two free fights at the same time?

giu-scopely commented 8 months ago

What I noticed today... it was adventuring in the mystic woods and trying to put a kramco goblin there, I got this message: Task Free Fight/Kramco spent a turn but was marked as not spending turns

Tapionator commented 8 months ago

Yeah this looks similar to the issue I have been having. Something is up with Kramco and it's wanderer zone

Tapionator commented 8 months ago

Mine was trying to also Yellow Ray at the same time as doing a Kramco free fight

Tapionator commented 8 months ago

Should this be identified as a string? Saw this within the code. I think something is wrong with this specific function where the kramco freefight function is identifying a location based on the Yellow Ray function.

function wandererTurnsAvailableToday(options, location) { var canWanderCache = { backup: canWander(location, "backup"), wanderer: canWander(location, "wanderer"), "yellow ray": canWander(location, "yellow ray"), freefight: canWander(location, "freefight") };