mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-05-01 13:27:08 +02:00
more updates
* added more keycodes constant support * implemented new faction mechanics for mini games * more small refactors
This commit is contained in:
@@ -3,9 +3,19 @@ import Grid from "@mui/material/Grid";
|
||||
import { IMinigameProps } from "./IMinigameProps";
|
||||
import { KeyHandler } from "./KeyHandler";
|
||||
import { GameTimer } from "./GameTimer";
|
||||
import { random, getArrow } from "../utils";
|
||||
import {
|
||||
random,
|
||||
getArrow,
|
||||
getInverseArrow,
|
||||
leftArrowSymbol,
|
||||
rightArrowSymbol,
|
||||
upArrowSymbol,
|
||||
downArrowSymbol,
|
||||
} from "../utils";
|
||||
import { interpolate } from "./Difficulty";
|
||||
import Typography from "@mui/material/Typography";
|
||||
import { AugmentationNames } from "../../Augmentation/data/AugmentationNames";
|
||||
import { Player } from "../../Player";
|
||||
|
||||
interface Difficulty {
|
||||
[key: string]: number;
|
||||
@@ -32,10 +42,11 @@ export function CheatCodeGame(props: IMinigameProps): React.ReactElement {
|
||||
const timer = difficulty.timer;
|
||||
const [code] = useState(generateCode(difficulty));
|
||||
const [index, setIndex] = useState(0);
|
||||
const hasAugment = Player.hasAugmentation(AugmentationNames.LameSharkRepository, true);
|
||||
|
||||
function press(this: Document, event: KeyboardEvent): void {
|
||||
event.preventDefault();
|
||||
if (code[index] !== getArrow(event)) {
|
||||
if (code[index] !== getArrow(event) || (hasAugment && getInverseArrow(event))) {
|
||||
props.onFailure();
|
||||
return;
|
||||
}
|
||||
@@ -56,7 +67,7 @@ export function CheatCodeGame(props: IMinigameProps): React.ReactElement {
|
||||
}
|
||||
|
||||
function generateCode(difficulty: Difficulty): string {
|
||||
const arrows = ["←", "→", "↑", "↓"];
|
||||
const arrows = [leftArrowSymbol, rightArrowSymbol, upArrowSymbol, downArrowSymbol];
|
||||
let code = "";
|
||||
for (let i = 0; i < random(difficulty.min, difficulty.max); i++) {
|
||||
let arrow = arrows[Math.floor(4 * Math.random())];
|
||||
|
||||
Reference in New Issue
Block a user