|
|
|
|
@ -246,7 +246,21 @@ class Board{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
drawCardsOnBoardOpponent(){
|
|
|
|
|
for (let i = 0; i < opponentBoard.length; i++) {
|
|
|
|
|
|
|
|
|
|
let name = 'cardOnBoardOpponent_'+(i+1);
|
|
|
|
|
|
|
|
|
|
let cardPadding = 10;
|
|
|
|
|
let fill = '#'+i+i+'AA00';
|
|
|
|
|
|
|
|
|
|
// TODO: fix positionX, actually have some maffs
|
|
|
|
|
let positionX = canvas.width/2 - ((cardWidth/4 * 2) * (opponentBoard.length - (i+1)) - (cardPadding * (i+1)));
|
|
|
|
|
let positionY = cardHeight/2;
|
|
|
|
|
let width = cardWidth/2;
|
|
|
|
|
let height = cardHeight/2;
|
|
|
|
|
|
|
|
|
|
this.drawCard(opponentBoard, i, name, positionX, positionY, width, height, fill);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Currently only functionality in hand
|
|
|
|
|
@ -266,6 +280,24 @@ class Board{
|
|
|
|
|
// Add to board
|
|
|
|
|
playerBoard.push(cardPlayed);
|
|
|
|
|
|
|
|
|
|
this.drawBoard();
|
|
|
|
|
}
|
|
|
|
|
playCardToBoardFromDeckOpponent(){
|
|
|
|
|
|
|
|
|
|
// Random card from deck
|
|
|
|
|
let cardToDraw = Math.floor(Math.random() * deckCount);
|
|
|
|
|
let cardPlayed = opponentDeck[cardToDraw];
|
|
|
|
|
|
|
|
|
|
if(opponentBoard.length >= maxBoardSize){
|
|
|
|
|
alert('No space on board to play card. '+opponentBoard.length+'/'+maxBoardSize);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Remove from deck
|
|
|
|
|
opponentDeck.splice(cardToDraw, 1);
|
|
|
|
|
// Add to board
|
|
|
|
|
opponentBoard.push(cardPlayed);
|
|
|
|
|
|
|
|
|
|
this.drawBoard();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -278,6 +310,9 @@ createDeckList(opponentDeck, deckCountOpponent);
|
|
|
|
|
let board = new Board;
|
|
|
|
|
//board.initBoard();
|
|
|
|
|
|
|
|
|
|
// TEMP: Play a card on opponents board (from their deck)
|
|
|
|
|
board.playCardToBoardFromDeckOpponent();
|
|
|
|
|
|
|
|
|
|
board.drawBoard();
|
|
|
|
|
|
|
|
|
|
canvas.addEventListener('click', function(event) {
|
|
|
|
|
|