mini game fixes

This commit is contained in:
phyzical 2022-03-25 23:39:14 +08:00
parent e69bb21b5c
commit a0d845ffae
8 changed files with 33 additions and 32 deletions

@ -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";

@ -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 (
<Grid container spacing={3}>
<GameTimer millis={timer} onExpire={props.onFailure} />
<Grid item xs={12}>
<Typography variant="h4">Type it backward</Typography>
<Typography variant="h4">Type it{!hasAugment ? " backward" : ""}</Typography>
<KeyHandler onKeyDown={press} onFailure={props.onFailure} />
</Grid>
<Grid item xs={6}>
<Typography style={answerStyle}>{answer}</Typography>
<Typography style={{ transform: hasAugment ? "none" : "scaleX(-1)", marginLeft: hasAugment ? "50%" : "none" }}>
{answer}
</Typography>
</Grid>
<Grid item xs={6}>
<Typography>

@ -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;

@ -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;
}

@ -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 (
<span key={`${x}${y}`} style={{ fontSize: fontSize, color: selectOptionColor }}>
<span key={`${x}${y}`} style={{ fontSize: fontSize, color: "blue" }}>
{cell}&nbsp;
</span>
);
}
const optionColor = hasAugment && isCorrectAnswer ? Settings.theme.success : Settings.theme.primary;
const optionColor = hasAugment && !isCorrectAnswer ? Settings.theme.disabled : Settings.theme.primary;
return (
<span key={`${x}${y}`} style={{ fontSize: fontSize, color: optionColor }}>
{cell}&nbsp;

@ -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{" "}
</>
) : (
<></>

@ -119,7 +119,7 @@ export function WireCuttingGame(props: IMinigameProps): React.ReactElement {
if ((i === 3 || i === 4) && cutWires[j]) {
return <span key={j}>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>;
}
const isCorrectWire = checkWire(j);
const isCorrectWire = checkWire(j + 1);
const wireColor =
hasAugment && !isCorrectWire ? Settings.theme.disabled : wire.colors[i % wire.colors.length];
return (

@ -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) {