Corp upgrades are now defined types

This commit is contained in:
Olivier Gagnon
2022-04-14 00:21:33 -04:00
parent a6ed2b9ed1
commit d8382ec762
9 changed files with 235 additions and 174 deletions

View File

@ -63,19 +63,19 @@ export function NewCity(corporation: ICorporation, division: IIndustry, city: st
} }
export function UnlockUpgrade(corporation: ICorporation, upgrade: CorporationUnlockUpgrade): void { export function UnlockUpgrade(corporation: ICorporation, upgrade: CorporationUnlockUpgrade): void {
if (corporation.funds < upgrade[1]) { if (corporation.funds < upgrade.price) {
throw new Error("Insufficient funds"); throw new Error("Insufficient funds");
} }
if (corporation.unlockUpgrades[upgrade[0]] === 1) { if (corporation.unlockUpgrades[upgrade.index] === 1) {
throw new Error(`You have already unlocked the ${upgrade[2]} upgrade!`); throw new Error(`You have already unlocked the ${upgrade.name} upgrade!`);
} }
corporation.unlock(upgrade); corporation.unlock(upgrade);
} }
export function LevelUpgrade(corporation: ICorporation, upgrade: CorporationUpgrade): void { export function LevelUpgrade(corporation: ICorporation, upgrade: CorporationUpgrade): void {
const baseCost = upgrade[1]; const baseCost = upgrade.basePrice;
const priceMult = upgrade[2]; const priceMult = upgrade.priceMult;
const level = corporation.upgrades[upgrade[0]]; const level = corporation.upgrades[upgrade.index];
const cost = baseCost * Math.pow(priceMult, level); const cost = baseCost * Math.pow(priceMult, level);
if (corporation.funds < cost) { if (corporation.funds < cost) {
throw new Error("Insufficient funds"); throw new Error("Insufficient funds");

View File

@ -264,8 +264,8 @@ export class Corporation {
//One time upgrades that unlock new features //One time upgrades that unlock new features
unlock(upgrade: CorporationUnlockUpgrade): void { unlock(upgrade: CorporationUnlockUpgrade): void {
const upgN = upgrade[0], const upgN = upgrade.index,
price = upgrade[1]; price = upgrade.price;
while (this.unlockUpgrades.length <= upgN) { while (this.unlockUpgrades.length <= upgN) {
this.unlockUpgrades.push(0); this.unlockUpgrades.push(0);
} }
@ -286,10 +286,10 @@ export class Corporation {
//Levelable upgrades //Levelable upgrades
upgrade(upgrade: CorporationUpgrade): void { upgrade(upgrade: CorporationUpgrade): void {
const upgN = upgrade[0], const upgN = upgrade.index,
basePrice = upgrade[1], basePrice = upgrade.basePrice,
priceMult = upgrade[2], priceMult = upgrade.priceMult,
upgradeAmt = upgrade[3]; //Amount by which the upgrade multiplier gets increased (additive) upgradeAmt = upgrade.benefit; //Amount by which the upgrade multiplier gets increased (additive)
while (this.upgrades.length <= upgN) { while (this.upgrades.length <= upgN) {
this.upgrades.push(0); this.upgrades.push(0);
} }

View File

@ -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 // Corporation Unlock Upgrades
// Upgrades for entire corporation, unlocks features, either you have it or you dont // Upgrades for entire corporation, unlocks features, either you have it or you dont
// The data structure is an array with the following format: export const CorporationUnlockUpgrades: Record<CorporationUnlockUpgradeIndex, CorporationUnlockUpgrade> = {
// [index in Corporation feature upgrades array, price, name, description]
export const CorporationUnlockUpgrades: IMap<CorporationUnlockUpgrade> = {
//Lets you export goods //Lets you export goods
"0": [ [CorporationUnlockUpgradeIndex.Export]: {
0, index: 0,
20e9, price: 20e9,
"Export", name: "Export",
desc:
"Develop infrastructure to export your materials to your other facilities. " + "Develop infrastructure to export your materials to your other facilities. " +
"This allows you to move materials around between different divisions and cities.", "This allows you to move materials around between different divisions and cities.",
], },
//Lets you buy exactly however many required materials you need for production //Lets you buy exactly however many required materials you need for production
"1": [ [CorporationUnlockUpgradeIndex.SmartSupply]: {
1, index: 1,
25e9, price: 25e9,
"Smart Supply", name: "Smart Supply",
desc:
"Use advanced AI to anticipate your supply needs. " + "Use advanced AI to anticipate your supply needs. " +
"This allows you to purchase exactly however many materials you need for production.", "This allows you to purchase exactly however many materials you need for production.",
], },
//Displays each material/product's demand //Displays each material/product's demand
"2": [ [CorporationUnlockUpgradeIndex.MarketResearchDemand]: {
2, index: 2,
5e9, price: 5e9,
"Market Research - Demand", name: "Market Research - Demand",
desc:
"Mine and analyze market data to determine the demand of all resources. " + "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.", "The demand attribute, which affects sales, will be displayed for every material and product.",
], },
//Display's each material/product's competition //Display's each material/product's competition
"3": [ [CorporationUnlockUpgradeIndex.MarketDataCompetition]: {
3, index: 3,
5e9, price: 5e9,
"Market Data - Competition", name: "Market Data - Competition",
desc:
"Mine and analyze market data to determine how much competition there is on the market " + "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 " + "for all resources. The competition attribute, which affects sales, will be displayed for " +
"every material and product.", "every material and product.",
], },
"4": [ [CorporationUnlockUpgradeIndex.VeChain]: {
4, index: 4,
10e9, price: 10e9,
"VeChain", name: "VeChain",
desc:
"Use AI and blockchain technology to identify where you can improve your supply chain systems. " + "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 " + "This upgrade will allow you to view a wide array of useful statistics about your " +
"Corporation.", "Corporation.",
], },
"5": [ [CorporationUnlockUpgradeIndex.ShadyAccounting]: {
5, index: 5,
500e12, price: 500e12,
"Shady Accounting", name: "Shady Accounting",
desc:
"Utilize unscrupulous accounting practices and pay off government officials to save money " + "Utilize unscrupulous accounting practices and pay off government officials to save money " +
"on taxes. This reduces the dividend tax rate by 5%.", "on taxes. This reduces the dividend tax rate by 5%.",
], },
"6": [ [CorporationUnlockUpgradeIndex.GovernmentPartnership]: {
6, index: 6,
2e15, price: 2e15,
"Government Partnership", name: "Government Partnership",
desc:
"Help national governments further their agendas in exchange for lowered taxes. " + "Help national governments further their agendas in exchange for lowered taxes. " +
"This reduces the dividend tax rate by 10%", "This reduces the dividend tax rate by 10%",
], },
"7": [7, 50e9, "Warehouse API", "Enables the warehouse API."], [CorporationUnlockUpgradeIndex.WarehouseAPI]: {
"8": [8, 50e9, "Office API", "Enables the office API."], 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.",
},
}; };

View File

@ -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 // Corporation Upgrades
// Upgrades for entire corporation, levelable upgrades // Upgrades for entire corporation, levelable upgrades
// The data structure is an array with the following format // The data structure is an array with the following format
// [index in Corporation upgrades array, base price, price mult, benefit mult (additive), name, desc] // [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 //Smart factories, increases production
"0": [ [CorporationUpgradeIndex.SmartFactories]: {
0, index: CorporationUpgradeIndex.SmartFactories,
2e9, basePrice: 2e9,
1.06, priceMult: 1.06,
0.03, benefit: 0.03,
"Smart Factories", name: "Smart Factories",
desc:
"Advanced AI automatically optimizes the operation and productivity " + "Advanced AI automatically optimizes the operation and productivity " +
"of factories. Each level of this upgrade increases your global production by 3% (additive).", "of factories. Each level of this upgrade increases your global production by 3% (additive).",
], },
//Smart warehouses, increases storage size //Smart warehouses, increases storage size
"1": [ [CorporationUpgradeIndex.SmartStorage]: {
1, index: CorporationUpgradeIndex.SmartStorage,
2e9, basePrice: 2e9,
1.06, priceMult: 1.06,
0.1, benefit: 0.1,
"Smart Storage", name: "Smart Storage",
desc:
"Advanced AI automatically optimizes your warehouse storage methods. " + "Advanced AI automatically optimizes your warehouse storage methods. " +
"Each level of this upgrade increases your global warehouse storage size by 10% (additive).", "Each level of this upgrade increases your global warehouse storage size by 10% (additive).",
], },
//Advertise through dreams, passive popularity/ awareness gain //Advertise through dreams, passive popularity/ awareness gain
"2": [ [CorporationUpgradeIndex.DreamSense]: {
2, index: CorporationUpgradeIndex.DreamSense,
4e9, basePrice: 4e9,
1.1, priceMult: 1.1,
0.001, benefit: 0.001,
"DreamSense", name: "DreamSense",
desc:
"Use DreamSense LCC Technologies to advertise your corporation " + "Use DreamSense LCC Technologies to advertise your corporation " +
"to consumers through their dreams. Each level of this upgrade provides a passive " + "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," + "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 " + "and in popularity by 0.001 / market cycle. A market cycle is approximately " +
"15 seconds.", "15 seconds.",
], },
//Makes advertising more effective //Makes advertising more effective
"3": [ [CorporationUpgradeIndex.WilsonAnalytics]: {
3, index: CorporationUpgradeIndex.WilsonAnalytics,
4e9, basePrice: 4e9,
1.5, priceMult: 1.5,
0.005, benefit: 0.005,
"Wilson Analytics", name: "Wilson Analytics",
desc:
"Purchase data and analysis from Wilson, a marketing research " + "Purchase data and analysis from Wilson, a marketing research " +
"firm. Each level of this upgrades increases the effectiveness of your " + "firm. Each level of this upgrades increases the effectiveness of your " +
"advertising by 0.5% (additive).", "advertising by 0.5% (additive).",
], },
//Augmentation for employees, increases cre //Augmentation for employees, increases cre
"4": [ [CorporationUpgradeIndex.NuoptimalNootropicInjectorImplants]: {
4, index: CorporationUpgradeIndex.NuoptimalNootropicInjectorImplants,
1e9, basePrice: 1e9,
1.06, priceMult: 1.06,
0.1, benefit: 0.1,
"Nuoptimal Nootropic Injector Implants", name: "Nuoptimal Nootropic Injector Implants",
desc:
"Purchase the Nuoptimal Nootropic " + "Purchase the Nuoptimal Nootropic " +
"Injector augmentation for your employees. Each level of this upgrade " + "Injector augmentation for your employees. Each level of this upgrade " +
"globally increases the creativity of your employees by 10% (additive).", "globally increases the creativity of your employees by 10% (additive).",
], },
//Augmentation for employees, increases cha //Augmentation for employees, increases cha
"5": [ [CorporationUpgradeIndex.SpeechProcessorImplants]: {
5, index: CorporationUpgradeIndex.SpeechProcessorImplants,
1e9, basePrice: 1e9,
1.06, priceMult: 1.06,
0.1, benefit: 0.1,
"Speech Processor Implants", name: "Speech Processor Implants",
desc:
"Purchase the Speech Processor augmentation for your employees. " + "Purchase the Speech Processor augmentation for your employees. " +
"Each level of this upgrade globally increases the charisma of your employees by 10% (additive).", "Each level of this upgrade globally increases the charisma of your employees by 10% (additive).",
], },
//Augmentation for employees, increases int //Augmentation for employees, increases int
"6": [ [CorporationUpgradeIndex.NeuralAccelerators]: {
6, index: CorporationUpgradeIndex.NeuralAccelerators,
1e9, basePrice: 1e9,
1.06, priceMult: 1.06,
0.1, benefit: 0.1,
"Neural Accelerators", name: "Neural Accelerators",
desc:
"Purchase the Neural Accelerator augmentation for your employees. " + "Purchase the Neural Accelerator augmentation for your employees. " +
"Each level of this upgrade globally increases the intelligence of your employees " + "Each level of this upgrade globally increases the intelligence of your employees " +
"by 10% (additive).", "by 10% (additive).",
], },
//Augmentation for employees, increases eff //Augmentation for employees, increases eff
"7": [ [CorporationUpgradeIndex.FocusWires]: {
7, index: CorporationUpgradeIndex.FocusWires,
1e9, basePrice: 1e9,
1.06, priceMult: 1.06,
0.1, benefit: 0.1,
"FocusWires", name: "FocusWires",
desc:
"Purchase the FocusWire augmentation for your employees. Each level " + "Purchase the FocusWire augmentation for your employees. Each level " +
"of this upgrade globally increases the efficiency of your employees by 10% (additive).", "of this upgrade globally increases the efficiency of your employees by 10% (additive).",
], },
//Improves sales of materials/products //Improves sales of materials/products
"8": [ [CorporationUpgradeIndex.ABCSalesBots]: {
8, index: CorporationUpgradeIndex.ABCSalesBots,
1e9, basePrice: 1e9,
1.07, priceMult: 1.07,
0.01, benefit: 0.01,
"ABC SalesBots", name: "ABC SalesBots",
desc:
"Always Be Closing. Purchase these robotic salesmen to increase the amount of " + "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 " + "materials and products you sell. Each level of this upgrade globally increases your sales " +
"by 1% (additive).", "by 1% (additive).",
], },
//Improves scientific research rate //Improves scientific research rate
"9": [ [CorporationUpgradeIndex.ProjectInsight]: {
9, index: CorporationUpgradeIndex.ProjectInsight,
5e9, basePrice: 5e9,
1.07, priceMult: 1.07,
0.05, benefit: 0.05,
"Project Insight", name: "Project Insight",
desc:
"Purchase 'Project Insight', a R&D service provided by the secretive " + "Purchase 'Project Insight', a R&D service provided by the secretive " +
"Fulcrum Technologies. Each level of this upgrade globally increases the amount of " + "Fulcrum Technologies. Each level of this upgrade globally increases the amount of " +
"Scientific Research you produce by 5% (additive).", "Scientific Research you produce by 5% (additive).",
], },
}; };

View File

@ -20,13 +20,13 @@ interface IProps {
export function LevelableUpgrade(props: IProps): React.ReactElement { export function LevelableUpgrade(props: IProps): React.ReactElement {
const corp = useCorporation(); const corp = useCorporation();
const data = props.upgrade; const data = props.upgrade;
const level = corp.upgrades[data[0]]; const level = corp.upgrades[data.index];
const baseCost = data[1]; const baseCost = data.basePrice;
const priceMult = data[2]; const priceMult = data.priceMult;
const cost = baseCost * Math.pow(priceMult, level); const cost = baseCost * Math.pow(priceMult, level);
const tooltip = data[5]; const tooltip = data.desc;
function onClick(): void { function onClick(): void {
if (corp.funds < cost) return; if (corp.funds < cost) return;
try { try {
@ -45,7 +45,7 @@ export function LevelableUpgrade(props: IProps): React.ReactElement {
</Button> </Button>
<Tooltip title={tooltip}> <Tooltip title={tooltip}>
<Typography> <Typography>
{data[4]} - lvl {level} {data.name} - lvl {level}
</Typography> </Typography>
</Tooltip> </Tooltip>
</Box> </Box>

View File

@ -13,7 +13,7 @@ import { Factions } from "../../Faction/Factions";
import { CorporationConstants } from "../data/Constants"; import { CorporationConstants } from "../data/Constants";
import { CorporationUnlockUpgrade, CorporationUnlockUpgrades } from "../data/CorporationUnlockUpgrades"; import { CorporationUnlockUpgrade, CorporationUnlockUpgrades } from "../data/CorporationUnlockUpgrades";
import { CorporationUpgrade, CorporationUpgrades } from "../data/CorporationUpgrades"; import { CorporationUpgrade, CorporationUpgradeIndex, CorporationUpgrades } from "../data/CorporationUpgrades";
import { CONSTANTS } from "../../Constants"; import { CONSTANTS } from "../../Constants";
import { numeralWrapper } from "../../ui/numeralFormat"; import { numeralWrapper } from "../../ui/numeralFormat";
@ -164,9 +164,9 @@ function Upgrades({ rerender }: IUpgradeProps): React.ReactElement {
<Typography variant="h4">Unlocks</Typography> <Typography variant="h4">Unlocks</Typography>
<Grid container> <Grid container>
{Object.values(CorporationUnlockUpgrades) {Object.values(CorporationUnlockUpgrades)
.filter((upgrade: CorporationUnlockUpgrade) => !corp.unlockUpgrades[upgrade[0]]) .filter((upgrade: CorporationUnlockUpgrade) => !corp.unlockUpgrades[upgrade.index])
.map((upgrade: CorporationUnlockUpgrade) => ( .map((upgrade: CorporationUnlockUpgrade) => (
<UnlockUpgrade rerender={rerender} upgradeData={upgrade} key={upgrade[0]} /> <UnlockUpgrade rerender={rerender} upgradeData={upgrade} key={upgrade.index} />
))} ))}
</Grid> </Grid>
</Paper> </Paper>
@ -174,9 +174,9 @@ function Upgrades({ rerender }: IUpgradeProps): React.ReactElement {
<Typography variant="h4">Upgrades</Typography> <Typography variant="h4">Upgrades</Typography>
<Grid container> <Grid container>
{corp.upgrades {corp.upgrades
.map((level: number, i: number) => CorporationUpgrades[i]) .map((level: number, i: number) => CorporationUpgrades[i as CorporationUpgradeIndex])
.map((upgrade: CorporationUpgrade) => ( .map((upgrade: CorporationUpgrade) => (
<LevelableUpgrade rerender={rerender} upgrade={upgrade} key={upgrade[0]} /> <LevelableUpgrade rerender={rerender} upgrade={upgrade} key={upgrade.index} />
))} ))}
</Grid> </Grid>
</Paper> </Paper>

View File

@ -20,9 +20,9 @@ interface IProps {
export function UnlockUpgrade(props: IProps): React.ReactElement { export function UnlockUpgrade(props: IProps): React.ReactElement {
const corp = useCorporation(); const corp = useCorporation();
const data = props.upgradeData; const data = props.upgradeData;
const tooltip = data[3]; const tooltip = data.desc;
function onClick(): void { function onClick(): void {
if (corp.funds < data[1]) return; if (corp.funds < data.price) return;
try { try {
UU(corp, props.upgradeData); UU(corp, props.upgradeData);
} catch (err) { } catch (err) {
@ -34,11 +34,11 @@ export function UnlockUpgrade(props: IProps): React.ReactElement {
return ( return (
<Grid item xs={4}> <Grid item xs={4}>
<Box display="flex" alignItems="center" flexDirection="row-reverse"> <Box display="flex" alignItems="center" flexDirection="row-reverse">
<Button disabled={corp.funds < data[1]} sx={{ mx: 1 }} onClick={onClick}> <Button disabled={corp.funds < data.price} sx={{ mx: 1 }} onClick={onClick}>
<MoneyCost money={data[1]} corp={corp} /> <MoneyCost money={data.price} corp={corp} />
</Button> </Button>
<Tooltip title={tooltip}> <Tooltip title={tooltip}>
<Typography>{data[2]}</Typography> <Typography>{data.name}</Typography>
</Tooltip> </Tooltip>
</Box> </Box>
</Grid> </Grid>

View File

@ -94,35 +94,35 @@ export function NetscriptCorporation(
function hasUnlockUpgrade(upgradeName: string): boolean { function hasUnlockUpgrade(upgradeName: string): boolean {
const corporation = getCorporation(); 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}'`); if (upgrade === undefined) throw new Error(`No upgrade named '${upgradeName}'`);
const upgN = upgrade[0]; const upgN = upgrade.index;
return corporation.unlockUpgrades[upgN] === 1; return corporation.unlockUpgrades[upgN] === 1;
} }
function getUnlockUpgradeCost(upgradeName: string): number { 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}'`); if (upgrade === undefined) throw new Error(`No upgrade named '${upgradeName}'`);
return upgrade[1]; return upgrade.price;
} }
function getUpgradeLevel(_upgradeName: string): number { function getUpgradeLevel(_upgradeName: string): number {
const upgradeName = helper.string("levelUpgrade", "upgradeName", _upgradeName); 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.name === upgradeName);
if (upgrade === undefined) throw new Error(`No upgrade named '${upgradeName}'`); if (upgrade === undefined) throw new Error(`No upgrade named '${upgradeName}'`);
const upgN = upgrade[0]; const upgN = upgrade.index;
return corporation.upgrades[upgN]; return corporation.upgrades[upgN];
} }
function getUpgradeLevelCost(_upgradeName: string): number { function getUpgradeLevelCost(_upgradeName: string): number {
const upgradeName = helper.string("levelUpgrade", "upgradeName", _upgradeName); 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.name === upgradeName);
if (upgrade === undefined) throw new Error(`No upgrade named '${upgradeName}'`); if (upgrade === undefined) throw new Error(`No upgrade named '${upgradeName}'`);
const upgN = upgrade[0]; const upgN = upgrade.index;
const baseCost = upgrade[1]; const baseCost = upgrade.basePrice;
const priceMult = upgrade[2]; const priceMult = upgrade.priceMult;
const level = corporation.upgrades[upgN]; const level = corporation.upgrades[upgN];
return baseCost * Math.pow(priceMult, level); return baseCost * Math.pow(priceMult, level);
} }
@ -861,7 +861,7 @@ export function NetscriptCorporation(
checkAccess("unlockUpgrade"); checkAccess("unlockUpgrade");
const upgradeName = helper.string("unlockUpgrade", "upgradeName", _upgradeName); 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.name === 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);
}, },
@ -869,7 +869,7 @@ export function NetscriptCorporation(
checkAccess("levelUpgrade"); checkAccess("levelUpgrade");
const upgradeName = helper.string("levelUpgrade", "upgradeName", _upgradeName); 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.name === 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);
}, },

View File

@ -1,5 +1,8 @@
import { Corporation } from "../../Corporation/Corporation"; import { Corporation } from "../../Corporation/Corporation";
import { CorporationUnlockUpgrades } from "../../Corporation/data/CorporationUnlockUpgrades"; import {
CorporationUnlockUpgradeIndex,
CorporationUnlockUpgrades,
} from "../../Corporation/data/CorporationUnlockUpgrades";
import { SourceFileFlags } from "../../SourceFile/SourceFileFlags"; import { SourceFileFlags } from "../../SourceFile/SourceFileFlags";
import { IPlayer } from "../IPlayer"; import { IPlayer } from "../IPlayer";
@ -20,8 +23,8 @@ export function startCorporation(this: IPlayer, corpName: string, additionalShar
}); });
if (SourceFileFlags[3] === 3) { if (SourceFileFlags[3] === 3) {
const warehouseApi = CorporationUnlockUpgrades["7"][0]; const warehouseApi = CorporationUnlockUpgrades[CorporationUnlockUpgradeIndex.WarehouseAPI].index;
const OfficeApi = CorporationUnlockUpgrades["8"][0]; const OfficeApi = CorporationUnlockUpgrades[CorporationUnlockUpgradeIndex.OfficeAPI].index;
this.corporation.unlockUpgrades[warehouseApi] = 1; this.corporation.unlockUpgrades[warehouseApi] = 1;
this.corporation.unlockUpgrades[OfficeApi] = 1; this.corporation.unlockUpgrades[OfficeApi] = 1;