bitburner-src/src/Programs/ProgramHelpers.ts

25 lines
614 B
TypeScript
Raw Normal View History

2021-09-11 07:54:19 +02:00
import { Programs } from "./Programs";
import { Program } from "./Program";
import { Player } from "@player";
2021-09-11 07:54:19 +02:00
//Returns the programs this player can create.
2022-09-06 15:07:12 +02:00
export function getAvailableCreatePrograms(): Program[] {
2021-09-11 07:54:19 +02:00
const programs: Program[] = [];
2022-01-16 01:45:03 +01:00
for (const key of Object.keys(Programs)) {
2021-09-11 07:54:19 +02:00
// Non-creatable program
const create = Programs[key].create;
if (create == null) continue;
// Already has program
2022-09-06 15:07:12 +02:00
if (Player.hasProgram(Programs[key].name)) continue;
2021-09-11 07:54:19 +02:00
// Does not meet requirements
2022-09-06 15:07:12 +02:00
if (!create.req()) continue;
2021-09-11 07:54:19 +02:00
programs.push(Programs[key]);
}
return programs;
}