|
|
|
@ -252,34 +252,39 @@ class Board{
|
|
|
|
drawCards(){}
|
|
|
|
drawCards(){}
|
|
|
|
|
|
|
|
|
|
|
|
// Draw a card, traditional TCG
|
|
|
|
// Draw a card, traditional TCG
|
|
|
|
drawACard(){
|
|
|
|
drawACard(cardsToDraw = 1){
|
|
|
|
if(playerHand.length >= maxHandSize){
|
|
|
|
// For loop so that animations will play each time (when they exist)
|
|
|
|
alert('Hand full '+playerHand.length+'/'+maxHandSize);
|
|
|
|
for(let draw = 0; draw < cardsToDraw; draw++){
|
|
|
|
return 0;
|
|
|
|
if(playerHand.length >= maxHandSize){
|
|
|
|
}
|
|
|
|
alert('Hand full '+playerHand.length+'/'+maxHandSize);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Random card from deck, remove from deck, add to hand
|
|
|
|
// Random card from deck, remove from deck, add to hand
|
|
|
|
let cardToDraw = Math.floor(Math.random() * deckCount);
|
|
|
|
let cardToDraw = Math.floor(Math.random() * deckCount);
|
|
|
|
let cardDrawn = playerDeck[cardToDraw];
|
|
|
|
let cardDrawn = playerDeck[cardToDraw];
|
|
|
|
// Remove from deck
|
|
|
|
// Remove from deck
|
|
|
|
playerDeck.splice(cardToDraw, 1);
|
|
|
|
playerDeck.splice(cardToDraw, 1);
|
|
|
|
// Add to hand
|
|
|
|
// Add to hand
|
|
|
|
playerHand.push(cardDrawn);
|
|
|
|
playerHand.push(cardDrawn);
|
|
|
|
this.drawBoard();
|
|
|
|
this.drawBoard();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
drawACardOpponent(){
|
|
|
|
drawACardOpponent(cardsToDraw = 1){
|
|
|
|
if(opponentHand.length >= maxHandSize){
|
|
|
|
for(let draw = 0; draw < cardsToDraw; draw++){
|
|
|
|
alert('Hand full '+opponentHand.length+'/'+maxHandSize);
|
|
|
|
if(opponentHand.length >= maxHandSize){
|
|
|
|
return 0;
|
|
|
|
alert('Hand full '+opponentHand.length+'/'+maxHandSize);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// Random card from deck, remove from deck, add to hand
|
|
|
|
|
|
|
|
let cardToDraw = Math.floor(Math.random() * deckCountOpponent);
|
|
|
|
|
|
|
|
let cardDrawn = opponentDeck[cardToDraw];
|
|
|
|
|
|
|
|
// Remove from deck
|
|
|
|
|
|
|
|
opponentDeck.splice(cardToDraw, 1);
|
|
|
|
|
|
|
|
// Add to hand
|
|
|
|
|
|
|
|
opponentHand.push(cardDrawn);
|
|
|
|
|
|
|
|
this.drawBoard();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Random card from deck, remove from deck, add to hand
|
|
|
|
|
|
|
|
let cardToDraw = Math.floor(Math.random() * deckCountOpponent);
|
|
|
|
|
|
|
|
let cardDrawn = opponentDeck[cardToDraw];
|
|
|
|
|
|
|
|
// Remove from deck
|
|
|
|
|
|
|
|
opponentDeck.splice(cardToDraw, 1);
|
|
|
|
|
|
|
|
// Add to hand
|
|
|
|
|
|
|
|
opponentHand.push(cardDrawn);
|
|
|
|
|
|
|
|
this.drawBoard();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -423,6 +428,7 @@ let board = new Board;
|
|
|
|
board.playCardToBoardFromDeckOpponent();
|
|
|
|
board.playCardToBoardFromDeckOpponent();
|
|
|
|
|
|
|
|
|
|
|
|
board.drawBoard();
|
|
|
|
board.drawBoard();
|
|
|
|
|
|
|
|
board.drawACard(3);
|
|
|
|
|
|
|
|
|
|
|
|
canvas.addEventListener('click', function(event) {
|
|
|
|
canvas.addEventListener('click', function(event) {
|
|
|
|
console.log('EVENT LISTENER');
|
|
|
|
console.log('EVENT LISTENER');
|
|
|
|
|