|
|
|
@ -118,13 +118,6 @@ class Board{
|
|
|
|
if(colourId == 0){ fill = '#EEE' }
|
|
|
|
if(colourId == 0){ fill = '#EEE' }
|
|
|
|
else if(colourId == 1){ fill = '#0033EE' }
|
|
|
|
else if(colourId == 1){ fill = '#0033EE' }
|
|
|
|
|
|
|
|
|
|
|
|
if(name == 'playerMana_1'){
|
|
|
|
|
|
|
|
console.log(playerMana);
|
|
|
|
|
|
|
|
console.log(array);
|
|
|
|
|
|
|
|
console.log(array[arrayKey]);
|
|
|
|
|
|
|
|
console.log(array[arrayKey].tapped);
|
|
|
|
|
|
|
|
console.log(name);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(array[arrayKey].tapped){
|
|
|
|
if(array[arrayKey].tapped){
|
|
|
|
border = '#E0BC00';
|
|
|
|
border = '#E0BC00';
|
|
|
|
console.log('drawCard tapped');
|
|
|
|
console.log('drawCard tapped');
|
|
|
|
@ -379,6 +372,7 @@ class Board{
|
|
|
|
playCardToBoard(index){
|
|
|
|
playCardToBoard(index){
|
|
|
|
// Get the card data
|
|
|
|
// Get the card data
|
|
|
|
let cardPlayed = playerHand[index];
|
|
|
|
let cardPlayed = playerHand[index];
|
|
|
|
|
|
|
|
let manaUsed = [];
|
|
|
|
|
|
|
|
|
|
|
|
// Check if there's space on board to play
|
|
|
|
// Check if there's space on board to play
|
|
|
|
// TODO: Check this in back-end
|
|
|
|
// TODO: Check this in back-end
|
|
|
|
@ -392,10 +386,17 @@ class Board{
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}else{
|
|
|
|
}else{
|
|
|
|
let canPlay = false;
|
|
|
|
let canPlay = false;
|
|
|
|
|
|
|
|
let needsMana = 1;
|
|
|
|
|
|
|
|
let usedMana = 0;
|
|
|
|
playerMana.forEach(function(manaCard, key){
|
|
|
|
playerMana.forEach(function(manaCard, key){
|
|
|
|
if(cardPlayed.colour == manaCard.colour && manaCard.tapped == false){
|
|
|
|
if(cardPlayed.colour == manaCard.colour && manaCard.tapped == false && needsMana > usedMana){
|
|
|
|
|
|
|
|
console.log(manaCard);
|
|
|
|
|
|
|
|
// Needs changing for multiple colour usage
|
|
|
|
|
|
|
|
// 2 red, 1 red + 1 blue, etc.
|
|
|
|
|
|
|
|
// Currently only gets one mana of the cards colour
|
|
|
|
|
|
|
|
manaUsed.push(key);
|
|
|
|
|
|
|
|
usedMana++;
|
|
|
|
canPlay = true;
|
|
|
|
canPlay = true;
|
|
|
|
playerMana[key].tapped = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
@ -404,6 +405,12 @@ class Board{
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Tap mana to be used
|
|
|
|
|
|
|
|
manaUsed.forEach(function(cardKey, key){
|
|
|
|
|
|
|
|
playerMana[cardKey].tapped = true;
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
console.log(playerMana);
|
|
|
|
console.log(playerMana);
|
|
|
|
|
|
|
|
|
|
|
|
// Remove from hand
|
|
|
|
// Remove from hand
|
|
|
|
|