mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-26 16:07:33 +01:00
Corp upgrades are now defined types
This commit is contained in:
parent
a6ed2b9ed1
commit
d8382ec762
@ -63,19 +63,19 @@ export function NewCity(corporation: ICorporation, division: IIndustry, city: st
|
||||
}
|
||||
|
||||
export function UnlockUpgrade(corporation: ICorporation, upgrade: CorporationUnlockUpgrade): void {
|
||||
if (corporation.funds < upgrade[1]) {
|
||||
if (corporation.funds < upgrade.price) {
|
||||
throw new Error("Insufficient funds");
|
||||
}
|
||||
if (corporation.unlockUpgrades[upgrade[0]] === 1) {
|
||||
throw new Error(`You have already unlocked the ${upgrade[2]} upgrade!`);
|
||||
if (corporation.unlockUpgrades[upgrade.index] === 1) {
|
||||
throw new Error(`You have already unlocked the ${upgrade.name} upgrade!`);
|
||||
}
|
||||
corporation.unlock(upgrade);
|
||||
}
|
||||
|
||||
export function LevelUpgrade(corporation: ICorporation, upgrade: CorporationUpgrade): void {
|
||||
const baseCost = upgrade[1];
|
||||
const priceMult = upgrade[2];
|
||||
const level = corporation.upgrades[upgrade[0]];
|
||||
const baseCost = upgrade.basePrice;
|
||||
const priceMult = upgrade.priceMult;
|
||||
const level = corporation.upgrades[upgrade.index];
|
||||
const cost = baseCost * Math.pow(priceMult, level);
|
||||
if (corporation.funds < cost) {
|
||||
throw new Error("Insufficient funds");
|
||||
|
@ -264,8 +264,8 @@ export class Corporation {
|
||||
|
||||
//One time upgrades that unlock new features
|
||||
unlock(upgrade: CorporationUnlockUpgrade): void {
|
||||
const upgN = upgrade[0],
|
||||
price = upgrade[1];
|
||||
const upgN = upgrade.index,
|
||||
price = upgrade.price;
|
||||
while (this.unlockUpgrades.length <= upgN) {
|
||||
this.unlockUpgrades.push(0);
|
||||
}
|
||||
@ -286,10 +286,10 @@ export class Corporation {
|
||||
|
||||
//Levelable upgrades
|
||||
upgrade(upgrade: CorporationUpgrade): void {
|
||||
const upgN = upgrade[0],
|
||||
basePrice = upgrade[1],
|
||||
priceMult = upgrade[2],
|
||||
upgradeAmt = upgrade[3]; //Amount by which the upgrade multiplier gets increased (additive)
|
||||
const upgN = upgrade.index,
|
||||
basePrice = upgrade.basePrice,
|
||||
priceMult = upgrade.priceMult,
|
||||
upgradeAmt = upgrade.benefit; //Amount by which the upgrade multiplier gets increased (additive)
|
||||
while (this.upgrades.length <= upgN) {
|
||||
this.upgrades.push(0);
|
||||
}
|
||||
|
@ -1,70 +1,100 @@
|
||||
import { IMap } from "../../types";
|
||||
export interface CorporationUnlockUpgrade {
|
||||
index: number;
|
||||
price: number;
|
||||
name: string;
|
||||
desc: string;
|
||||
}
|
||||
|
||||
export type CorporationUnlockUpgrade = [number, number, string, string];
|
||||
export enum CorporationUnlockUpgradeIndex {
|
||||
Export = 0,
|
||||
SmartSupply = 1,
|
||||
MarketResearchDemand = 2,
|
||||
MarketDataCompetition = 3,
|
||||
VeChain = 4,
|
||||
ShadyAccounting = 5,
|
||||
GovernmentPartnership = 6,
|
||||
WarehouseAPI = 7,
|
||||
OfficeAPI = 8,
|
||||
}
|
||||
|
||||
// Corporation Unlock Upgrades
|
||||
// Upgrades for entire corporation, unlocks features, either you have it or you dont
|
||||
// The data structure is an array with the following format:
|
||||
// [index in Corporation feature upgrades array, price, name, description]
|
||||
export const CorporationUnlockUpgrades: IMap<CorporationUnlockUpgrade> = {
|
||||
export const CorporationUnlockUpgrades: Record<CorporationUnlockUpgradeIndex, CorporationUnlockUpgrade> = {
|
||||
//Lets you export goods
|
||||
"0": [
|
||||
0,
|
||||
20e9,
|
||||
"Export",
|
||||
"Develop infrastructure to export your materials to your other facilities. " +
|
||||
[CorporationUnlockUpgradeIndex.Export]: {
|
||||
index: 0,
|
||||
price: 20e9,
|
||||
name: "Export",
|
||||
desc:
|
||||
"Develop infrastructure to export your materials to your other facilities. " +
|
||||
"This allows you to move materials around between different divisions and cities.",
|
||||
],
|
||||
},
|
||||
|
||||
//Lets you buy exactly however many required materials you need for production
|
||||
"1": [
|
||||
1,
|
||||
25e9,
|
||||
"Smart Supply",
|
||||
"Use advanced AI to anticipate your supply needs. " +
|
||||
[CorporationUnlockUpgradeIndex.SmartSupply]: {
|
||||
index: 1,
|
||||
price: 25e9,
|
||||
name: "Smart Supply",
|
||||
desc:
|
||||
"Use advanced AI to anticipate your supply needs. " +
|
||||
"This allows you to purchase exactly however many materials you need for production.",
|
||||
],
|
||||
},
|
||||
|
||||
//Displays each material/product's demand
|
||||
"2": [
|
||||
2,
|
||||
5e9,
|
||||
"Market Research - Demand",
|
||||
"Mine and analyze market data to determine the demand of all resources. " +
|
||||
[CorporationUnlockUpgradeIndex.MarketResearchDemand]: {
|
||||
index: 2,
|
||||
price: 5e9,
|
||||
name: "Market Research - Demand",
|
||||
desc:
|
||||
"Mine and analyze market data to determine the demand of all resources. " +
|
||||
"The demand attribute, which affects sales, will be displayed for every material and product.",
|
||||
],
|
||||
},
|
||||
|
||||
//Display's each material/product's competition
|
||||
"3": [
|
||||
3,
|
||||
5e9,
|
||||
"Market Data - Competition",
|
||||
"Mine and analyze market data to determine how much competition there is on the market " +
|
||||
[CorporationUnlockUpgradeIndex.MarketDataCompetition]: {
|
||||
index: 3,
|
||||
price: 5e9,
|
||||
name: "Market Data - Competition",
|
||||
desc:
|
||||
"Mine and analyze market data to determine how much competition there is on the market " +
|
||||
"for all resources. The competition attribute, which affects sales, will be displayed for " +
|
||||
"every material and product.",
|
||||
],
|
||||
"4": [
|
||||
4,
|
||||
10e9,
|
||||
"VeChain",
|
||||
"Use AI and blockchain technology to identify where you can improve your supply chain systems. " +
|
||||
},
|
||||
[CorporationUnlockUpgradeIndex.VeChain]: {
|
||||
index: 4,
|
||||
price: 10e9,
|
||||
name: "VeChain",
|
||||
desc:
|
||||
"Use AI and blockchain technology to identify where you can improve your supply chain systems. " +
|
||||
"This upgrade will allow you to view a wide array of useful statistics about your " +
|
||||
"Corporation.",
|
||||
],
|
||||
"5": [
|
||||
5,
|
||||
500e12,
|
||||
"Shady Accounting",
|
||||
"Utilize unscrupulous accounting practices and pay off government officials to save money " +
|
||||
},
|
||||
[CorporationUnlockUpgradeIndex.ShadyAccounting]: {
|
||||
index: 5,
|
||||
price: 500e12,
|
||||
name: "Shady Accounting",
|
||||
desc:
|
||||
"Utilize unscrupulous accounting practices and pay off government officials to save money " +
|
||||
"on taxes. This reduces the dividend tax rate by 5%.",
|
||||
],
|
||||
"6": [
|
||||
6,
|
||||
2e15,
|
||||
"Government Partnership",
|
||||
"Help national governments further their agendas in exchange for lowered taxes. " +
|
||||
},
|
||||
[CorporationUnlockUpgradeIndex.GovernmentPartnership]: {
|
||||
index: 6,
|
||||
price: 2e15,
|
||||
name: "Government Partnership",
|
||||
desc:
|
||||
"Help national governments further their agendas in exchange for lowered taxes. " +
|
||||
"This reduces the dividend tax rate by 10%",
|
||||
],
|
||||
"7": [7, 50e9, "Warehouse API", "Enables the warehouse API."],
|
||||
"8": [8, 50e9, "Office API", "Enables the office API."],
|
||||
},
|
||||
[CorporationUnlockUpgradeIndex.WarehouseAPI]: {
|
||||
index: 7,
|
||||
price: 50e9,
|
||||
name: "Warehouse API",
|
||||
desc: "Enables the warehouse API.",
|
||||
},
|
||||
[CorporationUnlockUpgradeIndex.OfficeAPI]: {
|
||||
index: 8,
|
||||
price: 50e9,
|
||||
name: "Office API",
|
||||
desc: "Enables the office API.",
|
||||
},
|
||||
};
|
||||
|
@ -1,127 +1,155 @@
|
||||
import { IMap } from "../../types";
|
||||
export interface CorporationUpgrade {
|
||||
index: number;
|
||||
basePrice: number;
|
||||
priceMult: number;
|
||||
benefit: number;
|
||||
name: string;
|
||||
desc: string;
|
||||
}
|
||||
|
||||
export type CorporationUpgrade = [number, number, number, number, string, string];
|
||||
export enum CorporationUpgradeIndex {
|
||||
SmartFactories = 0,
|
||||
SmartStorage = 1,
|
||||
DreamSense = 2,
|
||||
WilsonAnalytics = 3,
|
||||
NuoptimalNootropicInjectorImplants = 4,
|
||||
SpeechProcessorImplants = 5,
|
||||
NeuralAccelerators = 6,
|
||||
FocusWires = 7,
|
||||
ABCSalesBots = 8,
|
||||
ProjectInsight = 9,
|
||||
}
|
||||
|
||||
// Corporation Upgrades
|
||||
// Upgrades for entire corporation, levelable upgrades
|
||||
// The data structure is an array with the following format
|
||||
// [index in Corporation upgrades array, base price, price mult, benefit mult (additive), name, desc]
|
||||
export const CorporationUpgrades: IMap<CorporationUpgrade> = {
|
||||
export const CorporationUpgrades: Record<CorporationUpgradeIndex, CorporationUpgrade> = {
|
||||
//Smart factories, increases production
|
||||
"0": [
|
||||
0,
|
||||
2e9,
|
||||
1.06,
|
||||
0.03,
|
||||
"Smart Factories",
|
||||
"Advanced AI automatically optimizes the operation and productivity " +
|
||||
[CorporationUpgradeIndex.SmartFactories]: {
|
||||
index: CorporationUpgradeIndex.SmartFactories,
|
||||
basePrice: 2e9,
|
||||
priceMult: 1.06,
|
||||
benefit: 0.03,
|
||||
name: "Smart Factories",
|
||||
desc:
|
||||
"Advanced AI automatically optimizes the operation and productivity " +
|
||||
"of factories. Each level of this upgrade increases your global production by 3% (additive).",
|
||||
],
|
||||
},
|
||||
|
||||
//Smart warehouses, increases storage size
|
||||
"1": [
|
||||
1,
|
||||
2e9,
|
||||
1.06,
|
||||
0.1,
|
||||
"Smart Storage",
|
||||
"Advanced AI automatically optimizes your warehouse storage methods. " +
|
||||
[CorporationUpgradeIndex.SmartStorage]: {
|
||||
index: CorporationUpgradeIndex.SmartStorage,
|
||||
basePrice: 2e9,
|
||||
priceMult: 1.06,
|
||||
benefit: 0.1,
|
||||
name: "Smart Storage",
|
||||
desc:
|
||||
"Advanced AI automatically optimizes your warehouse storage methods. " +
|
||||
"Each level of this upgrade increases your global warehouse storage size by 10% (additive).",
|
||||
],
|
||||
},
|
||||
|
||||
//Advertise through dreams, passive popularity/ awareness gain
|
||||
"2": [
|
||||
2,
|
||||
4e9,
|
||||
1.1,
|
||||
0.001,
|
||||
"DreamSense",
|
||||
"Use DreamSense LCC Technologies to advertise your corporation " +
|
||||
[CorporationUpgradeIndex.DreamSense]: {
|
||||
index: CorporationUpgradeIndex.DreamSense,
|
||||
basePrice: 4e9,
|
||||
priceMult: 1.1,
|
||||
benefit: 0.001,
|
||||
name: "DreamSense",
|
||||
desc:
|
||||
"Use DreamSense LCC Technologies to advertise your corporation " +
|
||||
"to consumers through their dreams. Each level of this upgrade provides a passive " +
|
||||
"increase in awareness of all of your companies (divisions) by 0.004 / market cycle," +
|
||||
"and in popularity by 0.001 / market cycle. A market cycle is approximately " +
|
||||
"15 seconds.",
|
||||
],
|
||||
},
|
||||
|
||||
//Makes advertising more effective
|
||||
"3": [
|
||||
3,
|
||||
4e9,
|
||||
1.5,
|
||||
0.005,
|
||||
"Wilson Analytics",
|
||||
"Purchase data and analysis from Wilson, a marketing research " +
|
||||
[CorporationUpgradeIndex.WilsonAnalytics]: {
|
||||
index: CorporationUpgradeIndex.WilsonAnalytics,
|
||||
basePrice: 4e9,
|
||||
priceMult: 1.5,
|
||||
benefit: 0.005,
|
||||
name: "Wilson Analytics",
|
||||
desc:
|
||||
"Purchase data and analysis from Wilson, a marketing research " +
|
||||
"firm. Each level of this upgrades increases the effectiveness of your " +
|
||||
"advertising by 0.5% (additive).",
|
||||
],
|
||||
},
|
||||
|
||||
//Augmentation for employees, increases cre
|
||||
"4": [
|
||||
4,
|
||||
1e9,
|
||||
1.06,
|
||||
0.1,
|
||||
"Nuoptimal Nootropic Injector Implants",
|
||||
"Purchase the Nuoptimal Nootropic " +
|
||||
[CorporationUpgradeIndex.NuoptimalNootropicInjectorImplants]: {
|
||||
index: CorporationUpgradeIndex.NuoptimalNootropicInjectorImplants,
|
||||
basePrice: 1e9,
|
||||
priceMult: 1.06,
|
||||
benefit: 0.1,
|
||||
name: "Nuoptimal Nootropic Injector Implants",
|
||||
desc:
|
||||
"Purchase the Nuoptimal Nootropic " +
|
||||
"Injector augmentation for your employees. Each level of this upgrade " +
|
||||
"globally increases the creativity of your employees by 10% (additive).",
|
||||
],
|
||||
},
|
||||
|
||||
//Augmentation for employees, increases cha
|
||||
"5": [
|
||||
5,
|
||||
1e9,
|
||||
1.06,
|
||||
0.1,
|
||||
"Speech Processor Implants",
|
||||
"Purchase the Speech Processor augmentation for your employees. " +
|
||||
[CorporationUpgradeIndex.SpeechProcessorImplants]: {
|
||||
index: CorporationUpgradeIndex.SpeechProcessorImplants,
|
||||
basePrice: 1e9,
|
||||
priceMult: 1.06,
|
||||
benefit: 0.1,
|
||||
name: "Speech Processor Implants",
|
||||
desc:
|
||||
"Purchase the Speech Processor augmentation for your employees. " +
|
||||
"Each level of this upgrade globally increases the charisma of your employees by 10% (additive).",
|
||||
],
|
||||
},
|
||||
|
||||
//Augmentation for employees, increases int
|
||||
"6": [
|
||||
6,
|
||||
1e9,
|
||||
1.06,
|
||||
0.1,
|
||||
"Neural Accelerators",
|
||||
"Purchase the Neural Accelerator augmentation for your employees. " +
|
||||
[CorporationUpgradeIndex.NeuralAccelerators]: {
|
||||
index: CorporationUpgradeIndex.NeuralAccelerators,
|
||||
basePrice: 1e9,
|
||||
priceMult: 1.06,
|
||||
benefit: 0.1,
|
||||
name: "Neural Accelerators",
|
||||
desc:
|
||||
"Purchase the Neural Accelerator augmentation for your employees. " +
|
||||
"Each level of this upgrade globally increases the intelligence of your employees " +
|
||||
"by 10% (additive).",
|
||||
],
|
||||
},
|
||||
|
||||
//Augmentation for employees, increases eff
|
||||
"7": [
|
||||
7,
|
||||
1e9,
|
||||
1.06,
|
||||
0.1,
|
||||
"FocusWires",
|
||||
"Purchase the FocusWire augmentation for your employees. Each level " +
|
||||
[CorporationUpgradeIndex.FocusWires]: {
|
||||
index: CorporationUpgradeIndex.FocusWires,
|
||||
basePrice: 1e9,
|
||||
priceMult: 1.06,
|
||||
benefit: 0.1,
|
||||
name: "FocusWires",
|
||||
desc:
|
||||
"Purchase the FocusWire augmentation for your employees. Each level " +
|
||||
"of this upgrade globally increases the efficiency of your employees by 10% (additive).",
|
||||
],
|
||||
},
|
||||
|
||||
//Improves sales of materials/products
|
||||
"8": [
|
||||
8,
|
||||
1e9,
|
||||
1.07,
|
||||
0.01,
|
||||
"ABC SalesBots",
|
||||
"Always Be Closing. Purchase these robotic salesmen to increase the amount of " +
|
||||
[CorporationUpgradeIndex.ABCSalesBots]: {
|
||||
index: CorporationUpgradeIndex.ABCSalesBots,
|
||||
basePrice: 1e9,
|
||||
priceMult: 1.07,
|
||||
benefit: 0.01,
|
||||
name: "ABC SalesBots",
|
||||
desc:
|
||||
"Always Be Closing. Purchase these robotic salesmen to increase the amount of " +
|
||||
"materials and products you sell. Each level of this upgrade globally increases your sales " +
|
||||
"by 1% (additive).",
|
||||
],
|
||||
},
|
||||
|
||||
//Improves scientific research rate
|
||||
"9": [
|
||||
9,
|
||||
5e9,
|
||||
1.07,
|
||||
0.05,
|
||||
"Project Insight",
|
||||
"Purchase 'Project Insight', a R&D service provided by the secretive " +
|
||||
[CorporationUpgradeIndex.ProjectInsight]: {
|
||||
index: CorporationUpgradeIndex.ProjectInsight,
|
||||
basePrice: 5e9,
|
||||
priceMult: 1.07,
|
||||
benefit: 0.05,
|
||||
name: "Project Insight",
|
||||
desc:
|
||||
"Purchase 'Project Insight', a R&D service provided by the secretive " +
|
||||
"Fulcrum Technologies. Each level of this upgrade globally increases the amount of " +
|
||||
"Scientific Research you produce by 5% (additive).",
|
||||
],
|
||||
},
|
||||
};
|
||||
|
@ -20,13 +20,13 @@ interface IProps {
|
||||
export function LevelableUpgrade(props: IProps): React.ReactElement {
|
||||
const corp = useCorporation();
|
||||
const data = props.upgrade;
|
||||
const level = corp.upgrades[data[0]];
|
||||
const level = corp.upgrades[data.index];
|
||||
|
||||
const baseCost = data[1];
|
||||
const priceMult = data[2];
|
||||
const baseCost = data.basePrice;
|
||||
const priceMult = data.priceMult;
|
||||
const cost = baseCost * Math.pow(priceMult, level);
|
||||
|
||||
const tooltip = data[5];
|
||||
const tooltip = data.desc;
|
||||
function onClick(): void {
|
||||
if (corp.funds < cost) return;
|
||||
try {
|
||||
@ -45,7 +45,7 @@ export function LevelableUpgrade(props: IProps): React.ReactElement {
|
||||
</Button>
|
||||
<Tooltip title={tooltip}>
|
||||
<Typography>
|
||||
{data[4]} - lvl {level}
|
||||
{data.name} - lvl {level}
|
||||
</Typography>
|
||||
</Tooltip>
|
||||
</Box>
|
||||
|
@ -13,7 +13,7 @@ import { Factions } from "../../Faction/Factions";
|
||||
|
||||
import { CorporationConstants } from "../data/Constants";
|
||||
import { CorporationUnlockUpgrade, CorporationUnlockUpgrades } from "../data/CorporationUnlockUpgrades";
|
||||
import { CorporationUpgrade, CorporationUpgrades } from "../data/CorporationUpgrades";
|
||||
import { CorporationUpgrade, CorporationUpgradeIndex, CorporationUpgrades } from "../data/CorporationUpgrades";
|
||||
|
||||
import { CONSTANTS } from "../../Constants";
|
||||
import { numeralWrapper } from "../../ui/numeralFormat";
|
||||
@ -164,9 +164,9 @@ function Upgrades({ rerender }: IUpgradeProps): React.ReactElement {
|
||||
<Typography variant="h4">Unlocks</Typography>
|
||||
<Grid container>
|
||||
{Object.values(CorporationUnlockUpgrades)
|
||||
.filter((upgrade: CorporationUnlockUpgrade) => !corp.unlockUpgrades[upgrade[0]])
|
||||
.filter((upgrade: CorporationUnlockUpgrade) => !corp.unlockUpgrades[upgrade.index])
|
||||
.map((upgrade: CorporationUnlockUpgrade) => (
|
||||
<UnlockUpgrade rerender={rerender} upgradeData={upgrade} key={upgrade[0]} />
|
||||
<UnlockUpgrade rerender={rerender} upgradeData={upgrade} key={upgrade.index} />
|
||||
))}
|
||||
</Grid>
|
||||
</Paper>
|
||||
@ -174,9 +174,9 @@ function Upgrades({ rerender }: IUpgradeProps): React.ReactElement {
|
||||
<Typography variant="h4">Upgrades</Typography>
|
||||
<Grid container>
|
||||
{corp.upgrades
|
||||
.map((level: number, i: number) => CorporationUpgrades[i])
|
||||
.map((level: number, i: number) => CorporationUpgrades[i as CorporationUpgradeIndex])
|
||||
.map((upgrade: CorporationUpgrade) => (
|
||||
<LevelableUpgrade rerender={rerender} upgrade={upgrade} key={upgrade[0]} />
|
||||
<LevelableUpgrade rerender={rerender} upgrade={upgrade} key={upgrade.index} />
|
||||
))}
|
||||
</Grid>
|
||||
</Paper>
|
||||
|
@ -20,9 +20,9 @@ interface IProps {
|
||||
export function UnlockUpgrade(props: IProps): React.ReactElement {
|
||||
const corp = useCorporation();
|
||||
const data = props.upgradeData;
|
||||
const tooltip = data[3];
|
||||
const tooltip = data.desc;
|
||||
function onClick(): void {
|
||||
if (corp.funds < data[1]) return;
|
||||
if (corp.funds < data.price) return;
|
||||
try {
|
||||
UU(corp, props.upgradeData);
|
||||
} catch (err) {
|
||||
@ -34,11 +34,11 @@ export function UnlockUpgrade(props: IProps): React.ReactElement {
|
||||
return (
|
||||
<Grid item xs={4}>
|
||||
<Box display="flex" alignItems="center" flexDirection="row-reverse">
|
||||
<Button disabled={corp.funds < data[1]} sx={{ mx: 1 }} onClick={onClick}>
|
||||
<MoneyCost money={data[1]} corp={corp} />
|
||||
<Button disabled={corp.funds < data.price} sx={{ mx: 1 }} onClick={onClick}>
|
||||
<MoneyCost money={data.price} corp={corp} />
|
||||
</Button>
|
||||
<Tooltip title={tooltip}>
|
||||
<Typography>{data[2]}</Typography>
|
||||
<Typography>{data.name}</Typography>
|
||||
</Tooltip>
|
||||
</Box>
|
||||
</Grid>
|
||||
|
@ -94,35 +94,35 @@ export function NetscriptCorporation(
|
||||
|
||||
function hasUnlockUpgrade(upgradeName: string): boolean {
|
||||
const corporation = getCorporation();
|
||||
const upgrade = Object.values(CorporationUnlockUpgrades).find((upgrade) => upgrade[2] === upgradeName);
|
||||
const upgrade = Object.values(CorporationUnlockUpgrades).find((upgrade) => upgrade.name === upgradeName);
|
||||
if (upgrade === undefined) throw new Error(`No upgrade named '${upgradeName}'`);
|
||||
const upgN = upgrade[0];
|
||||
const upgN = upgrade.index;
|
||||
return corporation.unlockUpgrades[upgN] === 1;
|
||||
}
|
||||
|
||||
function getUnlockUpgradeCost(upgradeName: string): number {
|
||||
const upgrade = Object.values(CorporationUnlockUpgrades).find((upgrade) => upgrade[2] === upgradeName);
|
||||
const upgrade = Object.values(CorporationUnlockUpgrades).find((upgrade) => upgrade.name === upgradeName);
|
||||
if (upgrade === undefined) throw new Error(`No upgrade named '${upgradeName}'`);
|
||||
return upgrade[1];
|
||||
return upgrade.price;
|
||||
}
|
||||
|
||||
function getUpgradeLevel(_upgradeName: string): number {
|
||||
const upgradeName = helper.string("levelUpgrade", "upgradeName", _upgradeName);
|
||||
const corporation = getCorporation();
|
||||
const upgrade = Object.values(CorporationUpgrades).find((upgrade) => upgrade[4] === upgradeName);
|
||||
const upgrade = Object.values(CorporationUpgrades).find((upgrade) => upgrade.name === upgradeName);
|
||||
if (upgrade === undefined) throw new Error(`No upgrade named '${upgradeName}'`);
|
||||
const upgN = upgrade[0];
|
||||
const upgN = upgrade.index;
|
||||
return corporation.upgrades[upgN];
|
||||
}
|
||||
|
||||
function getUpgradeLevelCost(_upgradeName: string): number {
|
||||
const upgradeName = helper.string("levelUpgrade", "upgradeName", _upgradeName);
|
||||
const corporation = getCorporation();
|
||||
const upgrade = Object.values(CorporationUpgrades).find((upgrade) => upgrade[4] === upgradeName);
|
||||
const upgrade = Object.values(CorporationUpgrades).find((upgrade) => upgrade.name === upgradeName);
|
||||
if (upgrade === undefined) throw new Error(`No upgrade named '${upgradeName}'`);
|
||||
const upgN = upgrade[0];
|
||||
const baseCost = upgrade[1];
|
||||
const priceMult = upgrade[2];
|
||||
const upgN = upgrade.index;
|
||||
const baseCost = upgrade.basePrice;
|
||||
const priceMult = upgrade.priceMult;
|
||||
const level = corporation.upgrades[upgN];
|
||||
return baseCost * Math.pow(priceMult, level);
|
||||
}
|
||||
@ -861,7 +861,7 @@ export function NetscriptCorporation(
|
||||
checkAccess("unlockUpgrade");
|
||||
const upgradeName = helper.string("unlockUpgrade", "upgradeName", _upgradeName);
|
||||
const corporation = getCorporation();
|
||||
const upgrade = Object.values(CorporationUnlockUpgrades).find((upgrade) => upgrade[2] === upgradeName);
|
||||
const upgrade = Object.values(CorporationUnlockUpgrades).find((upgrade) => upgrade.name === upgradeName);
|
||||
if (upgrade === undefined) throw new Error(`No upgrade named '${upgradeName}'`);
|
||||
UnlockUpgrade(corporation, upgrade);
|
||||
},
|
||||
@ -869,7 +869,7 @@ export function NetscriptCorporation(
|
||||
checkAccess("levelUpgrade");
|
||||
const upgradeName = helper.string("levelUpgrade", "upgradeName", _upgradeName);
|
||||
const corporation = getCorporation();
|
||||
const upgrade = Object.values(CorporationUpgrades).find((upgrade) => upgrade[4] === upgradeName);
|
||||
const upgrade = Object.values(CorporationUpgrades).find((upgrade) => upgrade.name === upgradeName);
|
||||
if (upgrade === undefined) throw new Error(`No upgrade named '${upgradeName}'`);
|
||||
LevelUpgrade(corporation, upgrade);
|
||||
},
|
||||
|
@ -1,5 +1,8 @@
|
||||
import { Corporation } from "../../Corporation/Corporation";
|
||||
import { CorporationUnlockUpgrades } from "../../Corporation/data/CorporationUnlockUpgrades";
|
||||
import {
|
||||
CorporationUnlockUpgradeIndex,
|
||||
CorporationUnlockUpgrades,
|
||||
} from "../../Corporation/data/CorporationUnlockUpgrades";
|
||||
import { SourceFileFlags } from "../../SourceFile/SourceFileFlags";
|
||||
import { IPlayer } from "../IPlayer";
|
||||
|
||||
@ -20,8 +23,8 @@ export function startCorporation(this: IPlayer, corpName: string, additionalShar
|
||||
});
|
||||
|
||||
if (SourceFileFlags[3] === 3) {
|
||||
const warehouseApi = CorporationUnlockUpgrades["7"][0];
|
||||
const OfficeApi = CorporationUnlockUpgrades["8"][0];
|
||||
const warehouseApi = CorporationUnlockUpgrades[CorporationUnlockUpgradeIndex.WarehouseAPI].index;
|
||||
const OfficeApi = CorporationUnlockUpgrades[CorporationUnlockUpgradeIndex.OfficeAPI].index;
|
||||
|
||||
this.corporation.unlockUpgrades[warehouseApi] = 1;
|
||||
this.corporation.unlockUpgrades[OfficeApi] = 1;
|
||||
|
Loading…
Reference in New Issue
Block a user