|
|
|
|
@ -698,10 +698,15 @@ class Board{
|
|
|
|
|
this.drawBoard();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
tapManaRequired(itemToPayCost, playerId){
|
|
|
|
|
// TODO: Make to check mana, and actually do it.
|
|
|
|
|
// also make work for effects
|
|
|
|
|
tapManaRequired(itemToPayCost, playerId, checkOnly = false, effectCosts = null){
|
|
|
|
|
|
|
|
|
|
// TODO: Look at combining or normalising this and canPayMana()
|
|
|
|
|
let manaRequired = this.getManaTotalOf(itemToPayCost);
|
|
|
|
|
let manaRequired = [];
|
|
|
|
|
if(effectCosts !== null){ manaRequired = effectCosts; }
|
|
|
|
|
else{ manaRequired = this.getManaTotalOf(itemToPayCost); }
|
|
|
|
|
|
|
|
|
|
let noManaReq = {1:0, 2:0, 3:0, 4:0};
|
|
|
|
|
let manaToTap = [];
|
|
|
|
|
|
|
|
|
|
@ -723,7 +728,6 @@ class Board{
|
|
|
|
|
console.log(JSON.stringify(manaRequired[0]));
|
|
|
|
|
// Loop the requirements of the cost to pay
|
|
|
|
|
for (const manaColour in manaRequired[0]) {
|
|
|
|
|
//console.log(manaColour+' '+manaRequired[manaColour]+', '+colourId);
|
|
|
|
|
// If the colour of the mana is in the requirements
|
|
|
|
|
// of the cost to pay, reduce the cost for that colour by
|
|
|
|
|
// 1 and tap the mana
|
|
|
|
|
@ -745,17 +749,25 @@ class Board{
|
|
|
|
|
// For 3 cost cards that only require 1 red, two more mana (any colour)
|
|
|
|
|
// need to be tapped
|
|
|
|
|
// TODO: Better more efficiently and let user select...
|
|
|
|
|
let itemCostRemaining = cardData[itemToPayCost].cost - manaRequired[1];
|
|
|
|
|
if(itemCostRemaining > 0){
|
|
|
|
|
/*
|
|
|
|
|
let tapRequirement = (cardData[itemToPayCost].cost - manaRequired[1]);
|
|
|
|
|
alert('Tap: '+(tapRequirement)+' more mana to play');
|
|
|
|
|
let itemCostRemaining = 0;
|
|
|
|
|
let itemCost = 0;
|
|
|
|
|
if(itemToPayCost !== null){
|
|
|
|
|
itemCostRemaining = cardData[itemToPayCost].cost - manaRequired[1];
|
|
|
|
|
itemCost = cardData[itemToPayCost].cost;
|
|
|
|
|
}
|
|
|
|
|
else if(effectCosts !== null){
|
|
|
|
|
itemCostRemaining = manaRequired[1];
|
|
|
|
|
itemCost = manaRequired[1];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// start mana tap event
|
|
|
|
|
*/
|
|
|
|
|
if(itemCostRemaining > 0){
|
|
|
|
|
|
|
|
|
|
// TODO: decide 100% how cards are to be played/payed for
|
|
|
|
|
// don't want to slam time into a mana system if it'll be nuked.
|
|
|
|
|
if(items.length < itemCostRemaining){
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// For now, reloop and tap first available mana so that card
|
|
|
|
|
// payment is satiated
|
|
|
|
|
// Using same items from above
|
|
|
|
|
@ -772,18 +784,21 @@ class Board{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
manaToTap.push(mana);
|
|
|
|
|
itemCostRemaining--; // TODO: ??????
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(cardData[itemToPayCost].cost - manaToTap.length > 0){
|
|
|
|
|
if(itemCost - manaToTap.length > 0){
|
|
|
|
|
return 'itemCostRemaining: '+itemCostRemaining; // Didn't find another mana to tap so cost not satiated
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// If the mana to tap has been satitated then tap the mana selected
|
|
|
|
|
if(checkOnly == false){ // Tap the mana if this isn't a check
|
|
|
|
|
manaToTap.forEach(manaId => {
|
|
|
|
|
this.tapCard(manaId);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// And continue with whatever we were doing
|
|
|
|
|
return true;
|
|
|
|
|
|