|
|
|
|
@ -553,22 +553,8 @@ class Board{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let colourId = this.tempGetPrimaryManaOfCard(mana);
|
|
|
|
|
|
|
|
|
|
// TODO: do better.
|
|
|
|
|
let manaType = null; // TODO: Will use the highest mana req as it's colour for now
|
|
|
|
|
let manaColours = cardColours[mana];
|
|
|
|
|
for(let i = 0; i < manaColours.length; i++){
|
|
|
|
|
// Set mana colour for card if there isn't one
|
|
|
|
|
if(manaType == null){ manaType = manaColours[i]; }
|
|
|
|
|
// Check each other colour, use the highest cost colour
|
|
|
|
|
// as the colour type for this specific mana
|
|
|
|
|
// TODO: Do better, and nicer, manaType in DB with the colour?
|
|
|
|
|
if(manaColours[i][1] > manaType[1]){
|
|
|
|
|
manaType = manaColours[i];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let colourId = manaType[0];
|
|
|
|
|
console.log(JSON.stringify(manaRequired));
|
|
|
|
|
// Loop the requirements of the cost to pay
|
|
|
|
|
for (const manaColour in manaRequired) {
|
|
|
|
|
@ -647,6 +633,29 @@ class Board{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let colourId = this.tempGetPrimaryManaOfCard(itemKey);
|
|
|
|
|
manaAvailable[colourId] += 1;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// If the manaReq is satiated by the manaAvailable then return true
|
|
|
|
|
for (const manaColour in manaRequired) {
|
|
|
|
|
//console.log('req');
|
|
|
|
|
//console.log(manaRequired[manaColour]);
|
|
|
|
|
//console.log('av');
|
|
|
|
|
//console.log(manaAvailable[manaColour]);
|
|
|
|
|
if(manaRequired[manaColour] > manaAvailable[manaColour]){
|
|
|
|
|
return 'Do not have enough: '+manaColour+' mana';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//console.log('manaAvailable: ');
|
|
|
|
|
//console.log(manaAvailable);
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
tempGetPrimaryManaOfCard(targetCard){
|
|
|
|
|
|
|
|
|
|
// Loop the mana card's colours
|
|
|
|
|
// can be multi-coloured, and can be used as diff costs
|
|
|
|
|
@ -657,7 +666,7 @@ class Board{
|
|
|
|
|
// cards aren't all those when in mana (ie. 6 colour decks can't play
|
|
|
|
|
// everything all the time)
|
|
|
|
|
let manaType = null; // TODO: Will use the highest mana req as it's colour for now
|
|
|
|
|
let manaColours = cardColours[itemKey];
|
|
|
|
|
let manaColours = cardColours[targetCard];
|
|
|
|
|
for(let i = 0; i < manaColours.length; i++){
|
|
|
|
|
// Set mana colour for card if there isn't one
|
|
|
|
|
if(manaType == null){ manaType = manaColours[i]; }
|
|
|
|
|
@ -669,24 +678,8 @@ class Board{
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
let colourId = manaType[0];
|
|
|
|
|
manaAvailable[colourId] += 1;
|
|
|
|
|
}
|
|
|
|
|
return colourId;
|
|
|
|
|
|
|
|
|
|
// If the manaReq is satiated by the manaAvailable then return true
|
|
|
|
|
for (const manaColour in manaRequired) {
|
|
|
|
|
//console.log('req');
|
|
|
|
|
//console.log(manaRequired[manaColour]);
|
|
|
|
|
//console.log('av');
|
|
|
|
|
//console.log(manaAvailable[manaColour]);
|
|
|
|
|
if(manaRequired[manaColour] > manaAvailable[manaColour]){
|
|
|
|
|
return 'Do not have enough: '+manaColour+' mana';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//console.log('manaAvailable: ');
|
|
|
|
|
//console.log(manaAvailable);
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getManaTotalOf(itemKey){
|
|
|
|
|
|