Start 'pay' trigger + amend tapManaRequired

develop
Nathan Steel 1 year ago
parent 3fce4c0281
commit 876b705407

@ -698,10 +698,15 @@ class Board{
this.drawBoard(); 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() // 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 noManaReq = {1:0, 2:0, 3:0, 4:0};
let manaToTap = []; let manaToTap = [];
@ -723,7 +728,6 @@ class Board{
console.log(JSON.stringify(manaRequired[0])); console.log(JSON.stringify(manaRequired[0]));
// Loop the requirements of the cost to pay // Loop the requirements of the cost to pay
for (const manaColour in manaRequired[0]) { for (const manaColour in manaRequired[0]) {
//console.log(manaColour+' '+manaRequired[manaColour]+', '+colourId);
// If the colour of the mana is in the requirements // If the colour of the mana is in the requirements
// of the cost to pay, reduce the cost for that colour by // of the cost to pay, reduce the cost for that colour by
// 1 and tap the mana // 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) // For 3 cost cards that only require 1 red, two more mana (any colour)
// need to be tapped // need to be tapped
// TODO: Better more efficiently and let user select... // TODO: Better more efficiently and let user select...
let itemCostRemaining = cardData[itemToPayCost].cost - manaRequired[1]; let itemCostRemaining = 0;
if(itemCostRemaining > 0){ let itemCost = 0;
/* if(itemToPayCost !== null){
let tapRequirement = (cardData[itemToPayCost].cost - manaRequired[1]); itemCostRemaining = cardData[itemToPayCost].cost - manaRequired[1];
alert('Tap: '+(tapRequirement)+' more mana to play'); 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 // 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. // 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 // For now, reloop and tap first available mana so that card
// payment is satiated // payment is satiated
// Using same items from above // Using same items from above
@ -772,18 +784,21 @@ class Board{
} }
manaToTap.push(mana); 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 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 the mana to tap has been satitated then tap the mana selected
manaToTap.forEach(manaId => { if(checkOnly == false){ // Tap the mana if this isn't a check
this.tapCard(manaId); manaToTap.forEach(manaId => {
}); this.tapCard(manaId);
});
}
// And continue with whatever we were doing // And continue with whatever we were doing
return true; return true;

@ -87,7 +87,7 @@ function debugTriggerFunction(targetId = null, trigger = null, triggerAmount = n
triggerTap(targetId); triggerTap(targetId);
} }
if(trigger == 'pay'){ if(trigger == 'pay'){
triggerPay(targetId, triggerAmount); triggerPay(triggerAmount);
} }
} }

@ -130,7 +130,7 @@ function hurt(hurtDamage, hurtTarget = null, hurtPlayer = null){
// When card has been actively tapped // When card has been actively tapped
function triggerTap(card){ function triggerTap(card){
if(!canTriggerTap(card)){ return false; } if(canTriggerTap(card) == false){ return false; }
board.tapCard(card); board.tapCard(card);
@ -152,11 +152,29 @@ function canTriggerTap(card){
} }
// Pay the mana cost(s) to trigger event // Pay the mana cost(s) to trigger event
function triggerPay(){ function triggerPay(triggerAmount){
if(canTriggerPay(triggerAmount) == false){
return false;
}
let effectCosts = [{1:0,2:0,3:0,4:0}, triggerAmount];
board.tapManaRequired(null, 0, false, effectCosts);
console.log('triggerPay');
return true;
} }
// Check the mana cost(s) can be paid, otherwise don't start trigger // Check the mana cost(s) can be paid, otherwise don't start trigger
function canTriggerPay(){ function canTriggerPay(triggerAmount){
// For player0 only at the mo. and with no specific colour costs
let effectCosts = [{1:0,2:0,3:0,4:0}, triggerAmount];
if(board.tapManaRequired(null, 0, true, effectCosts) == false){
console.log('cannot trigger pay');
return false;
}
console.log('Can trigger pay');
return true;
} }

Loading…
Cancel
Save