-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
28 changed files
with
469 additions
and
322 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,20 @@ | ||
.pergunta { | ||
padding: 0 12px 12px 12px; | ||
background: #ffffff; | ||
color: #51575b; | ||
.GamePlaySessionQuestionUnanswered > .card { | ||
text-shadow: 1px 1px 1px #707070; | ||
} | ||
|
||
.GamePlaySessionQuestionUnanswered > .card code { | ||
text-shadow: none; | ||
padding: 4px 6px; | ||
border-radius: 6px; | ||
background-color: #ffffff; | ||
color: #565656; | ||
margin: 0 0.1rem; | ||
} | ||
|
||
.pergunta .radio p { | ||
display: inline-block; | ||
padding-left: 5px; | ||
.GamePlaySessionQuestionUnanswered > .card > .card-header code { | ||
font-size: 1rem; | ||
} | ||
|
||
.pergunta .radio code { | ||
padding: 2px 4px; | ||
font-size: 90%; | ||
color: #c7254e; | ||
background-color: #f9f2f4; | ||
border-radius: 4px; | ||
main .btn.btn-primary { | ||
box-shadow: rgba(64, 60, 67, 0.3) 1px 2px 5px 1px !important; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -69,7 +69,15 @@ export default function (): Game[] { | |
text: '`construtor__`' | ||
} | ||
] | ||
}, | ||
} | ||
] | ||
}, { | ||
id: 2, | ||
description: 'Avançado', | ||
author: '[email protected]', | ||
createdAt: new Date(), | ||
updatedAt: new Date(), | ||
questions: [ | ||
{ | ||
id: 3, | ||
text: 'Utilizando banco de dados MySQL, qual a função para enviar uma consulta SQL ao banco de dados ativo?', | ||
|
@@ -271,15 +279,7 @@ export default function (): Game[] { | |
text: '`__construct()` e `__destruct()`' | ||
} | ||
] | ||
} | ||
] | ||
}, { | ||
id: 2, | ||
description: 'Avançado', | ||
author: '[email protected]', | ||
createdAt: new Date(), | ||
updatedAt: new Date(), | ||
questions: [ | ||
}, | ||
{ | ||
id: 10, | ||
text: 'O que a keyword `final` faz?', | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { image } from '../../../config/assets.ts' | ||
|
||
export function Drink () { | ||
return ( | ||
<div className="d-flex justify-content-center justify-content-center"> | ||
<img | ||
className="img-fluid" | ||
src={image('/status/wrong.png')} | ||
alt="PHPinga" | ||
style={{ maxHeight: '40vh' }} | ||
/> | ||
</div> | ||
) | ||
} | ||
|
||
export function Celebrate () { | ||
return ( | ||
<div className="d-flex justify-content-center justify-content-center"> | ||
<img | ||
className="img-fluid" | ||
src={image('/status/correct.png')} | ||
alt="PHPinga" | ||
style={{ maxHeight: '40vh' }} | ||
/> | ||
</div> | ||
) | ||
} | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import { useEffect, useState } from 'react' | ||
|
||
import Question from '../../../app/Domain/Game/Question.ts' | ||
import AnswerStatus from '../../../app/Domain/Game/AnswerStatus.ts' | ||
import { shuffle } from '../../../app/Domain/Util.ts' | ||
import Game from '../../../app/Domain/Game/Game.ts' | ||
|
||
import { GamePlaySessionInstruction } from './game-play-session/GamePlaySessionInstruction.tsx' | ||
import { GamePlaySessionQuestion, GameQuestionAnswerQuestion } from './game-play-session/GamePlaySessionQuestion.tsx' | ||
|
||
export type GamePlaySessionProps = { | ||
game: Game, | ||
onStart?: () => void, | ||
onFinish?: () => void | ||
} | ||
|
||
export function GamePlaySession ({ game, onStart, onFinish }: GamePlaySessionProps) { | ||
const timeout = 1000000 | ||
const [questions, setQuestions] = useState<Question[]>([]) | ||
const [currentQuestion, setCurrentQuestion] = useState<Question | null>(null) | ||
|
||
const nextQuestion = () => { | ||
if (questions.length === 0) { | ||
finishGame() | ||
return | ||
} | ||
const randomIndex = Math.floor(Math.random() * questions.length) | ||
const newQuestion = questions[randomIndex] | ||
setCurrentQuestion(newQuestion) | ||
} | ||
|
||
const startGame = () => { | ||
nextQuestion() | ||
onStart && onStart() | ||
} | ||
|
||
const finishGame = () => { | ||
setCurrentQuestion(null) | ||
onFinish && onFinish() | ||
} | ||
|
||
const answerQuestion: GameQuestionAnswerQuestion = (status) => { | ||
// TODO: improve actions for each result | ||
const actions = { | ||
[AnswerStatus.CORRECT]: () => { | ||
console.log('Correct!') | ||
const current = questions.findIndex((q) => q === currentQuestion) | ||
const newQuestions = questions.filter((_, index) => index !== current) | ||
setQuestions(shuffle<Question>(newQuestions)) | ||
}, | ||
[AnswerStatus.WRONG]: () => console.log('Wrong!'), | ||
[AnswerStatus.UNANSWERED]: () => console.log('Unanswered!'), | ||
[AnswerStatus.TIME_EXPIRED]: () => console.log('Time expired!'), | ||
} | ||
actions[status]() | ||
} | ||
|
||
useEffect(() => { | ||
if (questions.length > 0) { | ||
return | ||
} | ||
setQuestions(shuffle<Question>(game.questions)) | ||
}, [game, questions]) | ||
|
||
return !currentQuestion ? | ||
<GamePlaySessionInstruction | ||
timeout={timeout} | ||
game={game} | ||
nextQuestion={startGame} | ||
/> : | ||
<> | ||
<GamePlaySessionQuestion | ||
timeout={timeout} | ||
text={currentQuestion.text} | ||
answers={currentQuestion.answers} | ||
answerQuestion={answerQuestion} | ||
nextQuestion={nextQuestion} | ||
/> | ||
<div className="pt-1"> | ||
<small>{game.questions.length - questions.length} / {game.questions.length}</small> | ||
</div> | ||
</> | ||
} |
Oops, something went wrong.