mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-20 05:05:47 +01:00
adjustments per review comments
* updated error message * used correct price for bulk purchasing check * moved onclose and rerenders outside try blocks
This commit is contained in:
parent
e9cea9dfd4
commit
6e21f16160
dist
src
Corporation
NetscriptFunctions
2
dist/bitburner.d.ts
vendored
2
dist/bitburner.d.ts
vendored
@ -960,10 +960,12 @@ export declare interface Corporation extends WarehouseAPI, OfficeAPI {
|
||||
issueDividends(percent: number): void;
|
||||
/**
|
||||
* Buyback Shares
|
||||
* @param amt - Number of shares to attempt to buyback.
|
||||
*/
|
||||
buyBackShares(amt: number): void;
|
||||
/**
|
||||
* Sell Shares
|
||||
* @param amt - Number of shares to attempt to sell.
|
||||
*/
|
||||
sellShares(amt: number): void;
|
||||
}
|
||||
|
@ -21,7 +21,6 @@ export function NewIndustry(corporation: ICorporation, industry: string, name: s
|
||||
for (let i = 0; i < corporation.divisions.length; ++i) {
|
||||
if (corporation.divisions[i].name === name) {
|
||||
throw new Error("This division name is already in use!");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@ -290,9 +289,8 @@ export function BuyBackShares(corporation: ICorporation, player: IPlayer, numSha
|
||||
if (numShares < 0) throw new Error("Invalid value for number of shares");
|
||||
if (numShares > corporation.issuedShares) throw new Error("You don't have that many shares to buy!");
|
||||
if (!corporation.public) throw new Error("You haven't gone public!");
|
||||
if (corporation.funds < (numShares * corporation.sharePrice)) throw new Error("You cant afford that many shares!");
|
||||
|
||||
const buybackPrice = corporation.sharePrice * 1.1;
|
||||
if (corporation.funds < (numShares * buybackPrice)) throw new Error("You cant afford that many shares!");
|
||||
corporation.numShares += numShares;
|
||||
corporation.issuedShares -= numShares;
|
||||
player.loseMoney(numShares * buybackPrice, "corporation");
|
||||
|
@ -40,12 +40,12 @@ export function BuybackSharesModal(props: IProps): React.ReactElement {
|
||||
if (disabled) return;
|
||||
try {
|
||||
BuyBackShares(corp, player, shares)
|
||||
props.onClose();
|
||||
props.rerender();
|
||||
}
|
||||
catch (err) {
|
||||
dialogBoxCreate(err + "");
|
||||
}
|
||||
props.onClose();
|
||||
props.rerender();
|
||||
}
|
||||
|
||||
function CostIndicator(): React.ReactElement {
|
||||
|
@ -61,10 +61,10 @@ function BulkPurchaseSection(props: IBPProps): React.ReactElement {
|
||||
function bulkPurchase(): void {
|
||||
try {
|
||||
BulkPurchase(corp, props.warehouse, props.mat, parseFloat(buyAmt));
|
||||
props.onClose();
|
||||
} catch (err) {
|
||||
dialogBoxCreate(err + "");
|
||||
}
|
||||
props.onClose();
|
||||
}
|
||||
|
||||
function onKeyDown(event: React.KeyboardEvent<HTMLInputElement>): void {
|
||||
|
@ -438,7 +438,7 @@ export function NetscriptCorporation(
|
||||
bulkPurchase: function (adivisionName: any, acityName: any, amaterialName: any, aamt: any): void {
|
||||
checkAccess("bulkPurchase", 7);
|
||||
const divisionName = helper.string("bulkPurchase", "divisionName", adivisionName);
|
||||
if (!hasResearched(getDivision(adivisionName), "Bulk Purchasing")) throw new Error(`You have not researched Bulk Purchase in ${adivisionName}`)
|
||||
if (!hasResearched(getDivision(adivisionName), "Bulk Purchasing")) throw new Error(`You have not researched Bulk Purchasing in ${adivisionName}`)
|
||||
const corporation = getCorporation();
|
||||
const cityName = helper.string("bulkPurchase", "cityName", acityName);
|
||||
const materialName = helper.string("bulkPurchase", "materialName", amaterialName);
|
||||
|
Loading…
Reference in New Issue
Block a user