mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-05-05 23:27:55 +02:00
prettify, sorry for the big ass commit
This commit is contained in:
+43
-32
@@ -5,44 +5,55 @@ import { IEngine } from "../IEngine";
|
||||
import * as React from "react";
|
||||
import * as ReactDOM from "react-dom";
|
||||
|
||||
let container: HTMLElement = document.createElement('div');
|
||||
let container: HTMLElement = document.createElement("div");
|
||||
|
||||
(function() {
|
||||
function setContainer(): void {
|
||||
const c = document.getElementById("infiltration-container");
|
||||
if(c === null) throw new Error("huh?");
|
||||
container = c;
|
||||
document.removeEventListener("DOMContentLoaded", setContainer);
|
||||
}
|
||||
(function () {
|
||||
function setContainer(): void {
|
||||
const c = document.getElementById("infiltration-container");
|
||||
if (c === null) throw new Error("huh?");
|
||||
container = c;
|
||||
document.removeEventListener("DOMContentLoaded", setContainer);
|
||||
}
|
||||
|
||||
document.addEventListener("DOMContentLoaded", setContainer);
|
||||
document.addEventListener("DOMContentLoaded", setContainer);
|
||||
})();
|
||||
|
||||
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;
|
||||
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 displayInfiltrationContent(engine: IEngine, player: IPlayer, location: string, startingDifficulty: number, maxLevel: number): void {
|
||||
if (!routing.isOn(Page.Infiltration)) return;
|
||||
export function displayInfiltrationContent(
|
||||
engine: IEngine,
|
||||
player: IPlayer,
|
||||
location: string,
|
||||
startingDifficulty: number,
|
||||
maxLevel: number,
|
||||
): void {
|
||||
if (!routing.isOn(Page.Infiltration)) return;
|
||||
|
||||
const difficulty = calcDifficulty(player, startingDifficulty);
|
||||
const difficulty = calcDifficulty(player, startingDifficulty);
|
||||
|
||||
ReactDOM.render(<Root
|
||||
Engine={engine}
|
||||
Player={player}
|
||||
Location={location}
|
||||
StartingDifficulty={startingDifficulty}
|
||||
Difficulty={difficulty}
|
||||
MaxLevel={maxLevel}
|
||||
/>, container);
|
||||
}
|
||||
ReactDOM.render(
|
||||
<Root
|
||||
Engine={engine}
|
||||
Player={player}
|
||||
Location={location}
|
||||
StartingDifficulty={startingDifficulty}
|
||||
Difficulty={difficulty}
|
||||
MaxLevel={maxLevel}
|
||||
/>,
|
||||
container,
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user