Fix error check in issueDividends expecting 0-100 when it actually takes 0-1

This commit is contained in:
Staszek Welsh 2022-05-30 22:31:51 +01:00
parent 74e4a32f13
commit 4a3558098c
2 changed files with 8 additions and 7 deletions

@ -918,14 +918,15 @@ export function NetscriptCorporation(player: IPlayer, workerScript: WorkerScript
},
issueDividends:
(ctx: NetscriptContext) =>
(_percent: unknown): void => {
(_rate: unknown): void => {
checkAccess(ctx);
const percent = ctx.helper.number("percent", _percent);
if (percent < 0 || percent > 100)
throw new Error("Invalid value for percent field! Must be numeric, greater than 0, and less than 100");
const rate = ctx.helper.number("rate", _rate);
const max = CorporationConstants.DividendMaxRate;
if (rate < 0 || rate > max)
throw new Error(`Invalid value for rate field! Must be numeric, greater than 0, and less than ${max}`);
const corporation = getCorporation();
if (!corporation.public) throw ctx.makeRuntimeErrorMsg(`Your company has not gone public!`);
IssueDividends(corporation, percent);
IssueDividends(corporation, rate);
},
// If you modify these objects you will affect them for real, it's not

@ -7048,9 +7048,9 @@ export interface Corporation extends WarehouseAPI, OfficeAPI {
levelUpgrade(upgradeName: string): void;
/**
* Issue dividends
* @param percent - Percent of profit to issue as dividends.
* @param rate - Fraction of profit to issue as dividends.
*/
issueDividends(percent: number): void;
issueDividends(rate: number): void;
/**
* Buyback Shares
* @param amount - Amount of shares to buy back.