bitburner-src/src/Programs/Program.ts

33 lines
966 B
TypeScript
Raw Normal View History

2021-09-16 01:50:44 +02:00
import { BaseServer } from "../Server/BaseServer";
import { ITerminal } from "../Terminal/ITerminal";
import { IPlayer } from "../PersonObjects/IPlayer";
2021-09-18 01:43:08 +02:00
import { IRouter } from "../ui/Router";
export interface IProgramCreate {
2021-09-05 01:09:30 +02:00
level: number;
req(p: IPlayer): boolean; // Function that indicates whether player meets requirements
time: number;
tooltip: string;
}
export class Program {
2021-09-05 01:09:30 +02:00
name = "";
create: IProgramCreate | null;
2021-09-18 01:43:08 +02:00
run: (router: IRouter, terminal: ITerminal, player: IPlayer, server: BaseServer, args: string[]) => void;
2021-09-16 01:50:44 +02:00
constructor(
name: string,
create: IProgramCreate | null,
2021-09-18 01:43:08 +02:00
run: (router: IRouter, terminal: ITerminal, player: IPlayer, server: BaseServer, args: string[]) => void,
2021-09-16 01:50:44 +02:00
) {
2021-09-05 01:09:30 +02:00
this.name = name;
this.create = create;
2021-09-16 01:50:44 +02:00
this.run = run;
2021-09-05 01:09:30 +02:00
}
2021-09-05 01:09:30 +02:00
htmlID(): string {
2021-09-09 05:47:34 +02:00
const name = this.name.endsWith(".exe") ? this.name.slice(0, -".exe".length) : this.name;
2021-09-05 01:09:30 +02:00
return "create-program-" + name;
}
}