2021-09-11 07:54:19 +02:00
|
|
|
import { Programs } from "./Programs";
|
|
|
|
import { Program } from "./Program";
|
|
|
|
|
|
|
|
import { IPlayer } from "../PersonObjects/IPlayer";
|
|
|
|
|
|
|
|
//Returns the programs this player can create.
|
|
|
|
export function getAvailableCreatePrograms(player: IPlayer): Program[] {
|
|
|
|
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
|
|
|
|
if (player.hasProgram(Programs[key].name)) continue;
|
|
|
|
|
|
|
|
// Does not meet requirements
|
|
|
|
if (!create.req(player)) continue;
|
|
|
|
|
|
|
|
programs.push(Programs[key]);
|
|
|
|
}
|
|
|
|
|
|
|
|
return programs;
|
|
|
|
}
|