MISC: Rename getRandomArbitrary (#1605)

This commit is contained in:
catloversg
2024-08-22 06:50:51 +07:00
committed by GitHub
parent 995e367432
commit 818d7446be
6 changed files with 13 additions and 13 deletions
+2 -2
View File
@@ -8,7 +8,7 @@ import { interpolate } from "./Difficulty";
import { GameTimer } from "./GameTimer";
import { IMinigameProps } from "./IMinigameProps";
import { KeyHandler } from "./KeyHandler";
import { getRandomArbitrary } from "../../utils/helpers/getRandomArbitrary";
import { randomInRange } from "../../utils/helpers/randomInRange";
interface Difficulty {
[key: string]: number;
@@ -67,7 +67,7 @@ export function BackwardGame(props: IMinigameProps): React.ReactElement {
}
function makeAnswer(difficulty: Difficulty): string {
const length = getRandomArbitrary(difficulty.min, difficulty.max);
const length = randomInRange(difficulty.min, difficulty.max);
let answer = "";
for (let i = 0; i < length; i++) {
if (i > 0) answer += " ";
+2 -2
View File
@@ -8,7 +8,7 @@ import { interpolate } from "./Difficulty";
import { GameTimer } from "./GameTimer";
import { IMinigameProps } from "./IMinigameProps";
import { KeyHandler } from "./KeyHandler";
import { getRandomArbitrary } from "../../utils/helpers/getRandomArbitrary";
import { randomInRange } from "../../utils/helpers/randomInRange";
interface Difficulty {
[key: string]: number;
@@ -35,7 +35,7 @@ function generateLeftSide(difficulty: Difficulty): string {
if (Player.hasAugmentation(AugmentationName.WisdomOfAthena, true)) {
options.splice(0, 1);
}
const length = getRandomArbitrary(difficulty.min, difficulty.max);
const length = randomInRange(difficulty.min, difficulty.max);
for (let i = 0; i < length; i++) {
str += options[Math.floor(Math.random() * options.length)];
}
+2 -2
View File
@@ -7,7 +7,7 @@ import { interpolate } from "./Difficulty";
import { GameTimer } from "./GameTimer";
import { IMinigameProps } from "./IMinigameProps";
import { KeyHandler } from "./KeyHandler";
import { getRandomArbitrary } from "../../utils/helpers/getRandomArbitrary";
import { randomInRange } from "../../utils/helpers/randomInRange";
interface Difficulty {
[key: string]: number;
@@ -78,7 +78,7 @@ export function CheatCodeGame(props: IMinigameProps): React.ReactElement {
function generateCode(difficulty: Difficulty): Arrow[] {
const arrows: Arrow[] = [leftArrowSymbol, rightArrowSymbol, upArrowSymbol, downArrowSymbol];
const code: Arrow[] = [];
for (let i = 0; i < getRandomArbitrary(difficulty.min, difficulty.max); i++) {
for (let i = 0; i < randomInRange(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())];
code.push(arrow);
+2 -2
View File
@@ -9,7 +9,7 @@ import { GameTimer } from "./GameTimer";
import { IMinigameProps } from "./IMinigameProps";
import { KeyHandler } from "./KeyHandler";
import { isPositiveInteger } from "../../types";
import { getRandomArbitrary } from "../../utils/helpers/getRandomArbitrary";
import { randomInRange } from "../../utils/helpers/randomInRange";
interface Difficulty {
[key: string]: number;
@@ -200,7 +200,7 @@ function generateQuestion(wires: Wire[], difficulty: Difficulty): Question[] {
function generateWires(difficulty: Difficulty): Wire[] {
const wires = [];
const numWires = getRandomArbitrary(difficulty.wiresmin, difficulty.wiresmax);
const numWires = randomInRange(difficulty.wiresmin, difficulty.wiresmax);
for (let i = 0; i < numWires; i++) {
const wireColors = [colors[Math.floor(Math.random() * colors.length)]];
if (Math.random() < 0.15) {