diff --git a/doc/source/v2.0.0_migration.rst b/doc/source/v2.0.0_migration.rst index 868eb2663..2ca0b20d4 100644 --- a/doc/source/v2.0.0_migration.rst +++ b/doc/source/v2.0.0_migration.rst @@ -89,5 +89,11 @@ Singularity stock.buy and stock.sell ------------------------ + These 2 functions were renamed to stock.buyStock and stock.sellStock because 'buy' and 'sell' - are very common tokens that would trick the ram calculation. \ No newline at end of file + are very common tokens that would trick the ram calculation. + +corporation.bribe +----------------- + + The ability to give stocks as bribe has been removed. The signature is now bribe(faction, money) \ No newline at end of file diff --git a/src/Corporation/ui/modals/BribeFactionModal.tsx b/src/Corporation/ui/modals/BribeFactionModal.tsx index 92a0fb6ef..87d20105d 100644 --- a/src/Corporation/ui/modals/BribeFactionModal.tsx +++ b/src/Corporation/ui/modals/BribeFactionModal.tsx @@ -28,37 +28,27 @@ export function BribeFactionModal(props: IProps): React.ReactElement { }); const corp = useCorporation(); const [money, setMoney] = useState(NaN); - const [stock, setStock] = useState(NaN); const [selectedFaction, setSelectedFaction] = useState(factions.length > 0 ? factions[0] : ""); - const disabled = - (money === 0 && stock === 0) || - isNaN(money) || - isNaN(stock) || - money < 0 || - stock < 0 || - corp.funds < money || - stock > corp.numShares; + const disabled = money === 0 || isNaN(money) || money < 0 || corp.funds < money; function changeFaction(event: SelectChangeEvent): void { setSelectedFaction(event.target.value); } - function repGain(money: number, stock: number): number { - return (money + stock * corp.sharePrice) / CorporationConstants.BribeToRepRatio; + function repGain(money: number): number { + return money / CorporationConstants.BribeToRepRatio; } - function getRepText(money: number, stock: number): string { - if (money === 0 && stock === 0) return ""; - if (isNaN(money) || isNaN(stock) || money < 0 || stock < 0) { + function getRepText(money: number): string { + if (money === 0) return ""; + if (isNaN(money) || money < 0) { return "ERROR: Invalid value(s) entered"; } else if (corp.funds < money) { return "ERROR: You do not have this much money to bribe with"; - } else if (stock > corp.numShares) { - return "ERROR: You do not have this many shares to bribe with"; } else { return ( "You will gain " + - numeralWrapper.formatReputation(repGain(money, stock)) + + numeralWrapper.formatReputation(repGain(money)) + " reputation with " + selectedFaction + " with this bribe" @@ -66,16 +56,15 @@ export function BribeFactionModal(props: IProps): React.ReactElement { } } - function bribe(money: number, stock: number): void { + function bribe(money: number): void { const fac = Factions[selectedFaction]; if (disabled) return; - const rep = repGain(money, stock); + const rep = repGain(money); dialogBoxCreate( "You gained " + numeralWrapper.formatReputation(rep) + " reputation with " + fac.name + " by bribing them.", ); fac.playerReputation += rep; corp.funds = corp.funds - money; - corp.numShares -= stock; props.onClose(); } @@ -99,10 +88,9 @@ export function BribeFactionModal(props: IProps): React.ReactElement { })} - {getRepText(money ? money : 0, stock ? stock : 0)} + {getRepText(money ? money : 0)} - - diff --git a/src/NetscriptFunctions/Corporation.ts b/src/NetscriptFunctions/Corporation.ts index 112f8960b..023d990db 100644 --- a/src/NetscriptFunctions/Corporation.ts +++ b/src/NetscriptFunctions/Corporation.ts @@ -203,23 +203,21 @@ export function NetscriptCorporation(player: IPlayer): InternalAPI - (_factionName: unknown, _amountCash: unknown, _amountShares: unknown): boolean => { + (_factionName: unknown, _amountCash: unknown): boolean => { checkAccess(ctx); const factionName = ctx.helper.string("factionName", _factionName); const amountCash = ctx.helper.number("amountCash", _amountCash); - const amountShares = ctx.helper.number("amountShares", _amountShares); - return bribe(factionName, amountCash, amountShares); + return bribe(factionName, amountCash); }, getBonusTime: (ctx: NetscriptContext) => (): number => { checkAccess(ctx); diff --git a/src/ScriptEditor/NetscriptDefinitions.d.ts b/src/ScriptEditor/NetscriptDefinitions.d.ts index 8d4e106eb..fe1af4e1e 100644 --- a/src/ScriptEditor/NetscriptDefinitions.d.ts +++ b/src/ScriptEditor/NetscriptDefinitions.d.ts @@ -6928,10 +6928,9 @@ export interface Corporation extends WarehouseAPI, OfficeAPI { * Bribe a faction * @param factionName - Faction name * @param amountCash - Amount of money to bribe - * @param amountShares - Amount of shares to bribe * @returns True if successful, false if not */ - bribe(factionName: string, amountCash: number, amountShares: number): boolean; + bribe(factionName: string, amountCash: number): boolean; /** * Get corporation data * @returns Corporation data diff --git a/src/index.tsx b/src/index.tsx index db30c785c..3720f3eca 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -40,3 +40,9 @@ function rerender(): void { throw new Error("You accidentally called window.print instead of ns.print"); }; })(); + +(function () { + window.prompt = () => { + throw new Error("You accidentally called window.prompt instead of ns.prompt"); + }; +})();