Skip to content

Commit 41fa124

Browse files
fix linter issues
1 parent b2b8104 commit 41fa124

File tree

6 files changed

+20
-26
lines changed

6 files changed

+20
-26
lines changed

src/components/game/Controllers/index.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ const Controllers: React.FC<ControllersProps> = ({ isSpinning, onSpin }) => {
2929
const isAutoSpinOn: boolean = useSelector((state: State) => state.slotMachine.isAutoSpinOn);
3030
const showPayLines: boolean = useSelector((state: State) => state.slotMachine.showPayLines);
3131
const winPayLines: PayLine[] = useSelector((state: State) => state.slotMachine.winPayLines);
32-
const bonusFactor: number = useSelector((state: State) => state.slotMachine.bonusFactor);
3332
const dispatch = useDispatch();
3433

3534
const coinsSound: HTMLAudioElement = new Audio(CoinsSound);

src/components/game/Reels/index.tsx

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useEffect, useMemo } from 'react';
1+
import React, { useMemo } from 'react';
22
import { nanoid } from 'nanoid';
33
import { useSelector } from 'react-redux';
44
import { PayLines, Reel } from '@/components';
@@ -15,7 +15,9 @@ interface ReelsProps {
1515
const Reels: React.FunctionComponent<ReelsProps> = ({ reels }) => {
1616
const animationDuration =
1717
getRandomNumber(MIN_SPIN_ANIMATION_DURATION, MAX_SPIN_ANIMATION_DURATION) * Math.random();
18-
const bonusWildCardsPositions: Position[] = useSelector((state: State) => state.slotMachine.bonusWildcardsPositions);
18+
const bonusWildCardsPositions: Position[] = useSelector(
19+
(state: State) => state.slotMachine.bonusWildcardsPositions
20+
);
1921
const bonusFactor: number = useSelector((state: State) => state.slotMachine.bonusFactor);
2022
const bonusText: string = useMemo(() => {
2123
if (!!bonusWildCardsPositions.length && !!bonusFactor) {

src/components/game/SlotMachine/index.tsx

+3-9
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,7 @@ import { nanoid } from 'nanoid';
44
import { Controllers, Reels, WinsDisplay } from '@/components';
55
import { ANIMATE_RESULTS_DURATION, ROW_NUMBER } from '@/game-configs';
66
import { ModalType, Position, SlotScreenResult, Symbol } from '@/types';
7-
import {
8-
SPIN_ENDED,
9-
GAME_RESET,
10-
GAME_LEFT,
11-
NEW_SPIN_PREPARED,
12-
SPAN,
13-
} from '@/store/action-types';
7+
import { SPIN_ENDED, GAME_RESET, GAME_LEFT, NEW_SPIN_PREPARED, SPAN } from '@/store/action-types';
148
import {
159
getScreenResult,
1610
getScreenWithBonusWildcards,
@@ -136,7 +130,7 @@ const SlotMachine: React.FC = () => {
136130
const endSound = !!slotResult.winPayLines.length ? winSound : loseSound;
137131
endSound.play();
138132
}
139-
133+
140134
const timeToNewSpin: number = getTimerForNewSpin(slotResult);
141135

142136
// shuffle reels for next spinning
@@ -176,7 +170,7 @@ const SlotMachine: React.FC = () => {
176170
const shuffledReels = getShuffledReels();
177171
setReels(shuffledReels);
178172
setGameConfigs();
179-
/* worker.postMessage('hello');
173+
/* worker.postMessage('hello');
180174
181175
worker.onmessage = event => {
182176
console.log(777, event)

src/game-utils.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { SYMBOLS_METADATA } from './game-configs';
2-
import { Position, SlotScreenResult, Symbol } from './types';
2+
import type { Position, SlotScreenResult, Symbol } from './types';
33
import { getRandomPosition, getScreenResult, isPositionFilled } from './game-utils';
44

55
// MATCH PAY LINES 2 and 3 with 3 React symbol (returns winAmount 2)

src/game-utils.ts

+11-12
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,9 @@ export const wonBonusWildCards = (): boolean => Math.random() < 0.3;
8080

8181
// not matched symbols are different and none of them is wildcard
8282
const areSymbolsNotMatched = (symbolAType: SymbolType, symbolB: Symbol): boolean =>
83-
symbolAType !== symbolB.type && (symbolAType !== WILDCARD_METADATA.type && symbolB.type !== WILDCARD_METADATA.type);
83+
symbolAType !== symbolB.type &&
84+
symbolAType !== WILDCARD_METADATA.type &&
85+
symbolB.type !== WILDCARD_METADATA.type;
8486

8587
export const getScreenWithBonusWildcards = (
8688
slotScreen: Symbol[][]
@@ -113,16 +115,16 @@ const getPayLineResult = (slotScreen: Symbol[][], payLine: PayLine): PayLineResu
113115
if (numberOfSymbolsInLine >= MIN_MATCH_SEQUENCE_NUMBER) {
114116
break;
115117
}
116-
117-
// If no win sequence yet, check if previous symbol is a Wildcard, which was not set as currentSymbol in the previous iteration
118+
119+
// If no win sequence yet, check if previous symbol is a Wildcard, which was not set as currentSymbol in the previous iteration
118120
// because regular symbols are preferentially stored instead, to be able to check if the next symbols are a match with them
119121

120-
// if index of previous symbol is higher than MIN_MATCH_SEQUENCE_NUMBER, there is no chance to match a line
122+
// if index of previous symbol is higher than MIN_MATCH_SEQUENCE_NUMBER, there is no chance to match a line
121123
// even if we have a wildcard in the previous posiiton, so break
122124
if (positionIndex - 1 > MIN_MATCH_SEQUENCE_NUMBER - 1) {
123125
break;
124126
}
125-
127+
126128
const previousPosition: Position = payLine.positions[positionIndex - 1];
127129
const previousSymbol: Symbol = slotScreen[previousPosition.reel][previousPosition.row];
128130
// Check if previous symbol is wildcard, so the new line can start being evaluated from the wildcard position
@@ -132,12 +134,12 @@ const getPayLineResult = (slotScreen: Symbol[][], payLine: PayLine): PayLineResu
132134
initialPositionIndex = positionIndex - 1;
133135
continue;
134136
}
135-
136-
// if no wildcard in previous position and currentSymbolIndex is higher than MIN_MATCH_SEQUENCE_NUMBER, there is no chance to match, so break
137+
138+
// if no wildcard in previous position and currentSymbolIndex is higher than MIN_MATCH_SEQUENCE_NUMBER, there is no chance to match, so break
137139
if (positionIndex > MIN_MATCH_SEQUENCE_NUMBER - 1) {
138140
break;
139141
}
140-
142+
141143
// if there is still a chance to match, adjust initial checking variables and continue to next iteration
142144
currentSymbolType = symbol.type;
143145
numberOfSymbolsInLine = 1;
@@ -185,10 +187,7 @@ export const getScreenResult = (slotScreen: Symbol[][]): SlotScreenResult => {
185187
freeSpins += FREE_SPINS_NUMBER;
186188
}
187189

188-
const winFactor: number = findWinFactor(
189-
currentSymbolType as SymbolType,
190-
numberOfSymbolsInLine
191-
);
190+
const winFactor: number = findWinFactor(currentSymbolType as SymbolType, numberOfSymbolsInLine);
192191
winAmount += winFactor;
193192
winPayLines.push({
194193
...payLine,

src/store/reducers/slot-machine.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { DEFAULT_BET, INITIAL_CREDITS, PAY_LINES_METADATA } from '@/game-configs';
2-
import { PayLine, Position, SlotScreenResult } from '@/types';
2+
import { PayLine, Position } from '@/types';
33
import { BET_UPDATED, SPAN, SPIN_ENDED } from '../action-types';
44
import { State, reducer as slotMachineReducer } from './slot-machine';
55

0 commit comments

Comments
 (0)