From a0d845ffaee1a033cb8f607e78625b750895c63e Mon Sep 17 00:00:00 2001 From: phyzical Date: Fri, 25 Mar 2022 23:39:14 +0800 Subject: [PATCH] mini game fixes --- src/Faction/FactionHelpers.tsx | 2 -- src/Infiltration/ui/BackwardGame.tsx | 15 +++-------- src/Infiltration/ui/BracketGame.tsx | 2 +- src/Infiltration/ui/CheatCodeGame.tsx | 2 +- src/Infiltration/ui/Cyberpunk2077Game.tsx | 5 ++-- src/Infiltration/ui/Victory.tsx | 31 +++++++++++++++-------- src/Infiltration/ui/WireCuttingGame.tsx | 2 +- src/Infiltration/utils.ts | 6 ++--- 8 files changed, 33 insertions(+), 32 deletions(-) diff --git a/src/Faction/FactionHelpers.tsx b/src/Faction/FactionHelpers.tsx index e4bad6b8f..96e489c64 100644 --- a/src/Faction/FactionHelpers.tsx +++ b/src/Faction/FactionHelpers.tsx @@ -3,7 +3,6 @@ import { Augmentation } from "../Augmentation/Augmentation"; import { PlayerOwnedAugmentation } from "../Augmentation/PlayerOwnedAugmentation"; import { AugmentationNames } from "../Augmentation/data/AugmentationNames"; import { BitNodeMultipliers } from "../BitNode/BitNodeMultipliers"; -import { CONSTANTS } from "../Constants"; import { Faction } from "./Faction"; import { Factions } from "./Factions"; @@ -14,7 +13,6 @@ import { getFactionSecurityWorkRepGain, getFactionFieldWorkRepGain, } from "../PersonObjects/formulas/reputation"; -import { SourceFileFlags } from "../SourceFile/SourceFileFlags"; import { dialogBoxCreate } from "../ui/React/DialogBox"; import { InvitationEvent } from "./ui/InvitationModal"; diff --git a/src/Infiltration/ui/BackwardGame.tsx b/src/Infiltration/ui/BackwardGame.tsx index 6081fcac6..8459af59b 100644 --- a/src/Infiltration/ui/BackwardGame.tsx +++ b/src/Infiltration/ui/BackwardGame.tsx @@ -47,24 +47,17 @@ export function BackwardGame(props: IMinigameProps): React.ReactElement { else setGuess(nextGuess); } - interface AnswerStyle { - transform?: string; - } - - const answerStyle: AnswerStyle = { transform: "scaleX(-1)" }; - if (hasAugment) { - delete answerStyle.transform; - } - return ( - Type it backward + Type it{!hasAugment ? " backward" : ""} - {answer} + + {answer} + diff --git a/src/Infiltration/ui/BracketGame.tsx b/src/Infiltration/ui/BracketGame.tsx index 72b3ecad4..0eec21a9f 100644 --- a/src/Infiltration/ui/BracketGame.tsx +++ b/src/Infiltration/ui/BracketGame.tsx @@ -38,7 +38,7 @@ function generateLeftSide(difficulty: Difficulty): string { } const length = random(difficulty.min, difficulty.max); for (let i = 0; i < length; i++) { - str += options[Math.floor(Math.random() * 4)]; + str += options[Math.floor(Math.random() * options.length)]; } return str; diff --git a/src/Infiltration/ui/CheatCodeGame.tsx b/src/Infiltration/ui/CheatCodeGame.tsx index d1f20c784..990477bc1 100644 --- a/src/Infiltration/ui/CheatCodeGame.tsx +++ b/src/Infiltration/ui/CheatCodeGame.tsx @@ -46,7 +46,7 @@ export function CheatCodeGame(props: IMinigameProps): React.ReactElement { function press(this: Document, event: KeyboardEvent): void { event.preventDefault(); - if (code[index] !== getArrow(event) || (hasAugment && getInverseArrow(event))) { + if (code[index] !== getArrow(event) && (!hasAugment || code[index] !== getInverseArrow(event))) { props.onFailure(); return; } diff --git a/src/Infiltration/ui/Cyberpunk2077Game.tsx b/src/Infiltration/ui/Cyberpunk2077Game.tsx index d86211e24..054c4a705 100644 --- a/src/Infiltration/ui/Cyberpunk2077Game.tsx +++ b/src/Infiltration/ui/Cyberpunk2077Game.tsx @@ -106,15 +106,14 @@ export function Cyberpunk2077Game(props: IMinigameProps): React.ReactElement { const isCorrectAnswer = cell === answers[currentAnswerIndex]; if (x == pos[0] && y == pos[1]) { - const selectOptionColor = hasAugment && isCorrectAnswer ? Settings.theme.success : "blue"; return ( - + {cell}  ); } - const optionColor = hasAugment && isCorrectAnswer ? Settings.theme.success : Settings.theme.primary; + const optionColor = hasAugment && !isCorrectAnswer ? Settings.theme.disabled : Settings.theme.primary; return ( {cell}  diff --git a/src/Infiltration/ui/Victory.tsx b/src/Infiltration/ui/Victory.tsx index aa77ace16..4c2388f9b 100644 --- a/src/Infiltration/ui/Victory.tsx +++ b/src/Infiltration/ui/Victory.tsx @@ -11,6 +11,8 @@ import MenuItem from "@mui/material/MenuItem"; import Select, { SelectChangeEvent } from "@mui/material/Select"; import { FactionNames } from "../../Faction/data/FactionNames"; import { AugmentationNames } from "../../Augmentation/data/AugmentationNames"; +import { LocationsMetadata } from "../../Locations/data/LocationsMetadata"; +import { formatNumber } from "../../utils/StringHelperFunctions"; interface IProps { StartingDifficulty: number; @@ -38,14 +40,6 @@ export function Victory(props: IProps): React.ReactElement { levelBonus * BitNodeMultipliers.InfiltrationRep; - const bionicFingersRepGain = player.hasAugmentation(AugmentationNames.BionicFingers, true) ? 5 : 0; - const CorporationManagementImplantRepMultiplier = player.hasAugmentation( - AugmentationNames.CorporationManagementImplant, - true, - ) - ? 2.5 - : 1; - const infiltratorsRepGain = (5 + bionicFingersRepGain) * CorporationManagementImplantRepMultiplier; const infiltratorFaction = Factions[FactionNames.Infiltrators]; const isMemberOfInfiltrators = infiltratorFaction && infiltratorFaction.isMember; @@ -56,6 +50,23 @@ export function Victory(props: IProps): React.ReactElement { levelBonus * BitNodeMultipliers.InfiltrationMoney; + function calculateInfiltratorsRepReward(): number { + const bionicFingersRepGain = player.hasAugmentation(AugmentationNames.BionicFingers, true) ? 5 : 0; + const CorporationManagementImplantRepMultiplier = player.hasAugmentation( + AugmentationNames.CorporationManagementImplant, + true, + ) + ? 2.5 + : 1; + const maxStartingSecurityLevel = LocationsMetadata.reduce((acc, data): number => { + const startingSecurityLevel = data.infiltrationData?.startingSecurityLevel || 0; + return acc > startingSecurityLevel ? acc : startingSecurityLevel; + }, 0); + const baseRepGain = (props.StartingDifficulty / maxStartingSecurityLevel) * 10; + + return (baseRepGain + bionicFingersRepGain) * CorporationManagementImplantRepMultiplier; + } + function sell(): void { handleInfiltrators(); player.gainMoney(moneyGain, "infiltration"); @@ -76,7 +87,7 @@ export function Victory(props: IProps): React.ReactElement { function handleInfiltrators(): void { player.hasCompletedAnInfiltration = true; if (isMemberOfInfiltrators) { - infiltratorFaction.playerReputation += infiltratorsRepGain; + infiltratorFaction.playerReputation += calculateInfiltratorsRepReward(); } } @@ -91,7 +102,7 @@ export function Victory(props: IProps): React.ReactElement { You{" "} {isMemberOfInfiltrators ? ( <> - have gained {infiltratorsRepGain} rep for {FactionNames.Infiltrators} and + have gained {formatNumber(calculateInfiltratorsRepReward(), 2)} rep for {FactionNames.Infiltrators} and{" "} ) : ( <> diff --git a/src/Infiltration/ui/WireCuttingGame.tsx b/src/Infiltration/ui/WireCuttingGame.tsx index 7cbfd0948..e236c4351 100644 --- a/src/Infiltration/ui/WireCuttingGame.tsx +++ b/src/Infiltration/ui/WireCuttingGame.tsx @@ -119,7 +119,7 @@ export function WireCuttingGame(props: IMinigameProps): React.ReactElement { if ((i === 3 || i === 4) && cutWires[j]) { return       ; } - const isCorrectWire = checkWire(j); + const isCorrectWire = checkWire(j + 1); const wireColor = hasAugment && !isCorrectWire ? Settings.theme.disabled : wire.colors[i % wire.colors.length]; return ( diff --git a/src/Infiltration/utils.ts b/src/Infiltration/utils.ts index d338423d5..ed8f6fedc 100644 --- a/src/Infiltration/utils.ts +++ b/src/Infiltration/utils.ts @@ -5,9 +5,9 @@ export function random(min: number, max: number): number { } export const upArrowSymbol = "↑"; -export const downArrowSymbol = "↑"; -export const leftArrowSymbol = "↑"; -export const rightArrowSymbol = "↑"; +export const downArrowSymbol = "↓"; +export const leftArrowSymbol = "←"; +export const rightArrowSymbol = "→"; export function getArrow(event: KeyboardEvent): string { switch (event.key) {