mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-21 15:13:46 +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 MenuItem from "@mui/material/MenuItem";
|
||||||
import Button from "@mui/material/Button";
|
import Button from "@mui/material/Button";
|
||||||
import { AugmentationName } from "@enums";
|
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 enum ServerType {
|
||||||
export const ServerType = {
|
All = 0,
|
||||||
All: 0,
|
Foreign = 1, // Non-owned servers
|
||||||
Foreign: 1, // Hackable, non-owned servers
|
Owned = 2, // Home Computer, Purchased Servers, and Hacknet Servers
|
||||||
Owned: 2, // Home Computer, Purchased Servers, and Hacknet Servers
|
Purchased = 3, // Everything from Owned except home computer
|
||||||
Purchased: 3, // Everything from Owned except home computer
|
}
|
||||||
};
|
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
purchase: () => void;
|
purchase: () => void;
|
||||||
canPurchase: boolean;
|
canPurchase: boolean;
|
||||||
serverType: number;
|
serverType: ServerType;
|
||||||
onChange: (event: SelectChangeEvent) => void;
|
onChange: (event: SelectChangeEvent) => void;
|
||||||
value: string;
|
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
|
* Checks if the server should be shown in the dropdown menu, based on the
|
||||||
* 'serverType' property
|
* 'serverType' property
|
||||||
*/
|
*/
|
||||||
function isValidServer(s: BaseServer): boolean {
|
function isValidServer(baseServer: BaseServer): boolean {
|
||||||
const purchased = (s instanceof Server && s.purchasedByPlayer) || s instanceof HacknetServer;
|
/**
|
||||||
|
* 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;
|
const type = props.serverType;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case ServerType.All:
|
case ServerType.All:
|
||||||
return true;
|
return true;
|
||||||
case ServerType.Foreign:
|
case ServerType.Foreign:
|
||||||
return s.hostname !== "home" && !purchased && !Player.hasAugmentation(AugmentationName.TheRedPill, true)
|
// Exclude home, private servers, hacknet servers.
|
||||||
? s.hostname !== "w0r1d_d43m0n"
|
if (isOwnedServer) {
|
||||||
: true;
|
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:
|
case ServerType.Owned:
|
||||||
return purchased || s.hostname === "home";
|
return isOwnedServer;
|
||||||
case ServerType.Purchased:
|
case ServerType.Purchased:
|
||||||
return purchased;
|
return isOwnedServer && baseServer.hostname !== SpecialServers.Home;
|
||||||
default:
|
default:
|
||||||
console.warn(`Invalid ServerType specified for ServerDropdown component: ${type}`);
|
throwIfReachable(type);
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const servers = [];
|
const servers = [];
|
||||||
|
Loading…
Reference in New Issue
Block a user