From 17fb1253b37e9b43b4584816b3e42ab372013eec Mon Sep 17 00:00:00 2001 From: Thayol Date: Wed, 23 Jun 2021 20:51:14 +0200 Subject: [PATCH] Added option for redraw --- script.js | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/script.js b/script.js index acef8fb..aedb54f 100644 --- a/script.js +++ b/script.js @@ -9,6 +9,7 @@ var sameColorExtra = 4; // extra points given for sets of the same color if they var autoDraw = false; // whether the script should automatically draw on start and on discard var autoRecommend = true; // whether the script should automatically recommend on change var measurePerformance = false; // whether the performance should be logged into the console +var allowRedraw = true; // if redrawing a card by hand is allowed (sometimes the real game is bugged and will give dupes) var allCards = undefined; var deck = undefined; @@ -191,12 +192,24 @@ function drawCard(cardId, thisHand = null, thisDeck = null) { handGiven = false; } - if (!isHandFull(thisHand) && thisDeck.includes(cardId)) { - thisDeck.splice(thisDeck.indexOf(cardId), 1); - thisHand.push(cardId); - - if (!handGiven) { - updateUI(); + if (!isHandFull(thisHand)) { + let allowed = false; + if (allowRedraw) { + allowed = true; + } + else { + if (thisDeck.includes(cardId)) { + allowed = true; + } + } + + if (allowed) { + thisDeck.splice(thisDeck.indexOf(cardId), 1); + thisHand.push(cardId); + + if (!handGiven) { + updateUI(); + } } } }