From 5bf39a7a929a5466b556ae9b7fc6f7342907aac1 Mon Sep 17 00:00:00 2001 From: marsteralex Date: Wed, 17 Aug 2022 18:01:59 -0700 Subject: [PATCH] sort by set name (#770) * fix https * add beasts * Remove extra file * Prettier-ify code * Prettier-ify * add basic land guesser also added fetcher to filter all cards instead of only unique art * default to original makes basic better * added set symbol to basics added set symbol to the basics game mode. Changed name to "How Basic" * cleanup * changed some pixels * only load set data if needed * hacked fix for removing image from name * removed check from original * remove check from original * sort names by set instead of by set symbol Co-authored-by: Austin Chen --- web/public/mtg/app.js | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/web/public/mtg/app.js b/web/public/mtg/app.js index 160c887e..e6e46ae5 100644 --- a/web/public/mtg/app.js +++ b/web/public/mtg/app.js @@ -221,7 +221,9 @@ function setUpNewGame() { artDict = sampledData[0] let randomImages = Object.keys(artDict) shuffleArray(randomImages) - let namesList = Array.from(sampledData[1]).sort() + let namesList = Array.from(sampledData[1]).sort((a, b) => + removeSymbol(a).localeCompare(removeSymbol(b)) + ) // fill in the new cards and names for (let cardIndex = 1; cardIndex <= k; cardIndex++) { let currCard = document.getElementById('card-' + cardIndex) @@ -239,6 +241,11 @@ function setUpNewGame() { } } +function removeSymbol(name) { + let arr = name.split('>') + return arr[arr.length - 1] +} + function checkAnswers() { let score = k // show the correct full cards @@ -247,12 +254,12 @@ function checkAnswers() { let incorrect = true if (currCard.dataset.name) { // remove image text - let guess = document - .getElementById(currCard.dataset.name) - .innerText.split('>') - let ans = artDict[currCard.dataset.url][0].split('>') + let guess = removeSymbol( + document.getElementById(currCard.dataset.name).innerText + ) + let ans = removeSymbol(artDict[currCard.dataset.url][0]) window.console.log(ans, guess) - incorrect = ans[ans.length - 1] !== guess[guess.length - 1] + incorrect = ans !== guess // decide if their guess was correct } if (incorrect) currCard.classList.add('incorrect')