mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-16 06:18:42 +02:00
BUGFIX: ns.corporation.bribe can bribe faction that player is not member of (#1966)
This commit is contained in:
@@ -8,6 +8,8 @@ Bribe a faction. You must satisfy these conditions:
|
||||
|
||||
- The corporation valuation must be greater than or equal to a threshold. You can use [getCorporation](./bitburner.corporation.getcorporation.md) and [getConstants](./bitburner.corporation.getconstants.md) to get this information.
|
||||
|
||||
- You must be a member of the specified faction.
|
||||
|
||||
- The specified faction must offer at least 1 type of work. You can use [getFactionWorkTypes](./bitburner.singularity.getfactionworktypes.md) to get the list of work types of a faction.
|
||||
|
||||
**Signature:**
|
||||
|
||||
@@ -18,7 +18,7 @@ export interface Corporation extends WarehouseAPI, OfficeAPI
|
||||
| Method | Description |
|
||||
| --- | --- |
|
||||
| [acceptInvestmentOffer()](./bitburner.corporation.acceptinvestmentoffer.md) | Accept the investment offer. The value of offer is based on current corporation valuation. |
|
||||
| [bribe(factionName, amountCash)](./bitburner.corporation.bribe.md) | <p>Bribe a faction. You must satisfy these conditions:</p><p>- The corporation valuation must be greater than or equal to a threshold. You can use [getCorporation](./bitburner.corporation.getcorporation.md) and [getConstants](./bitburner.corporation.getconstants.md) to get this information.</p><p>- The specified faction must offer at least 1 type of work. You can use [getFactionWorkTypes](./bitburner.singularity.getfactionworktypes.md) to get the list of work types of a faction.</p> |
|
||||
| [bribe(factionName, amountCash)](./bitburner.corporation.bribe.md) | <p>Bribe a faction. You must satisfy these conditions:</p><p>- The corporation valuation must be greater than or equal to a threshold. You can use [getCorporation](./bitburner.corporation.getcorporation.md) and [getConstants](./bitburner.corporation.getconstants.md) to get this information.</p><p>- You must be a member of the specified faction.</p><p>- The specified faction must offer at least 1 type of work. You can use [getFactionWorkTypes](./bitburner.singularity.getfactionworktypes.md) to get the list of work types of a faction.</p> |
|
||||
| [buyBackShares(amount)](./bitburner.corporation.buybackshares.md) | Buyback shares. Spend money from the player's wallet to transfer shares from public traders to the CEO. |
|
||||
| [canCreateCorporation(selfFund)](./bitburner.corporation.cancreatecorporation.md) | Return whether the player can create a corporation. Does not require API access. |
|
||||
| [createCorporation(corporationName, selfFund)](./bitburner.corporation.createcorporation.md) | <p>Create a Corporation. You should use [canCreateCorporation](./bitburner.corporation.cancreatecorporation.md) to check if you are unsure you can do it, because it throws an error in these cases:</p><p>- Use seed money outside BitNode 3.</p><p>- Be in a BitNode that has CorporationSoftcap (a BitNode modifier) less than 0.15.</p> |
|
||||
|
||||
@@ -28,7 +28,7 @@ import {
|
||||
import { PositiveInteger, Result } from "../types";
|
||||
import { Factions } from "../Faction/Factions";
|
||||
import { throwIfReachable } from "../utils/helpers/throwIfReachable";
|
||||
import { formatMoney } from "../ui/formatNumber";
|
||||
import { formatMoney, formatNumber } from "../ui/formatNumber";
|
||||
|
||||
export function createCorporation(corporationName: string, selfFund: boolean, restart: boolean): Result {
|
||||
const checkResult = canCreateCorporation(selfFund, restart);
|
||||
@@ -632,16 +632,24 @@ export function bribe(
|
||||
fundsForBribing: number,
|
||||
factionName: FactionName,
|
||||
): Result<{ reputationGain: number }> {
|
||||
if (corporation.valuation < corpConstants.bribeThreshold) {
|
||||
return {
|
||||
success: false,
|
||||
message: `The corporation valuation is below the threshold. Threshold: ${corpConstants.bribeThreshold}.`,
|
||||
};
|
||||
}
|
||||
if (!Number.isFinite(fundsForBribing) || fundsForBribing <= 0 || corporation.funds < fundsForBribing) {
|
||||
return {
|
||||
success: false,
|
||||
message: "Invalid amount of cash for bribing",
|
||||
message: "Invalid amount of cash for bribing.",
|
||||
};
|
||||
}
|
||||
if (corporation.valuation < corpConstants.bribeThreshold) {
|
||||
return {
|
||||
success: false,
|
||||
message: `The corporation valuation is below the threshold. Threshold: ${formatNumber(
|
||||
corpConstants.bribeThreshold,
|
||||
)}.`,
|
||||
};
|
||||
}
|
||||
if (!Player.factions.includes(factionName)) {
|
||||
return {
|
||||
success: false,
|
||||
message: `You are not a member of ${factionName}.`,
|
||||
};
|
||||
}
|
||||
const faction = Factions[factionName];
|
||||
|
||||
2
src/ScriptEditor/NetscriptDefinitions.d.ts
vendored
2
src/ScriptEditor/NetscriptDefinitions.d.ts
vendored
@@ -9354,6 +9354,8 @@ export interface Corporation extends WarehouseAPI, OfficeAPI {
|
||||
* {@link Corporation.getCorporation | getCorporation} and {@link Corporation.getConstants | getConstants} to get this
|
||||
* information.
|
||||
*
|
||||
* - You must be a member of the specified faction.
|
||||
*
|
||||
* - The specified faction must offer at least 1 type of work. You can use
|
||||
* {@link Singularity.getFactionWorkTypes | getFactionWorkTypes} to get the list of work types of a faction.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user