diff --git a/.gitignore b/.gitignore index c71e11d1b..15432b4a3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +.vscode Changelog.txt Netburner.txt /doc/build diff --git a/src/Infiltration/ui/BackwardGame.tsx b/src/Infiltration/ui/BackwardGame.tsx index 65d818a9c..7dcaf4254 100644 --- a/src/Infiltration/ui/BackwardGame.tsx +++ b/src/Infiltration/ui/BackwardGame.tsx @@ -46,7 +46,7 @@ export function BackwardGame(props: IMinigameProps): React.ReactElement {

Type it backward

- +

{answer}

diff --git a/src/Infiltration/ui/BracketGame.tsx b/src/Infiltration/ui/BracketGame.tsx index 5309b281f..f3d6cd16d 100644 --- a/src/Infiltration/ui/BracketGame.tsx +++ b/src/Infiltration/ui/BracketGame.tsx @@ -78,7 +78,7 @@ export function BracketGame(props: IMinigameProps): React.ReactElement {

Close the brackets

{`${left}${right}`}

- +
) } \ No newline at end of file diff --git a/src/Infiltration/ui/BribeGame.tsx b/src/Infiltration/ui/BribeGame.tsx index 03040dc11..c4160a23e 100644 --- a/src/Infiltration/ui/BribeGame.tsx +++ b/src/Infiltration/ui/BribeGame.tsx @@ -51,7 +51,7 @@ export function BribeGame(props: IMinigameProps): React.ReactElement {

Say something nice about the guard.

- +

diff --git a/src/Infiltration/ui/CheatCodeGame.tsx b/src/Infiltration/ui/CheatCodeGame.tsx index c0c12cbcf..943b314ae 100644 --- a/src/Infiltration/ui/CheatCodeGame.tsx +++ b/src/Infiltration/ui/CheatCodeGame.tsx @@ -47,7 +47,7 @@ export function CheatCodeGame(props: IMinigameProps): React.ReactElement {

Enter the Code!

{code[index]}

- +
) } diff --git a/src/Infiltration/ui/Cyberpunk2077Game.tsx b/src/Infiltration/ui/Cyberpunk2077Game.tsx index edd2787e3..49b8cac58 100644 --- a/src/Infiltration/ui/Cyberpunk2077Game.tsx +++ b/src/Infiltration/ui/Cyberpunk2077Game.tsx @@ -86,7 +86,7 @@ export function Cyberpunk2077Game(props: IMinigameProps): React.ReactElement { return {cell}  return {cell}  })}
)} - + ) } diff --git a/src/Infiltration/ui/Game.tsx b/src/Infiltration/ui/Game.tsx index 08aad0f35..e4c15188e 100644 --- a/src/Infiltration/ui/Game.tsx +++ b/src/Infiltration/ui/Game.tsx @@ -85,10 +85,13 @@ export function Game(props: IProps): React.ReactElement { }) } - function failure(): void { + function failure(options?: { automated: boolean }): void { setStage(Stage.Countdown); pushResult(false); - if(props.Player.takeDamage(props.StartingDifficulty*3)) { + // 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; + if(props.Player.takeDamage(damage)) { const menu = document.getElementById("mainmenu-container"); if(menu === null) throw new Error("mainmenu-container not found"); menu.style.visibility = "visible"; diff --git a/src/Infiltration/ui/IMinigameProps.tsx b/src/Infiltration/ui/IMinigameProps.tsx index 595c1ba8e..d3ba7ab63 100644 --- a/src/Infiltration/ui/IMinigameProps.tsx +++ b/src/Infiltration/ui/IMinigameProps.tsx @@ -1,5 +1,8 @@ export interface IMinigameProps { onSuccess: () => void; - onFailure: () => void; + onFailure: (options?: { + /** Failed due to using untrusted events (automation) */ + automated: boolean; + }) => void; difficulty: number; } \ No newline at end of file diff --git a/src/Infiltration/ui/KeyHandler.tsx b/src/Infiltration/ui/KeyHandler.tsx index 42f8c5d23..384f6f8c6 100644 --- a/src/Infiltration/ui/KeyHandler.tsx +++ b/src/Infiltration/ui/KeyHandler.tsx @@ -2,6 +2,7 @@ import React, { useEffect } from 'react'; interface IProps { onKeyDown: (event: React.KeyboardEvent) => void; + onFailure: (options?: { automated: boolean }) => void; } export function KeyHandler(props: IProps): React.ReactElement { @@ -9,7 +10,12 @@ export function KeyHandler(props: IProps): React.ReactElement { useEffect(() => elem.focus()); function onKeyDown(event: React.KeyboardEvent): void { - if(!event.isTrusted) return; + console.log("isTrusted?", event.isTrusted) + if(!event.isTrusted) { + console.log("untrusted event!") + props.onFailure({ automated: true }); + return; + } props.onKeyDown(event); } diff --git a/src/Infiltration/ui/MinesweeperGame.tsx b/src/Infiltration/ui/MinesweeperGame.tsx index bdafb5f4f..3f1434c32 100644 --- a/src/Infiltration/ui/MinesweeperGame.tsx +++ b/src/Infiltration/ui/MinesweeperGame.tsx @@ -94,7 +94,7 @@ export function MinesweeperGame(props: IMinigameProps): React.ReactElement { return [ ]  } })}
)} - + ) } diff --git a/src/Infiltration/ui/SlashGame.tsx b/src/Infiltration/ui/SlashGame.tsx index aab93b888..eede5efcb 100644 --- a/src/Infiltration/ui/SlashGame.tsx +++ b/src/Infiltration/ui/SlashGame.tsx @@ -54,7 +54,7 @@ export function SlashGame(props: IMinigameProps): React.ReactElement {

Slash when his guard is down!

{guarding ? "!Guarding!" : "!ATTACKING!"}

- +
) } \ No newline at end of file diff --git a/src/Infiltration/ui/WireCuttingGame.tsx b/src/Infiltration/ui/WireCuttingGame.tsx index c6816dadc..92201baeb 100644 --- a/src/Infiltration/ui/WireCuttingGame.tsx +++ b/src/Infiltration/ui/WireCuttingGame.tsx @@ -111,7 +111,7 @@ export function WireCuttingGame(props: IMinigameProps): React.ReactElement { })} )} - + ) }