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 { PlayerOwnedAugmentation } from "../Augmentation/PlayerOwnedAugmentation";
import { AugmentationNames } from "../Augmentation/data/AugmentationNames"; import { AugmentationNames } from "../Augmentation/data/AugmentationNames";
import { BitNodeMultipliers } from "../BitNode/BitNodeMultipliers"; import { BitNodeMultipliers } from "../BitNode/BitNodeMultipliers";
import { CONSTANTS } from "../Constants";
import { Faction } from "./Faction"; import { Faction } from "./Faction";
import { Factions } from "./Factions"; import { Factions } from "./Factions";
@ -14,7 +13,6 @@ import {
getFactionSecurityWorkRepGain, getFactionSecurityWorkRepGain,
getFactionFieldWorkRepGain, getFactionFieldWorkRepGain,
} from "../PersonObjects/formulas/reputation"; } from "../PersonObjects/formulas/reputation";
import { SourceFileFlags } from "../SourceFile/SourceFileFlags";
import { dialogBoxCreate } from "../ui/React/DialogBox"; import { dialogBoxCreate } from "../ui/React/DialogBox";
import { InvitationEvent } from "./ui/InvitationModal"; import { InvitationEvent } from "./ui/InvitationModal";

@ -47,24 +47,17 @@ export function BackwardGame(props: IMinigameProps): React.ReactElement {
else setGuess(nextGuess); else setGuess(nextGuess);
} }
interface AnswerStyle {
transform?: string;
}
const answerStyle: AnswerStyle = { transform: "scaleX(-1)" };
if (hasAugment) {
delete answerStyle.transform;
}
return ( return (
<Grid container spacing={3}> <Grid container spacing={3}>
<GameTimer millis={timer} onExpire={props.onFailure} /> <GameTimer millis={timer} onExpire={props.onFailure} />
<Grid item xs={12}> <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} /> <KeyHandler onKeyDown={press} onFailure={props.onFailure} />
</Grid> </Grid>
<Grid item xs={6}> <Grid item xs={6}>
<Typography style={answerStyle}>{answer}</Typography> <Typography style={{ transform: hasAugment ? "none" : "scaleX(-1)", marginLeft: hasAugment ? "50%" : "none" }}>
{answer}
</Typography>
</Grid> </Grid>
<Grid item xs={6}> <Grid item xs={6}>
<Typography> <Typography>

@ -38,7 +38,7 @@ function generateLeftSide(difficulty: Difficulty): string {
} }
const length = random(difficulty.min, difficulty.max); const length = random(difficulty.min, difficulty.max);
for (let i = 0; i < length; i++) { for (let i = 0; i < length; i++) {
str += options[Math.floor(Math.random() * 4)]; str += options[Math.floor(Math.random() * options.length)];
} }
return str; return str;

@ -46,7 +46,7 @@ export function CheatCodeGame(props: IMinigameProps): React.ReactElement {
function press(this: Document, event: KeyboardEvent): void { function press(this: Document, event: KeyboardEvent): void {
event.preventDefault(); event.preventDefault();
if (code[index] !== getArrow(event) || (hasAugment && getInverseArrow(event))) { if (code[index] !== getArrow(event) && (!hasAugment || code[index] !== getInverseArrow(event))) {
props.onFailure(); props.onFailure();
return; return;
} }

@ -106,15 +106,14 @@ export function Cyberpunk2077Game(props: IMinigameProps): React.ReactElement {
const isCorrectAnswer = cell === answers[currentAnswerIndex]; const isCorrectAnswer = cell === answers[currentAnswerIndex];
if (x == pos[0] && y == pos[1]) { if (x == pos[0] && y == pos[1]) {
const selectOptionColor = hasAugment && isCorrectAnswer ? Settings.theme.success : "blue";
return ( return (
<span key={`${x}${y}`} style={{ fontSize: fontSize, color: selectOptionColor }}> <span key={`${x}${y}`} style={{ fontSize: fontSize, color: "blue" }}>
{cell}&nbsp; {cell}&nbsp;
</span> </span>
); );
} }
const optionColor = hasAugment && isCorrectAnswer ? Settings.theme.success : Settings.theme.primary; const optionColor = hasAugment && !isCorrectAnswer ? Settings.theme.disabled : Settings.theme.primary;
return ( return (
<span key={`${x}${y}`} style={{ fontSize: fontSize, color: optionColor }}> <span key={`${x}${y}`} style={{ fontSize: fontSize, color: optionColor }}>
{cell}&nbsp; {cell}&nbsp;

@ -11,6 +11,8 @@ import MenuItem from "@mui/material/MenuItem";
import Select, { SelectChangeEvent } from "@mui/material/Select"; import Select, { SelectChangeEvent } from "@mui/material/Select";
import { FactionNames } from "../../Faction/data/FactionNames"; import { FactionNames } from "../../Faction/data/FactionNames";
import { AugmentationNames } from "../../Augmentation/data/AugmentationNames"; import { AugmentationNames } from "../../Augmentation/data/AugmentationNames";
import { LocationsMetadata } from "../../Locations/data/LocationsMetadata";
import { formatNumber } from "../../utils/StringHelperFunctions";
interface IProps { interface IProps {
StartingDifficulty: number; StartingDifficulty: number;
@ -38,14 +40,6 @@ export function Victory(props: IProps): React.ReactElement {
levelBonus * levelBonus *
BitNodeMultipliers.InfiltrationRep; 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 infiltratorFaction = Factions[FactionNames.Infiltrators];
const isMemberOfInfiltrators = infiltratorFaction && infiltratorFaction.isMember; const isMemberOfInfiltrators = infiltratorFaction && infiltratorFaction.isMember;
@ -56,6 +50,23 @@ export function Victory(props: IProps): React.ReactElement {
levelBonus * levelBonus *
BitNodeMultipliers.InfiltrationMoney; 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 { function sell(): void {
handleInfiltrators(); handleInfiltrators();
player.gainMoney(moneyGain, "infiltration"); player.gainMoney(moneyGain, "infiltration");
@ -76,7 +87,7 @@ export function Victory(props: IProps): React.ReactElement {
function handleInfiltrators(): void { function handleInfiltrators(): void {
player.hasCompletedAnInfiltration = true; player.hasCompletedAnInfiltration = true;
if (isMemberOfInfiltrators) { if (isMemberOfInfiltrators) {
infiltratorFaction.playerReputation += infiltratorsRepGain; infiltratorFaction.playerReputation += calculateInfiltratorsRepReward();
} }
} }
@ -91,7 +102,7 @@ export function Victory(props: IProps): React.ReactElement {
You{" "} You{" "}
{isMemberOfInfiltrators ? ( {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]) { 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>;
} }
const isCorrectWire = checkWire(j); const isCorrectWire = checkWire(j + 1);
const wireColor = const wireColor =
hasAugment && !isCorrectWire ? Settings.theme.disabled : wire.colors[i % wire.colors.length]; hasAugment && !isCorrectWire ? Settings.theme.disabled : wire.colors[i % wire.colors.length];
return ( return (

@ -5,9 +5,9 @@ export function random(min: number, max: number): number {
} }
export const upArrowSymbol = "↑"; export const upArrowSymbol = "↑";
export const downArrowSymbol = ""; export const downArrowSymbol = "";
export const leftArrowSymbol = ""; export const leftArrowSymbol = "";
export const rightArrowSymbol = ""; export const rightArrowSymbol = "";
export function getArrow(event: KeyboardEvent): string { export function getArrow(event: KeyboardEvent): string {
switch (event.key) { switch (event.key) {