sneak in corp API.

This commit is contained in:
Olivier Gagnon
2021-09-10 02:17:55 -04:00
parent e906a6331f
commit e5dcb424a2
13 changed files with 388 additions and 157 deletions
+24 -10
View File
@@ -9,19 +9,12 @@ import { ICorporation } from "./ICorporation";
interface IParams {
loc?: string;
cost?: number;
size?: number;
comfort?: number;
beauty?: number;
}
export class OfficeSpace {
loc: string;
cost: number;
size: number;
comf: number;
beau: number;
tier = "Basic";
minEne = 0;
maxEne = 100;
minHap = 0;
@@ -39,10 +32,7 @@ export class OfficeSpace {
constructor(params: IParams = {}) {
this.loc = params.loc ? params.loc : "";
this.cost = params.cost ? params.cost : 1;
this.size = params.size ? params.size : 1;
this.comf = params.comfort ? params.comfort : 1;
this.beau = params.beauty ? params.beauty : 1;
}
atCapacity(): boolean {
@@ -184,6 +174,30 @@ export class OfficeSpace {
return false;
}
copy(): OfficeSpace {
const office = new OfficeSpace();
office.loc = this.loc;
office.size = this.size;
office.minEne = this.minEne;
office.maxEne = this.maxEne;
office.minHap = this.minHap;
office.maxHap = this.maxHap;
office.maxMor = this.maxMor;
office.employeeProd = {
[EmployeePositions.Operations]: this.employeeProd[EmployeePositions.Operations],
[EmployeePositions.Engineer]: this.employeeProd[EmployeePositions.Engineer],
[EmployeePositions.Business]: this.employeeProd[EmployeePositions.Business],
[EmployeePositions.Management]: this.employeeProd[EmployeePositions.Management],
[EmployeePositions.RandD]: this.employeeProd[EmployeePositions.RandD],
total: this.employeeProd["total"],
};
office.employees = [];
for (const employee of this.employees) {
office.employees.push(employee.copy());
}
return office;
}
toJSON(): any {
return Generic_toJSON("OfficeSpace", this);
}