mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-22 01:03:01 +02:00
NETSCRIPT: Added ns.corporation.issueNewShares function (#261)
This commit is contained in:
@@ -24,6 +24,7 @@ import {
|
||||
UnlockUpgrade,
|
||||
LevelUpgrade,
|
||||
IssueDividends,
|
||||
IssueNewShares,
|
||||
SellMaterial,
|
||||
SellProduct,
|
||||
SetSmartSupply,
|
||||
@@ -820,6 +821,21 @@ export function NetscriptCorporation(): InternalAPI<NSCorporation> {
|
||||
if (!corporation.public) throw helpers.makeRuntimeErrorMsg(ctx, `Your company has not gone public!`);
|
||||
IssueDividends(corporation, rate);
|
||||
},
|
||||
issueNewShares: (ctx) => (_amount) => {
|
||||
checkAccess(ctx);
|
||||
const corporation = getCorporation();
|
||||
const maxNewShares = corporation.calculateMaxNewShares();
|
||||
if (_amount == undefined) _amount = maxNewShares;
|
||||
const amount = helpers.number(ctx, "amount", _amount);
|
||||
if (corporation.issueNewSharesCooldown > 0) throw new Error(`Can't issue new shares, action on cooldown.`);
|
||||
if (amount < 10e6 || amount > maxNewShares)
|
||||
throw new Error(
|
||||
`Invalid value for amount field! Must be numeric, greater than 10m, and less than ${maxNewShares} (20% of total shares)`,
|
||||
);
|
||||
if (!corporation.public) throw helpers.makeRuntimeErrorMsg(ctx, `Your company has not gone public!`);
|
||||
const [funds] = IssueNewShares(corporation, amount);
|
||||
return funds;
|
||||
},
|
||||
getDivision: (ctx) => (_divisionName) => {
|
||||
checkAccess(ctx);
|
||||
const divisionName = helpers.string(ctx, "divisionName", _divisionName);
|
||||
|
||||
Reference in New Issue
Block a user