From 4a3558098ce26b8c6fd95051eddc59d874d184e4 Mon Sep 17 00:00:00 2001 From: Staszek Welsh Date: Mon, 30 May 2022 22:31:51 +0100 Subject: [PATCH] Fix error check in issueDividends expecting 0-100 when it actually takes 0-1 --- src/NetscriptFunctions/Corporation.ts | 11 ++++++----- src/ScriptEditor/NetscriptDefinitions.d.ts | 4 ++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/NetscriptFunctions/Corporation.ts b/src/NetscriptFunctions/Corporation.ts index 1303151cc..18bab912b 100644 --- a/src/NetscriptFunctions/Corporation.ts +++ b/src/NetscriptFunctions/Corporation.ts @@ -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 diff --git a/src/ScriptEditor/NetscriptDefinitions.d.ts b/src/ScriptEditor/NetscriptDefinitions.d.ts index b9bda8ce9..a1b01a9ca 100644 --- a/src/ScriptEditor/NetscriptDefinitions.d.ts +++ b/src/ScriptEditor/NetscriptDefinitions.d.ts @@ -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.