Code: Select all
function findPoweredLabsWithPacks() {
var lab, labs = findAllLabs();
var ready = [];
for (lab in labs) {
if (lab.hasPower() && lab.inventory.contains(currentResearch.packsNeeded))
ready.push(lab)
}
return ready;
}
function startNewResearch() {
var labs = findPoweredLabsWithPacks();
var needed = currentResearch.getNeededCount();
var active = 0;
for (lab in labs) {
if active < needed {
lab.startResearch()
active += 1;
}
}
}