2021-12-04 05:06:04 +01:00
import { INetscriptHelper } from "./INetscriptHelper" ;
import { WorkerScript } from "../Netscript/WorkerScript" ;
2021-10-14 09:22:02 +02:00
import { IPlayer } from "../PersonObjects/IPlayer" ;
2021-12-04 05:06:04 +01:00
import { netscriptDelay } from "../NetscriptEvaluator" ;
2021-10-14 09:22:02 +02:00
import { OfficeSpace } from "../Corporation/OfficeSpace" ;
import { Employee } from "../Corporation/Employee" ;
import { Product } from "../Corporation/Product" ;
import { Material } from "../Corporation/Material" ;
import { Warehouse } from "../Corporation/Warehouse" ;
import { IIndustry } from "../Corporation/IIndustry" ;
2021-12-04 05:06:04 +01:00
import { ICorporation } from "../Corporation/ICorporation" ;
import {
Corporation as NSCorporation ,
CorporationInfo ,
Employee as NSEmployee ,
Product as NSProduct ,
Material as NSMaterial ,
Warehouse as NSWarehouse ,
Division as NSDivision ,
WarehouseAPI ,
OfficeAPI ,
2022-01-13 12:42:23 +01:00
InvestmentOffer
2021-12-04 05:06:04 +01:00
} from "../ScriptEditor/NetscriptDefinitions" ;
2021-10-14 09:22:02 +02:00
import {
NewIndustry ,
NewCity ,
UnlockUpgrade ,
LevelUpgrade ,
IssueDividends ,
SellMaterial ,
SellProduct ,
SetSmartSupply ,
BuyMaterial ,
AssignJob ,
UpgradeOfficeSize ,
ThrowParty ,
PurchaseWarehouse ,
UpgradeWarehouse ,
BuyCoffee ,
HireAdVert ,
MakeProduct ,
Research ,
ExportMaterial ,
CancelExportMaterial ,
SetMaterialMarketTA1 ,
SetMaterialMarketTA2 ,
SetProductMarketTA1 ,
SetProductMarketTA2 ,
2022-01-17 11:03:29 +01:00
BulkPurchase ,
SellShares ,
BuyBackShares ,
2022-01-25 19:51:07 +01:00
SetSmartSupplyUseLeftovers ,
2021-10-14 09:22:02 +02:00
} from "../Corporation/Actions" ;
import { CorporationUnlockUpgrades } from "../Corporation/data/CorporationUnlockUpgrades" ;
import { CorporationUpgrades } from "../Corporation/data/CorporationUpgrades" ;
2021-12-04 05:06:04 +01:00
import { EmployeePositions } from "../Corporation/EmployeePositions" ;
import { calculateIntelligenceBonus } from "../PersonObjects/formulas/intelligence" ;
2022-01-11 21:25:23 +01:00
import { Industry } from "../Corporation/Industry" ;
2022-01-13 18:47:11 +01:00
import { IndustryResearchTrees , IndustryStartingCosts } from "../Corporation/IndustryData" ;
2022-01-12 00:47:04 +01:00
import { CorporationConstants } from "../Corporation/data/Constants" ;
import { IndustryUpgrades } from "../Corporation/IndustryUpgrades" ;
2022-01-13 18:47:11 +01:00
import { ResearchMap } from "../Corporation/ResearchMap" ;
2022-01-13 22:05:06 +01:00
import { Factions } from "../Faction/Factions" ;
2021-10-14 09:22:02 +02:00
2021-12-04 05:06:04 +01:00
export function NetscriptCorporation (
player : IPlayer ,
workerScript : WorkerScript ,
helper : INetscriptHelper ,
) : NSCorporation {
2022-01-11 20:43:29 +01:00
function createCorporation ( corporationName : string , selfFund = true ) : boolean {
if ( ! player . canAccessCorporation ( ) || player . hasCorporation ( ) ) return false ;
if ( ! corporationName ) return false ;
2022-01-11 20:53:53 +01:00
if ( player . bitNodeN !== 3 && ! selfFund ) throw new Error ( "cannot use seed funds outside of BitNode 3" ) ;
2022-01-11 20:43:29 +01:00
if ( selfFund ) {
if ( ! player . canAfford ( 150 e9 ) ) return false ;
player . startCorporation ( corporationName ) ;
player . loseMoney ( 150 e9 , "corporation" ) ;
} else {
player . startCorporation ( corporationName , 500 e6 ) ;
}
return true ;
}
2022-01-12 00:47:04 +01:00
function hasUnlockUpgrade ( upgradeName : string ) : boolean {
const corporation = getCorporation ( ) ;
const upgrade = Object . values ( CorporationUnlockUpgrades ) . find ( ( upgrade ) = > upgrade [ 2 ] === upgradeName ) ;
if ( upgrade === undefined ) throw new Error ( ` No upgrade named ' ${ upgradeName } ' ` ) ;
const upgN = upgrade [ 0 ] ;
return corporation . unlockUpgrades [ upgN ] === 1 ;
}
function getUnlockUpgradeCost ( upgradeName : string ) : number {
const upgrade = Object . values ( CorporationUnlockUpgrades ) . find ( ( upgrade ) = > upgrade [ 2 ] === upgradeName ) ;
if ( upgrade === undefined ) throw new Error ( ` No upgrade named ' ${ upgradeName } ' ` ) ;
return upgrade [ 1 ] ;
}
function getUpgradeLevel ( aupgradeName : string ) : number {
const upgradeName = helper . string ( "levelUpgrade" , "upgradeName" , aupgradeName ) ;
const corporation = getCorporation ( ) ;
const upgrade = Object . values ( CorporationUpgrades ) . find ( ( upgrade ) = > upgrade [ 4 ] === upgradeName ) ;
if ( upgrade === undefined ) throw new Error ( ` No upgrade named ' ${ upgradeName } ' ` ) ;
const upgN = upgrade [ 0 ] ;
return corporation . upgrades [ upgN ] ;
}
function getUpgradeLevelCost ( aupgradeName : string ) : number {
const upgradeName = helper . string ( "levelUpgrade" , "upgradeName" , aupgradeName ) ;
const corporation = getCorporation ( ) ;
const upgrade = Object . values ( CorporationUpgrades ) . find ( ( upgrade ) = > upgrade [ 4 ] === upgradeName ) ;
if ( upgrade === undefined ) throw new Error ( ` No upgrade named ' ${ upgradeName } ' ` ) ;
const upgN = upgrade [ 0 ] ;
const baseCost = upgrade [ 1 ] ;
const priceMult = upgrade [ 2 ] ;
const level = corporation . upgrades [ upgN ] ;
return baseCost * Math . pow ( priceMult , level ) ;
}
function getExpandIndustryCost ( industryName : string ) : number {
const cost = IndustryStartingCosts [ industryName ] ;
if ( cost === undefined ) {
throw new Error ( ` Invalid industry: ' ${ industryName } ' ` ) ;
}
return cost ;
}
function getExpandCityCost ( ) : number {
return CorporationConstants . OfficeInitialCost ;
}
2022-01-13 12:42:23 +01:00
function getInvestmentOffer ( ) : InvestmentOffer {
const corporation = getCorporation ( ) ;
2022-01-17 11:03:29 +01:00
if ( corporation . fundingRound >= CorporationConstants . FundingRoundShares . length || corporation . fundingRound >= CorporationConstants . FundingRoundMultiplier . length || corporation . public )
2022-01-13 12:42:23 +01:00
return {
funds : 0 ,
shares : 0 ,
2022-01-17 11:03:29 +01:00
round : corporation.fundingRound + 1 // Make more readable
2022-01-13 12:42:23 +01:00
} ; // Don't throw an error here, no reason to have a second function to check if you can get investment.
const val = corporation . determineValuation ( ) ;
const percShares = CorporationConstants . FundingRoundShares [ corporation . fundingRound ] ;
const roundMultiplier = CorporationConstants . FundingRoundMultiplier [ corporation . fundingRound ] ;
const funding = val * percShares * roundMultiplier ;
const investShares = Math . floor ( CorporationConstants . INITIALSHARES * percShares ) ;
return {
funds : funding ,
shares : investShares ,
2022-01-17 11:03:29 +01:00
round : corporation.fundingRound + 1 // Make more readable
2022-01-13 12:42:23 +01:00
} ;
}
function acceptInvestmentOffer ( ) : boolean {
const corporation = getCorporation ( ) ;
2022-01-13 18:47:11 +01:00
if ( corporation . fundingRound >= CorporationConstants . FundingRoundShares . length || corporation . fundingRound >= CorporationConstants . FundingRoundMultiplier . length || corporation . public ) return false ;
2022-01-13 12:42:23 +01:00
const val = corporation . determineValuation ( ) ;
const percShares = CorporationConstants . FundingRoundShares [ corporation . fundingRound ] ;
const roundMultiplier = CorporationConstants . FundingRoundMultiplier [ corporation . fundingRound ] ;
const funding = val * percShares * roundMultiplier ;
const investShares = Math . floor ( CorporationConstants . INITIALSHARES * percShares ) ;
corporation . fundingRound ++ ;
corporation . addFunds ( funding ) ;
corporation . numShares -= investShares ;
return true ;
}
2022-01-13 18:47:11 +01:00
function goPublic ( numShares : number ) : boolean {
const corporation = getCorporation ( ) ;
const initialSharePrice = corporation . determineValuation ( ) / corporation . totalShares ;
if ( isNaN ( numShares ) ) throw new Error ( "Invalid value for number of issued shares" ) ;
if ( numShares < 0 ) throw new Error ( "Invalid value for number of issued shares" ) ;
if ( numShares > corporation . numShares ) throw new Error ( "You don't have that many shares to issue!" ) ;
corporation . public = true ;
corporation . sharePrice = initialSharePrice ;
corporation . issuedShares = numShares ;
corporation . numShares -= numShares ;
corporation . addFunds ( numShares * initialSharePrice ) ;
return true ;
}
2022-01-17 11:03:29 +01:00
2022-01-13 18:47:11 +01:00
function getResearchCost ( division : IIndustry , researchName : string ) : number {
const researchTree = IndustryResearchTrees [ division . type ] ;
if ( researchTree === undefined ) throw new Error ( ` No research tree for industry ' ${ division . type } ' ` ) ;
const allResearch = researchTree . getAllNodes ( ) ;
if ( ! allResearch . includes ( researchName ) ) throw new Error ( ` No research named ' ${ researchName } ' ` ) ;
const research = ResearchMap [ researchName ] ;
return research . cost ;
}
function hasResearched ( division : IIndustry , researchName : string ) : boolean {
return division . researched [ researchName ] === undefined ? false : division . researched [ researchName ] as boolean ;
}
2022-01-13 22:05:06 +01:00
function bribe ( factionName : string , amountCash : number , amountShares : number ) : boolean {
if ( ! player . factions . includes ( factionName ) ) throw new Error ( "Invalid faction name" ) ;
2022-01-17 11:03:29 +01:00
if ( isNaN ( amountCash ) || amountCash < 0 || isNaN ( amountShares ) || amountShares < 0 ) throw new Error ( "Invalid value for amount field! Must be numeric, grater than 0." ) ;
2022-03-07 23:43:29 +01:00
2022-01-13 22:05:06 +01:00
const corporation = getCorporation ( ) ;
if ( corporation . funds < amountCash ) return false ;
if ( corporation . numShares < amountShares ) return false ;
const faction = Factions [ factionName ]
const info = faction . getInfo ( ) ;
if ( ! info . offersWork ( ) ) return false ;
if ( player . hasGangWith ( factionName ) ) return false ;
const repGain = ( amountCash + amountShares * corporation . sharePrice ) / CorporationConstants . BribeToRepRatio ;
faction . playerReputation += repGain ;
corporation . funds = corporation . funds - amountCash ;
corporation . numShares -= amountShares ;
return true ;
}
2021-12-04 05:06:04 +01:00
function getCorporation ( ) : ICorporation {
2021-10-14 09:22:02 +02:00
const corporation = player . corporation ;
if ( corporation === null ) throw new Error ( "cannot be called without a corporation" ) ;
2021-12-04 05:06:04 +01:00
return corporation ;
}
function getDivision ( divisionName : any ) : IIndustry {
const corporation = getCorporation ( ) ;
2021-10-14 09:22:02 +02:00
const division = corporation . divisions . find ( ( div ) = > div . name === divisionName ) ;
if ( division === undefined ) throw new Error ( ` No division named ' ${ divisionName } ' ` ) ;
return division ;
}
function getOffice ( divisionName : any , cityName : any ) : OfficeSpace {
const division = getDivision ( divisionName ) ;
if ( ! ( cityName in division . offices ) ) throw new Error ( ` Invalid city name ' ${ cityName } ' ` ) ;
const office = division . offices [ cityName ] ;
if ( office === 0 ) throw new Error ( ` ${ division . name } has not expanded to ' ${ cityName } ' ` ) ;
return office ;
}
function getWarehouse ( divisionName : any , cityName : any ) : Warehouse {
const division = getDivision ( divisionName ) ;
if ( ! ( cityName in division . warehouses ) ) throw new Error ( ` Invalid city name ' ${ cityName } ' ` ) ;
const warehouse = division . warehouses [ cityName ] ;
if ( warehouse === 0 ) throw new Error ( ` ${ division . name } has not expanded to ' ${ cityName } ' ` ) ;
return warehouse ;
}
function getMaterial ( divisionName : any , cityName : any , materialName : any ) : Material {
const warehouse = getWarehouse ( divisionName , cityName ) ;
2022-01-12 00:47:04 +01:00
const matName = ( materialName as string ) . replace ( / /g , "" ) ;
const material = warehouse . materials [ matName ] ;
2021-10-14 09:22:02 +02:00
if ( material === undefined ) throw new Error ( ` Invalid material name: ' ${ materialName } ' ` ) ;
return material ;
}
function getProduct ( divisionName : any , productName : any ) : Product {
const division = getDivision ( divisionName ) ;
const product = division . products [ productName ] ;
if ( product === undefined ) throw new Error ( ` Invalid product name: ' ${ productName } ' ` ) ;
return product ;
}
function getEmployee ( divisionName : any , cityName : any , employeeName : any ) : Employee {
const office = getOffice ( divisionName , cityName ) ;
const employee = office . employees . find ( ( e ) = > e . name === employeeName ) ;
if ( employee === undefined ) throw new Error ( ` Invalid employee name: ' ${ employeeName } ' ` ) ;
return employee ;
}
2021-12-04 05:06:04 +01:00
function checkAccess ( func : string , api? : number ) : void {
if ( player . corporation === null ) throw helper . makeRuntimeErrorMsg ( ` corporation. ${ func } ` , "Must own a corporation." ) ;
if ( ! api ) return ;
if ( ! player . corporation . unlockUpgrades [ api ] )
throw helper . makeRuntimeErrorMsg ( ` corporation. ${ func } ` , "You do not have access to this API." ) ;
}
2022-01-11 21:25:23 +01:00
function getSafeDivision ( division : Industry ) : NSDivision {
const cities : string [ ] = [ ] ;
2022-01-17 11:03:29 +01:00
for ( const office of Object . values ( division . offices ) ) {
if ( office === 0 ) continue ;
cities . push ( office . loc ) ;
}
return {
name : division.name ,
type : division . type ,
awareness : division.awareness ,
popularity : division.popularity ,
prodMult : division.prodMult ,
research : division.sciResearch.qty ,
lastCycleRevenue : division.lastCycleRevenue ,
lastCycleExpenses : division.lastCycleExpenses ,
thisCycleRevenue : division.thisCycleRevenue ,
thisCycleExpenses : division.thisCycleExpenses ,
upgrades : division.upgrades ,
cities : cities ,
products : division.products === undefined ? [ ] : Object . keys ( division . products ) ,
} ;
2022-01-11 21:25:23 +01:00
}
2021-12-04 05:06:04 +01:00
const warehouseAPI : WarehouseAPI = {
2022-01-12 00:47:04 +01:00
getPurchaseWarehouseCost : function ( ) : number {
checkAccess ( "getPurchaseWarehouseCost" , 7 ) ;
return CorporationConstants . WarehouseInitialCost ;
} ,
getUpgradeWarehouseCost : function ( adivisionName : any , acityName : any ) : number {
checkAccess ( "upgradeWarehouse" , 7 ) ;
const divisionName = helper . string ( "getUpgradeWarehouseCost" , "divisionName" , adivisionName ) ;
const cityName = helper . string ( "getUpgradeWarehouseCost" , "cityName" , acityName ) ;
const warehouse = getWarehouse ( divisionName , cityName ) ;
return CorporationConstants . WarehouseUpgradeBaseCost * Math . pow ( 1.07 , warehouse . level + 1 ) ;
} ,
hasWarehouse : function ( adivisionName : any , acityName : any ) : boolean {
checkAccess ( "hasWarehouse" , 7 ) ;
const divisionName = helper . string ( "getWarehouse" , "divisionName" , adivisionName ) ;
const cityName = helper . string ( "getWarehouse" , "cityName" , acityName ) ;
const division = getDivision ( divisionName ) ;
if ( ! ( cityName in division . warehouses ) ) throw new Error ( ` Invalid city name ' ${ cityName } ' ` ) ;
const warehouse = division . warehouses [ cityName ] ;
return warehouse !== 0 ;
} ,
2021-12-04 05:06:04 +01:00
getWarehouse : function ( adivisionName : any , acityName : any ) : NSWarehouse {
checkAccess ( "getWarehouse" , 7 ) ;
const divisionName = helper . string ( "getWarehouse" , "divisionName" , adivisionName ) ;
const cityName = helper . string ( "getWarehouse" , "cityName" , acityName ) ;
const warehouse = getWarehouse ( divisionName , cityName ) ;
return {
level : warehouse.level ,
loc : warehouse.loc ,
size : warehouse.size ,
sizeUsed : warehouse.sizeUsed ,
2022-01-12 00:47:04 +01:00
smartSupplyEnabled : warehouse.smartSupplyEnabled
2021-12-04 05:06:04 +01:00
} ;
} ,
getMaterial : function ( adivisionName : any , acityName : any , amaterialName : any ) : NSMaterial {
checkAccess ( "getMaterial" , 7 ) ;
const divisionName = helper . string ( "getMaterial" , "divisionName" , adivisionName ) ;
const cityName = helper . string ( "getMaterial" , "cityName" , acityName ) ;
const materialName = helper . string ( "getMaterial" , "materialName" , amaterialName ) ;
const material = getMaterial ( divisionName , cityName , materialName ) ;
return {
name : material.name ,
qty : material.qty ,
qlt : material.qlt ,
2022-01-13 18:47:11 +01:00
prod : material.prd ,
sell : material.sll ,
2021-12-04 05:06:04 +01:00
} ;
} ,
getProduct : function ( adivisionName : any , aproductName : any ) : NSProduct {
checkAccess ( "getProduct" , 7 ) ;
const divisionName = helper . string ( "getProduct" , "divisionName" , adivisionName ) ;
const productName = helper . string ( "getProduct" , "productName" , aproductName ) ;
const product = getProduct ( divisionName , productName ) ;
return {
name : product.name ,
dmd : product.dmd ,
cmp : product.cmp ,
pCost : product.pCost ,
sCost : product.sCost ,
2022-01-13 18:47:11 +01:00
cityData : product.data ,
developmentProgress : product.prog ,
2021-12-04 05:06:04 +01:00
} ;
} ,
purchaseWarehouse : function ( adivisionName : any , acityName : any ) : void {
checkAccess ( "purchaseWarehouse" , 7 ) ;
const divisionName = helper . string ( "purchaseWarehouse" , "divisionName" , adivisionName ) ;
const cityName = helper . string ( "purchaseWarehouse" , "cityName" , acityName ) ;
const corporation = getCorporation ( ) ;
PurchaseWarehouse ( corporation , getDivision ( divisionName ) , cityName ) ;
2021-10-14 09:22:02 +02:00
} ,
2021-12-04 05:06:04 +01:00
upgradeWarehouse : function ( adivisionName : any , acityName : any ) : void {
checkAccess ( "upgradeWarehouse" , 7 ) ;
const divisionName = helper . string ( "upgradeWarehouse" , "divisionName" , adivisionName ) ;
const cityName = helper . string ( "upgradeWarehouse" , "cityName" , acityName ) ;
const corporation = getCorporation ( ) ;
UpgradeWarehouse ( corporation , getDivision ( divisionName ) , getWarehouse ( divisionName , cityName ) ) ;
2021-10-14 09:22:02 +02:00
} ,
2021-12-04 05:06:04 +01:00
sellMaterial : function ( adivisionName : any , acityName : any , amaterialName : any , aamt : any , aprice : any ) : void {
checkAccess ( "sellMaterial" , 7 ) ;
const divisionName = helper . string ( "sellMaterial" , "divisionName" , adivisionName ) ;
const cityName = helper . string ( "sellMaterial" , "cityName" , acityName ) ;
const materialName = helper . string ( "sellMaterial" , "materialName" , amaterialName ) ;
const amt = helper . string ( "sellMaterial" , "amt" , aamt ) ;
const price = helper . string ( "sellMaterial" , "price" , aprice ) ;
2021-10-14 09:22:02 +02:00
const material = getMaterial ( divisionName , cityName , materialName ) ;
SellMaterial ( material , amt , price ) ;
} ,
2021-12-04 05:06:04 +01:00
sellProduct : function (
adivisionName : any ,
acityName : any ,
aproductName : any ,
aamt : any ,
aprice : any ,
aall : any ,
) : void {
checkAccess ( "sellProduct" , 7 ) ;
const divisionName = helper . string ( "sellProduct" , "divisionName" , adivisionName ) ;
const cityName = helper . string ( "sellProduct" , "cityName" , acityName ) ;
const productName = helper . string ( "sellProduct" , "productName" , aproductName ) ;
const amt = helper . string ( "sellProduct" , "amt" , aamt ) ;
const price = helper . string ( "sellProduct" , "price" , aprice ) ;
const all = helper . boolean ( aall ) ;
2021-10-14 09:22:02 +02:00
const product = getProduct ( divisionName , productName ) ;
SellProduct ( product , cityName , amt , price , all ) ;
} ,
2021-12-04 05:06:04 +01:00
discontinueProduct : function ( adivisionName : any , aproductName : any ) : void {
checkAccess ( "discontinueProduct" , 7 ) ;
const divisionName = helper . string ( "discontinueProduct" , "divisionName" , adivisionName ) ;
const productName = helper . string ( "discontinueProduct" , "productName" , aproductName ) ;
2021-10-14 09:22:02 +02:00
getDivision ( divisionName ) . discontinueProduct ( getProduct ( divisionName , productName ) ) ;
} ,
2021-12-04 05:06:04 +01:00
setSmartSupply : function ( adivisionName : any , acityName : any , aenabled : any ) : void {
checkAccess ( "setSmartSupply" , 7 ) ;
const divisionName = helper . string ( "setSmartSupply" , "divisionName" , adivisionName ) ;
const cityName = helper . string ( "sellProduct" , "cityName" , acityName ) ;
const enabled = helper . boolean ( aenabled ) ;
2021-10-14 09:22:02 +02:00
const warehouse = getWarehouse ( divisionName , cityName ) ;
2022-03-09 01:05:00 +01:00
if ( ! hasUnlockUpgrade ( "Smart Supply" ) )
throw helper . makeRuntimeErrorMsg ( ` corporation.setSmartSupply ` , ` You have not purchased the Smart Supply upgrade! ` ) ;
2021-10-14 09:22:02 +02:00
SetSmartSupply ( warehouse , enabled ) ;
} ,
2022-01-25 19:51:07 +01:00
setSmartSupplyUseLeftovers : function ( adivisionName : any , acityName : any , amaterialName : any , aenabled : any ) : void {
checkAccess ( "setSmartSupplyUseLeftovers" , 7 ) ;
const divisionName = helper . string ( "setSmartSupply" , "divisionName" , adivisionName ) ;
const cityName = helper . string ( "sellProduct" , "cityName" , acityName ) ;
const materialName = helper . string ( "sellProduct" , "materialName" , amaterialName ) ;
const enabled = helper . boolean ( aenabled ) ;
const warehouse = getWarehouse ( divisionName , cityName ) ;
const material = getMaterial ( divisionName , cityName , materialName ) ;
2022-03-09 01:05:00 +01:00
if ( ! hasUnlockUpgrade ( "Smart Supply" ) )
throw helper . makeRuntimeErrorMsg ( ` corporation.setSmartSupply ` , ` You have not purchased the Smart Supply upgrade! ` ) ;
2022-01-25 19:51:07 +01:00
SetSmartSupplyUseLeftovers ( warehouse , material , enabled ) ;
} ,
2021-12-04 05:06:04 +01:00
buyMaterial : function ( adivisionName : any , acityName : any , amaterialName : any , aamt : any ) : void {
checkAccess ( "buyMaterial" , 7 ) ;
const divisionName = helper . string ( "buyMaterial" , "divisionName" , adivisionName ) ;
const cityName = helper . string ( "buyMaterial" , "cityName" , acityName ) ;
const materialName = helper . string ( "buyMaterial" , "materialName" , amaterialName ) ;
const amt = helper . number ( "buyMaterial" , "amt" , aamt ) ;
2022-02-01 12:43:14 +01:00
if ( amt < 0 ) throw new Error ( "Invalid value for amount field! Must be numeric and greater than 0" ) ;
2021-10-14 09:22:02 +02:00
const material = getMaterial ( divisionName , cityName , materialName ) ;
BuyMaterial ( material , amt ) ;
} ,
2022-01-17 11:03:29 +01:00
bulkPurchase : function ( adivisionName : any , acityName : any , amaterialName : any , aamt : any ) : void {
checkAccess ( "bulkPurchase" , 7 ) ;
const divisionName = helper . string ( "bulkPurchase" , "divisionName" , adivisionName ) ;
2022-02-19 09:06:52 +01:00
if ( ! hasResearched ( getDivision ( adivisionName ) , "Bulk Purchasing" ) ) throw new Error ( ` You have not researched Bulk Purchasing in ${ divisionName } ` )
2022-01-17 13:00:19 +01:00
const corporation = getCorporation ( ) ;
2022-01-17 11:03:29 +01:00
const cityName = helper . string ( "bulkPurchase" , "cityName" , acityName ) ;
const materialName = helper . string ( "bulkPurchase" , "materialName" , amaterialName ) ;
const amt = helper . number ( "bulkPurchase" , "amt" , aamt ) ;
const warehouse = getWarehouse ( divisionName , cityName )
const material = getMaterial ( divisionName , cityName , materialName ) ;
BulkPurchase ( corporation , warehouse , material , amt ) ;
} ,
2021-12-04 05:06:04 +01:00
makeProduct : function (
adivisionName : any ,
acityName : any ,
aproductName : any ,
adesignInvest : any ,
amarketingInvest : any ,
) : void {
checkAccess ( "makeProduct" , 7 ) ;
const divisionName = helper . string ( "makeProduct" , "divisionName" , adivisionName ) ;
const cityName = helper . string ( "makeProduct" , "cityName" , acityName ) ;
const productName = helper . string ( "makeProduct" , "productName" , aproductName ) ;
const designInvest = helper . number ( "makeProduct" , "designInvest" , adesignInvest ) ;
const marketingInvest = helper . number ( "makeProduct" , "marketingInvest" , amarketingInvest ) ;
const corporation = getCorporation ( ) ;
MakeProduct ( corporation , getDivision ( divisionName ) , cityName , productName , designInvest , marketingInvest ) ;
} ,
exportMaterial : function (
asourceDivision : any ,
asourceCity : any ,
atargetDivision : any ,
atargetCity : any ,
amaterialName : any ,
aamt : any ,
) : void {
checkAccess ( "exportMaterial" , 7 ) ;
const sourceDivision = helper . string ( "exportMaterial" , "sourceDivision" , asourceDivision ) ;
const sourceCity = helper . string ( "exportMaterial" , "sourceCity" , asourceCity ) ;
const targetDivision = helper . string ( "exportMaterial" , "targetDivision" , atargetDivision ) ;
const targetCity = helper . string ( "exportMaterial" , "targetCity" , atargetCity ) ;
const materialName = helper . string ( "exportMaterial" , "materialName" , amaterialName ) ;
const amt = helper . string ( "exportMaterial" , "amt" , aamt ) ;
2022-02-12 04:31:50 +01:00
ExportMaterial ( targetDivision , targetCity , getMaterial ( sourceDivision , sourceCity , materialName ) , amt + "" , getDivision ( targetDivision ) ) ;
2021-12-04 05:06:04 +01:00
} ,
cancelExportMaterial : function (
asourceDivision : any ,
asourceCity : any ,
atargetDivision : any ,
atargetCity : any ,
amaterialName : any ,
aamt : any ,
) : void {
checkAccess ( "cancelExportMaterial" , 7 ) ;
const sourceDivision = helper . string ( "cancelExportMaterial" , "sourceDivision" , asourceDivision ) ;
const sourceCity = helper . string ( "cancelExportMaterial" , "sourceCity" , asourceCity ) ;
const targetDivision = helper . string ( "cancelExportMaterial" , "targetDivision" , atargetDivision ) ;
const targetCity = helper . string ( "cancelExportMaterial" , "targetCity" , atargetCity ) ;
const materialName = helper . string ( "cancelExportMaterial" , "materialName" , amaterialName ) ;
const amt = helper . string ( "cancelExportMaterial" , "amt" , aamt ) ;
CancelExportMaterial ( targetDivision , targetCity , getMaterial ( sourceDivision , sourceCity , materialName ) , amt + "" ) ;
} ,
setMaterialMarketTA1 : function ( adivisionName : any , acityName : any , amaterialName : any , aon : any ) : void {
checkAccess ( "setMaterialMarketTA1" , 7 ) ;
const divisionName = helper . string ( "setMaterialMarketTA1" , "divisionName" , adivisionName ) ;
const cityName = helper . string ( "setMaterialMarketTA1" , "cityName" , acityName ) ;
const materialName = helper . string ( "setMaterialMarketTA1" , "materialName" , amaterialName ) ;
const on = helper . boolean ( aon ) ;
2022-02-11 16:48:19 +01:00
if ( ! getDivision ( divisionName ) . hasResearch ( "Market-TA.I" ) )
throw helper . makeRuntimeErrorMsg ( ` corporation.setMaterialMarketTA1 ` , ` You have not researched MarketTA.I for division: ${ divisionName } ` ) ;
2021-12-04 05:06:04 +01:00
SetMaterialMarketTA1 ( getMaterial ( divisionName , cityName , materialName ) , on ) ;
} ,
setMaterialMarketTA2 : function ( adivisionName : any , acityName : any , amaterialName : any , aon : any ) : void {
checkAccess ( "setMaterialMarketTA2" , 7 ) ;
const divisionName = helper . string ( "setMaterialMarketTA2" , "divisionName" , adivisionName ) ;
const cityName = helper . string ( "setMaterialMarketTA2" , "cityName" , acityName ) ;
const materialName = helper . string ( "setMaterialMarketTA2" , "materialName" , amaterialName ) ;
const on = helper . boolean ( aon ) ;
2022-02-11 16:48:19 +01:00
if ( ! getDivision ( divisionName ) . hasResearch ( "Market-TA.II" ) )
throw helper . makeRuntimeErrorMsg ( ` corporation.setMaterialMarketTA2 ` , ` You have not researched MarketTA.II for division: ${ divisionName } ` ) ;
2021-12-04 05:06:04 +01:00
SetMaterialMarketTA2 ( getMaterial ( divisionName , cityName , materialName ) , on ) ;
} ,
setProductMarketTA1 : function ( adivisionName : any , aproductName : any , aon : any ) : void {
checkAccess ( "setProductMarketTA1" , 7 ) ;
const divisionName = helper . string ( "setProductMarketTA1" , "divisionName" , adivisionName ) ;
const productName = helper . string ( "setProductMarketTA1" , "productName" , aproductName ) ;
const on = helper . boolean ( aon ) ;
2022-02-11 16:48:19 +01:00
if ( ! getDivision ( divisionName ) . hasResearch ( "Market-TA.I" ) )
throw helper . makeRuntimeErrorMsg ( ` corporation.setProductMarketTA1 ` , ` You have not researched MarketTA.I for division: ${ divisionName } ` ) ;
2021-12-04 05:06:04 +01:00
SetProductMarketTA1 ( getProduct ( divisionName , productName ) , on ) ;
} ,
setProductMarketTA2 : function ( adivisionName : any , aproductName : any , aon : any ) : void {
checkAccess ( "setProductMarketTA2" , 7 ) ;
const divisionName = helper . string ( "setProductMarketTA2" , "divisionName" , adivisionName ) ;
const productName = helper . string ( "setProductMarketTA2" , "productName" , aproductName ) ;
const on = helper . boolean ( aon ) ;
2022-02-11 16:48:19 +01:00
if ( ! getDivision ( divisionName ) . hasResearch ( "Market-TA.II" ) )
2022-02-12 04:31:50 +01:00
throw helper . makeRuntimeErrorMsg ( ` corporation.setProductMarketTA2 ` , ` You have not researched MarketTA.II for division: ${ divisionName } ` ) ;
2021-12-04 05:06:04 +01:00
SetProductMarketTA2 ( getProduct ( divisionName , productName ) , on ) ;
} ,
} ;
const officeAPI : OfficeAPI = {
2022-01-13 18:47:11 +01:00
getHireAdVertCost : function ( adivisionName : any ) : number {
checkAccess ( "getHireAdVertCost" , 8 ) ;
const divisionName = helper . string ( "getHireAdVertCost" , "divisionName" , adivisionName ) ;
2022-01-12 00:47:04 +01:00
const division = getDivision ( divisionName ) ;
const upgrade = IndustryUpgrades [ 1 ] ;
return upgrade [ 1 ] * Math . pow ( upgrade [ 2 ] , division . upgrades [ 1 ] ) ;
} ,
2022-01-13 18:47:11 +01:00
getHireAdVertCount : function ( adivisionName : any ) : number {
checkAccess ( "getHireAdVertCount" , 8 ) ;
const divisionName = helper . string ( "getHireAdVertCount" , "divisionName" , adivisionName ) ;
2022-01-12 00:47:04 +01:00
const division = getDivision ( divisionName ) ;
return division . upgrades [ 1 ]
} ,
2022-01-13 18:47:11 +01:00
getResearchCost : function ( adivisionName : any , aresearchName : any ) : number {
checkAccess ( "getResearchCost" , 8 ) ;
const divisionName = helper . string ( "getResearchCost" , "divisionName" , adivisionName ) ;
const researchName = helper . string ( "getResearchCost" , "researchName" , aresearchName ) ;
return getResearchCost ( getDivision ( divisionName ) , researchName ) ;
} ,
hasResearched : function ( adivisionName : any , aresearchName : any ) : boolean {
checkAccess ( "hasResearched" , 8 ) ;
const divisionName = helper . string ( "hasResearched" , "divisionName" , adivisionName ) ;
const researchName = helper . string ( "hasResearched" , "researchName" , aresearchName ) ;
return hasResearched ( getDivision ( divisionName ) , researchName ) ;
} ,
2022-01-13 19:47:54 +01:00
setAutoJobAssignment : function ( adivisionName : any , acityName : any , ajob : any , aamount : any ) : Promise < boolean > {
checkAccess ( "setAutoJobAssignment" , 8 ) ;
const divisionName = helper . string ( "setAutoJobAssignment" , "divisionName" , adivisionName ) ;
const cityName = helper . string ( "setAutoJobAssignment" , "cityName" , acityName ) ;
const amount = helper . number ( "setAutoJobAssignment" , "amount" , aamount ) ;
const job = helper . string ( "setAutoJobAssignment" , "job" , ajob ) ;
const office = getOffice ( divisionName , cityName ) ;
if ( ! Object . values ( EmployeePositions ) . includes ( job ) ) throw new Error ( ` ' ${ job } ' is not a valid job. ` ) ;
return netscriptDelay ( 1000 , workerScript ) . then ( function ( ) {
if ( workerScript . env . stopFlag ) {
return Promise . reject ( workerScript ) ;
}
return Promise . resolve ( office . setEmployeeToJob ( job , amount ) ) ;
} ) ;
} ,
2022-01-15 15:24:01 +01:00
getOfficeSizeUpgradeCost : function ( adivisionName : any , acityName : any , asize : any ) : number {
checkAccess ( "getOfficeSizeUpgradeCost" , 8 ) ;
const divisionName = helper . string ( "getOfficeSizeUpgradeCost" , "divisionName" , adivisionName ) ;
const cityName = helper . string ( "getOfficeSizeUpgradeCost" , "cityName" , acityName ) ;
const size = helper . number ( "getOfficeSizeUpgradeCost" , "size" , asize ) ;
2022-02-01 12:43:14 +01:00
if ( size < 0 ) throw new Error ( "Invalid value for size field! Must be numeric and greater than 0" ) ;
2022-01-15 15:24:01 +01:00
const office = getOffice ( divisionName , cityName ) ;
const initialPriceMult = Math . round ( office . size / CorporationConstants . OfficeInitialSize ) ;
const costMultiplier = 1.09 ;
let mult = 0 ;
for ( let i = 0 ; i < size / CorporationConstants . OfficeInitialSize ; ++ i ) {
mult += Math . pow ( costMultiplier , initialPriceMult + i ) ;
}
return CorporationConstants . OfficeInitialCost * mult ;
} ,
2021-12-04 05:06:04 +01:00
assignJob : function ( adivisionName : any , acityName : any , aemployeeName : any , ajob : any ) : Promise < void > {
checkAccess ( "assignJob" , 8 ) ;
const divisionName = helper . string ( "assignJob" , "divisionName" , adivisionName ) ;
const cityName = helper . string ( "assignJob" , "cityName" , acityName ) ;
const employeeName = helper . string ( "assignJob" , "employeeName" , aemployeeName ) ;
const job = helper . string ( "assignJob" , "job" , ajob ) ;
2021-10-14 09:22:02 +02:00
const employee = getEmployee ( divisionName , cityName , employeeName ) ;
2021-12-04 05:06:04 +01:00
return netscriptDelay ( 1000 , workerScript ) . then ( function ( ) {
return Promise . resolve ( AssignJob ( employee , job ) ) ;
} ) ;
} ,
hireEmployee : function ( adivisionName : any , acityName : any ) : any {
checkAccess ( "hireEmployee" , 8 ) ;
const divisionName = helper . string ( "hireEmployee" , "divisionName" , adivisionName ) ;
const cityName = helper . string ( "hireEmployee" , "cityName" , acityName ) ;
2021-10-14 09:22:02 +02:00
const office = getOffice ( divisionName , cityName ) ;
2021-12-09 02:03:22 +01:00
return office . hireRandomEmployee ( ) ;
2021-10-14 09:22:02 +02:00
} ,
2021-12-04 05:06:04 +01:00
upgradeOfficeSize : function ( adivisionName : any , acityName : any , asize : any ) : void {
checkAccess ( "upgradeOfficeSize" , 8 ) ;
const divisionName = helper . string ( "upgradeOfficeSize" , "divisionName" , adivisionName ) ;
const cityName = helper . string ( "upgradeOfficeSize" , "cityName" , acityName ) ;
const size = helper . number ( "upgradeOfficeSize" , "size" , asize ) ;
2022-02-01 12:43:14 +01:00
if ( size < 0 ) throw new Error ( "Invalid value for size field! Must be numeric and greater than 0" ) ;
2021-10-14 09:22:02 +02:00
const office = getOffice ( divisionName , cityName ) ;
2021-12-04 05:06:04 +01:00
const corporation = getCorporation ( ) ;
2021-10-14 09:22:02 +02:00
UpgradeOfficeSize ( corporation , office , size ) ;
} ,
2021-12-04 05:06:04 +01:00
throwParty : function ( adivisionName : any , acityName : any , acostPerEmployee : any ) : Promise < number > {
checkAccess ( "throwParty" , 8 ) ;
const divisionName = helper . string ( "throwParty" , "divisionName" , adivisionName ) ;
const cityName = helper . string ( "throwParty" , "cityName" , acityName ) ;
const costPerEmployee = helper . number ( "throwParty" , "costPerEmployee" , acostPerEmployee ) ;
2022-02-01 12:43:14 +01:00
if ( costPerEmployee < 0 ) throw new Error ( "Invalid value for Cost Per Employee field! Must be numeric and greater than 0" ) ;
2021-10-14 09:22:02 +02:00
const office = getOffice ( divisionName , cityName ) ;
2021-12-04 05:06:04 +01:00
const corporation = getCorporation ( ) ;
return netscriptDelay (
( 60 * 1000 ) / ( player . hacking_speed_mult * calculateIntelligenceBonus ( player . intelligence , 1 ) ) ,
workerScript ,
) . then ( function ( ) {
return Promise . resolve ( ThrowParty ( corporation , office , costPerEmployee ) ) ;
} ) ;
} ,
buyCoffee : function ( adivisionName : any , acityName : any ) : Promise < void > {
checkAccess ( "buyCoffee" , 8 ) ;
const divisionName = helper . string ( "buyCoffee" , "divisionName" , adivisionName ) ;
const cityName = helper . string ( "buyCoffee" , "cityName" , acityName ) ;
const corporation = getCorporation ( ) ;
return netscriptDelay (
( 60 * 1000 ) / ( player . hacking_speed_mult * calculateIntelligenceBonus ( player . intelligence , 1 ) ) ,
workerScript ,
) . then ( function ( ) {
return Promise . resolve ( BuyCoffee ( corporation , getDivision ( divisionName ) , getOffice ( divisionName , cityName ) ) ) ;
} ) ;
} ,
hireAdVert : function ( adivisionName : any ) : void {
checkAccess ( "hireAdVert" , 8 ) ;
const divisionName = helper . string ( "hireAdVert" , "divisionName" , adivisionName ) ;
const corporation = getCorporation ( ) ;
2021-10-14 09:22:02 +02:00
HireAdVert ( corporation , getDivision ( divisionName ) , getOffice ( divisionName , "Sector-12" ) ) ;
} ,
2021-12-04 05:06:04 +01:00
research : function ( adivisionName : any , aresearchName : any ) : void {
checkAccess ( "research" , 8 ) ;
const divisionName = helper . string ( "research" , "divisionName" , adivisionName ) ;
const researchName = helper . string ( "research" , "researchName" , aresearchName ) ;
2021-10-14 09:22:02 +02:00
Research ( getDivision ( divisionName ) , researchName ) ;
} ,
2021-12-04 05:06:04 +01:00
getOffice : function ( adivisionName : any , acityName : any ) : any {
checkAccess ( "getOffice" , 8 ) ;
const divisionName = helper . string ( "getOffice" , "divisionName" , adivisionName ) ;
const cityName = helper . string ( "getOffice" , "cityName" , acityName ) ;
const office = getOffice ( divisionName , cityName ) ;
return {
loc : office.loc ,
size : office.size ,
minEne : office.minEne ,
maxEne : office.maxEne ,
minHap : office.minHap ,
maxHap : office.maxHap ,
maxMor : office.maxMor ,
employees : office.employees.map ( ( e ) = > e . name ) ,
employeeProd : {
Operations : office.employeeProd [ EmployeePositions . Operations ] ,
Engineer : office.employeeProd [ EmployeePositions . Engineer ] ,
Business : office.employeeProd [ EmployeePositions . Business ] ,
Management : office.employeeProd [ EmployeePositions . Management ] ,
"Research & Development" : office . employeeProd [ EmployeePositions . RandD ] ,
Training : office.employeeProd [ EmployeePositions . Training ] ,
} ,
} ;
} ,
getEmployee : function ( adivisionName : any , acityName : any , aemployeeName : any ) : NSEmployee {
checkAccess ( "getEmployee" , 8 ) ;
const divisionName = helper . string ( "getEmployee" , "divisionName" , adivisionName ) ;
const cityName = helper . string ( "getEmployee" , "cityName" , acityName ) ;
const employeeName = helper . string ( "getEmployee" , "employeeName" , aemployeeName ) ;
const employee = getEmployee ( divisionName , cityName , employeeName ) ;
return {
name : employee.name ,
mor : employee.mor ,
hap : employee.hap ,
ene : employee.ene ,
int : employee.int ,
cha : employee.cha ,
exp : employee.exp ,
cre : employee.cre ,
eff : employee.eff ,
sal : employee.sal ,
loc : employee.loc ,
pos : employee.pos ,
} ;
2021-10-14 09:22:02 +02:00
} ,
2021-12-04 05:06:04 +01:00
} ;
return {
. . . warehouseAPI ,
. . . officeAPI ,
expandIndustry : function ( aindustryName : any , adivisionName : any ) : void {
checkAccess ( "expandIndustry" ) ;
const industryName = helper . string ( "expandIndustry" , "industryName" , aindustryName ) ;
const divisionName = helper . string ( "expandIndustry" , "divisionName" , adivisionName ) ;
const corporation = getCorporation ( ) ;
NewIndustry ( corporation , industryName , divisionName ) ;
2021-10-14 09:22:02 +02:00
} ,
2021-12-04 05:06:04 +01:00
expandCity : function ( adivisionName : any , acityName : any ) : void {
checkAccess ( "expandCity" ) ;
const divisionName = helper . string ( "expandCity" , "divisionName" , adivisionName ) ;
const cityName = helper . string ( "expandCity" , "cityName" , acityName ) ;
2022-01-13 18:47:11 +01:00
if ( ! CorporationConstants . Cities . includes ( cityName ) ) throw new Error ( "Invalid city name" ) ;
2021-12-04 05:06:04 +01:00
const corporation = getCorporation ( ) ;
const division = getDivision ( divisionName ) ;
NewCity ( corporation , division , cityName ) ;
2021-10-14 09:22:02 +02:00
} ,
2021-12-04 05:06:04 +01:00
unlockUpgrade : function ( aupgradeName : any ) : void {
checkAccess ( "unlockUpgrade" ) ;
const upgradeName = helper . string ( "unlockUpgrade" , "upgradeName" , aupgradeName ) ;
const corporation = getCorporation ( ) ;
const upgrade = Object . values ( CorporationUnlockUpgrades ) . find ( ( upgrade ) = > upgrade [ 2 ] === upgradeName ) ;
if ( upgrade === undefined ) throw new Error ( ` No upgrade named ' ${ upgradeName } ' ` ) ;
UnlockUpgrade ( corporation , upgrade ) ;
2021-10-14 09:22:02 +02:00
} ,
2021-12-04 05:06:04 +01:00
levelUpgrade : function ( aupgradeName : any ) : void {
checkAccess ( "levelUpgrade" ) ;
const upgradeName = helper . string ( "levelUpgrade" , "upgradeName" , aupgradeName ) ;
const corporation = getCorporation ( ) ;
const upgrade = Object . values ( CorporationUpgrades ) . find ( ( upgrade ) = > upgrade [ 4 ] === upgradeName ) ;
if ( upgrade === undefined ) throw new Error ( ` No upgrade named ' ${ upgradeName } ' ` ) ;
LevelUpgrade ( corporation , upgrade ) ;
2021-10-14 09:22:02 +02:00
} ,
2021-12-04 05:06:04 +01:00
issueDividends : function ( apercent : any ) : void {
checkAccess ( "issueDividends" ) ;
const percent = helper . number ( "issueDividends" , "percent" , apercent ) ;
2022-02-01 12:43:14 +01:00
if ( percent < 0 || percent > 100 ) throw new Error ( "Invalid value for percent field! Must be numeric, greater than 0, and less than 100" ) ;
2021-12-04 05:06:04 +01:00
const corporation = getCorporation ( ) ;
2022-02-12 04:31:50 +01:00
if ( ! corporation . public )
throw helper . makeRuntimeErrorMsg ( ` corporation.issueDividends ` , ` Your company has not gone public! ` ) ;
2021-12-04 05:06:04 +01:00
IssueDividends ( corporation , percent ) ;
2021-10-14 09:22:02 +02:00
} ,
2021-12-04 05:06:04 +01:00
2021-10-14 09:22:02 +02:00
// If you modify these objects you will affect them for real, it's not
// copies.
2021-12-04 05:06:04 +01:00
getDivision : function ( adivisionName : any ) : NSDivision {
checkAccess ( "getDivision" ) ;
const divisionName = helper . string ( "getDivision" , "divisionName" , adivisionName ) ;
const division = getDivision ( divisionName ) ;
2022-01-11 21:25:23 +01:00
return getSafeDivision ( division ) ;
2021-12-04 05:06:04 +01:00
} ,
getCorporation : function ( ) : CorporationInfo {
checkAccess ( "getCorporation" ) ;
const corporation = getCorporation ( ) ;
return {
name : corporation.name ,
funds : corporation.funds ,
revenue : corporation.revenue ,
expenses : corporation.expenses ,
public : corporation . public ,
totalShares : corporation.totalShares ,
numShares : corporation.numShares ,
shareSaleCooldown : corporation.shareSaleCooldown ,
issuedShares : corporation.issuedShares ,
sharePrice : corporation.sharePrice ,
2021-12-24 17:32:51 +01:00
state : corporation.state.getState ( ) ,
2022-01-11 21:25:23 +01:00
divisions : corporation.divisions.map ( ( division ) : NSDivision = > getSafeDivision ( division ) ) ,
2021-12-04 05:06:04 +01:00
} ;
2021-10-14 09:22:02 +02:00
} ,
2022-01-13 18:47:11 +01:00
createCorporation : function ( acorporationName : string , selfFund = true ) : boolean {
const corporationName = helper . string ( "createCorporation" , "corporationName" , acorporationName ) ;
2022-01-12 00:47:04 +01:00
return createCorporation ( corporationName , selfFund ) ;
} ,
2022-01-13 18:47:11 +01:00
hasUnlockUpgrade : function ( aupgradeName : any ) : boolean {
2022-01-12 00:47:04 +01:00
checkAccess ( "hasUnlockUpgrade" ) ;
2022-01-13 18:47:11 +01:00
const upgradeName = helper . string ( "hasUnlockUpgrade" , "upgradeName" , aupgradeName ) ;
2022-01-12 00:47:04 +01:00
return hasUnlockUpgrade ( upgradeName ) ;
} ,
2022-01-13 18:47:11 +01:00
getUnlockUpgradeCost : function ( aupgradeName : any ) : number {
2022-01-12 00:47:04 +01:00
checkAccess ( "getUnlockUpgradeCost" ) ;
2022-01-13 18:47:11 +01:00
const upgradeName = helper . string ( "getUnlockUpgradeCost" , "upgradeName" , aupgradeName ) ;
2022-01-12 00:47:04 +01:00
return getUnlockUpgradeCost ( upgradeName ) ;
} ,
2022-01-13 18:47:11 +01:00
getUpgradeLevel : function ( aupgradeName : any ) : number {
2022-01-12 00:47:04 +01:00
checkAccess ( "hasUnlockUpgrade" ) ;
2022-01-13 18:47:11 +01:00
const upgradeName = helper . string ( "getUpgradeLevel" , "upgradeName" , aupgradeName ) ;
2022-01-12 00:47:04 +01:00
return getUpgradeLevel ( upgradeName ) ;
} ,
2022-01-13 18:47:11 +01:00
getUpgradeLevelCost : function ( aupgradeName : any ) : number {
2022-01-12 00:47:04 +01:00
checkAccess ( "getUpgradeLevelCost" ) ;
2022-01-13 18:47:11 +01:00
const upgradeName = helper . string ( "getUpgradeLevelCost" , "upgradeName" , aupgradeName ) ;
2022-01-12 00:47:04 +01:00
return getUpgradeLevelCost ( upgradeName ) ;
} ,
2022-01-13 18:47:11 +01:00
getExpandIndustryCost : function ( aindustryName : any ) : number {
2022-01-12 00:47:04 +01:00
checkAccess ( "getExpandIndustryCost" ) ;
2022-01-13 18:47:11 +01:00
const industryName = helper . string ( "getExpandIndustryCost" , "industryName" , aindustryName ) ;
2022-01-12 00:47:04 +01:00
return getExpandIndustryCost ( industryName ) ;
} ,
2022-01-17 11:03:29 +01:00
getExpandCityCost : function ( ) : number {
2022-01-12 00:47:04 +01:00
checkAccess ( "getExpandCityCost" ) ;
return getExpandCityCost ( ) ;
2022-01-13 12:42:23 +01:00
} ,
2022-01-17 11:03:29 +01:00
getInvestmentOffer : function ( ) : InvestmentOffer {
2022-01-13 12:42:23 +01:00
checkAccess ( "getInvestmentOffer" ) ;
return getInvestmentOffer ( ) ;
} ,
2022-01-17 11:03:29 +01:00
acceptInvestmentOffer : function ( ) : boolean {
2022-01-13 12:42:23 +01:00
checkAccess ( "acceptInvestmentOffer" ) ;
return acceptInvestmentOffer ( ) ;
} ,
2022-01-17 11:03:29 +01:00
goPublic : function ( anumShares : any ) : boolean {
2022-01-13 18:47:11 +01:00
checkAccess ( "acceptInvestmentOffer" ) ;
const numShares = helper . number ( "goPublic" , "numShares" , anumShares ) ;
return goPublic ( numShares ) ;
} ,
2022-01-17 11:03:29 +01:00
sellShares : function ( anumShares : any ) : number {
checkAccess ( "acceptInvestmentOffer" ) ;
const numShares = helper . number ( "sellStock" , "numShares" , anumShares ) ;
return SellShares ( getCorporation ( ) , player , numShares ) ;
} ,
buyBackShares : function ( anumShares : any ) : boolean {
checkAccess ( "acceptInvestmentOffer" ) ;
const numShares = helper . number ( "buyStock" , "numShares" , anumShares ) ;
return BuyBackShares ( getCorporation ( ) , player , numShares ) ;
} ,
bribe : function ( afactionName : string , aamountCash : any , aamountShares : any ) : boolean {
2022-01-13 22:05:06 +01:00
checkAccess ( "bribe" ) ;
const factionName = helper . string ( "bribe" , "factionName" , afactionName ) ;
const amountCash = helper . number ( "bribe" , "amountCash" , aamountCash ) ;
const amountShares = helper . number ( "bribe" , "amountShares" , aamountShares ) ;
return bribe ( factionName , amountCash , amountShares ) ;
} ,
2021-10-14 09:22:02 +02:00
} ;
}