mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-23 09:42:53 +02:00
No more player/router context
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
import { Button, Container, Paper, Typography } from "@mui/material";
|
||||
import React, { useState } from "react";
|
||||
import { AugmentationNames } from "../../Augmentation/data/AugmentationNames";
|
||||
import { use } from "../../ui/Context";
|
||||
import { Router } from "../../ui/GameRoot";
|
||||
import { Player } from "../../Player";
|
||||
import { BackwardGame } from "./BackwardGame";
|
||||
import { BracketGame } from "./BracketGame";
|
||||
import { BribeGame } from "./BribeGame";
|
||||
@@ -39,8 +40,6 @@ const minigames = [
|
||||
];
|
||||
|
||||
export function Game(props: IProps): React.ReactElement {
|
||||
const player = use.Player();
|
||||
const router = use.Router();
|
||||
const [level, setLevel] = useState(1);
|
||||
const [stage, setStage] = useState(Stage.Countdown);
|
||||
const [results, setResults] = useState("");
|
||||
@@ -91,17 +90,17 @@ export function Game(props: IProps): React.ReactElement {
|
||||
// Kill the player immediately if they use automation, so
|
||||
// it's clear they're not meant to
|
||||
const damage = options?.automated
|
||||
? player.hp.current
|
||||
: props.StartingDifficulty * 3 * (player.hasAugmentation(AugmentationNames.WKSharmonizer, true) ? 0.5 : 1);
|
||||
if (player.takeDamage(damage)) {
|
||||
router.toCity();
|
||||
? Player.hp.current
|
||||
: props.StartingDifficulty * 3 * (Player.hasAugmentation(AugmentationNames.WKSharmonizer, true) ? 0.5 : 1);
|
||||
if (Player.takeDamage(damage)) {
|
||||
Router.toCity();
|
||||
return;
|
||||
}
|
||||
setupNextGame();
|
||||
}
|
||||
|
||||
function cancel(): void {
|
||||
router.toCity();
|
||||
Router.toCity();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Paper } from "@mui/material";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { AugmentationNames } from "../../Augmentation/data/AugmentationNames";
|
||||
import { use } from "../../ui/Context";
|
||||
import { Player } from "../../Player";
|
||||
import { ProgressBar } from "../../ui/React/Progress";
|
||||
|
||||
interface IProps {
|
||||
@@ -11,9 +11,8 @@ interface IProps {
|
||||
}
|
||||
|
||||
export function GameTimer(props: IProps): React.ReactElement {
|
||||
const player = use.Player();
|
||||
const [v, setV] = useState(100);
|
||||
const totalMillis = (player.hasAugmentation(AugmentationNames.WKSharmonizer, true) ? 1.3 : 1) * props.millis;
|
||||
const totalMillis = (Player.hasAugmentation(AugmentationNames.WKSharmonizer, true) ? 1.3 : 1) * props.millis;
|
||||
|
||||
const tick = 200;
|
||||
useEffect(() => {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import React, { useState } from "react";
|
||||
import { Location } from "../../Locations/Location";
|
||||
import { use } from "../../ui/Context";
|
||||
import { Router } from "../../ui/GameRoot";
|
||||
import { Player } from "../../Player";
|
||||
import { calculateDifficulty, calculateReward } from "../formulas/game";
|
||||
import { Game } from "./Game";
|
||||
import { Intro } from "./Intro";
|
||||
@@ -9,17 +10,15 @@ interface IProps {
|
||||
}
|
||||
|
||||
export function InfiltrationRoot(props: IProps): React.ReactElement {
|
||||
const player = use.Player();
|
||||
const router = use.Router();
|
||||
const [start, setStart] = useState(false);
|
||||
|
||||
if (props.location.infiltrationData === undefined) throw new Error("Trying to do infiltration on invalid location.");
|
||||
const startingSecurityLevel = props.location.infiltrationData.startingSecurityLevel;
|
||||
const difficulty = calculateDifficulty(player, startingSecurityLevel);
|
||||
const reward = calculateReward(player, startingSecurityLevel);
|
||||
const difficulty = calculateDifficulty(Player, startingSecurityLevel);
|
||||
const reward = calculateReward(Player, startingSecurityLevel);
|
||||
|
||||
function cancel(): void {
|
||||
router.toCity();
|
||||
Router.toCity();
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
@@ -3,7 +3,8 @@ import React, { useState } from "react";
|
||||
import { FactionNames } from "../../Faction/data/FactionNames";
|
||||
import { inviteToFaction } from "../../Faction/FactionHelpers";
|
||||
import { Factions } from "../../Faction/Factions";
|
||||
import { use } from "../../ui/Context";
|
||||
import { Router } from "../../ui/GameRoot";
|
||||
import { Player } from "../../Player";
|
||||
import { Money } from "../../ui/React/Money";
|
||||
import { Reputation } from "../../ui/React/Reputation";
|
||||
import { formatNumber } from "../../utils/StringHelperFunctions";
|
||||
@@ -21,25 +22,23 @@ interface IProps {
|
||||
}
|
||||
|
||||
export function Victory(props: IProps): React.ReactElement {
|
||||
const player = use.Player();
|
||||
const router = use.Router();
|
||||
const [faction, setFaction] = useState("none");
|
||||
|
||||
function quitInfiltration(): void {
|
||||
handleInfiltrators();
|
||||
router.toCity();
|
||||
Router.toCity();
|
||||
}
|
||||
|
||||
const soa = Factions[FactionNames.ShadowsOfAnarchy];
|
||||
const repGain = calculateTradeInformationRepReward(player, props.Reward, props.MaxLevel, props.StartingDifficulty);
|
||||
const moneyGain = calculateSellInformationCashReward(player, props.Reward, props.MaxLevel, props.StartingDifficulty);
|
||||
const infiltrationRepGain = calculateInfiltratorsRepReward(player, soa, props.StartingDifficulty);
|
||||
const repGain = calculateTradeInformationRepReward(Player, props.Reward, props.MaxLevel, props.StartingDifficulty);
|
||||
const moneyGain = calculateSellInformationCashReward(Player, props.Reward, props.MaxLevel, props.StartingDifficulty);
|
||||
const infiltrationRepGain = calculateInfiltratorsRepReward(Player, soa, props.StartingDifficulty);
|
||||
|
||||
const isMemberOfInfiltrators = player.factions.includes(FactionNames.ShadowsOfAnarchy);
|
||||
const isMemberOfInfiltrators = Player.factions.includes(FactionNames.ShadowsOfAnarchy);
|
||||
|
||||
function sell(): void {
|
||||
handleInfiltrators();
|
||||
player.gainMoney(moneyGain, "infiltration");
|
||||
Player.gainMoney(moneyGain, "infiltration");
|
||||
quitInfiltration();
|
||||
}
|
||||
|
||||
@@ -81,7 +80,7 @@ export function Victory(props: IProps): React.ReactElement {
|
||||
<MenuItem key={"none"} value={"none"}>
|
||||
{"none"}
|
||||
</MenuItem>
|
||||
{player.factions
|
||||
{Player.factions
|
||||
.filter((f) => Factions[f].getInfo().offersWork())
|
||||
.map((f) => (
|
||||
<MenuItem key={f} value={f}>
|
||||
|
||||
Reference in New Issue
Block a user