mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-26 19:14:32 +02:00
big work
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import { IPlayer } from "../../PersonObjects/IPlayer";
|
||||
import { IEngine } from "../../IEngine";
|
||||
import { use } from "../../ui/Context";
|
||||
import React, { useState } from "react";
|
||||
import Grid from "@mui/material/Grid";
|
||||
import { Countdown } from "./Countdown";
|
||||
@@ -14,8 +13,6 @@ import { WireCuttingGame } from "./WireCuttingGame";
|
||||
import { Victory } from "./Victory";
|
||||
|
||||
interface IProps {
|
||||
Player: IPlayer;
|
||||
Engine: IEngine;
|
||||
StartingDifficulty: number;
|
||||
Difficulty: number;
|
||||
MaxLevel: number;
|
||||
@@ -40,6 +37,8 @@ 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("");
|
||||
@@ -89,12 +88,10 @@ export function Game(props: IProps): React.ReactElement {
|
||||
pushResult(false);
|
||||
// Kill the player immediately if they use automation, so
|
||||
// it's clear they're not meant to
|
||||
const damage = options?.automated ? props.Player.hp : props.StartingDifficulty * 3;
|
||||
if (props.Player.takeDamage(damage)) {
|
||||
const menu = document.getElementById("mainmenu-container");
|
||||
if (menu === null) throw new Error("mainmenu-container not found");
|
||||
menu.style.visibility = "visible";
|
||||
props.Engine.loadLocationContent();
|
||||
const damage = options?.automated ? player.hp : props.StartingDifficulty * 3;
|
||||
if (player.takeDamage(damage)) {
|
||||
router.toCity();
|
||||
return;
|
||||
}
|
||||
setupNextGame();
|
||||
}
|
||||
@@ -112,8 +109,6 @@ export function Game(props: IProps): React.ReactElement {
|
||||
case Stage.Sell:
|
||||
stageComponent = (
|
||||
<Victory
|
||||
Player={props.Player}
|
||||
Engine={props.Engine}
|
||||
StartingDifficulty={props.StartingDifficulty}
|
||||
Difficulty={props.Difficulty}
|
||||
MaxLevel={props.MaxLevel}
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
import { IPlayer } from "../../PersonObjects/IPlayer";
|
||||
import React, { useState } from "react";
|
||||
import { Intro } from "./Intro";
|
||||
import { Game } from "./Game";
|
||||
import { LocationName } from "../../Locations/data/LocationNames";
|
||||
import { Locations } from "../../Locations/Locations";
|
||||
import { use } from "../../ui/Context";
|
||||
|
||||
interface IProps {
|
||||
location: LocationName;
|
||||
}
|
||||
function calcDifficulty(player: IPlayer, startingDifficulty: number): number {
|
||||
const totalStats = player.strength + player.defense + player.dexterity + player.agility + player.charisma;
|
||||
const difficulty = startingDifficulty - Math.pow(totalStats, 0.9) / 250 - player.intelligence / 1600;
|
||||
if (difficulty < 0) return 0;
|
||||
if (difficulty > 3) return 3;
|
||||
return difficulty;
|
||||
}
|
||||
|
||||
export function InfiltrationRoot(props: IProps): React.ReactElement {
|
||||
const player = use.Player();
|
||||
const router = use.Router();
|
||||
const [start, setStart] = useState(false);
|
||||
|
||||
const loc = Locations[props.location];
|
||||
if (loc.infiltrationData === undefined) throw new Error("Trying to do infiltration on invalid location.");
|
||||
const startingDifficulty = loc.infiltrationData.startingSecurityLevel;
|
||||
const difficulty = calcDifficulty(player, startingDifficulty);
|
||||
|
||||
function cancel(): void {
|
||||
router.toCity();
|
||||
}
|
||||
|
||||
if (!start) {
|
||||
return (
|
||||
<Intro
|
||||
Location={props.location}
|
||||
Difficulty={difficulty}
|
||||
MaxLevel={loc.infiltrationData.maxClearanceLevel}
|
||||
start={() => setStart(true)}
|
||||
cancel={cancel}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Game
|
||||
StartingDifficulty={startingDifficulty}
|
||||
Difficulty={difficulty}
|
||||
MaxLevel={loc.infiltrationData.maxClearanceLevel}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -1,12 +1,8 @@
|
||||
import { IPlayer } from "../../PersonObjects/IPlayer";
|
||||
import { IEngine } from "../../IEngine";
|
||||
import React from "react";
|
||||
import { StdButton } from "../../ui/React/StdButton";
|
||||
import Grid from "@mui/material/Grid";
|
||||
|
||||
interface IProps {
|
||||
Player: IPlayer;
|
||||
Engine: IEngine;
|
||||
Location: string;
|
||||
Difficulty: number;
|
||||
MaxLevel: number;
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
import { IPlayer } from "../../PersonObjects/IPlayer";
|
||||
import { IEngine } from "../../IEngine";
|
||||
import React, { useState } from "react";
|
||||
import { Intro } from "./Intro";
|
||||
import { Game } from "./Game";
|
||||
|
||||
interface IProps {
|
||||
Player: IPlayer;
|
||||
Engine: IEngine;
|
||||
Location: string;
|
||||
StartingDifficulty: number;
|
||||
Difficulty: number;
|
||||
MaxLevel: number;
|
||||
}
|
||||
|
||||
export function Root(props: IProps): React.ReactElement {
|
||||
const [start, setStart] = useState(false);
|
||||
|
||||
function cancel(): void {
|
||||
const menu = document.getElementById("mainmenu-container");
|
||||
if (menu === null) throw new Error("mainmenu-container not found");
|
||||
menu.style.visibility = "visible";
|
||||
props.Engine.loadLocationContent();
|
||||
}
|
||||
|
||||
if (!start) {
|
||||
return (
|
||||
<Intro
|
||||
Player={props.Player}
|
||||
Engine={props.Engine}
|
||||
Location={props.Location}
|
||||
Difficulty={props.Difficulty}
|
||||
MaxLevel={props.MaxLevel}
|
||||
start={() => setStart(true)}
|
||||
cancel={cancel}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Game
|
||||
Player={props.Player}
|
||||
Engine={props.Engine}
|
||||
StartingDifficulty={props.StartingDifficulty}
|
||||
Difficulty={props.Difficulty}
|
||||
MaxLevel={props.MaxLevel}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -1,5 +1,3 @@
|
||||
import { IPlayer } from "../../PersonObjects/IPlayer";
|
||||
import { IEngine } from "../../IEngine";
|
||||
import { Factions } from "../../Faction/Factions";
|
||||
import React, { useState } from "react";
|
||||
import { StdButton } from "../../ui/React/StdButton";
|
||||
@@ -7,23 +5,21 @@ import Grid from "@mui/material/Grid";
|
||||
import { Money } from "../../ui/React/Money";
|
||||
import { Reputation } from "../../ui/React/Reputation";
|
||||
import { BitNodeMultipliers } from "../../BitNode/BitNodeMultipliers";
|
||||
import { use } from "../../ui/Context";
|
||||
|
||||
interface IProps {
|
||||
Player: IPlayer;
|
||||
Engine: IEngine;
|
||||
StartingDifficulty: number;
|
||||
Difficulty: number;
|
||||
MaxLevel: number;
|
||||
}
|
||||
|
||||
export function Victory(props: IProps): React.ReactElement {
|
||||
const player = use.Player();
|
||||
const router = use.Router();
|
||||
const [faction, setFaction] = useState("none");
|
||||
|
||||
function quitInfiltration(): void {
|
||||
const menu = document.getElementById("mainmenu-container");
|
||||
if (!menu) throw new Error("mainmenu-container somehow null");
|
||||
menu.style.visibility = "visible";
|
||||
props.Engine.loadLocationContent();
|
||||
router.toCity();
|
||||
}
|
||||
|
||||
const levelBonus = props.MaxLevel * Math.pow(1.01, props.MaxLevel);
|
||||
@@ -43,8 +39,8 @@ export function Victory(props: IProps): React.ReactElement {
|
||||
BitNodeMultipliers.InfiltrationMoney;
|
||||
|
||||
function sell(): void {
|
||||
props.Player.gainMoney(moneyGain);
|
||||
props.Player.recordMoneySource(moneyGain, "infiltration");
|
||||
player.gainMoney(moneyGain);
|
||||
player.recordMoneySource(moneyGain, "infiltration");
|
||||
quitInfiltration();
|
||||
}
|
||||
|
||||
@@ -70,7 +66,7 @@ export function Victory(props: IProps): React.ReactElement {
|
||||
<option key={"none"} value={"none"}>
|
||||
{"none"}
|
||||
</option>
|
||||
{props.Player.factions
|
||||
{player.factions
|
||||
.filter((f) => Factions[f].getInfo().offersWork())
|
||||
.map((f) => (
|
||||
<option key={f} value={f}>
|
||||
|
||||
Reference in New Issue
Block a user