mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-30 03:23:48 +01:00
Merge pull request #3092 from ChrissiQ/bugfix/corp-buybackshares-canaffordcheck
🐛 (Bug: Corp) Fixes sufficient player money check to buy back shares.
This commit is contained in:
commit
0a64da51e0
@ -291,7 +291,7 @@ export function BuyBackShares(corporation: ICorporation, player: IPlayer, numSha
|
|||||||
if (numShares > corporation.issuedShares) throw new Error("You don't have that many shares to buy!");
|
if (numShares > corporation.issuedShares) throw new Error("You don't have that many shares to buy!");
|
||||||
if (!corporation.public) throw new Error("You haven't gone public!");
|
if (!corporation.public) throw new Error("You haven't gone public!");
|
||||||
const buybackPrice = corporation.sharePrice * 1.1;
|
const buybackPrice = corporation.sharePrice * 1.1;
|
||||||
if (corporation.funds < (numShares * buybackPrice)) throw new Error("You cant afford that many shares!");
|
if (player.money < (numShares * buybackPrice)) throw new Error("You cant afford that many shares!");
|
||||||
corporation.numShares += numShares;
|
corporation.numShares += numShares;
|
||||||
corporation.issuedShares -= numShares;
|
corporation.issuedShares -= numShares;
|
||||||
player.loseMoney(numShares * buybackPrice, "corporation");
|
player.loseMoney(numShares * buybackPrice, "corporation");
|
||||||
|
Loading…
Reference in New Issue
Block a user