Skip to content

Commit

Permalink
Merge pull request #5 from 8-bit-sheep/highscore-debug
Browse files Browse the repository at this point in the history
fix bug
  • Loading branch information
skallinen authored Aug 1, 2019
2 parents 5eab8a2 + 2942a4d commit ac302da
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
4 changes: 2 additions & 2 deletions end.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const parseUrlParameters = parameter =>
.reduce((acc, cur) => ({ ...acc, [cur[0]]: cur[1] }), {});

const username = document.getElementById("username");
const finalScore = document.getElementById("finalScore");
finalScore = document.getElementById("finalScore");
const mostRecentScore = localStorage.getItem("mostRecentScore");
const saveScoreBtn = document.getElementById("saveScoreButton");
const urlParams = parseUrlParameters(window.location.search);
Expand All @@ -20,7 +20,7 @@ const saveHighscore = e => {

const rankingUrl = `https://script.google.com/macros/s/AKfycbwdGGPzI9JdH_6FN-na4boXQNZmGyv6y_690ErJc0Xhzd_CQ4A_/exec?contentId=${
urlParams.contentId
}&score=${mostRecentScore}&name=${username.value}`;
}&name=${username.value}&score=${mostRecentScore}`;
fetch(rankingUrl);
setInterval(
() =>
Expand Down
2 changes: 1 addition & 1 deletion game.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const startGame = () => {
if (contentId === "0") {
game.classList.remove("hidden");
availableQuestions = [...questions];
maxQuestions = 50;
maxQuestions = 3;
getNewQuestion();
} else if (contributed) {
segmentBox.classList.remove("hidden");
Expand Down
8 changes: 2 additions & 6 deletions highscores.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,8 @@ d3.csv(
const params = parseUrlParameters(window.location.search);
const id = params.contentId;
let ranking = highscores.filter(x => x.contentId === id);
let exists = ranking
.filter(x => x.name === params.name)
.map(y => y.score)
.filter(x => x === params.score).length;
if ((exists === 0) & params.name) ranking.push(params);
ranking = ranking
ranking.push(params);
ranking = [...new Set(ranking)]
.sort((a, b) => parseInt(b.score) - parseInt(a.score))
.slice(0, 10);
const highscoreList = document.getElementById("highscoreList");
Expand Down

0 comments on commit ac302da

Please sign in to comment.