mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-13 03:03: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.`);
|
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) {
|
} catch (e) {
|
||||||
player.hashManager.refundUpgrade(upgName);
|
player.hashManager.refundUpgrade(upgName);
|
||||||
return false;
|
return false;
|
||||||
|
@ -64,13 +64,21 @@ export function HacknetUpgradeElem(props: IProps): React.ReactElement {
|
|||||||
</Typography>
|
</Typography>
|
||||||
|
|
||||||
<Typography>{upg.desc}</Typography>
|
<Typography>{upg.desc}</Typography>
|
||||||
<Button onClick={purchase} disabled={!canPurchase}>
|
{!upg.hasTargetServer && (
|
||||||
Purchase
|
<Button onClick={purchase} disabled={!canPurchase}>
|
||||||
</Button>
|
Buy
|
||||||
{level > 0 && effect && <Typography>{effect}</Typography>}
|
</Button>
|
||||||
{upg.hasTargetServer && (
|
|
||||||
<ServerDropdown value={selectedServer} serverType={ServerType.Foreign} onChange={changeTargetServer} />
|
|
||||||
)}
|
)}
|
||||||
|
{upg.hasTargetServer && (
|
||||||
|
<ServerDropdown
|
||||||
|
purchase={purchase}
|
||||||
|
canPurchase={canPurchase}
|
||||||
|
value={selectedServer}
|
||||||
|
serverType={ServerType.Foreign}
|
||||||
|
onChange={changeTargetServer}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
{level > 0 && effect && <Typography>{effect}</Typography>}
|
||||||
</Paper>
|
</Paper>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -125,14 +125,16 @@ export class Server extends BaseServer {
|
|||||||
/**
|
/**
|
||||||
* Change this server's maximum money
|
* Change this server's maximum money
|
||||||
* @param n - Value by which to change the 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 {
|
changeMaximumMoney(n: number): void {
|
||||||
if (perc) {
|
const softCap = 10e12;
|
||||||
this.moneyMax *= n;
|
if (this.moneyMax > softCap) {
|
||||||
} else {
|
const aboveCap = this.moneyMax - softCap;
|
||||||
this.moneyMax += n;
|
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 { HacknetServer } from "../../Hacknet/HacknetServer";
|
||||||
import Select, { SelectChangeEvent } from "@mui/material/Select";
|
import Select, { SelectChangeEvent } from "@mui/material/Select";
|
||||||
import MenuItem from "@mui/material/MenuItem";
|
import MenuItem from "@mui/material/MenuItem";
|
||||||
|
import Button from "@mui/material/Button";
|
||||||
|
|
||||||
// TODO make this an enum when this gets converted to TypeScript
|
// TODO make this an enum when this gets converted to TypeScript
|
||||||
export const ServerType = {
|
export const ServerType = {
|
||||||
@ -21,6 +22,8 @@ export const ServerType = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
|
purchase: () => void;
|
||||||
|
canPurchase: boolean;
|
||||||
serverType: number;
|
serverType: number;
|
||||||
onChange: (event: SelectChangeEvent<string>) => void;
|
onChange: (event: SelectChangeEvent<string>) => void;
|
||||||
value: string;
|
value: string;
|
||||||
@ -61,7 +64,16 @@ export function ServerDropdown(props: IProps): React.ReactElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
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}
|
{servers}
|
||||||
</Select>
|
</Select>
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user