From 30554560dad1b9f7aabd9160458349ef5c0e647e Mon Sep 17 00:00:00 2001 From: Olivier Gagnon Date: Mon, 11 Oct 2021 17:43:48 -0400 Subject: [PATCH] softcap hacknet max moneyt upgrade --- src/Hacknet/HacknetHelpers.tsx | 4 +++- src/Hacknet/ui/HacknetUpgradeElem.tsx | 20 ++++++++++++++------ src/Server/Server.ts | 14 ++++++++------ src/ui/React/ServerDropdown.tsx | 14 +++++++++++++- 4 files changed, 38 insertions(+), 14 deletions(-) diff --git a/src/Hacknet/HacknetHelpers.tsx b/src/Hacknet/HacknetHelpers.tsx index 9ad6a8d48..0047543f3 100644 --- a/src/Hacknet/HacknetHelpers.tsx +++ b/src/Hacknet/HacknetHelpers.tsx @@ -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; diff --git a/src/Hacknet/ui/HacknetUpgradeElem.tsx b/src/Hacknet/ui/HacknetUpgradeElem.tsx index 10d96fab7..e1ddd2f43 100644 --- a/src/Hacknet/ui/HacknetUpgradeElem.tsx +++ b/src/Hacknet/ui/HacknetUpgradeElem.tsx @@ -64,13 +64,21 @@ export function HacknetUpgradeElem(props: IProps): React.ReactElement { {upg.desc} - - {level > 0 && effect && {effect}} - {upg.hasTargetServer && ( - + {!upg.hasTargetServer && ( + )} + {upg.hasTargetServer && ( + + )} + {level > 0 && effect && {effect}} ); } diff --git a/src/Server/Server.ts b/src/Server/Server.ts index 1de0cd81f..fdec8c148 100644 --- a/src/Server/Server.ts +++ b/src/Server/Server.ts @@ -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; } /** diff --git a/src/ui/React/ServerDropdown.tsx b/src/ui/React/ServerDropdown.tsx index b08ecf71c..0c93a9dc7 100644 --- a/src/ui/React/ServerDropdown.tsx +++ b/src/ui/React/ServerDropdown.tsx @@ -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) => void; value: string; @@ -61,7 +64,16 @@ export function ServerDropdown(props: IProps): React.ReactElement { } return ( - + Buy + + } + sx={{ mx: 1 }} + value={props.value} + onChange={props.onChange} + > {servers} );