Skip to content

Commit

Permalink
altered participant array to accomodate for stats in the frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
achen220 committed Nov 10, 2023
1 parent 2dd8ace commit 9e44a7c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 15 deletions.
23 changes: 12 additions & 11 deletions server/controllers/apiController.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,18 +69,19 @@ const apiController = {
}
participantsArray.forEach((player) => {
let userName = player.summonerName;
let playerStats = {};
playerStats.name = userName;
playerStats.totalDamageDealt = player.totalDamageDealt;
playerStats.killParticipation = player.KillParticipation;
playerStats.totalMinionsKilledt = player.totalMinionsKilled;
playerStats.visionScore = player.visionScore;
//determine which team each player is in
if (player.teamId === 100) filteredMatchInfo.participants.blue.push(player.userName)
else if (player.teamId === 200) filteredMatchInfo.participants.red.push(player.userName)

//pentagon chart data
//initiate object
filteredMatchInfo[userName] = {}
filteredMatchInfo[userName].totalDamageDealt = player.totalDamageDealt;
filteredMatchInfo[userName].deaths = player.deaths;
filteredMatchInfo[userName].KillParticipation = player.challenges.KillParticipation;
filteredMatchInfo[userName].totalMinionsKilled = player.totalMinionsKilled;
filteredMatchInfo[userName].visionScore = player.visionScore;
if (player.teamId === 100) {
filteredMatchInfo.participants.blue.push(playerStats)
}
else if (player.teamId === 200) {
filteredMatchInfo.participants.red.push(playerStats)
}
})

filteredMatchInfo.gameDuration = matchInfo.info.gameDuration;
Expand Down
6 changes: 3 additions & 3 deletions src/components/MatchCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ function MatchCard (props:any) {
setQueueType(idToQueueType[props.match.queueId]);
setTimeDiff(calculateTimeDifference(props.match.gameEndTime));
setTimeDuration(convertRiotTimesDuration(props.match.gameDuration));
setParticipants(props.match.participants)
setParticipants(() => props.match.participants)
setMatchStatus(() => {
return props.match.matchStatus === true ? 'VICTORY' : 'DEFEAT';
});
Expand Down Expand Up @@ -96,7 +96,7 @@ function MatchCard (props:any) {
{participants?.blue.map((player, index) => (
<li key={index} className="whitespace-nowrap">
<button>
{player}
{player.name}
</button>
</li>
) )}
Expand All @@ -105,7 +105,7 @@ function MatchCard (props:any) {
{participants?.red.map((player, index) => (
<li key={index} className="whitespace-nowrap">
<button>
{player}
{player.name}
</button>
</li>
) )}
Expand Down
2 changes: 1 addition & 1 deletion src/components/PentagonalGraph.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as d3 from "d3";
function PentagonalGraph (props) {
const chartRef = useRef();
const data = props.matchStats;
console.log('totalDamage:', data[0])

useEffect(() => {
// Clear the previous SVG if it exists
d3.select(chartRef.current).selectAll('svg').remove();
Expand Down

0 comments on commit 9e44a7c

Please sign in to comment.