diff --git a/public/board.js b/public/board.js index e6e4591..8e85919 100644 --- a/public/board.js +++ b/public/board.js @@ -220,11 +220,17 @@ class Board{ } return false; } - flipCard(itemKey){ - if(cardFace[itemKey] == 1){ + flipCard(itemKey, direction = null){ + // TODO: Add a third param for 'triggerEffects', for instance + // flipping up from deck to hand, or shield to hand shouldn't trigger + // MOST TIMES + if(cardFace[itemKey] == 1 && (direction == null || direction == 0)){ cardFace[itemKey] = 0; - }else{ + return true; + } + if(cardFace[itemKey] == 0 && (direction == null || direction == 1)){ cardFace[itemKey] = 1; + return true; } // TODO:Activate any flip effects, etc. } @@ -842,7 +848,14 @@ class Board{ } playMana(fromPosition, fromElement, fromPlayer){ + // TODO: getItemKey may be the best way to normalise other function calls instead of searching for item key within certain other funcs. (such as addFromBoardElement) + let itemKey = this.getItemKey(fromElement, fromPosition, fromPlayer); + + console.log(itemKey); + // Now add to mana zone this.addFromBoardElement(fromPlayer, fromPosition, fromElement, 'mana', null, null); + // Flip the card face down (for now) TODO: just add colour atop + this.flipCard(itemKey, 0); // Face down (TODO: Change to have spec. style) } // HELPER METHODS, to simplify code-base for me in the future