mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-24 00:23:49 +01:00
BUGFIX: Hashserver UI shows wrong server list when purchasing upgrades (#1782)
This commit is contained in:
parent
fe2c98e3cf
commit
70a231e421
@ -13,19 +13,20 @@ import Select, { SelectChangeEvent } from "@mui/material/Select";
|
||||
import MenuItem from "@mui/material/MenuItem";
|
||||
import Button from "@mui/material/Button";
|
||||
import { AugmentationName } from "@enums";
|
||||
import { SpecialServers } from "../../Server/data/SpecialServers";
|
||||
import { throwIfReachable } from "../../utils/helpers/throwIfReachable";
|
||||
|
||||
// TODO make this an enum when this gets converted to TypeScript
|
||||
export const ServerType = {
|
||||
All: 0,
|
||||
Foreign: 1, // Hackable, non-owned servers
|
||||
Owned: 2, // Home Computer, Purchased Servers, and Hacknet Servers
|
||||
Purchased: 3, // Everything from Owned except home computer
|
||||
};
|
||||
export enum ServerType {
|
||||
All = 0,
|
||||
Foreign = 1, // Non-owned servers
|
||||
Owned = 2, // Home Computer, Purchased Servers, and Hacknet Servers
|
||||
Purchased = 3, // Everything from Owned except home computer
|
||||
}
|
||||
|
||||
interface IProps {
|
||||
purchase: () => void;
|
||||
canPurchase: boolean;
|
||||
serverType: number;
|
||||
serverType: ServerType;
|
||||
onChange: (event: SelectChangeEvent) => void;
|
||||
value: string;
|
||||
}
|
||||
@ -35,24 +36,35 @@ export function ServerDropdown(props: IProps): React.ReactElement {
|
||||
* Checks if the server should be shown in the dropdown menu, based on the
|
||||
* 'serverType' property
|
||||
*/
|
||||
function isValidServer(s: BaseServer): boolean {
|
||||
const purchased = (s instanceof Server && s.purchasedByPlayer) || s instanceof HacknetServer;
|
||||
function isValidServer(baseServer: BaseServer): boolean {
|
||||
/**
|
||||
* isOwnedServer is true if baseServer is home, private servers, or hacknet servers. Note that, with home computer,
|
||||
* baseServer.purchasedByPlayer is true.
|
||||
*/
|
||||
const isOwnedServer =
|
||||
(baseServer instanceof Server && baseServer.purchasedByPlayer) || baseServer instanceof HacknetServer;
|
||||
const type = props.serverType;
|
||||
switch (type) {
|
||||
case ServerType.All:
|
||||
return true;
|
||||
case ServerType.Foreign:
|
||||
return s.hostname !== "home" && !purchased && !Player.hasAugmentation(AugmentationName.TheRedPill, true)
|
||||
? s.hostname !== "w0r1d_d43m0n"
|
||||
: true;
|
||||
case ServerType.Owned:
|
||||
return purchased || s.hostname === "home";
|
||||
case ServerType.Purchased:
|
||||
return purchased;
|
||||
default:
|
||||
console.warn(`Invalid ServerType specified for ServerDropdown component: ${type}`);
|
||||
// Exclude home, private servers, hacknet servers.
|
||||
if (isOwnedServer) {
|
||||
return false;
|
||||
}
|
||||
// If the player has not installed TRP, exclude WD server.
|
||||
return (
|
||||
Player.hasAugmentation(AugmentationName.TheRedPill, true) ||
|
||||
baseServer.hostname !== SpecialServers.WorldDaemon
|
||||
);
|
||||
case ServerType.Owned:
|
||||
return isOwnedServer;
|
||||
case ServerType.Purchased:
|
||||
return isOwnedServer && baseServer.hostname !== SpecialServers.Home;
|
||||
default:
|
||||
throwIfReachable(type);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
const servers = [];
|
||||
|
Loading…
Reference in New Issue
Block a user