mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-30 03:23:48 +01:00
unknown-ify corp API.
This commit is contained in:
parent
c1401bef27
commit
6c9a3a336e
@ -21,7 +21,7 @@ import {
|
|||||||
Division as NSDivision,
|
Division as NSDivision,
|
||||||
WarehouseAPI,
|
WarehouseAPI,
|
||||||
OfficeAPI,
|
OfficeAPI,
|
||||||
InvestmentOffer
|
InvestmentOffer,
|
||||||
} from "../ScriptEditor/NetscriptDefinitions";
|
} from "../ScriptEditor/NetscriptDefinitions";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@ -100,8 +100,8 @@ export function NetscriptCorporation(
|
|||||||
return upgrade[1];
|
return upgrade[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
function getUpgradeLevel(aupgradeName: string): number {
|
function getUpgradeLevel(_upgradeName: string): number {
|
||||||
const upgradeName = helper.string("levelUpgrade", "upgradeName", aupgradeName);
|
const upgradeName = helper.string("levelUpgrade", "upgradeName", _upgradeName);
|
||||||
const corporation = getCorporation();
|
const corporation = getCorporation();
|
||||||
const upgrade = Object.values(CorporationUpgrades).find((upgrade) => upgrade[4] === upgradeName);
|
const upgrade = Object.values(CorporationUpgrades).find((upgrade) => upgrade[4] === upgradeName);
|
||||||
if (upgrade === undefined) throw new Error(`No upgrade named '${upgradeName}'`);
|
if (upgrade === undefined) throw new Error(`No upgrade named '${upgradeName}'`);
|
||||||
@ -109,8 +109,8 @@ export function NetscriptCorporation(
|
|||||||
return corporation.upgrades[upgN];
|
return corporation.upgrades[upgN];
|
||||||
}
|
}
|
||||||
|
|
||||||
function getUpgradeLevelCost(aupgradeName: string): number {
|
function getUpgradeLevelCost(_upgradeName: string): number {
|
||||||
const upgradeName = helper.string("levelUpgrade", "upgradeName", aupgradeName);
|
const upgradeName = helper.string("levelUpgrade", "upgradeName", _upgradeName);
|
||||||
const corporation = getCorporation();
|
const corporation = getCorporation();
|
||||||
const upgrade = Object.values(CorporationUpgrades).find((upgrade) => upgrade[4] === upgradeName);
|
const upgrade = Object.values(CorporationUpgrades).find((upgrade) => upgrade[4] === upgradeName);
|
||||||
if (upgrade === undefined) throw new Error(`No upgrade named '${upgradeName}'`);
|
if (upgrade === undefined) throw new Error(`No upgrade named '${upgradeName}'`);
|
||||||
@ -135,11 +135,15 @@ export function NetscriptCorporation(
|
|||||||
|
|
||||||
function getInvestmentOffer(): InvestmentOffer {
|
function getInvestmentOffer(): InvestmentOffer {
|
||||||
const corporation = getCorporation();
|
const corporation = getCorporation();
|
||||||
if (corporation.fundingRound >= CorporationConstants.FundingRoundShares.length || corporation.fundingRound >= CorporationConstants.FundingRoundMultiplier.length || corporation.public)
|
if (
|
||||||
|
corporation.fundingRound >= CorporationConstants.FundingRoundShares.length ||
|
||||||
|
corporation.fundingRound >= CorporationConstants.FundingRoundMultiplier.length ||
|
||||||
|
corporation.public
|
||||||
|
)
|
||||||
return {
|
return {
|
||||||
funds: 0,
|
funds: 0,
|
||||||
shares: 0,
|
shares: 0,
|
||||||
round: corporation.fundingRound + 1 // Make more readable
|
round: corporation.fundingRound + 1, // Make more readable
|
||||||
}; // Don't throw an error here, no reason to have a second function to check if you can get investment.
|
}; // 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 val = corporation.determineValuation();
|
||||||
const percShares = CorporationConstants.FundingRoundShares[corporation.fundingRound];
|
const percShares = CorporationConstants.FundingRoundShares[corporation.fundingRound];
|
||||||
@ -149,13 +153,18 @@ export function NetscriptCorporation(
|
|||||||
return {
|
return {
|
||||||
funds: funding,
|
funds: funding,
|
||||||
shares: investShares,
|
shares: investShares,
|
||||||
round: corporation.fundingRound + 1 // Make more readable
|
round: corporation.fundingRound + 1, // Make more readable
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function acceptInvestmentOffer(): boolean {
|
function acceptInvestmentOffer(): boolean {
|
||||||
const corporation = getCorporation();
|
const corporation = getCorporation();
|
||||||
if (corporation.fundingRound >= CorporationConstants.FundingRoundShares.length || corporation.fundingRound >= CorporationConstants.FundingRoundMultiplier.length || corporation.public) return false;
|
if (
|
||||||
|
corporation.fundingRound >= CorporationConstants.FundingRoundShares.length ||
|
||||||
|
corporation.fundingRound >= CorporationConstants.FundingRoundMultiplier.length ||
|
||||||
|
corporation.public
|
||||||
|
)
|
||||||
|
return false;
|
||||||
const val = corporation.determineValuation();
|
const val = corporation.determineValuation();
|
||||||
const percShares = CorporationConstants.FundingRoundShares[corporation.fundingRound];
|
const percShares = CorporationConstants.FundingRoundShares[corporation.fundingRound];
|
||||||
const roundMultiplier = CorporationConstants.FundingRoundMultiplier[corporation.fundingRound];
|
const roundMultiplier = CorporationConstants.FundingRoundMultiplier[corporation.fundingRound];
|
||||||
@ -181,7 +190,6 @@ export function NetscriptCorporation(
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function getResearchCost(division: IIndustry, researchName: string): number {
|
function getResearchCost(division: IIndustry, researchName: string): number {
|
||||||
const researchTree = IndustryResearchTrees[division.type];
|
const researchTree = IndustryResearchTrees[division.type];
|
||||||
if (researchTree === undefined) throw new Error(`No research tree for industry '${division.type}'`);
|
if (researchTree === undefined) throw new Error(`No research tree for industry '${division.type}'`);
|
||||||
@ -192,17 +200,18 @@ export function NetscriptCorporation(
|
|||||||
}
|
}
|
||||||
|
|
||||||
function hasResearched(division: IIndustry, researchName: string): boolean {
|
function hasResearched(division: IIndustry, researchName: string): boolean {
|
||||||
return division.researched[researchName] === undefined ? false : division.researched[researchName] as boolean;
|
return division.researched[researchName] === undefined ? false : (division.researched[researchName] as boolean);
|
||||||
}
|
}
|
||||||
|
|
||||||
function bribe(factionName: string, amountCash: number, amountShares: number): boolean {
|
function bribe(factionName: string, amountCash: number, amountShares: number): boolean {
|
||||||
if (!player.factions.includes(factionName)) throw new Error("Invalid faction name");
|
if (!player.factions.includes(factionName)) throw new Error("Invalid faction name");
|
||||||
if (isNaN(amountCash) || amountCash < 0 || isNaN(amountShares) || amountShares < 0) throw new Error("Invalid value for amount field! Must be numeric, grater than 0.");
|
if (isNaN(amountCash) || amountCash < 0 || isNaN(amountShares) || amountShares < 0)
|
||||||
|
throw new Error("Invalid value for amount field! Must be numeric, grater than 0.");
|
||||||
|
|
||||||
const corporation = getCorporation();
|
const corporation = getCorporation();
|
||||||
if (corporation.funds < amountCash) return false;
|
if (corporation.funds < amountCash) return false;
|
||||||
if (corporation.numShares < amountShares) return false;
|
if (corporation.numShares < amountShares) return false;
|
||||||
const faction = Factions[factionName]
|
const faction = Factions[factionName];
|
||||||
const info = faction.getInfo();
|
const info = faction.getInfo();
|
||||||
if (!info.offersWork()) return false;
|
if (!info.offersWork()) return false;
|
||||||
if (player.hasGangWith(factionName)) return false;
|
if (player.hasGangWith(factionName)) return false;
|
||||||
@ -302,40 +311,40 @@ export function NetscriptCorporation(
|
|||||||
checkAccess("getPurchaseWarehouseCost", 7);
|
checkAccess("getPurchaseWarehouseCost", 7);
|
||||||
return CorporationConstants.WarehouseInitialCost;
|
return CorporationConstants.WarehouseInitialCost;
|
||||||
},
|
},
|
||||||
getUpgradeWarehouseCost: function (adivisionName: any, acityName: any): number {
|
getUpgradeWarehouseCost: function (_divisionName: unknown, _cityName: unknown): number {
|
||||||
checkAccess("upgradeWarehouse", 7);
|
checkAccess("upgradeWarehouse", 7);
|
||||||
const divisionName = helper.string("getUpgradeWarehouseCost", "divisionName", adivisionName);
|
const divisionName = helper.string("getUpgradeWarehouseCost", "divisionName", _divisionName);
|
||||||
const cityName = helper.string("getUpgradeWarehouseCost", "cityName", acityName);
|
const cityName = helper.string("getUpgradeWarehouseCost", "cityName", _cityName);
|
||||||
const warehouse = getWarehouse(divisionName, cityName);
|
const warehouse = getWarehouse(divisionName, cityName);
|
||||||
return CorporationConstants.WarehouseUpgradeBaseCost * Math.pow(1.07, warehouse.level + 1);
|
return CorporationConstants.WarehouseUpgradeBaseCost * Math.pow(1.07, warehouse.level + 1);
|
||||||
},
|
},
|
||||||
hasWarehouse: function (adivisionName: any, acityName: any): boolean {
|
hasWarehouse: function (_divisionName: unknown, _cityName: unknown): boolean {
|
||||||
checkAccess("hasWarehouse", 7);
|
checkAccess("hasWarehouse", 7);
|
||||||
const divisionName = helper.string("getWarehouse", "divisionName", adivisionName);
|
const divisionName = helper.string("getWarehouse", "divisionName", _divisionName);
|
||||||
const cityName = helper.string("getWarehouse", "cityName", acityName);
|
const cityName = helper.string("getWarehouse", "cityName", _cityName);
|
||||||
const division = getDivision(divisionName);
|
const division = getDivision(divisionName);
|
||||||
if (!(cityName in division.warehouses)) throw new Error(`Invalid city name '${cityName}'`);
|
if (!(cityName in division.warehouses)) throw new Error(`Invalid city name '${cityName}'`);
|
||||||
const warehouse = division.warehouses[cityName];
|
const warehouse = division.warehouses[cityName];
|
||||||
return warehouse !== 0;
|
return warehouse !== 0;
|
||||||
},
|
},
|
||||||
getWarehouse: function (adivisionName: any, acityName: any): NSWarehouse {
|
getWarehouse: function (_divisionName: unknown, _cityName: unknown): NSWarehouse {
|
||||||
checkAccess("getWarehouse", 7);
|
checkAccess("getWarehouse", 7);
|
||||||
const divisionName = helper.string("getWarehouse", "divisionName", adivisionName);
|
const divisionName = helper.string("getWarehouse", "divisionName", _divisionName);
|
||||||
const cityName = helper.string("getWarehouse", "cityName", acityName);
|
const cityName = helper.string("getWarehouse", "cityName", _cityName);
|
||||||
const warehouse = getWarehouse(divisionName, cityName);
|
const warehouse = getWarehouse(divisionName, cityName);
|
||||||
return {
|
return {
|
||||||
level: warehouse.level,
|
level: warehouse.level,
|
||||||
loc: warehouse.loc,
|
loc: warehouse.loc,
|
||||||
size: warehouse.size,
|
size: warehouse.size,
|
||||||
sizeUsed: warehouse.sizeUsed,
|
sizeUsed: warehouse.sizeUsed,
|
||||||
smartSupplyEnabled: warehouse.smartSupplyEnabled
|
smartSupplyEnabled: warehouse.smartSupplyEnabled,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
getMaterial: function (adivisionName: any, acityName: any, amaterialName: any): NSMaterial {
|
getMaterial: function (_divisionName: unknown, _cityName: unknown, _materialName: unknown): NSMaterial {
|
||||||
checkAccess("getMaterial", 7);
|
checkAccess("getMaterial", 7);
|
||||||
const divisionName = helper.string("getMaterial", "divisionName", adivisionName);
|
const divisionName = helper.string("getMaterial", "divisionName", _divisionName);
|
||||||
const cityName = helper.string("getMaterial", "cityName", acityName);
|
const cityName = helper.string("getMaterial", "cityName", _cityName);
|
||||||
const materialName = helper.string("getMaterial", "materialName", amaterialName);
|
const materialName = helper.string("getMaterial", "materialName", _materialName);
|
||||||
const material = getMaterial(divisionName, cityName, materialName);
|
const material = getMaterial(divisionName, cityName, materialName);
|
||||||
return {
|
return {
|
||||||
name: material.name,
|
name: material.name,
|
||||||
@ -345,10 +354,10 @@ export function NetscriptCorporation(
|
|||||||
sell: material.sll,
|
sell: material.sll,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
getProduct: function (adivisionName: any, aproductName: any): NSProduct {
|
getProduct: function (_divisionName: unknown, _productName: unknown): NSProduct {
|
||||||
checkAccess("getProduct", 7);
|
checkAccess("getProduct", 7);
|
||||||
const divisionName = helper.string("getProduct", "divisionName", adivisionName);
|
const divisionName = helper.string("getProduct", "divisionName", _divisionName);
|
||||||
const productName = helper.string("getProduct", "productName", aproductName);
|
const productName = helper.string("getProduct", "productName", _productName);
|
||||||
const product = getProduct(divisionName, productName);
|
const product = getProduct(divisionName, productName);
|
||||||
return {
|
return {
|
||||||
name: product.name,
|
name: product.name,
|
||||||
@ -360,220 +369,271 @@ export function NetscriptCorporation(
|
|||||||
developmentProgress: product.prog,
|
developmentProgress: product.prog,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
purchaseWarehouse: function (adivisionName: any, acityName: any): void {
|
purchaseWarehouse: function (_divisionName: unknown, _cityName: unknown): void {
|
||||||
checkAccess("purchaseWarehouse", 7);
|
checkAccess("purchaseWarehouse", 7);
|
||||||
const divisionName = helper.string("purchaseWarehouse", "divisionName", adivisionName);
|
const divisionName = helper.string("purchaseWarehouse", "divisionName", _divisionName);
|
||||||
const cityName = helper.string("purchaseWarehouse", "cityName", acityName);
|
const cityName = helper.string("purchaseWarehouse", "cityName", _cityName);
|
||||||
const corporation = getCorporation();
|
const corporation = getCorporation();
|
||||||
PurchaseWarehouse(corporation, getDivision(divisionName), cityName);
|
PurchaseWarehouse(corporation, getDivision(divisionName), cityName);
|
||||||
},
|
},
|
||||||
upgradeWarehouse: function (adivisionName: any, acityName: any): void {
|
upgradeWarehouse: function (_divisionName: unknown, _cityName: unknown): void {
|
||||||
checkAccess("upgradeWarehouse", 7);
|
checkAccess("upgradeWarehouse", 7);
|
||||||
const divisionName = helper.string("upgradeWarehouse", "divisionName", adivisionName);
|
const divisionName = helper.string("upgradeWarehouse", "divisionName", _divisionName);
|
||||||
const cityName = helper.string("upgradeWarehouse", "cityName", acityName);
|
const cityName = helper.string("upgradeWarehouse", "cityName", _cityName);
|
||||||
const corporation = getCorporation();
|
const corporation = getCorporation();
|
||||||
UpgradeWarehouse(corporation, getDivision(divisionName), getWarehouse(divisionName, cityName));
|
UpgradeWarehouse(corporation, getDivision(divisionName), getWarehouse(divisionName, cityName));
|
||||||
},
|
},
|
||||||
sellMaterial: function (adivisionName: any, acityName: any, amaterialName: any, aamt: any, aprice: any): void {
|
sellMaterial: function (
|
||||||
|
_divisionName: unknown,
|
||||||
|
_cityName: unknown,
|
||||||
|
_materialName: unknown,
|
||||||
|
_amt: unknown,
|
||||||
|
_price: unknown,
|
||||||
|
): void {
|
||||||
checkAccess("sellMaterial", 7);
|
checkAccess("sellMaterial", 7);
|
||||||
const divisionName = helper.string("sellMaterial", "divisionName", adivisionName);
|
const divisionName = helper.string("sellMaterial", "divisionName", _divisionName);
|
||||||
const cityName = helper.string("sellMaterial", "cityName", acityName);
|
const cityName = helper.string("sellMaterial", "cityName", _cityName);
|
||||||
const materialName = helper.string("sellMaterial", "materialName", amaterialName);
|
const materialName = helper.string("sellMaterial", "materialName", _materialName);
|
||||||
const amt = helper.string("sellMaterial", "amt", aamt);
|
const amt = helper.string("sellMaterial", "amt", _amt);
|
||||||
const price = helper.string("sellMaterial", "price", aprice);
|
const price = helper.string("sellMaterial", "price", _price);
|
||||||
const material = getMaterial(divisionName, cityName, materialName);
|
const material = getMaterial(divisionName, cityName, materialName);
|
||||||
SellMaterial(material, amt, price);
|
SellMaterial(material, amt, price);
|
||||||
},
|
},
|
||||||
sellProduct: function (
|
sellProduct: function (
|
||||||
adivisionName: any,
|
_divisionName: unknown,
|
||||||
acityName: any,
|
_cityName: unknown,
|
||||||
aproductName: any,
|
_productName: unknown,
|
||||||
aamt: any,
|
_amt: unknown,
|
||||||
aprice: any,
|
_price: unknown,
|
||||||
aall: any,
|
_all: unknown,
|
||||||
): void {
|
): void {
|
||||||
checkAccess("sellProduct", 7);
|
checkAccess("sellProduct", 7);
|
||||||
const divisionName = helper.string("sellProduct", "divisionName", adivisionName);
|
const divisionName = helper.string("sellProduct", "divisionName", _divisionName);
|
||||||
const cityName = helper.string("sellProduct", "cityName", acityName);
|
const cityName = helper.string("sellProduct", "cityName", _cityName);
|
||||||
const productName = helper.string("sellProduct", "productName", aproductName);
|
const productName = helper.string("sellProduct", "productName", _productName);
|
||||||
const amt = helper.string("sellProduct", "amt", aamt);
|
const amt = helper.string("sellProduct", "amt", _amt);
|
||||||
const price = helper.string("sellProduct", "price", aprice);
|
const price = helper.string("sellProduct", "price", _price);
|
||||||
const all = helper.boolean(aall);
|
const all = helper.boolean(_all);
|
||||||
const product = getProduct(divisionName, productName);
|
const product = getProduct(divisionName, productName);
|
||||||
SellProduct(product, cityName, amt, price, all);
|
SellProduct(product, cityName, amt, price, all);
|
||||||
},
|
},
|
||||||
discontinueProduct: function (adivisionName: any, aproductName: any): void {
|
discontinueProduct: function (_divisionName: unknown, _productName: unknown): void {
|
||||||
checkAccess("discontinueProduct", 7);
|
checkAccess("discontinueProduct", 7);
|
||||||
const divisionName = helper.string("discontinueProduct", "divisionName", adivisionName);
|
const divisionName = helper.string("discontinueProduct", "divisionName", _divisionName);
|
||||||
const productName = helper.string("discontinueProduct", "productName", aproductName);
|
const productName = helper.string("discontinueProduct", "productName", _productName);
|
||||||
getDivision(divisionName).discontinueProduct(getProduct(divisionName, productName));
|
getDivision(divisionName).discontinueProduct(getProduct(divisionName, productName));
|
||||||
},
|
},
|
||||||
setSmartSupply: function (adivisionName: any, acityName: any, aenabled: any): void {
|
setSmartSupply: function (_divisionName: unknown, _cityName: unknown, _enabled: unknown): void {
|
||||||
checkAccess("setSmartSupply", 7);
|
checkAccess("setSmartSupply", 7);
|
||||||
const divisionName = helper.string("setSmartSupply", "divisionName", adivisionName);
|
const divisionName = helper.string("setSmartSupply", "divisionName", _divisionName);
|
||||||
const cityName = helper.string("sellProduct", "cityName", acityName);
|
const cityName = helper.string("sellProduct", "cityName", _cityName);
|
||||||
const enabled = helper.boolean(aenabled);
|
const enabled = helper.boolean(_enabled);
|
||||||
const warehouse = getWarehouse(divisionName, cityName);
|
const warehouse = getWarehouse(divisionName, cityName);
|
||||||
if (!hasUnlockUpgrade("Smart Supply"))
|
if (!hasUnlockUpgrade("Smart Supply"))
|
||||||
throw helper.makeRuntimeErrorMsg(`corporation.setSmartSupply`, `You have not purchased the Smart Supply upgrade!`);
|
throw helper.makeRuntimeErrorMsg(
|
||||||
|
`corporation.setSmartSupply`,
|
||||||
|
`You have not purchased the Smart Supply upgrade!`,
|
||||||
|
);
|
||||||
SetSmartSupply(warehouse, enabled);
|
SetSmartSupply(warehouse, enabled);
|
||||||
},
|
},
|
||||||
setSmartSupplyUseLeftovers: function (adivisionName: any, acityName: any, amaterialName: any, aenabled: any): void {
|
setSmartSupplyUseLeftovers: function (
|
||||||
|
_divisionName: unknown,
|
||||||
|
_cityName: unknown,
|
||||||
|
_materialName: unknown,
|
||||||
|
_enabled: unknown,
|
||||||
|
): void {
|
||||||
checkAccess("setSmartSupplyUseLeftovers", 7);
|
checkAccess("setSmartSupplyUseLeftovers", 7);
|
||||||
const divisionName = helper.string("setSmartSupply", "divisionName", adivisionName);
|
const divisionName = helper.string("setSmartSupply", "divisionName", _divisionName);
|
||||||
const cityName = helper.string("sellProduct", "cityName", acityName);
|
const cityName = helper.string("sellProduct", "cityName", _cityName);
|
||||||
const materialName = helper.string("sellProduct", "materialName", amaterialName);
|
const materialName = helper.string("sellProduct", "materialName", _materialName);
|
||||||
const enabled = helper.boolean(aenabled);
|
const enabled = helper.boolean(_enabled);
|
||||||
const warehouse = getWarehouse(divisionName, cityName);
|
const warehouse = getWarehouse(divisionName, cityName);
|
||||||
const material = getMaterial(divisionName, cityName, materialName);
|
const material = getMaterial(divisionName, cityName, materialName);
|
||||||
if (!hasUnlockUpgrade("Smart Supply"))
|
if (!hasUnlockUpgrade("Smart Supply"))
|
||||||
throw helper.makeRuntimeErrorMsg(`corporation.setSmartSupply`, `You have not purchased the Smart Supply upgrade!`);
|
throw helper.makeRuntimeErrorMsg(
|
||||||
|
`corporation.setSmartSupply`,
|
||||||
|
`You have not purchased the Smart Supply upgrade!`,
|
||||||
|
);
|
||||||
SetSmartSupplyUseLeftovers(warehouse, material, enabled);
|
SetSmartSupplyUseLeftovers(warehouse, material, enabled);
|
||||||
},
|
},
|
||||||
buyMaterial: function (adivisionName: any, acityName: any, amaterialName: any, aamt: any): void {
|
buyMaterial: function (_divisionName: unknown, _cityName: unknown, _materialName: unknown, _amt: unknown): void {
|
||||||
checkAccess("buyMaterial", 7);
|
checkAccess("buyMaterial", 7);
|
||||||
const divisionName = helper.string("buyMaterial", "divisionName", adivisionName);
|
const divisionName = helper.string("buyMaterial", "divisionName", _divisionName);
|
||||||
const cityName = helper.string("buyMaterial", "cityName", acityName);
|
const cityName = helper.string("buyMaterial", "cityName", _cityName);
|
||||||
const materialName = helper.string("buyMaterial", "materialName", amaterialName);
|
const materialName = helper.string("buyMaterial", "materialName", _materialName);
|
||||||
const amt = helper.number("buyMaterial", "amt", aamt);
|
const amt = helper.number("buyMaterial", "amt", _amt);
|
||||||
if (amt < 0) throw new Error("Invalid value for amount field! Must be numeric and greater than 0");
|
if (amt < 0) throw new Error("Invalid value for amount field! Must be numeric and greater than 0");
|
||||||
const material = getMaterial(divisionName, cityName, materialName);
|
const material = getMaterial(divisionName, cityName, materialName);
|
||||||
BuyMaterial(material, amt);
|
BuyMaterial(material, amt);
|
||||||
},
|
},
|
||||||
bulkPurchase: function (adivisionName: any, acityName: any, amaterialName: any, aamt: any): void {
|
bulkPurchase: function (_divisionName: unknown, _cityName: unknown, _materialName: unknown, _amt: unknown): void {
|
||||||
checkAccess("bulkPurchase", 7);
|
checkAccess("bulkPurchase", 7);
|
||||||
const divisionName = helper.string("bulkPurchase", "divisionName", adivisionName);
|
const divisionName = helper.string("bulkPurchase", "divisionName", _divisionName);
|
||||||
if (!hasResearched(getDivision(adivisionName), "Bulk Purchasing")) throw new Error(`You have not researched Bulk Purchasing in ${divisionName}`)
|
if (!hasResearched(getDivision(_divisionName), "Bulk Purchasing"))
|
||||||
|
throw new Error(`You have not researched Bulk Purchasing in ${divisionName}`);
|
||||||
const corporation = getCorporation();
|
const corporation = getCorporation();
|
||||||
const cityName = helper.string("bulkPurchase", "cityName", acityName);
|
const cityName = helper.string("bulkPurchase", "cityName", _cityName);
|
||||||
const materialName = helper.string("bulkPurchase", "materialName", amaterialName);
|
const materialName = helper.string("bulkPurchase", "materialName", _materialName);
|
||||||
const amt = helper.number("bulkPurchase", "amt", aamt);
|
const amt = helper.number("bulkPurchase", "amt", _amt);
|
||||||
const warehouse = getWarehouse(divisionName, cityName)
|
const warehouse = getWarehouse(divisionName, cityName);
|
||||||
const material = getMaterial(divisionName, cityName, materialName);
|
const material = getMaterial(divisionName, cityName, materialName);
|
||||||
BulkPurchase(corporation, warehouse, material, amt);
|
BulkPurchase(corporation, warehouse, material, amt);
|
||||||
},
|
},
|
||||||
makeProduct: function (
|
makeProduct: function (
|
||||||
adivisionName: any,
|
_divisionName: unknown,
|
||||||
acityName: any,
|
_cityName: unknown,
|
||||||
aproductName: any,
|
_productName: unknown,
|
||||||
adesignInvest: any,
|
_designInvest: unknown,
|
||||||
amarketingInvest: any,
|
_marketingInvest: unknown,
|
||||||
): void {
|
): void {
|
||||||
checkAccess("makeProduct", 7);
|
checkAccess("makeProduct", 7);
|
||||||
const divisionName = helper.string("makeProduct", "divisionName", adivisionName);
|
const divisionName = helper.string("makeProduct", "divisionName", _divisionName);
|
||||||
const cityName = helper.string("makeProduct", "cityName", acityName);
|
const cityName = helper.string("makeProduct", "cityName", _cityName);
|
||||||
const productName = helper.string("makeProduct", "productName", aproductName);
|
const productName = helper.string("makeProduct", "productName", _productName);
|
||||||
const designInvest = helper.number("makeProduct", "designInvest", adesignInvest);
|
const designInvest = helper.number("makeProduct", "designInvest", _designInvest);
|
||||||
const marketingInvest = helper.number("makeProduct", "marketingInvest", amarketingInvest);
|
const marketingInvest = helper.number("makeProduct", "marketingInvest", _marketingInvest);
|
||||||
const corporation = getCorporation();
|
const corporation = getCorporation();
|
||||||
MakeProduct(corporation, getDivision(divisionName), cityName, productName, designInvest, marketingInvest);
|
MakeProduct(corporation, getDivision(divisionName), cityName, productName, designInvest, marketingInvest);
|
||||||
},
|
},
|
||||||
exportMaterial: function (
|
exportMaterial: function (
|
||||||
asourceDivision: any,
|
_sourceDivision: unknown,
|
||||||
asourceCity: any,
|
_sourceCity: unknown,
|
||||||
atargetDivision: any,
|
_targetDivision: unknown,
|
||||||
atargetCity: any,
|
_targetCity: unknown,
|
||||||
amaterialName: any,
|
_materialName: unknown,
|
||||||
aamt: any,
|
_amt: unknown,
|
||||||
): void {
|
): void {
|
||||||
checkAccess("exportMaterial", 7);
|
checkAccess("exportMaterial", 7);
|
||||||
const sourceDivision = helper.string("exportMaterial", "sourceDivision", asourceDivision);
|
const sourceDivision = helper.string("exportMaterial", "sourceDivision", _sourceDivision);
|
||||||
const sourceCity = helper.string("exportMaterial", "sourceCity", asourceCity);
|
const sourceCity = helper.string("exportMaterial", "sourceCity", _sourceCity);
|
||||||
const targetDivision = helper.string("exportMaterial", "targetDivision", atargetDivision);
|
const targetDivision = helper.string("exportMaterial", "targetDivision", _targetDivision);
|
||||||
const targetCity = helper.string("exportMaterial", "targetCity", atargetCity);
|
const targetCity = helper.string("exportMaterial", "targetCity", _targetCity);
|
||||||
const materialName = helper.string("exportMaterial", "materialName", amaterialName);
|
const materialName = helper.string("exportMaterial", "materialName", _materialName);
|
||||||
const amt = helper.string("exportMaterial", "amt", aamt);
|
const amt = helper.string("exportMaterial", "amt", _amt);
|
||||||
ExportMaterial(targetDivision, targetCity, getMaterial(sourceDivision, sourceCity, materialName), amt + "", getDivision(targetDivision));
|
ExportMaterial(
|
||||||
|
targetDivision,
|
||||||
|
targetCity,
|
||||||
|
getMaterial(sourceDivision, sourceCity, materialName),
|
||||||
|
amt + "",
|
||||||
|
getDivision(targetDivision),
|
||||||
|
);
|
||||||
},
|
},
|
||||||
cancelExportMaterial: function (
|
cancelExportMaterial: function (
|
||||||
asourceDivision: any,
|
_sourceDivision: unknown,
|
||||||
asourceCity: any,
|
_sourceCity: unknown,
|
||||||
atargetDivision: any,
|
_targetDivision: unknown,
|
||||||
atargetCity: any,
|
_targetCity: unknown,
|
||||||
amaterialName: any,
|
_materialName: unknown,
|
||||||
aamt: any,
|
_amt: unknown,
|
||||||
): void {
|
): void {
|
||||||
checkAccess("cancelExportMaterial", 7);
|
checkAccess("cancelExportMaterial", 7);
|
||||||
const sourceDivision = helper.string("cancelExportMaterial", "sourceDivision", asourceDivision);
|
const sourceDivision = helper.string("cancelExportMaterial", "sourceDivision", _sourceDivision);
|
||||||
const sourceCity = helper.string("cancelExportMaterial", "sourceCity", asourceCity);
|
const sourceCity = helper.string("cancelExportMaterial", "sourceCity", _sourceCity);
|
||||||
const targetDivision = helper.string("cancelExportMaterial", "targetDivision", atargetDivision);
|
const targetDivision = helper.string("cancelExportMaterial", "targetDivision", _targetDivision);
|
||||||
const targetCity = helper.string("cancelExportMaterial", "targetCity", atargetCity);
|
const targetCity = helper.string("cancelExportMaterial", "targetCity", _targetCity);
|
||||||
const materialName = helper.string("cancelExportMaterial", "materialName", amaterialName);
|
const materialName = helper.string("cancelExportMaterial", "materialName", _materialName);
|
||||||
const amt = helper.string("cancelExportMaterial", "amt", aamt);
|
const amt = helper.string("cancelExportMaterial", "amt", _amt);
|
||||||
CancelExportMaterial(targetDivision, targetCity, getMaterial(sourceDivision, sourceCity, materialName), amt + "");
|
CancelExportMaterial(targetDivision, targetCity, getMaterial(sourceDivision, sourceCity, materialName), amt + "");
|
||||||
},
|
},
|
||||||
setMaterialMarketTA1: function (adivisionName: any, acityName: any, amaterialName: any, aon: any): void {
|
setMaterialMarketTA1: function (
|
||||||
|
_divisionName: unknown,
|
||||||
|
_cityName: unknown,
|
||||||
|
_materialName: unknown,
|
||||||
|
_on: unknown,
|
||||||
|
): void {
|
||||||
checkAccess("setMaterialMarketTA1", 7);
|
checkAccess("setMaterialMarketTA1", 7);
|
||||||
const divisionName = helper.string("setMaterialMarketTA1", "divisionName", adivisionName);
|
const divisionName = helper.string("setMaterialMarketTA1", "divisionName", _divisionName);
|
||||||
const cityName = helper.string("setMaterialMarketTA1", "cityName", acityName);
|
const cityName = helper.string("setMaterialMarketTA1", "cityName", _cityName);
|
||||||
const materialName = helper.string("setMaterialMarketTA1", "materialName", amaterialName);
|
const materialName = helper.string("setMaterialMarketTA1", "materialName", _materialName);
|
||||||
const on = helper.boolean(aon);
|
const on = helper.boolean(_on);
|
||||||
if (!getDivision(divisionName).hasResearch("Market-TA.I"))
|
if (!getDivision(divisionName).hasResearch("Market-TA.I"))
|
||||||
throw helper.makeRuntimeErrorMsg(`corporation.setMaterialMarketTA1`, `You have not researched MarketTA.I for division: ${divisionName}`);
|
throw helper.makeRuntimeErrorMsg(
|
||||||
|
`corporation.setMaterialMarketTA1`,
|
||||||
|
`You have not researched MarketTA.I for division: ${divisionName}`,
|
||||||
|
);
|
||||||
SetMaterialMarketTA1(getMaterial(divisionName, cityName, materialName), on);
|
SetMaterialMarketTA1(getMaterial(divisionName, cityName, materialName), on);
|
||||||
},
|
},
|
||||||
setMaterialMarketTA2: function (adivisionName: any, acityName: any, amaterialName: any, aon: any): void {
|
setMaterialMarketTA2: function (
|
||||||
|
_divisionName: unknown,
|
||||||
|
_cityName: unknown,
|
||||||
|
_materialName: unknown,
|
||||||
|
_on: unknown,
|
||||||
|
): void {
|
||||||
checkAccess("setMaterialMarketTA2", 7);
|
checkAccess("setMaterialMarketTA2", 7);
|
||||||
const divisionName = helper.string("setMaterialMarketTA2", "divisionName", adivisionName);
|
const divisionName = helper.string("setMaterialMarketTA2", "divisionName", _divisionName);
|
||||||
const cityName = helper.string("setMaterialMarketTA2", "cityName", acityName);
|
const cityName = helper.string("setMaterialMarketTA2", "cityName", _cityName);
|
||||||
const materialName = helper.string("setMaterialMarketTA2", "materialName", amaterialName);
|
const materialName = helper.string("setMaterialMarketTA2", "materialName", _materialName);
|
||||||
const on = helper.boolean(aon);
|
const on = helper.boolean(_on);
|
||||||
if (!getDivision(divisionName).hasResearch("Market-TA.II"))
|
if (!getDivision(divisionName).hasResearch("Market-TA.II"))
|
||||||
throw helper.makeRuntimeErrorMsg(`corporation.setMaterialMarketTA2`, `You have not researched MarketTA.II for division: ${divisionName}`);
|
throw helper.makeRuntimeErrorMsg(
|
||||||
|
`corporation.setMaterialMarketTA2`,
|
||||||
|
`You have not researched MarketTA.II for division: ${divisionName}`,
|
||||||
|
);
|
||||||
SetMaterialMarketTA2(getMaterial(divisionName, cityName, materialName), on);
|
SetMaterialMarketTA2(getMaterial(divisionName, cityName, materialName), on);
|
||||||
},
|
},
|
||||||
setProductMarketTA1: function (adivisionName: any, aproductName: any, aon: any): void {
|
setProductMarketTA1: function (_divisionName: unknown, _productName: unknown, _on: unknown): void {
|
||||||
checkAccess("setProductMarketTA1", 7);
|
checkAccess("setProductMarketTA1", 7);
|
||||||
const divisionName = helper.string("setProductMarketTA1", "divisionName", adivisionName);
|
const divisionName = helper.string("setProductMarketTA1", "divisionName", _divisionName);
|
||||||
const productName = helper.string("setProductMarketTA1", "productName", aproductName);
|
const productName = helper.string("setProductMarketTA1", "productName", _productName);
|
||||||
const on = helper.boolean(aon);
|
const on = helper.boolean(_on);
|
||||||
if (!getDivision(divisionName).hasResearch("Market-TA.I"))
|
if (!getDivision(divisionName).hasResearch("Market-TA.I"))
|
||||||
throw helper.makeRuntimeErrorMsg(`corporation.setProductMarketTA1`, `You have not researched MarketTA.I for division: ${divisionName}`);
|
throw helper.makeRuntimeErrorMsg(
|
||||||
|
`corporation.setProductMarketTA1`,
|
||||||
|
`You have not researched MarketTA.I for division: ${divisionName}`,
|
||||||
|
);
|
||||||
SetProductMarketTA1(getProduct(divisionName, productName), on);
|
SetProductMarketTA1(getProduct(divisionName, productName), on);
|
||||||
},
|
},
|
||||||
setProductMarketTA2: function (adivisionName: any, aproductName: any, aon: any): void {
|
setProductMarketTA2: function (_divisionName: unknown, _productName: unknown, _on: unknown): void {
|
||||||
checkAccess("setProductMarketTA2", 7);
|
checkAccess("setProductMarketTA2", 7);
|
||||||
const divisionName = helper.string("setProductMarketTA2", "divisionName", adivisionName);
|
const divisionName = helper.string("setProductMarketTA2", "divisionName", _divisionName);
|
||||||
const productName = helper.string("setProductMarketTA2", "productName", aproductName);
|
const productName = helper.string("setProductMarketTA2", "productName", _productName);
|
||||||
const on = helper.boolean(aon);
|
const on = helper.boolean(_on);
|
||||||
if (!getDivision(divisionName).hasResearch("Market-TA.II"))
|
if (!getDivision(divisionName).hasResearch("Market-TA.II"))
|
||||||
throw helper.makeRuntimeErrorMsg(`corporation.setProductMarketTA2`, `You have not researched MarketTA.II for division: ${divisionName}`);
|
throw helper.makeRuntimeErrorMsg(
|
||||||
|
`corporation.setProductMarketTA2`,
|
||||||
|
`You have not researched MarketTA.II for division: ${divisionName}`,
|
||||||
|
);
|
||||||
SetProductMarketTA2(getProduct(divisionName, productName), on);
|
SetProductMarketTA2(getProduct(divisionName, productName), on);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const officeAPI: OfficeAPI = {
|
const officeAPI: OfficeAPI = {
|
||||||
getHireAdVertCost: function (adivisionName: any): number {
|
getHireAdVertCost: function (_divisionName: unknown): number {
|
||||||
checkAccess("getHireAdVertCost", 8);
|
checkAccess("getHireAdVertCost", 8);
|
||||||
const divisionName = helper.string("getHireAdVertCost", "divisionName", adivisionName);
|
const divisionName = helper.string("getHireAdVertCost", "divisionName", _divisionName);
|
||||||
const division = getDivision(divisionName);
|
const division = getDivision(divisionName);
|
||||||
const upgrade = IndustryUpgrades[1];
|
const upgrade = IndustryUpgrades[1];
|
||||||
return upgrade[1] * Math.pow(upgrade[2], division.upgrades[1]);
|
return upgrade[1] * Math.pow(upgrade[2], division.upgrades[1]);
|
||||||
},
|
},
|
||||||
getHireAdVertCount: function (adivisionName: any): number {
|
getHireAdVertCount: function (_divisionName: unknown): number {
|
||||||
checkAccess("getHireAdVertCount", 8);
|
checkAccess("getHireAdVertCount", 8);
|
||||||
const divisionName = helper.string("getHireAdVertCount", "divisionName", adivisionName);
|
const divisionName = helper.string("getHireAdVertCount", "divisionName", _divisionName);
|
||||||
const division = getDivision(divisionName);
|
const division = getDivision(divisionName);
|
||||||
return division.upgrades[1]
|
return division.upgrades[1];
|
||||||
},
|
},
|
||||||
getResearchCost: function (adivisionName: any, aresearchName: any): number {
|
getResearchCost: function (_divisionName: unknown, _researchName: unknown): number {
|
||||||
checkAccess("getResearchCost", 8);
|
checkAccess("getResearchCost", 8);
|
||||||
const divisionName = helper.string("getResearchCost", "divisionName", adivisionName);
|
const divisionName = helper.string("getResearchCost", "divisionName", _divisionName);
|
||||||
const researchName = helper.string("getResearchCost", "researchName", aresearchName);
|
const researchName = helper.string("getResearchCost", "researchName", _researchName);
|
||||||
return getResearchCost(getDivision(divisionName), researchName);
|
return getResearchCost(getDivision(divisionName), researchName);
|
||||||
},
|
},
|
||||||
hasResearched: function (adivisionName: any, aresearchName: any): boolean {
|
hasResearched: function (_divisionName: unknown, _researchName: unknown): boolean {
|
||||||
checkAccess("hasResearched", 8);
|
checkAccess("hasResearched", 8);
|
||||||
const divisionName = helper.string("hasResearched", "divisionName", adivisionName);
|
const divisionName = helper.string("hasResearched", "divisionName", _divisionName);
|
||||||
const researchName = helper.string("hasResearched", "researchName", aresearchName);
|
const researchName = helper.string("hasResearched", "researchName", _researchName);
|
||||||
return hasResearched(getDivision(divisionName), researchName);
|
return hasResearched(getDivision(divisionName), researchName);
|
||||||
},
|
},
|
||||||
setAutoJobAssignment: function (adivisionName: any, acityName: any, ajob: any, aamount: any): Promise<boolean> {
|
setAutoJobAssignment: function (
|
||||||
|
_divisionName: unknown,
|
||||||
|
_cityName: unknown,
|
||||||
|
_job: unknown,
|
||||||
|
_amount: unknown,
|
||||||
|
): Promise<boolean> {
|
||||||
checkAccess("setAutoJobAssignment", 8);
|
checkAccess("setAutoJobAssignment", 8);
|
||||||
const divisionName = helper.string("setAutoJobAssignment", "divisionName", adivisionName);
|
const divisionName = helper.string("setAutoJobAssignment", "divisionName", _divisionName);
|
||||||
const cityName = helper.string("setAutoJobAssignment", "cityName", acityName);
|
const cityName = helper.string("setAutoJobAssignment", "cityName", _cityName);
|
||||||
const amount = helper.number("setAutoJobAssignment", "amount", aamount);
|
const amount = helper.number("setAutoJobAssignment", "amount", _amount);
|
||||||
const job = helper.string("setAutoJobAssignment", "job", ajob);
|
const job = helper.string("setAutoJobAssignment", "job", _job);
|
||||||
const office = getOffice(divisionName, cityName);
|
const office = getOffice(divisionName, cityName);
|
||||||
if (!Object.values(EmployeePositions).includes(job)) throw new Error(`'${job}' is not a valid job.`);
|
if (!Object.values(EmployeePositions).includes(job)) throw new Error(`'${job}' is not a valid job.`);
|
||||||
return netscriptDelay(1000, workerScript).then(function () {
|
return netscriptDelay(1000, workerScript).then(function () {
|
||||||
@ -583,11 +643,11 @@ export function NetscriptCorporation(
|
|||||||
return Promise.resolve(office.setEmployeeToJob(job, amount));
|
return Promise.resolve(office.setEmployeeToJob(job, amount));
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
getOfficeSizeUpgradeCost: function (adivisionName: any, acityName: any, asize: any): number {
|
getOfficeSizeUpgradeCost: function (_divisionName: unknown, _cityName: unknown, _size: unknown): number {
|
||||||
checkAccess("getOfficeSizeUpgradeCost", 8);
|
checkAccess("getOfficeSizeUpgradeCost", 8);
|
||||||
const divisionName = helper.string("getOfficeSizeUpgradeCost", "divisionName", adivisionName);
|
const divisionName = helper.string("getOfficeSizeUpgradeCost", "divisionName", _divisionName);
|
||||||
const cityName = helper.string("getOfficeSizeUpgradeCost", "cityName", acityName);
|
const cityName = helper.string("getOfficeSizeUpgradeCost", "cityName", _cityName);
|
||||||
const size = helper.number("getOfficeSizeUpgradeCost", "size", asize);
|
const size = helper.number("getOfficeSizeUpgradeCost", "size", _size);
|
||||||
if (size < 0) throw new Error("Invalid value for size field! Must be numeric and greater than 0");
|
if (size < 0) throw new Error("Invalid value for size field! Must be numeric and greater than 0");
|
||||||
const office = getOffice(divisionName, cityName);
|
const office = getOffice(divisionName, cityName);
|
||||||
const initialPriceMult = Math.round(office.size / CorporationConstants.OfficeInitialSize);
|
const initialPriceMult = Math.round(office.size / CorporationConstants.OfficeInitialSize);
|
||||||
@ -598,40 +658,46 @@ export function NetscriptCorporation(
|
|||||||
}
|
}
|
||||||
return CorporationConstants.OfficeInitialCost * mult;
|
return CorporationConstants.OfficeInitialCost * mult;
|
||||||
},
|
},
|
||||||
assignJob: function (adivisionName: any, acityName: any, aemployeeName: any, ajob: any): Promise<void> {
|
assignJob: function (
|
||||||
|
_divisionName: unknown,
|
||||||
|
_cityName: unknown,
|
||||||
|
_employeeName: unknown,
|
||||||
|
_job: unknown,
|
||||||
|
): Promise<void> {
|
||||||
checkAccess("assignJob", 8);
|
checkAccess("assignJob", 8);
|
||||||
const divisionName = helper.string("assignJob", "divisionName", adivisionName);
|
const divisionName = helper.string("assignJob", "divisionName", _divisionName);
|
||||||
const cityName = helper.string("assignJob", "cityName", acityName);
|
const cityName = helper.string("assignJob", "cityName", _cityName);
|
||||||
const employeeName = helper.string("assignJob", "employeeName", aemployeeName);
|
const employeeName = helper.string("assignJob", "employeeName", _employeeName);
|
||||||
const job = helper.string("assignJob", "job", ajob);
|
const job = helper.string("assignJob", "job", _job);
|
||||||
const employee = getEmployee(divisionName, cityName, employeeName);
|
const employee = getEmployee(divisionName, cityName, employeeName);
|
||||||
return netscriptDelay(1000, workerScript).then(function () {
|
return netscriptDelay(1000, workerScript).then(function () {
|
||||||
return Promise.resolve(AssignJob(employee, job));
|
return Promise.resolve(AssignJob(employee, job));
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
hireEmployee: function (adivisionName: any, acityName: any): any {
|
hireEmployee: function (_divisionName: unknown, _cityName: unknown): any {
|
||||||
checkAccess("hireEmployee", 8);
|
checkAccess("hireEmployee", 8);
|
||||||
const divisionName = helper.string("hireEmployee", "divisionName", adivisionName);
|
const divisionName = helper.string("hireEmployee", "divisionName", _divisionName);
|
||||||
const cityName = helper.string("hireEmployee", "cityName", acityName);
|
const cityName = helper.string("hireEmployee", "cityName", _cityName);
|
||||||
const office = getOffice(divisionName, cityName);
|
const office = getOffice(divisionName, cityName);
|
||||||
return office.hireRandomEmployee();
|
return office.hireRandomEmployee();
|
||||||
},
|
},
|
||||||
upgradeOfficeSize: function (adivisionName: any, acityName: any, asize: any): void {
|
upgradeOfficeSize: function (_divisionName: unknown, _cityName: unknown, _size: unknown): void {
|
||||||
checkAccess("upgradeOfficeSize", 8);
|
checkAccess("upgradeOfficeSize", 8);
|
||||||
const divisionName = helper.string("upgradeOfficeSize", "divisionName", adivisionName);
|
const divisionName = helper.string("upgradeOfficeSize", "divisionName", _divisionName);
|
||||||
const cityName = helper.string("upgradeOfficeSize", "cityName", acityName);
|
const cityName = helper.string("upgradeOfficeSize", "cityName", _cityName);
|
||||||
const size = helper.number("upgradeOfficeSize", "size", asize);
|
const size = helper.number("upgradeOfficeSize", "size", _size);
|
||||||
if (size < 0) throw new Error("Invalid value for size field! Must be numeric and greater than 0");
|
if (size < 0) throw new Error("Invalid value for size field! Must be numeric and greater than 0");
|
||||||
const office = getOffice(divisionName, cityName);
|
const office = getOffice(divisionName, cityName);
|
||||||
const corporation = getCorporation();
|
const corporation = getCorporation();
|
||||||
UpgradeOfficeSize(corporation, office, size);
|
UpgradeOfficeSize(corporation, office, size);
|
||||||
},
|
},
|
||||||
throwParty: function (adivisionName: any, acityName: any, acostPerEmployee: any): Promise<number> {
|
throwParty: function (_divisionName: unknown, _cityName: unknown, _costPerEmployee: unknown): Promise<number> {
|
||||||
checkAccess("throwParty", 8);
|
checkAccess("throwParty", 8);
|
||||||
const divisionName = helper.string("throwParty", "divisionName", adivisionName);
|
const divisionName = helper.string("throwParty", "divisionName", _divisionName);
|
||||||
const cityName = helper.string("throwParty", "cityName", acityName);
|
const cityName = helper.string("throwParty", "cityName", _cityName);
|
||||||
const costPerEmployee = helper.number("throwParty", "costPerEmployee", acostPerEmployee);
|
const costPerEmployee = helper.number("throwParty", "costPerEmployee", _costPerEmployee);
|
||||||
if (costPerEmployee < 0) throw new Error("Invalid value for Cost Per Employee field! Must be numeric and greater than 0");
|
if (costPerEmployee < 0)
|
||||||
|
throw new Error("Invalid value for Cost Per Employee field! Must be numeric and greater than 0");
|
||||||
const office = getOffice(divisionName, cityName);
|
const office = getOffice(divisionName, cityName);
|
||||||
const corporation = getCorporation();
|
const corporation = getCorporation();
|
||||||
return netscriptDelay(
|
return netscriptDelay(
|
||||||
@ -641,10 +707,10 @@ export function NetscriptCorporation(
|
|||||||
return Promise.resolve(ThrowParty(corporation, office, costPerEmployee));
|
return Promise.resolve(ThrowParty(corporation, office, costPerEmployee));
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
buyCoffee: function (adivisionName: any, acityName: any): Promise<void> {
|
buyCoffee: function (_divisionName: unknown, _cityName: unknown): Promise<void> {
|
||||||
checkAccess("buyCoffee", 8);
|
checkAccess("buyCoffee", 8);
|
||||||
const divisionName = helper.string("buyCoffee", "divisionName", adivisionName);
|
const divisionName = helper.string("buyCoffee", "divisionName", _divisionName);
|
||||||
const cityName = helper.string("buyCoffee", "cityName", acityName);
|
const cityName = helper.string("buyCoffee", "cityName", _cityName);
|
||||||
const corporation = getCorporation();
|
const corporation = getCorporation();
|
||||||
return netscriptDelay(
|
return netscriptDelay(
|
||||||
(60 * 1000) / (player.hacking_speed_mult * calculateIntelligenceBonus(player.intelligence, 1)),
|
(60 * 1000) / (player.hacking_speed_mult * calculateIntelligenceBonus(player.intelligence, 1)),
|
||||||
@ -653,22 +719,22 @@ export function NetscriptCorporation(
|
|||||||
return Promise.resolve(BuyCoffee(corporation, getDivision(divisionName), getOffice(divisionName, cityName)));
|
return Promise.resolve(BuyCoffee(corporation, getDivision(divisionName), getOffice(divisionName, cityName)));
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
hireAdVert: function (adivisionName: any): void {
|
hireAdVert: function (_divisionName: unknown): void {
|
||||||
checkAccess("hireAdVert", 8);
|
checkAccess("hireAdVert", 8);
|
||||||
const divisionName = helper.string("hireAdVert", "divisionName", adivisionName);
|
const divisionName = helper.string("hireAdVert", "divisionName", _divisionName);
|
||||||
const corporation = getCorporation();
|
const corporation = getCorporation();
|
||||||
HireAdVert(corporation, getDivision(divisionName), getOffice(divisionName, "Sector-12"));
|
HireAdVert(corporation, getDivision(divisionName), getOffice(divisionName, "Sector-12"));
|
||||||
},
|
},
|
||||||
research: function (adivisionName: any, aresearchName: any): void {
|
research: function (_divisionName: unknown, _researchName: unknown): void {
|
||||||
checkAccess("research", 8);
|
checkAccess("research", 8);
|
||||||
const divisionName = helper.string("research", "divisionName", adivisionName);
|
const divisionName = helper.string("research", "divisionName", _divisionName);
|
||||||
const researchName = helper.string("research", "researchName", aresearchName);
|
const researchName = helper.string("research", "researchName", _researchName);
|
||||||
Research(getDivision(divisionName), researchName);
|
Research(getDivision(divisionName), researchName);
|
||||||
},
|
},
|
||||||
getOffice: function (adivisionName: any, acityName: any): any {
|
getOffice: function (_divisionName: unknown, _cityName: unknown): any {
|
||||||
checkAccess("getOffice", 8);
|
checkAccess("getOffice", 8);
|
||||||
const divisionName = helper.string("getOffice", "divisionName", adivisionName);
|
const divisionName = helper.string("getOffice", "divisionName", _divisionName);
|
||||||
const cityName = helper.string("getOffice", "cityName", acityName);
|
const cityName = helper.string("getOffice", "cityName", _cityName);
|
||||||
const office = getOffice(divisionName, cityName);
|
const office = getOffice(divisionName, cityName);
|
||||||
return {
|
return {
|
||||||
loc: office.loc,
|
loc: office.loc,
|
||||||
@ -689,11 +755,11 @@ export function NetscriptCorporation(
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
getEmployee: function (adivisionName: any, acityName: any, aemployeeName: any): NSEmployee {
|
getEmployee: function (_divisionName: unknown, _cityName: unknown, _employeeName: unknown): NSEmployee {
|
||||||
checkAccess("getEmployee", 8);
|
checkAccess("getEmployee", 8);
|
||||||
const divisionName = helper.string("getEmployee", "divisionName", adivisionName);
|
const divisionName = helper.string("getEmployee", "divisionName", _divisionName);
|
||||||
const cityName = helper.string("getEmployee", "cityName", acityName);
|
const cityName = helper.string("getEmployee", "cityName", _cityName);
|
||||||
const employeeName = helper.string("getEmployee", "employeeName", aemployeeName);
|
const employeeName = helper.string("getEmployee", "employeeName", _employeeName);
|
||||||
const employee = getEmployee(divisionName, cityName, employeeName);
|
const employee = getEmployee(divisionName, cityName, employeeName);
|
||||||
return {
|
return {
|
||||||
name: employee.name,
|
name: employee.name,
|
||||||
@ -715,42 +781,43 @@ export function NetscriptCorporation(
|
|||||||
return {
|
return {
|
||||||
...warehouseAPI,
|
...warehouseAPI,
|
||||||
...officeAPI,
|
...officeAPI,
|
||||||
expandIndustry: function (aindustryName: any, adivisionName: any): void {
|
expandIndustry: function (_industryName: unknown, _divisionName: unknown): void {
|
||||||
checkAccess("expandIndustry");
|
checkAccess("expandIndustry");
|
||||||
const industryName = helper.string("expandIndustry", "industryName", aindustryName);
|
const industryName = helper.string("expandIndustry", "industryName", _industryName);
|
||||||
const divisionName = helper.string("expandIndustry", "divisionName", adivisionName);
|
const divisionName = helper.string("expandIndustry", "divisionName", _divisionName);
|
||||||
const corporation = getCorporation();
|
const corporation = getCorporation();
|
||||||
NewIndustry(corporation, industryName, divisionName);
|
NewIndustry(corporation, industryName, divisionName);
|
||||||
},
|
},
|
||||||
expandCity: function (adivisionName: any, acityName: any): void {
|
expandCity: function (_divisionName: unknown, _cityName: unknown): void {
|
||||||
checkAccess("expandCity");
|
checkAccess("expandCity");
|
||||||
const divisionName = helper.string("expandCity", "divisionName", adivisionName);
|
const divisionName = helper.string("expandCity", "divisionName", _divisionName);
|
||||||
const cityName = helper.string("expandCity", "cityName", acityName);
|
const cityName = helper.string("expandCity", "cityName", _cityName);
|
||||||
if (!CorporationConstants.Cities.includes(cityName)) throw new Error("Invalid city name");
|
if (!CorporationConstants.Cities.includes(cityName)) throw new Error("Invalid city name");
|
||||||
const corporation = getCorporation();
|
const corporation = getCorporation();
|
||||||
const division = getDivision(divisionName);
|
const division = getDivision(divisionName);
|
||||||
NewCity(corporation, division, cityName);
|
NewCity(corporation, division, cityName);
|
||||||
},
|
},
|
||||||
unlockUpgrade: function (aupgradeName: any): void {
|
unlockUpgrade: function (_upgradeName: unknown): void {
|
||||||
checkAccess("unlockUpgrade");
|
checkAccess("unlockUpgrade");
|
||||||
const upgradeName = helper.string("unlockUpgrade", "upgradeName", aupgradeName);
|
const upgradeName = helper.string("unlockUpgrade", "upgradeName", _upgradeName);
|
||||||
const corporation = getCorporation();
|
const corporation = getCorporation();
|
||||||
const upgrade = Object.values(CorporationUnlockUpgrades).find((upgrade) => upgrade[2] === upgradeName);
|
const upgrade = Object.values(CorporationUnlockUpgrades).find((upgrade) => upgrade[2] === upgradeName);
|
||||||
if (upgrade === undefined) throw new Error(`No upgrade named '${upgradeName}'`);
|
if (upgrade === undefined) throw new Error(`No upgrade named '${upgradeName}'`);
|
||||||
UnlockUpgrade(corporation, upgrade);
|
UnlockUpgrade(corporation, upgrade);
|
||||||
},
|
},
|
||||||
levelUpgrade: function (aupgradeName: any): void {
|
levelUpgrade: function (_upgradeName: unknown): void {
|
||||||
checkAccess("levelUpgrade");
|
checkAccess("levelUpgrade");
|
||||||
const upgradeName = helper.string("levelUpgrade", "upgradeName", aupgradeName);
|
const upgradeName = helper.string("levelUpgrade", "upgradeName", _upgradeName);
|
||||||
const corporation = getCorporation();
|
const corporation = getCorporation();
|
||||||
const upgrade = Object.values(CorporationUpgrades).find((upgrade) => upgrade[4] === upgradeName);
|
const upgrade = Object.values(CorporationUpgrades).find((upgrade) => upgrade[4] === upgradeName);
|
||||||
if (upgrade === undefined) throw new Error(`No upgrade named '${upgradeName}'`);
|
if (upgrade === undefined) throw new Error(`No upgrade named '${upgradeName}'`);
|
||||||
LevelUpgrade(corporation, upgrade);
|
LevelUpgrade(corporation, upgrade);
|
||||||
},
|
},
|
||||||
issueDividends: function (apercent: any): void {
|
issueDividends: function (_percent: unknown): void {
|
||||||
checkAccess("issueDividends");
|
checkAccess("issueDividends");
|
||||||
const percent = helper.number("issueDividends", "percent", apercent);
|
const percent = helper.number("issueDividends", "percent", _percent);
|
||||||
if (percent < 0 || percent > 100) throw new Error("Invalid value for percent field! Must be numeric, greater than 0, and less than 100");
|
if (percent < 0 || percent > 100)
|
||||||
|
throw new Error("Invalid value for percent field! Must be numeric, greater than 0, and less than 100");
|
||||||
const corporation = getCorporation();
|
const corporation = getCorporation();
|
||||||
if (!corporation.public)
|
if (!corporation.public)
|
||||||
throw helper.makeRuntimeErrorMsg(`corporation.issueDividends`, `Your company has not gone public!`);
|
throw helper.makeRuntimeErrorMsg(`corporation.issueDividends`, `Your company has not gone public!`);
|
||||||
@ -759,9 +826,9 @@ export function NetscriptCorporation(
|
|||||||
|
|
||||||
// If you modify these objects you will affect them for real, it's not
|
// If you modify these objects you will affect them for real, it's not
|
||||||
// copies.
|
// copies.
|
||||||
getDivision: function (adivisionName: any): NSDivision {
|
getDivision: function (_divisionName: unknown): NSDivision {
|
||||||
checkAccess("getDivision");
|
checkAccess("getDivision");
|
||||||
const divisionName = helper.string("getDivision", "divisionName", adivisionName);
|
const divisionName = helper.string("getDivision", "divisionName", _divisionName);
|
||||||
const division = getDivision(divisionName);
|
const division = getDivision(divisionName);
|
||||||
return getSafeDivision(division);
|
return getSafeDivision(division);
|
||||||
},
|
},
|
||||||
@ -783,33 +850,34 @@ export function NetscriptCorporation(
|
|||||||
divisions: corporation.divisions.map((division): NSDivision => getSafeDivision(division)),
|
divisions: corporation.divisions.map((division): NSDivision => getSafeDivision(division)),
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
createCorporation: function (acorporationName: string, selfFund = true): boolean {
|
createCorporation: function (_corporationName: unknown, _selfFund: unknown = true): boolean {
|
||||||
const corporationName = helper.string("createCorporation", "corporationName", acorporationName);
|
const corporationName = helper.string("createCorporation", "corporationName", _corporationName);
|
||||||
|
const selfFund = helper.boolean(_selfFund);
|
||||||
return createCorporation(corporationName, selfFund);
|
return createCorporation(corporationName, selfFund);
|
||||||
},
|
},
|
||||||
hasUnlockUpgrade: function (aupgradeName: any): boolean {
|
hasUnlockUpgrade: function (_upgradeName: unknown): boolean {
|
||||||
checkAccess("hasUnlockUpgrade");
|
checkAccess("hasUnlockUpgrade");
|
||||||
const upgradeName = helper.string("hasUnlockUpgrade", "upgradeName", aupgradeName);
|
const upgradeName = helper.string("hasUnlockUpgrade", "upgradeName", _upgradeName);
|
||||||
return hasUnlockUpgrade(upgradeName);
|
return hasUnlockUpgrade(upgradeName);
|
||||||
},
|
},
|
||||||
getUnlockUpgradeCost: function (aupgradeName: any): number {
|
getUnlockUpgradeCost: function (_upgradeName: unknown): number {
|
||||||
checkAccess("getUnlockUpgradeCost");
|
checkAccess("getUnlockUpgradeCost");
|
||||||
const upgradeName = helper.string("getUnlockUpgradeCost", "upgradeName", aupgradeName);
|
const upgradeName = helper.string("getUnlockUpgradeCost", "upgradeName", _upgradeName);
|
||||||
return getUnlockUpgradeCost(upgradeName);
|
return getUnlockUpgradeCost(upgradeName);
|
||||||
},
|
},
|
||||||
getUpgradeLevel: function (aupgradeName: any): number {
|
getUpgradeLevel: function (_upgradeName: unknown): number {
|
||||||
checkAccess("hasUnlockUpgrade");
|
checkAccess("hasUnlockUpgrade");
|
||||||
const upgradeName = helper.string("getUpgradeLevel", "upgradeName", aupgradeName);
|
const upgradeName = helper.string("getUpgradeLevel", "upgradeName", _upgradeName);
|
||||||
return getUpgradeLevel(upgradeName);
|
return getUpgradeLevel(upgradeName);
|
||||||
},
|
},
|
||||||
getUpgradeLevelCost: function (aupgradeName: any): number {
|
getUpgradeLevelCost: function (_upgradeName: unknown): number {
|
||||||
checkAccess("getUpgradeLevelCost");
|
checkAccess("getUpgradeLevelCost");
|
||||||
const upgradeName = helper.string("getUpgradeLevelCost", "upgradeName", aupgradeName);
|
const upgradeName = helper.string("getUpgradeLevelCost", "upgradeName", _upgradeName);
|
||||||
return getUpgradeLevelCost(upgradeName);
|
return getUpgradeLevelCost(upgradeName);
|
||||||
},
|
},
|
||||||
getExpandIndustryCost: function (aindustryName: any): number {
|
getExpandIndustryCost: function (_industryName: unknown): number {
|
||||||
checkAccess("getExpandIndustryCost");
|
checkAccess("getExpandIndustryCost");
|
||||||
const industryName = helper.string("getExpandIndustryCost", "industryName", aindustryName);
|
const industryName = helper.string("getExpandIndustryCost", "industryName", _industryName);
|
||||||
return getExpandIndustryCost(industryName);
|
return getExpandIndustryCost(industryName);
|
||||||
},
|
},
|
||||||
getExpandCityCost: function (): number {
|
getExpandCityCost: function (): number {
|
||||||
@ -824,31 +892,31 @@ export function NetscriptCorporation(
|
|||||||
checkAccess("acceptInvestmentOffer");
|
checkAccess("acceptInvestmentOffer");
|
||||||
return acceptInvestmentOffer();
|
return acceptInvestmentOffer();
|
||||||
},
|
},
|
||||||
goPublic: function (anumShares: any): boolean {
|
goPublic: function (_numShares: unknown): boolean {
|
||||||
checkAccess("acceptInvestmentOffer");
|
checkAccess("acceptInvestmentOffer");
|
||||||
const numShares = helper.number("goPublic", "numShares", anumShares);
|
const numShares = helper.number("goPublic", "numShares", _numShares);
|
||||||
return goPublic(numShares);
|
return goPublic(numShares);
|
||||||
},
|
},
|
||||||
sellShares: function (anumShares: any): number {
|
sellShares: function (_numShares: unknown): number {
|
||||||
checkAccess("acceptInvestmentOffer");
|
checkAccess("acceptInvestmentOffer");
|
||||||
const numShares = helper.number("sellStock", "numShares", anumShares);
|
const numShares = helper.number("sellStock", "numShares", _numShares);
|
||||||
return SellShares(getCorporation(), player, numShares);
|
return SellShares(getCorporation(), player, numShares);
|
||||||
},
|
},
|
||||||
buyBackShares: function (anumShares: any): boolean {
|
buyBackShares: function (_numShares: unknown): boolean {
|
||||||
checkAccess("acceptInvestmentOffer");
|
checkAccess("acceptInvestmentOffer");
|
||||||
const numShares = helper.number("buyStock", "numShares", anumShares);
|
const numShares = helper.number("buyStock", "numShares", _numShares);
|
||||||
return BuyBackShares(getCorporation(), player, numShares);
|
return BuyBackShares(getCorporation(), player, numShares);
|
||||||
},
|
},
|
||||||
bribe: function (afactionName: string, aamountCash: any, aamountShares: any): boolean {
|
bribe: function (_factionName: unknown, _amountCash: unknown, _amountShares: unknown): boolean {
|
||||||
checkAccess("bribe");
|
checkAccess("bribe");
|
||||||
const factionName = helper.string("bribe", "factionName", afactionName);
|
const factionName = helper.string("bribe", "factionName", _factionName);
|
||||||
const amountCash = helper.number("bribe", "amountCash", aamountCash);
|
const amountCash = helper.number("bribe", "amountCash", _amountCash);
|
||||||
const amountShares = helper.number("bribe", "amountShares", aamountShares);
|
const amountShares = helper.number("bribe", "amountShares", _amountShares);
|
||||||
return bribe(factionName, amountCash, amountShares);
|
return bribe(factionName, amountCash, amountShares);
|
||||||
},
|
},
|
||||||
getBonusTime: function (): number {
|
getBonusTime: function (): number {
|
||||||
checkAccess("getBonusTime");
|
checkAccess("getBonusTime");
|
||||||
return Math.round(getCorporation().storedCycles / 5) * 1000;
|
return Math.round(getCorporation().storedCycles / 5) * 1000;
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user