mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-10 09:43:54 +01:00
Add createCorp
This commit is contained in:
parent
bea6b0e0b1
commit
e2bb76ae6d
@ -59,6 +59,21 @@ export function NetscriptCorporation(
|
||||
workerScript: WorkerScript,
|
||||
helper: INetscriptHelper,
|
||||
): NSCorporation {
|
||||
function createCorporation(corporationName: string, selfFund = true): boolean {
|
||||
if (!player.canAccessCorporation() || player.hasCorporation()) return false;
|
||||
if (!corporationName) return false;
|
||||
|
||||
if (selfFund) {
|
||||
if (!player.canAfford(150e9)) return false;
|
||||
|
||||
player.startCorporation(corporationName);
|
||||
player.loseMoney(150e9, "corporation");
|
||||
} else {
|
||||
player.startCorporation(corporationName, 500e6);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function getCorporation(): ICorporation {
|
||||
const corporation = player.corporation;
|
||||
if (corporation === null) throw new Error("cannot be called without a corporation");
|
||||
@ -482,6 +497,10 @@ export function NetscriptCorporation(
|
||||
cities: cities,
|
||||
};
|
||||
},
|
||||
createCorporation: function (corporationName: string, selfFund = true): boolean {
|
||||
checkAccess("createCorporation");
|
||||
return createCorporation(corporationName, selfFund);
|
||||
},
|
||||
getCorporation: function (): CorporationInfo {
|
||||
checkAccess("getCorporation");
|
||||
const corporation = getCorporation();
|
||||
|
6
src/ScriptEditor/NetscriptDefinitions.d.ts
vendored
6
src/ScriptEditor/NetscriptDefinitions.d.ts
vendored
@ -6314,6 +6314,12 @@ export interface WarehouseAPI {
|
||||
* @public
|
||||
*/
|
||||
export interface Corporation extends WarehouseAPI, OfficeAPI {
|
||||
/**
|
||||
* Create a Corporation
|
||||
* @param divisionName - Name of the division
|
||||
* @returns true if created and false if not
|
||||
*/
|
||||
createCorporation(corporationName: string, selfFund: boolean): boolean;
|
||||
/**
|
||||
* Get corporation data
|
||||
* @returns Corporation data
|
||||
|
Loading…
Reference in New Issue
Block a user