-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from MurilloCunha/dev
First Release
- Loading branch information
Showing
14 changed files
with
160 additions
and
22 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
.game-stats{ | ||
width: 100%; | ||
height:100%; | ||
box-sizing: border-box; | ||
padding: 2rem 0; | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
justify-content: center; | ||
color: #000 | ||
} | ||
|
||
.game-stats__winner{ | ||
width: 100%; | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
} | ||
|
||
.game-stats__winner h2{ | ||
margin-top:0rem; | ||
} | ||
|
||
.game-stats__winner h3 { | ||
color: var(--scrabble-tile-text); | ||
font-size: 2rem; | ||
font-weight: 700; | ||
margin: 2rem 0; | ||
} | ||
|
||
.game-stats__stats { | ||
margin-top:2rem; | ||
} | ||
.game-stats__stats li{ | ||
color: var(--scrabble-tile-text); | ||
font-size: 1rem; | ||
font-weight: 700; | ||
margin: 0.5rem 0; | ||
} |
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,56 @@ | ||
import React, { useContext } from 'react' | ||
import Match from '../../context/status' | ||
import MatchDuration from '../../context/duration' | ||
|
||
function GameStats() { | ||
const MatchPlayers = useContext(Match) | ||
const matchTimer = useContext(MatchDuration) | ||
|
||
const winner = MatchPlayers.all.reduce((compare,player) => | ||
compare.totalScore > player.totalScore ? compare : player | ||
) | ||
|
||
const playerhigherScore = MatchPlayers.all.reduce((compare,player) => | ||
Math.max(compare.score) > Math.max(player.score) ? compare : player | ||
) | ||
const higherScore = { | ||
score:Math.max(...playerhigherScore.score), | ||
player:playerhigherScore.name | ||
} | ||
|
||
const playerLowerScore = MatchPlayers.all.reduce((compare,player) => | ||
Math.min(...player.score) > Math.min(compare.score) ? player : compare | ||
) | ||
const lowerScore = { | ||
score:Math.min(...playerLowerScore.score), | ||
player:playerLowerScore.name | ||
} | ||
|
||
return ( | ||
<section className="game-stats"> | ||
<article className="game-stats__winner"> | ||
<h2 className="logo__title"> | ||
<span className="logo__title--tile">V</span> | ||
<span className="logo__title--tile">E</span> | ||
<span className="logo__title--tile">N</span> | ||
<span className="logo__title--tile">C</span> | ||
<span className="logo__title--tile">E</span> | ||
<span className="logo__title--tile">D</span> | ||
<span className="logo__title--tile">O</span> | ||
<span className="logo__title--tile">R</span> | ||
<span className="logo__title--tile">(A)</span> | ||
</h2> | ||
<h3>{winner.name}</h3> | ||
</article> | ||
<article className="game-stats__stats"> | ||
<ul> | ||
<li>Maior pontuação: {higherScore.score}({higherScore.player})</li> | ||
<li>Menor pontuação: {lowerScore.score}({lowerScore.player})</li> | ||
<li>Tempo de jogo: {matchTimer.getDuration()}</li> | ||
</ul> | ||
</article> | ||
</section> | ||
) | ||
} | ||
|
||
export default GameStats |
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 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 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,8 @@ | ||
import { createContext } from 'react' | ||
import { gameDuration } from '../models/game-duration' | ||
|
||
const matchTime = new gameDuration() | ||
|
||
const MatchDuration = createContext(matchTime) | ||
|
||
export default MatchDuration |
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,25 @@ | ||
export class gameDuration { | ||
constructor(){ | ||
this._startTime = 0 | ||
this._endTime = 0 | ||
} | ||
|
||
setStartTime(){ | ||
const currentDate = new Date() | ||
this._startTime = [currentDate.getHours(),currentDate.getMinutes(),currentDate.getSeconds()] | ||
} | ||
|
||
setEndTime(){ | ||
const currentDate = new Date() | ||
this._endTime = [currentDate.getHours(),currentDate.getMinutes(),currentDate.getSeconds()] | ||
} | ||
|
||
getDuration(){ | ||
const hours = Math.abs(this._endTime[0] - this._startTime[0]) | ||
const minutes = Math.abs(this._endTime[1] - this._startTime[1]) | ||
const seconds = Math.abs(this._endTime[2] - this._startTime[2]) | ||
|
||
return `${hours}h ${minutes}m ${seconds}s` | ||
} | ||
|
||
} |
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 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