Make 'untap all' button work ECSey

develop
Nathan Steel 1 year ago
parent 54f136295d
commit 9e65811dd3

@ -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){

@ -16,7 +16,7 @@
<button onclick="requestCreateRoom()" style="background:#EEE">Create Room</button>
</div>
<canvas id="canvas" width="1000" height="600"></canvas>
<button onclick="untapAll()">Untap all</button>
<button onclick="untapAllZones()">Untap all</button>
<script src="/socket.io/socket.io.js"></script>
<script src="/shapes.js"></script>

Loading…
Cancel
Save