diff --git a/public/board.js b/public/board.js index c1f8fdb..9412b4c 100644 --- a/public/board.js +++ b/public/board.js @@ -1167,17 +1167,37 @@ function shuffleDeck(playerId){ } -function untap(array){ - console.log(array); - array.forEach(function(card, key){ - array[key].tapped = false; - }); +function untapZone(elementFrom, playerFrom){ + // TODO: Currently copy of the loop. Make the loop multi-purpose without needing to dupe the layers + // of the loop (THIS APPLIES FOR ALL USES OF THE LOOP!!) + for(let itemKey = 0; itemKey < item.length; itemKey++){ + // Get the item from the element + if(itemKey in boardElement && boardElement[itemKey] == elementFrom){ + // Check if item belongs to playerFrom + if(itemKey in player && player[itemKey] == playerFrom){ + // Just basic, if tapped, untap logic + // See why the loop shouldn't need re-adding each time? + if(cardStatus[itemKey] == 'tapped'){ + cardStatus[itemKey] = null; + } + } + } + } board.drawBoard(); } -function untapAll(){ - untap(playerMana); - untap(playerBoard); - untap(opponentShield); +function untapAllZones(currentPlayer = null){ + console.log('ut zone'); + if(currentPlayer === null){ + currentPlayer = 0; + } + for(let currentPlayer = 0; currentPlayer <= players-1; currentPlayer++){ + let elements = ['deck','board','hand','mana','shield', 'grave']; + // Loop all the elements, and utap each card in the zone + for(let element = 0; element < elements.length; element++){ + untapZone(elements[element], currentPlayer); + } + + } } function getCurrentPositionAndLength(elementName, playerId){ diff --git a/public/index.html b/public/index.html index 3a95905..d741199 100644 --- a/public/index.html +++ b/public/index.html @@ -16,7 +16,7 @@ - +