mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-25 18:50:56 +02:00
fix sleeve memory bug
This commit is contained in:
@@ -59,8 +59,7 @@ function generateCode(difficulty: Difficulty): string {
|
||||
let code = "";
|
||||
for (let i = 0; i < random(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())];
|
||||
while (arrow === code[code.length - 1]) arrow = arrows[Math.floor(4 * Math.random())];
|
||||
code += arrow;
|
||||
}
|
||||
|
||||
|
||||
@@ -99,10 +99,7 @@ export function Cyberpunk2077Game(props: IMinigameProps): React.ReactElement {
|
||||
{line.map((cell, x) => {
|
||||
if (x == pos[0] && y == pos[1])
|
||||
return (
|
||||
<span
|
||||
key={`${x}${y}`}
|
||||
style={{ fontSize: fontSize, color: "blue" }}
|
||||
>
|
||||
<span key={`${x}${y}`} style={{ fontSize: fontSize, color: "blue" }}>
|
||||
{cell}
|
||||
</span>
|
||||
);
|
||||
@@ -125,11 +122,7 @@ export function Cyberpunk2077Game(props: IMinigameProps): React.ReactElement {
|
||||
function generateAnswer(grid: string[][], difficulty: Difficulty): string[] {
|
||||
const answer = [];
|
||||
for (let i = 0; i < Math.round(difficulty.symbols); i++) {
|
||||
answer.push(
|
||||
grid[Math.floor(Math.random() * grid.length)][
|
||||
Math.floor(Math.random() * grid[0].length)
|
||||
],
|
||||
);
|
||||
answer.push(grid[Math.floor(Math.random() * grid.length)][Math.floor(Math.random() * grid[0].length)]);
|
||||
}
|
||||
return answer;
|
||||
}
|
||||
|
||||
@@ -12,17 +12,9 @@ interface DifficultySettings {
|
||||
// I could use `any` to simply some of this but I also want to take advantage
|
||||
// of the type safety that typescript provides. I'm just not sure how in this
|
||||
// case.
|
||||
export function interpolate(
|
||||
settings: DifficultySettings,
|
||||
n: number,
|
||||
out: DifficultySetting,
|
||||
): DifficultySetting {
|
||||
export function interpolate(settings: DifficultySettings, n: number, out: DifficultySetting): DifficultySetting {
|
||||
// interpolates between 2 difficulties.
|
||||
function lerpD(
|
||||
a: DifficultySetting,
|
||||
b: DifficultySetting,
|
||||
t: number,
|
||||
): DifficultySetting {
|
||||
function lerpD(a: DifficultySetting, b: DifficultySetting, t: number): DifficultySetting {
|
||||
// interpolates between 2 numbers.
|
||||
function lerp(x: number, y: number, t: number): number {
|
||||
return (1 - t) * x + t * y;
|
||||
|
||||
@@ -89,9 +89,7 @@ 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;
|
||||
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");
|
||||
@@ -108,13 +106,7 @@ export function Game(props: IProps): React.ReactElement {
|
||||
break;
|
||||
case Stage.Minigame: {
|
||||
const MiniGame = minigames[gameIds.id];
|
||||
stageComponent = (
|
||||
<MiniGame
|
||||
onSuccess={success}
|
||||
onFailure={failure}
|
||||
difficulty={props.Difficulty + level / 50}
|
||||
/>
|
||||
);
|
||||
stageComponent = <MiniGame onSuccess={success} onFailure={failure} difficulty={props.Difficulty + level / 50} />;
|
||||
break;
|
||||
}
|
||||
case Stage.Sell:
|
||||
@@ -133,9 +125,7 @@ export function Game(props: IProps): React.ReactElement {
|
||||
function Progress(): React.ReactElement {
|
||||
return (
|
||||
<h4>
|
||||
<span style={{ color: "gray" }}>
|
||||
{results.slice(0, results.length - 1)}
|
||||
</span>
|
||||
<span style={{ color: "gray" }}>{results.slice(0, results.length - 1)}</span>
|
||||
{results[results.length - 1]}
|
||||
</h4>
|
||||
);
|
||||
|
||||
@@ -67,15 +67,11 @@ export function Intro(props: IProps): React.ReactElement {
|
||||
</Grid>
|
||||
<Grid item xs={10}>
|
||||
<p>
|
||||
Infiltration is a series of short minigames that get progressively
|
||||
harder. You take damage for failing them. Reaching the maximum level
|
||||
rewards you with intel you can trade for money or reputation.
|
||||
Infiltration is a series of short minigames that get progressively harder. You take damage for failing them.
|
||||
Reaching the maximum level rewards you with intel you can trade for money or reputation.
|
||||
</p>
|
||||
<br />
|
||||
<p>
|
||||
The minigames you play are randomly selected. It might take you few
|
||||
tries to get used to them.
|
||||
</p>
|
||||
<p>The minigames you play are randomly selected. It might take you few tries to get used to them.</p>
|
||||
<br />
|
||||
<p>No game require use of the mouse.</p>
|
||||
<br />
|
||||
|
||||
@@ -81,9 +81,7 @@ export function MinesweeperGame(props: IMinigameProps): React.ReactElement {
|
||||
<Grid container spacing={3}>
|
||||
<GameTimer millis={timer} onExpire={props.onFailure} />
|
||||
<Grid item xs={12}>
|
||||
<h1 className={"noselect"}>
|
||||
{memoryPhase ? "Remember all the mines!" : "Mark all the mines!"}
|
||||
</h1>
|
||||
<h1 className={"noselect"}>{memoryPhase ? "Remember all the mines!" : "Mark all the mines!"}</h1>
|
||||
{minefield.map((line, y) => (
|
||||
<div key={y}>
|
||||
<pre>
|
||||
@@ -92,8 +90,7 @@ export function MinesweeperGame(props: IMinigameProps): React.ReactElement {
|
||||
if (minefield[y][x]) return <span key={x}>[?] </span>;
|
||||
return <span key={x}>[ ] </span>;
|
||||
} else {
|
||||
if (x == pos[0] && y == pos[1])
|
||||
return <span key={x}>[X] </span>;
|
||||
if (x == pos[0] && y == pos[1]) return <span key={x}>[X] </span>;
|
||||
if (answer[y][x]) return <span key={x}>[.] </span>;
|
||||
return <span key={x}>[ ] </span>;
|
||||
}
|
||||
|
||||
@@ -54,9 +54,7 @@ export function SlashGame(props: IMinigameProps): React.ReactElement {
|
||||
<GameTimer millis={5000} onExpire={props.onFailure} />
|
||||
<Grid item xs={12}>
|
||||
<h1 className={"noselect"}>Slash when his guard is down!</h1>
|
||||
<p style={{ fontSize: "5em" }}>
|
||||
{guarding ? "!Guarding!" : "!ATTACKING!"}
|
||||
</p>
|
||||
<p style={{ fontSize: "5em" }}>{guarding ? "!Guarding!" : "!ATTACKING!"}</p>
|
||||
<KeyHandler onKeyDown={press} onFailure={props.onFailure} />
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
||||
@@ -65,10 +65,7 @@ export function Victory(props: IProps): React.ReactElement {
|
||||
<h1>Infiltration successful!</h1>
|
||||
</Grid>
|
||||
<Grid item xs={10}>
|
||||
<h2>
|
||||
You can trade the confidential information you found for money or
|
||||
reputation.
|
||||
</h2>
|
||||
<h2>You can trade the confidential information you found for money or reputation.</h2>
|
||||
<select className={"dropdown"} onChange={changeDropdown}>
|
||||
<option key={"none"} value={"none"}>
|
||||
{"none"}
|
||||
|
||||
@@ -68,9 +68,7 @@ export function WireCuttingGame(props: IMinigameProps): React.ReactElement {
|
||||
setCutWires((old) => {
|
||||
const next = [...old];
|
||||
next[wireNum - 1] = true;
|
||||
if (
|
||||
!questions.some((q) => q.shouldCut(wires[wireNum - 1], wireNum - 1))
|
||||
) {
|
||||
if (!questions.some((q) => q.shouldCut(wires[wireNum - 1], wireNum - 1))) {
|
||||
props.onFailure();
|
||||
}
|
||||
|
||||
@@ -95,9 +93,7 @@ export function WireCuttingGame(props: IMinigameProps): React.ReactElement {
|
||||
<Grid container spacing={3}>
|
||||
<GameTimer millis={timer} onExpire={props.onFailure} />
|
||||
<Grid item xs={12}>
|
||||
<h1 className={"noselect"}>
|
||||
Cut the wires with the following properties! (keyboard 1 to 9)
|
||||
</h1>
|
||||
<h1 className={"noselect"}>Cut the wires with the following properties! (keyboard 1 to 9)</h1>
|
||||
{questions.map((question, i) => (
|
||||
<h3 key={i}>{question.toString()}</h3>
|
||||
))}
|
||||
@@ -111,14 +107,9 @@ export function WireCuttingGame(props: IMinigameProps): React.ReactElement {
|
||||
<pre>
|
||||
{wires.map((wire, j) => {
|
||||
if ((i === 3 || i === 4) && cutWires[j])
|
||||
return (
|
||||
<span key={j}> </span>
|
||||
);
|
||||
return <span key={j}> </span>;
|
||||
return (
|
||||
<span
|
||||
key={j}
|
||||
style={{ color: wire.colors[i % wire.colors.length] }}
|
||||
>
|
||||
<span key={j} style={{ color: wire.colors[i % wire.colors.length] }}>
|
||||
|{wire.tpe}|
|
||||
</span>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user