fix sleeve memory bug

This commit is contained in:
Olivier Gagnon
2021-09-08 23:47:34 -04:00
parent bada8a5f39
commit 2a13db39c7
360 changed files with 5424 additions and 15764 deletions
+1 -2
View File
@@ -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;
}
+2 -9
View File
@@ -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}&nbsp;
</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;
}
+2 -10
View File
@@ -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;
+3 -13
View File
@@ -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>
);
+3 -7
View File
@@ -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 />
+2 -5
View File
@@ -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}>[?]&nbsp;</span>;
return <span key={x}>[&nbsp;]&nbsp;</span>;
} else {
if (x == pos[0] && y == pos[1])
return <span key={x}>[X]&nbsp;</span>;
if (x == pos[0] && y == pos[1]) return <span key={x}>[X]&nbsp;</span>;
if (answer[y][x]) return <span key={x}>[.]&nbsp;</span>;
return <span key={x}>[&nbsp;]&nbsp;</span>;
}
+1 -3
View File
@@ -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>
+1 -4
View File
@@ -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"}
+4 -13
View File
@@ -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}>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
);
return <span key={j}>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</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}|&nbsp;&nbsp;&nbsp;
</span>
);