mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-05-06 07:37:56 +02:00
MISC: Refactor code of traveling and going to location (#1365)
This commit is contained in:
@@ -57,7 +57,7 @@ export function CompanyLocation(props: IProps): React.ReactElement {
|
||||
*/
|
||||
const currentPosition = jobTitle ? CompanyPositions[jobTitle] : null;
|
||||
|
||||
Player.location = companyNameAsLocationName(props.companyName);
|
||||
Player.gotoLocation(companyNameAsLocationName(props.companyName));
|
||||
|
||||
function startInfiltration(e: React.MouseEvent<HTMLElement>): void {
|
||||
if (!e.isTrusted) {
|
||||
|
||||
@@ -24,14 +24,12 @@ import Button from "@mui/material/Button";
|
||||
import { useRerender } from "../../ui/React/hooks";
|
||||
|
||||
function travel(to: CityName): void {
|
||||
const cost = CONSTANTS.TravelCost;
|
||||
if (!Player.canAfford(cost)) {
|
||||
if (!Player.travel(to)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Player.loseMoney(cost, "other");
|
||||
Player.travel(to);
|
||||
if (!Settings.SuppressTravelConfirmation) dialogBoxCreate(`You are now in ${to}!`);
|
||||
if (!Settings.SuppressTravelConfirmation) {
|
||||
dialogBoxCreate(`You are now in ${to}!`);
|
||||
}
|
||||
Router.toPage(Page.City);
|
||||
}
|
||||
|
||||
@@ -41,8 +39,7 @@ export function TravelAgencyRoot(): React.ReactElement {
|
||||
useRerender(1000);
|
||||
|
||||
function startTravel(city: CityName): void {
|
||||
const cost = CONSTANTS.TravelCost;
|
||||
if (!Player.canAfford(cost)) {
|
||||
if (!Player.canAfford(CONSTANTS.TravelCost)) {
|
||||
return;
|
||||
}
|
||||
if (Settings.SuppressTravelConfirmation) {
|
||||
|
||||
@@ -14,7 +14,6 @@ interface IProps {
|
||||
}
|
||||
|
||||
export function TravelConfirmationModal(props: IProps): React.ReactElement {
|
||||
const cost = CONSTANTS.TravelCost;
|
||||
function travel(): void {
|
||||
props.travel();
|
||||
}
|
||||
@@ -22,7 +21,8 @@ export function TravelConfirmationModal(props: IProps): React.ReactElement {
|
||||
return (
|
||||
<Modal open={props.open} onClose={props.onClose}>
|
||||
<Typography>
|
||||
Would you like to travel to {props.city}? The trip will cost <Money money={cost} forPurchase={true} />.
|
||||
Would you like to travel to {props.city}? The trip will cost{" "}
|
||||
<Money money={CONSTANTS.TravelCost} forPurchase={true} />.
|
||||
</Typography>
|
||||
<br />
|
||||
<br />
|
||||
|
||||
Reference in New Issue
Block a user