mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-26 17:43:48 +01:00
Add createCorp
This commit is contained in:
parent
bea6b0e0b1
commit
e2bb76ae6d
@ -59,6 +59,21 @@ export function NetscriptCorporation(
|
|||||||
workerScript: WorkerScript,
|
workerScript: WorkerScript,
|
||||||
helper: INetscriptHelper,
|
helper: INetscriptHelper,
|
||||||
): NSCorporation {
|
): 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 {
|
function getCorporation(): ICorporation {
|
||||||
const corporation = player.corporation;
|
const corporation = player.corporation;
|
||||||
if (corporation === null) throw new Error("cannot be called without a corporation");
|
if (corporation === null) throw new Error("cannot be called without a corporation");
|
||||||
@ -482,6 +497,10 @@ export function NetscriptCorporation(
|
|||||||
cities: cities,
|
cities: cities,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
createCorporation: function (corporationName: string, selfFund = true): boolean {
|
||||||
|
checkAccess("createCorporation");
|
||||||
|
return createCorporation(corporationName, selfFund);
|
||||||
|
},
|
||||||
getCorporation: function (): CorporationInfo {
|
getCorporation: function (): CorporationInfo {
|
||||||
checkAccess("getCorporation");
|
checkAccess("getCorporation");
|
||||||
const corporation = 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
|
* @public
|
||||||
*/
|
*/
|
||||||
export interface Corporation extends WarehouseAPI, OfficeAPI {
|
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
|
* Get corporation data
|
||||||
* @returns Corporation data
|
* @returns Corporation data
|
||||||
|
Loading…
Reference in New Issue
Block a user