Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat/game-actions #134

Merged
merged 2 commits into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 55 additions & 20 deletions frontend/src/app/(private)/game/play/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export default function PlayPage() {
>
<div className="animate-spin rounded-full h-24 w-24 border-t-2 border-b-2 border-purple42-200"></div>
<div className="text-white text-3xl text-center">
Waiting for player 2...
Aguardando oponente...
</div>
</div>
</>
Expand All @@ -51,22 +51,53 @@ export default function PlayPage() {
<>
<div
className="
bg-black42-300
rounded-lg
w-full
mt-4
flex
flex-col
justify-center
items-center
py-6
h-[calc(100vh-130px)]
"
bg-black42-300
rounded-lg
w-full
mt-4
flex
flex-col
justify-center
items-center
py-6
h-[calc(100vh-130px)]
p-4
"
>
<div className="text-white text-3xl text-center">Game finished</div>
<div className="text-white text-3xl text-center flex flex-col">
<span>Player 1 Final Score: {gameFinishedData.score?.player1}</span>
<span>Player 2 Final Score: {gameFinishedData.score?.player2}</span>
<div className="text-white text-4xl text-center mb-4">
Jogo finalizado
</div>
<div className="text-white text-2xl text-center flex flex-col items-center space-y-2">
<span>
{gameFinishedData.player1.login} Pontos:{" "}
{gameFinishedData.score?.player1}
</span>
<span>
{gameFinishedData.player2.login} Pontos:{" "}
{gameFinishedData.score?.player2}
</span>
<span className="text-green-500 text-3xl mt-4">
Vencedor:{" "}
{gameFinishedData.score?.player1 > gameFinishedData.score?.player2
? gameFinishedData.player1.login
: gameFinishedData.player2.login}
</span>
<Link
href="/game"
className="
bg-purple42-400
hover:bg-purple42-500
text-white
font-bold
py-2
px-4
rounded
text-sm
mt-6
"
>
Voltar ao inicio
</Link>
</div>
</div>
</>
Expand All @@ -90,7 +121,7 @@ export default function PlayPage() {
h-[calc(100vh-130px)]
"
>
<div className="text-white text-3xl text-center">Game abandoned</div>
<div className="text-white text-3xl text-center">Jogo abandonado</div>
</div>
</>
);
Expand Down Expand Up @@ -160,8 +191,12 @@ export default function PlayPage() {
mx-auto
"
>
<div>Score: {gameData.score?.player1}</div>
<div>Score: {gameData.score?.player2}</div>
<div>
{gameData.player1?.login}: {gameData.score?.player1}
</div>
<div>
{gameData.player2?.login}: {gameData.score?.player2}
</div>
</div>
<div id="game-canvas" ref={canvasRef}>
<div
Expand Down Expand Up @@ -201,7 +236,7 @@ export default function PlayPage() {
rounded
"
>
Quit the game
Sair do jogo
</Link>
</div>
</div>
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/contexts/GameContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@ export type GameData = {
finished: boolean;
player1: {
id: string;
login: string;
x: number;
y: number;
width: number;
height: number;
};
player2: {
id: string;
login: string;
x: number;
y: number;
width: number;
Expand Down
Loading