mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-22 14:12:27 +01:00
removed the ability to bribe for shares
This commit is contained in:
parent
ebae95dd4a
commit
18c3572423
@ -89,5 +89,11 @@ Singularity
|
|||||||
|
|
||||||
stock.buy and stock.sell
|
stock.buy and stock.sell
|
||||||
------------------------
|
------------------------
|
||||||
|
|
||||||
These 2 functions were renamed to stock.buyStock and stock.sellStock because 'buy' and '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.
|
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)
|
@ -28,37 +28,27 @@ export function BribeFactionModal(props: IProps): React.ReactElement {
|
|||||||
});
|
});
|
||||||
const corp = useCorporation();
|
const corp = useCorporation();
|
||||||
const [money, setMoney] = useState<number>(NaN);
|
const [money, setMoney] = useState<number>(NaN);
|
||||||
const [stock, setStock] = useState<number>(NaN);
|
|
||||||
const [selectedFaction, setSelectedFaction] = useState(factions.length > 0 ? factions[0] : "");
|
const [selectedFaction, setSelectedFaction] = useState(factions.length > 0 ? factions[0] : "");
|
||||||
const disabled =
|
const disabled = money === 0 || isNaN(money) || money < 0 || corp.funds < money;
|
||||||
(money === 0 && stock === 0) ||
|
|
||||||
isNaN(money) ||
|
|
||||||
isNaN(stock) ||
|
|
||||||
money < 0 ||
|
|
||||||
stock < 0 ||
|
|
||||||
corp.funds < money ||
|
|
||||||
stock > corp.numShares;
|
|
||||||
|
|
||||||
function changeFaction(event: SelectChangeEvent<string>): void {
|
function changeFaction(event: SelectChangeEvent<string>): void {
|
||||||
setSelectedFaction(event.target.value);
|
setSelectedFaction(event.target.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
function repGain(money: number, stock: number): number {
|
function repGain(money: number): number {
|
||||||
return (money + stock * corp.sharePrice) / CorporationConstants.BribeToRepRatio;
|
return money / CorporationConstants.BribeToRepRatio;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getRepText(money: number, stock: number): string {
|
function getRepText(money: number): string {
|
||||||
if (money === 0 && stock === 0) return "";
|
if (money === 0) return "";
|
||||||
if (isNaN(money) || isNaN(stock) || money < 0 || stock < 0) {
|
if (isNaN(money) || money < 0) {
|
||||||
return "ERROR: Invalid value(s) entered";
|
return "ERROR: Invalid value(s) entered";
|
||||||
} else if (corp.funds < money) {
|
} else if (corp.funds < money) {
|
||||||
return "ERROR: You do not have this much money to bribe with";
|
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 {
|
} else {
|
||||||
return (
|
return (
|
||||||
"You will gain " +
|
"You will gain " +
|
||||||
numeralWrapper.formatReputation(repGain(money, stock)) +
|
numeralWrapper.formatReputation(repGain(money)) +
|
||||||
" reputation with " +
|
" reputation with " +
|
||||||
selectedFaction +
|
selectedFaction +
|
||||||
" with this bribe"
|
" 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];
|
const fac = Factions[selectedFaction];
|
||||||
if (disabled) return;
|
if (disabled) return;
|
||||||
const rep = repGain(money, stock);
|
const rep = repGain(money);
|
||||||
dialogBoxCreate(
|
dialogBoxCreate(
|
||||||
"You gained " + numeralWrapper.formatReputation(rep) + " reputation with " + fac.name + " by bribing them.",
|
"You gained " + numeralWrapper.formatReputation(rep) + " reputation with " + fac.name + " by bribing them.",
|
||||||
);
|
);
|
||||||
fac.playerReputation += rep;
|
fac.playerReputation += rep;
|
||||||
corp.funds = corp.funds - money;
|
corp.funds = corp.funds - money;
|
||||||
corp.numShares -= stock;
|
|
||||||
props.onClose();
|
props.onClose();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -99,10 +88,9 @@ export function BribeFactionModal(props: IProps): React.ReactElement {
|
|||||||
})}
|
})}
|
||||||
</Select>
|
</Select>
|
||||||
</Box>
|
</Box>
|
||||||
<Typography>{getRepText(money ? money : 0, stock ? stock : 0)}</Typography>
|
<Typography>{getRepText(money ? money : 0)}</Typography>
|
||||||
<NumberInput onChange={setMoney} placeholder="Corporation funds" />
|
<NumberInput onChange={setMoney} placeholder="Corporation funds" />
|
||||||
<NumberInput sx={{ mx: 1 }} onChange={setStock} placeholder="Stock Shares" />
|
<Button disabled={disabled} sx={{ mx: 1 }} onClick={() => bribe(money ? money : 0)}>
|
||||||
<Button disabled={disabled} sx={{ mx: 1 }} onClick={() => bribe(money ? money : 0, stock ? stock : 0)}>
|
|
||||||
Bribe
|
Bribe
|
||||||
</Button>
|
</Button>
|
||||||
</Modal>
|
</Modal>
|
||||||
|
@ -203,23 +203,21 @@ export function NetscriptCorporation(player: IPlayer): InternalAPI<NSCorporation
|
|||||||
return division.researched[researchName] === undefined ? false : (division.researched[researchName] as boolean);
|
return division.researched[researchName] === undefined ? false : (division.researched[researchName] as boolean);
|
||||||
}
|
}
|
||||||
|
|
||||||
function bribe(factionName: string, amountCash: number, amountShares: number): boolean {
|
function bribe(factionName: string, amountCash: number): boolean {
|
||||||
if (!player.factions.includes(factionName)) throw new Error("Invalid faction name");
|
if (!player.factions.includes(factionName)) throw new Error("Invalid faction name");
|
||||||
if (isNaN(amountCash) || amountCash < 0 || isNaN(amountShares) || amountShares < 0)
|
if (isNaN(amountCash) || amountCash < 0)
|
||||||
throw new Error("Invalid value for amount field! Must be numeric, grater than 0.");
|
throw new Error("Invalid value for amount field! Must be numeric, grater than 0.");
|
||||||
|
|
||||||
const corporation = getCorporation();
|
const corporation = getCorporation();
|
||||||
if (corporation.funds < amountCash) return false;
|
if (corporation.funds < amountCash) return false;
|
||||||
if (corporation.numShares < amountShares) return false;
|
|
||||||
const faction = Factions[factionName];
|
const faction = Factions[factionName];
|
||||||
const info = faction.getInfo();
|
const info = faction.getInfo();
|
||||||
if (!info.offersWork()) return false;
|
if (!info.offersWork()) return false;
|
||||||
if (player.hasGangWith(factionName)) return false;
|
if (player.hasGangWith(factionName)) return false;
|
||||||
|
|
||||||
const repGain = (amountCash + amountShares * corporation.sharePrice) / CorporationConstants.BribeToRepRatio;
|
const repGain = amountCash / CorporationConstants.BribeToRepRatio;
|
||||||
faction.playerReputation += repGain;
|
faction.playerReputation += repGain;
|
||||||
corporation.funds = corporation.funds - amountCash;
|
corporation.funds = corporation.funds - amountCash;
|
||||||
corporation.numShares -= amountShares;
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1034,12 +1032,11 @@ export function NetscriptCorporation(player: IPlayer): InternalAPI<NSCorporation
|
|||||||
},
|
},
|
||||||
bribe:
|
bribe:
|
||||||
(ctx: NetscriptContext) =>
|
(ctx: NetscriptContext) =>
|
||||||
(_factionName: unknown, _amountCash: unknown, _amountShares: unknown): boolean => {
|
(_factionName: unknown, _amountCash: unknown): boolean => {
|
||||||
checkAccess(ctx);
|
checkAccess(ctx);
|
||||||
const factionName = ctx.helper.string("factionName", _factionName);
|
const factionName = ctx.helper.string("factionName", _factionName);
|
||||||
const amountCash = ctx.helper.number("amountCash", _amountCash);
|
const amountCash = ctx.helper.number("amountCash", _amountCash);
|
||||||
const amountShares = ctx.helper.number("amountShares", _amountShares);
|
return bribe(factionName, amountCash);
|
||||||
return bribe(factionName, amountCash, amountShares);
|
|
||||||
},
|
},
|
||||||
getBonusTime: (ctx: NetscriptContext) => (): number => {
|
getBonusTime: (ctx: NetscriptContext) => (): number => {
|
||||||
checkAccess(ctx);
|
checkAccess(ctx);
|
||||||
|
3
src/ScriptEditor/NetscriptDefinitions.d.ts
vendored
3
src/ScriptEditor/NetscriptDefinitions.d.ts
vendored
@ -6928,10 +6928,9 @@ export interface Corporation extends WarehouseAPI, OfficeAPI {
|
|||||||
* Bribe a faction
|
* Bribe a faction
|
||||||
* @param factionName - Faction name
|
* @param factionName - Faction name
|
||||||
* @param amountCash - Amount of money to bribe
|
* @param amountCash - Amount of money to bribe
|
||||||
* @param amountShares - Amount of shares to bribe
|
|
||||||
* @returns True if successful, false if not
|
* @returns True if successful, false if not
|
||||||
*/
|
*/
|
||||||
bribe(factionName: string, amountCash: number, amountShares: number): boolean;
|
bribe(factionName: string, amountCash: number): boolean;
|
||||||
/**
|
/**
|
||||||
* Get corporation data
|
* Get corporation data
|
||||||
* @returns Corporation data
|
* @returns Corporation data
|
||||||
|
@ -40,3 +40,9 @@ function rerender(): void {
|
|||||||
throw new Error("You accidentally called window.print instead of ns.print");
|
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");
|
||||||
|
};
|
||||||
|
})();
|
||||||
|
Loading…
Reference in New Issue
Block a user