throw error without bulk purchase reasearch

This commit is contained in:
phyzical 2022-01-17 20:00:19 +08:00
parent 6f2924dc0d
commit dd47a8baa0
4 changed files with 5 additions and 4 deletions

@ -270,6 +270,7 @@ export function SellShares(corporation: ICorporation, player: IPlayer, numShares
if (numShares < 0) throw new Error("Invalid value for number of shares");
if (numShares > corporation.numShares) throw new Error("You don't have that many shares to sell!");
if (!corporation.public) throw new Error("You haven't gone public!");
if (corporation.shareSaleCooldown) throw new Error("Share sale on cooldown!");
const stockSaleResults = corporation.calculateShareSale(numShares);
const profit = stockSaleResults[0];
const newSharePrice = stockSaleResults[1];

@ -43,7 +43,7 @@ export function BuybackSharesModal(props: IProps): React.ReactElement {
props.onClose();
props.rerender();
}
catch (e) {
catch (err) {
dialogBoxCreate(err + "");
}
}

@ -60,7 +60,7 @@ function BulkPurchaseSection(props: IBPProps): React.ReactElement {
function bulkPurchase(): void {
try {
BulkPurchase(corp, props.warehouse, props.mat, buyAmt);
BulkPurchase(corp, props.warehouse, props.mat, parseFloat(buyAmt));
props.onClose();
} catch (err) {
dialogBoxCreate(err + "");

@ -63,7 +63,6 @@ import { CorporationConstants } from "../Corporation/data/Constants";
import { IndustryUpgrades } from "../Corporation/IndustryUpgrades";
import { ResearchMap } from "../Corporation/ResearchMap";
import { Factions } from "../Faction/Factions";
import { sellStock } from '../StockMarket/BuyingAndSelling';
export function NetscriptCorporation(
player: IPlayer,
@ -427,8 +426,9 @@ export function NetscriptCorporation(
},
bulkPurchase: function (adivisionName: any, acityName: any, amaterialName: any, aamt: any): void {
checkAccess("bulkPurchase", 7);
const corporation = getCorporation();
const divisionName = helper.string("bulkPurchase", "divisionName", adivisionName);
if (!hasResearched(getDivision(adivisionName), "Bulk Purchasing")) throw new Error(`You have not researched Bulk Purchase in ${adivisionName}`)
const corporation = getCorporation();
const cityName = helper.string("bulkPurchase", "cityName", acityName);
const materialName = helper.string("bulkPurchase", "materialName", amaterialName);
const amt = helper.number("bulkPurchase", "amt", aamt);