blob: 2f4a2ec7640e4ceb05876f33c009f683c2d21734 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
import React from "react";
import { GuessType } from "../../types/guess";
import { Song } from "../../types/song";
import { playTimes } from "../../constants";
import { Button, Guess, Player, Search, Result } from "../";
import * as Styled from "./index.styled";
interface Props {
guesses: GuessType[];
todaysSolution: Song;
currentTry: number;
didGuess: boolean;
setSelectedSong: React.Dispatch<React.SetStateAction<Song | undefined>>;
skip: () => void;
guess: () => void;
}
export function Game({
guesses,
todaysSolution,
currentTry,
didGuess,
setSelectedSong,
skip,
guess,
}: Props) {
if (didGuess || currentTry === 6) {
return (
<Result
didGuess={didGuess}
currentTry={currentTry}
todaysSolution={todaysSolution}
guesses={guesses}
/>
);
}
return (
<>
{guesses.map((guess: GuessType, index) => (
<Guess
key={index}
guess={guess}
active={index === currentTry}
/>
))}
<Player id={todaysSolution.youtubeId} currentTry={currentTry} />
<Search currentTry={currentTry} setSelectedSong={setSelectedSong} />
<Styled.Buttons>
<Button onClick={skip}>
{currentTry === 5
? "Give Up"
: `Skip +${playTimes[currentTry] / 1000}s`}
</Button>
<Button variant="green" onClick={guess}>
Submit
</Button>
</Styled.Buttons>
</>
);
}
|