mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-10 09:43:54 +01:00
softcap hacknet max moneyt upgrade
This commit is contained in:
parent
ac3a6b9a6f
commit
30554560da
@ -510,7 +510,9 @@ export function purchaseHashUpgrade(player: IPlayer, upgName: string, upgTarget:
|
||||
}
|
||||
if (!(target instanceof Server)) throw new Error(`'${upgTarget}' is not a normal server.`);
|
||||
|
||||
target.changeMaximumMoney(upg.value, true);
|
||||
const old = target.moneyMax;
|
||||
target.changeMaximumMoney(upg.value);
|
||||
console.log(target.moneyMax / old);
|
||||
} catch (e) {
|
||||
player.hashManager.refundUpgrade(upgName);
|
||||
return false;
|
||||
|
@ -64,13 +64,21 @@ export function HacknetUpgradeElem(props: IProps): React.ReactElement {
|
||||
</Typography>
|
||||
|
||||
<Typography>{upg.desc}</Typography>
|
||||
<Button onClick={purchase} disabled={!canPurchase}>
|
||||
Purchase
|
||||
</Button>
|
||||
{level > 0 && effect && <Typography>{effect}</Typography>}
|
||||
{upg.hasTargetServer && (
|
||||
<ServerDropdown value={selectedServer} serverType={ServerType.Foreign} onChange={changeTargetServer} />
|
||||
{!upg.hasTargetServer && (
|
||||
<Button onClick={purchase} disabled={!canPurchase}>
|
||||
Buy
|
||||
</Button>
|
||||
)}
|
||||
{upg.hasTargetServer && (
|
||||
<ServerDropdown
|
||||
purchase={purchase}
|
||||
canPurchase={canPurchase}
|
||||
value={selectedServer}
|
||||
serverType={ServerType.Foreign}
|
||||
onChange={changeTargetServer}
|
||||
/>
|
||||
)}
|
||||
{level > 0 && effect && <Typography>{effect}</Typography>}
|
||||
</Paper>
|
||||
);
|
||||
}
|
||||
|
@ -125,14 +125,16 @@ export class Server extends BaseServer {
|
||||
/**
|
||||
* Change this server's maximum money
|
||||
* @param n - Value by which to change the server's maximum money
|
||||
* @param perc - Whether it should be changed by a percentage, or a flat value
|
||||
*/
|
||||
changeMaximumMoney(n: number, perc = false): void {
|
||||
if (perc) {
|
||||
this.moneyMax *= n;
|
||||
} else {
|
||||
this.moneyMax += n;
|
||||
changeMaximumMoney(n: number): void {
|
||||
const softCap = 10e12;
|
||||
if (this.moneyMax > softCap) {
|
||||
const aboveCap = this.moneyMax - softCap;
|
||||
n = 1 + (n - 1) / Math.log(aboveCap) / Math.log(8);
|
||||
}
|
||||
console.log(n);
|
||||
|
||||
this.moneyMax *= n;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -11,6 +11,7 @@ import { BaseServer } from "../../Server/BaseServer";
|
||||
import { HacknetServer } from "../../Hacknet/HacknetServer";
|
||||
import Select, { SelectChangeEvent } from "@mui/material/Select";
|
||||
import MenuItem from "@mui/material/MenuItem";
|
||||
import Button from "@mui/material/Button";
|
||||
|
||||
// TODO make this an enum when this gets converted to TypeScript
|
||||
export const ServerType = {
|
||||
@ -21,6 +22,8 @@ export const ServerType = {
|
||||
};
|
||||
|
||||
interface IProps {
|
||||
purchase: () => void;
|
||||
canPurchase: boolean;
|
||||
serverType: number;
|
||||
onChange: (event: SelectChangeEvent<string>) => void;
|
||||
value: string;
|
||||
@ -61,7 +64,16 @@ export function ServerDropdown(props: IProps): React.ReactElement {
|
||||
}
|
||||
|
||||
return (
|
||||
<Select sx={{ mx: 1 }} value={props.value} onChange={props.onChange}>
|
||||
<Select
|
||||
startAdornment={
|
||||
<Button onClick={props.purchase} disabled={!props.canPurchase}>
|
||||
Buy
|
||||
</Button>
|
||||
}
|
||||
sx={{ mx: 1 }}
|
||||
value={props.value}
|
||||
onChange={props.onChange}
|
||||
>
|
||||
{servers}
|
||||
</Select>
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user