mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-05-02 05:47:14 +02:00
BLADEBURNER: Add API to calculate max upgrade count of skill (#1475)
This commit is contained in:
@@ -3,12 +3,12 @@ import React, { useState } from "react";
|
||||
import { AugmentationName } from "@enums";
|
||||
import { Player } from "@player";
|
||||
import { KEY } from "../../utils/helpers/keyCodes";
|
||||
import { random } from "../utils";
|
||||
import { BlinkingCursor } from "./BlinkingCursor";
|
||||
import { interpolate } from "./Difficulty";
|
||||
import { GameTimer } from "./GameTimer";
|
||||
import { IMinigameProps } from "./IMinigameProps";
|
||||
import { KeyHandler } from "./KeyHandler";
|
||||
import { getRandomArbitrary } from "../../utils/helpers/getRandomArbitrary";
|
||||
|
||||
interface Difficulty {
|
||||
[key: string]: number;
|
||||
@@ -67,7 +67,7 @@ export function BackwardGame(props: IMinigameProps): React.ReactElement {
|
||||
}
|
||||
|
||||
function makeAnswer(difficulty: Difficulty): string {
|
||||
const length = random(difficulty.min, difficulty.max);
|
||||
const length = getRandomArbitrary(difficulty.min, difficulty.max);
|
||||
let answer = "";
|
||||
for (let i = 0; i < length; i++) {
|
||||
if (i > 0) answer += " ";
|
||||
|
||||
@@ -3,12 +3,12 @@ import React, { useState } from "react";
|
||||
import { AugmentationName } from "@enums";
|
||||
import { Player } from "@player";
|
||||
import { KEY } from "../../utils/helpers/keyCodes";
|
||||
import { random } from "../utils";
|
||||
import { BlinkingCursor } from "./BlinkingCursor";
|
||||
import { interpolate } from "./Difficulty";
|
||||
import { GameTimer } from "./GameTimer";
|
||||
import { IMinigameProps } from "./IMinigameProps";
|
||||
import { KeyHandler } from "./KeyHandler";
|
||||
import { getRandomArbitrary } from "../../utils/helpers/getRandomArbitrary";
|
||||
|
||||
interface Difficulty {
|
||||
[key: string]: number;
|
||||
@@ -35,7 +35,7 @@ function generateLeftSide(difficulty: Difficulty): string {
|
||||
if (Player.hasAugmentation(AugmentationName.WisdomOfAthena, true)) {
|
||||
options.splice(0, 1);
|
||||
}
|
||||
const length = random(difficulty.min, difficulty.max);
|
||||
const length = getRandomArbitrary(difficulty.min, difficulty.max);
|
||||
for (let i = 0; i < length; i++) {
|
||||
str += options[Math.floor(Math.random() * options.length)];
|
||||
}
|
||||
|
||||
@@ -2,11 +2,12 @@ import { Paper, Typography } from "@mui/material";
|
||||
import React, { useState } from "react";
|
||||
import { AugmentationName } from "@enums";
|
||||
import { Player } from "@player";
|
||||
import { Arrow, downArrowSymbol, getArrow, leftArrowSymbol, random, rightArrowSymbol, upArrowSymbol } from "../utils";
|
||||
import { Arrow, downArrowSymbol, getArrow, leftArrowSymbol, rightArrowSymbol, upArrowSymbol } from "../utils";
|
||||
import { interpolate } from "./Difficulty";
|
||||
import { GameTimer } from "./GameTimer";
|
||||
import { IMinigameProps } from "./IMinigameProps";
|
||||
import { KeyHandler } from "./KeyHandler";
|
||||
import { getRandomArbitrary } from "../../utils/helpers/getRandomArbitrary";
|
||||
|
||||
interface Difficulty {
|
||||
[key: string]: number;
|
||||
@@ -77,7 +78,7 @@ export function CheatCodeGame(props: IMinigameProps): React.ReactElement {
|
||||
function generateCode(difficulty: Difficulty): Arrow[] {
|
||||
const arrows: Arrow[] = [leftArrowSymbol, rightArrowSymbol, upArrowSymbol, downArrowSymbol];
|
||||
const code: Arrow[] = [];
|
||||
for (let i = 0; i < random(difficulty.min, difficulty.max); i++) {
|
||||
for (let i = 0; i < getRandomArbitrary(difficulty.min, difficulty.max); i++) {
|
||||
let arrow = arrows[Math.floor(4 * Math.random())];
|
||||
while (arrow === code[code.length - 1]) arrow = arrows[Math.floor(4 * Math.random())];
|
||||
code.push(arrow);
|
||||
|
||||
@@ -4,12 +4,12 @@ import { Box, Paper, Typography } from "@mui/material";
|
||||
import { AugmentationName } from "@enums";
|
||||
import { Player } from "@player";
|
||||
import { Settings } from "../../Settings/Settings";
|
||||
import { random } from "../utils";
|
||||
import { interpolate } from "./Difficulty";
|
||||
import { GameTimer } from "./GameTimer";
|
||||
import { IMinigameProps } from "./IMinigameProps";
|
||||
import { KeyHandler } from "./KeyHandler";
|
||||
import { isPositiveInteger } from "../../types";
|
||||
import { getRandomArbitrary } from "../../utils/helpers/getRandomArbitrary";
|
||||
|
||||
interface Difficulty {
|
||||
[key: string]: number;
|
||||
@@ -200,7 +200,7 @@ function generateQuestion(wires: Wire[], difficulty: Difficulty): Question[] {
|
||||
|
||||
function generateWires(difficulty: Difficulty): Wire[] {
|
||||
const wires = [];
|
||||
const numWires = random(difficulty.wiresmin, difficulty.wiresmax);
|
||||
const numWires = getRandomArbitrary(difficulty.wiresmin, difficulty.wiresmax);
|
||||
for (let i = 0; i < numWires; i++) {
|
||||
const wireColors = [colors[Math.floor(Math.random() * colors.length)]];
|
||||
if (Math.random() < 0.15) {
|
||||
|
||||
Reference in New Issue
Block a user