Skip to content

Commit

Permalink
Remove first stage
Browse files Browse the repository at this point in the history
  • Loading branch information
T-Damer committed Aug 7, 2024
1 parent f551c58 commit f8377d5
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 11 deletions.
5 changes: 2 additions & 3 deletions src/components/TowerGame/SkeletonLoader.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import GridWrapper from 'components/TowerGame/GridWrapper'
import towerHeight from 'components/TowerGame/towerHeight'
import { TowerType, TypeToGuessMax } from 'types/TowerGame'
import { towerHeight, TowerType, TypeToGuessMax } from 'types/TowerGame'

export default function ({ towerType }: { towerType: TowerType }) {
const cardsInRow = TypeToGuessMax[towerType] + 1

const components = [...Array(cardsInRow * towerHeight)].map(() => (
const components = [...Array(cardsInRow * towerHeight(towerType))].map(() => (
<div className="rounded-2xl w-full h-20 bg-pale-purple animate-pulse" />
))
return <GridWrapper maxInRow={cardsInRow}>{components}</GridWrapper>
Expand Down
4 changes: 2 additions & 2 deletions src/components/TowerGame/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import HatIcon from 'components/icons/HatIcon'
import GridWrapper from 'components/TowerGame/GridWrapper'
import TowerCard from 'components/TowerGame/TowerCard'
import towerHeight from 'components/TowerGame/towerHeight'
import { guess } from 'helpers/api/towerGame'
import roundNumber from 'helpers/numbers/roundNumber'
import queryClient from 'helpers/queryClient'
Expand All @@ -12,6 +11,7 @@ import {
TowerCardStatus,
TowerGame,
TowerGameStatus,
towerHeight,
TowerType,
TypeToGuessMax,
TypeToMultipliers,
Expand Down Expand Up @@ -112,7 +112,7 @@ export default function ({

return (
<GridWrapper maxInRow={maxInRow}>
{[...Array(towerHeight)].map((_, index) => (
{[...Array(towerHeight(towerType))].map((_, index) => (
<CardRow
rowLength={maxInRow}
onClick={onClick}
Expand Down
1 change: 0 additions & 1 deletion src/components/TowerGame/towerHeight.tsx

This file was deleted.

10 changes: 7 additions & 3 deletions src/helpers/tower/getHiddenCardStatuses.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import towerHeight from 'components/TowerGame/towerHeight'
import { TowerCardStatus, TowerType, TypeToGuessMax } from 'types/TowerGame'
import {
TowerCardStatus,
towerHeight,
TowerType,
TypeToGuessMax,
} from 'types/TowerGame'

export default function (towerType: TowerType) {
const rowLength = TypeToGuessMax[towerType] + 1

const singleRow = Array(rowLength).fill(TowerCardStatus.hidden)
return Array(towerHeight).fill(singleRow)
return Array(towerHeight(towerType)).fill(singleRow)
}
7 changes: 5 additions & 2 deletions src/types/TowerGame.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@ export const TypeToGuessMax = {
}

export const TypeToMultipliers = {
[TowerType.easy]: [1, 1.4, 2.1, 3, 4.4, 6.5, 9.4, 13.8, 20, 29.2],
[TowerType.hard]: [1, 3, 7, 14, 27, 53, 103, 200, 389, 755],
[TowerType.easy]: [1.4, 2.1, 3, 4.4, 6.5, 9.4, 13.8, 20, 29.2],
[TowerType.hard]: [3, 7, 14, 27, 53, 103, 200, 389, 755],
}

export const towerHeight = (towerType: TowerType) =>
TypeToMultipliers[towerType].length

export enum TowerGameStatus {
ongoing,
finished,
Expand Down

0 comments on commit f8377d5

Please sign in to comment.