Added/fixed primitives, improved "anytypeofmana" ability for both player and AI and implemented "anytypeofmanaability" keyword to allow the user and the AI to spend mana of any color to activate abilities.
This commit is contained in:
@@ -59,7 +59,7 @@ int AIMomirPlayer::momir()
|
||||
MTGCardInstance * card = game->hand->cards[0];
|
||||
if (ability->isReactingToClick(card, cost))
|
||||
{
|
||||
payTheManaCost(cost);
|
||||
payTheManaCost(cost, card->has(Constants::ANYTYPEOFMANA));
|
||||
AIAction * a = NEW AIAction(this, ability, card);
|
||||
clickstream.push(a);
|
||||
result = 1;
|
||||
|
||||
@@ -1360,7 +1360,7 @@ MTGCardInstance * AIPlayerBaka::chooseCard(TargetChooser * tc, MTGCardInstance *
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool AIPlayerBaka::payTheManaCost(ManaCost * cost, MTGCardInstance * target,vector<MTGAbility*>gotPayments)
|
||||
bool AIPlayerBaka::payTheManaCost(ManaCost * cost, int anytypeofmana, MTGCardInstance * target,vector<MTGAbility*>gotPayments)
|
||||
{
|
||||
DebugTrace("AIPlayerBaka: AI attempting to pay a mana cost." << endl
|
||||
<< "- Target: " << (target ? target->name : "None" ) << endl
|
||||
@@ -1437,7 +1437,7 @@ bool AIPlayerBaka::payTheManaCost(ManaCost * cost, MTGCardInstance * target,vect
|
||||
}
|
||||
if(k == gotPayments.size()-1)//only add it once, and at the end.
|
||||
paid->add(this->getManaPool());//incase some of our payments were mana already in the pool/.
|
||||
if(paid->canAfford(cost))
|
||||
if(paid->canAfford(cost, anytypeofmana))
|
||||
{
|
||||
if((!cost->hasX() && !cost->hasAnotherCost()) || k == gotPayments.size()-1)
|
||||
{
|
||||
@@ -1471,7 +1471,7 @@ bool AIPlayerBaka::payTheManaCost(ManaCost * cost, MTGCardInstance * target,vect
|
||||
cost = pMana;//{x}:effect, set x to max.
|
||||
}
|
||||
|
||||
if(!pMana->canAfford(cost))
|
||||
if(!pMana->canAfford(cost, 0))
|
||||
{
|
||||
delete pMana;
|
||||
return false;
|
||||
@@ -1556,17 +1556,19 @@ ManaCost * AIPlayerBaka::getPotentialMana(MTGCardInstance * target)
|
||||
return result;
|
||||
}
|
||||
|
||||
vector<MTGAbility*> AIPlayerBaka::canPayMana(MTGCardInstance * target,ManaCost * cost)
|
||||
vector<MTGAbility*> AIPlayerBaka::canPayMana(MTGCardInstance * target, ManaCost * cost, int anytypeofmana)
|
||||
{
|
||||
if(!cost || (cost && !cost->getConvertedCost()) || !target)
|
||||
return vector<MTGAbility*>();
|
||||
map<MTGCardInstance*, bool> usedCards;
|
||||
|
||||
return canPayMana(target, cost, usedCards);
|
||||
return canPayMana(target, cost, anytypeofmana, usedCards);
|
||||
}
|
||||
|
||||
vector<MTGAbility*> AIPlayerBaka::canPayMana(MTGCardInstance * target,ManaCost * cost, map<MTGCardInstance*,bool> &used ,bool searchingAgain)
|
||||
vector<MTGAbility*> AIPlayerBaka::canPayMana(MTGCardInstance * target, ManaCost * _cost, int anytypeofmana, map<MTGCardInstance*,bool> &used ,bool searchingAgain)
|
||||
{
|
||||
ManaCost * cost = _cost;
|
||||
|
||||
if(!cost->getConvertedCost())
|
||||
return vector<MTGAbility*>();
|
||||
ManaCost * result = NEW ManaCost();
|
||||
@@ -1577,6 +1579,14 @@ vector<MTGAbility*> AIPlayerBaka::canPayMana(MTGCardInstance * target,ManaCost *
|
||||
//adding the current manapool if any.
|
||||
result->add(this->getManaPool());
|
||||
}
|
||||
|
||||
if(anytypeofmana){
|
||||
int convertedC = cost->getConvertedCost();
|
||||
cost = NEW ManaCost(ManaCost::parseManaCost("{0}", NULL, target));
|
||||
for (int jj = 0; jj < convertedC; jj++)
|
||||
cost->add(Constants::MTG_COLOR_ARTIFACT, 1);
|
||||
}
|
||||
|
||||
int needColorConverted = cost->getConvertedCost() - int(cost->getCost(0)+cost->getCost(7));
|
||||
int fullColor = 0;
|
||||
for (size_t i = 0; i < observer->mLayers->actionLayer()->manaObjects.size(); i++)
|
||||
@@ -1589,7 +1599,7 @@ vector<MTGAbility*> AIPlayerBaka::canPayMana(MTGCardInstance * target,ManaCost *
|
||||
{
|
||||
if(cost->hasColor(0) && amp)//find colorless after color mana.
|
||||
{
|
||||
if(result->canAfford(cost))
|
||||
if(result->canAfford(cost,0))
|
||||
continue;
|
||||
if (canHandleCost(amp))
|
||||
{
|
||||
@@ -1598,7 +1608,7 @@ vector<MTGAbility*> AIPlayerBaka::canPayMana(MTGCardInstance * target,ManaCost *
|
||||
used[card] = true; //http://code.google.com/p/wagic/issues/detail?id=76
|
||||
if (!used[card] && amp->isReactingToClick(card) && amp->output->getConvertedCost() >= 1)
|
||||
{
|
||||
if(!(result->canAfford(cost)))//if we got to this point we should be filling colorless mana requirements.
|
||||
if(!(result->canAfford(cost,0)))//if we got to this point we should be filling colorless mana requirements.
|
||||
{
|
||||
payments.push_back(amp);
|
||||
result->add(amp->output);
|
||||
@@ -1653,7 +1663,7 @@ vector<MTGAbility*> AIPlayerBaka::canPayMana(MTGCardInstance * target,ManaCost *
|
||||
check->add(k,cost->getCost(k));
|
||||
ManaCost * checkResult = NEW ManaCost();
|
||||
checkResult->add(k,result->getCost(k));
|
||||
if(!(checkResult->canAfford(check)))
|
||||
if(!(checkResult->canAfford(check,0)))
|
||||
{
|
||||
payments.push_back(amp);
|
||||
result->add(k,amp->output->getCost(k));
|
||||
@@ -1698,7 +1708,7 @@ vector<MTGAbility*> AIPlayerBaka::canPayMana(MTGCardInstance * target,ManaCost *
|
||||
check->add(foundColor1?hybridCost->color1:hybridCost->color2,foundColor1?hybridCost->value1:hybridCost->value2);
|
||||
ManaCost * checkResult = NEW ManaCost();
|
||||
checkResult->add(foundColor1?hybridCost->color1:hybridCost->color2,result->getCost(foundColor1?hybridCost->color1:hybridCost->color2));
|
||||
if(((foundColor1 && !foundColor2)||(!foundColor1 && foundColor2)) &&!(checkResult->canAfford(check)))
|
||||
if(((foundColor1 && !foundColor2)||(!foundColor1 && foundColor2)) &&!(checkResult->canAfford(check,0)))
|
||||
{
|
||||
payments.push_back(amp);
|
||||
result->add(foundColor1?hybridCost->color1:hybridCost->color2,amp->output->getCost(foundColor1?hybridCost->color1:hybridCost->color2));
|
||||
@@ -1722,7 +1732,7 @@ vector<MTGAbility*> AIPlayerBaka::canPayMana(MTGCardInstance * target,ManaCost *
|
||||
{
|
||||
check->add(k,cost->getCost(k));
|
||||
checkResult->add(k,result->getCost(k));
|
||||
if(!(checkResult->canAfford(check)))
|
||||
if(!(checkResult->canAfford(check,0)))
|
||||
{
|
||||
SAFE_DELETE(check);
|
||||
SAFE_DELETE(checkResult);
|
||||
@@ -1739,7 +1749,7 @@ vector<MTGAbility*> AIPlayerBaka::canPayMana(MTGCardInstance * target,ManaCost *
|
||||
bool keepLooking = true;
|
||||
while(keepLooking)
|
||||
{
|
||||
kickerPayment = canPayMana(target, withKickerCost, used,true);
|
||||
kickerPayment = canPayMana(target, withKickerCost, target->has(Constants::ANYTYPEOFMANA), used, true);
|
||||
if(kickerPayment.size())
|
||||
{
|
||||
for(unsigned int w = 0;w < kickerPayment.size();++w)
|
||||
@@ -1776,9 +1786,11 @@ vector<MTGAbility*> AIPlayerBaka::canPayMana(MTGCardInstance * target,ManaCost *
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!result->canAfford(cost))
|
||||
if(!result->canAfford(cost,0))
|
||||
payments.clear();
|
||||
SAFE_DELETE(result);
|
||||
if(anytypeofmana)
|
||||
SAFE_DELETE(cost);
|
||||
return payments;
|
||||
}
|
||||
|
||||
@@ -1817,7 +1829,7 @@ vector<MTGAbility*> AIPlayerBaka::canPaySunBurst(ManaCost * cost)
|
||||
check->add(k,1);
|
||||
ManaCost * checkResult = NEW ManaCost();
|
||||
checkResult->add(k,result->getCost(k));
|
||||
if(!(checkResult->canAfford(check)))
|
||||
if(!(checkResult->canAfford(check,card->has(Constants::ANYTYPEOFMANA))))
|
||||
{
|
||||
payments.push_back(amp);
|
||||
result->add(k,amp->output->getCost(k));
|
||||
@@ -1843,7 +1855,7 @@ vector<MTGAbility*> AIPlayerBaka::canPaySunBurst(ManaCost * cost)
|
||||
MTGCardInstance * card = amp->source;
|
||||
if (!used[card] && amp->isReactingToClick(card) && amp->output->getConvertedCost() >= 1)
|
||||
{
|
||||
if(!(result->canAfford(cost)))//if we got to this point we should be filling colorless mana requirements.
|
||||
if(!(result->canAfford(cost,card->has(Constants::ANYTYPEOFMANA))))//if we got to this point we should be filling colorless mana requirements.
|
||||
{
|
||||
payments.push_back(amp);
|
||||
result->add(amp->output);
|
||||
@@ -1853,7 +1865,7 @@ vector<MTGAbility*> AIPlayerBaka::canPaySunBurst(ManaCost * cost)
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!result->canAfford(cost))
|
||||
if(!result->canAfford(cost,0))
|
||||
payments.clear();
|
||||
SAFE_DELETE(result);
|
||||
return payments;
|
||||
@@ -2024,7 +2036,7 @@ int AIPlayerBaka::selectHintAbility()
|
||||
if (!clickstream.size())
|
||||
{
|
||||
DebugTrace("AIPlayer:Using Activated ability");
|
||||
if (payTheManaCost(action->ability->getCost(), action->click))
|
||||
if (payTheManaCost(action->ability->getCost(), action->click->has(Constants::ANYTYPEOFMANAABILITY), action->click))
|
||||
{
|
||||
clickstream.push(action);
|
||||
SAFE_DELETE(totalPotentialMana);
|
||||
@@ -2045,10 +2057,10 @@ int AIPlayerBaka::selectAbility()
|
||||
check = dynamic_cast<ExtraManaCost*>(observer->mExtraPayment->costs[0]);
|
||||
if(check)
|
||||
{
|
||||
vector<MTGAbility*> CostToPay = canPayMana(observer->mExtraPayment->source,check->costToPay);
|
||||
vector<MTGAbility*> CostToPay = canPayMana(observer->mExtraPayment->source,check->costToPay,check->source->has(Constants::ANYTYPEOFMANAABILITY));
|
||||
if(CostToPay.size())
|
||||
{
|
||||
payTheManaCost(check->costToPay,check->source,CostToPay);
|
||||
payTheManaCost(check->costToPay,check->source->has(Constants::ANYTYPEOFMANAABILITY),check->source,CostToPay);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2087,7 +2099,7 @@ int AIPlayerBaka::selectAbility()
|
||||
MTGCardInstance * card = game->inPlay->cards[j];
|
||||
if(a->getCost() && !a->isReactingToClick(card, totalPotentialMana))//for performance reason only look for specific mana if the payment couldnt be made with potential.
|
||||
{
|
||||
abilityPayment = canPayMana(card,a->getCost());
|
||||
abilityPayment = canPayMana(card,a->getCost(),card->has(Constants::ANYTYPEOFMANAABILITY));
|
||||
}
|
||||
if (a->isReactingToClick(card, totalPotentialMana) || abilityPayment.size())
|
||||
{ //This test is to avoid the huge call to getPotentialManaCost after that
|
||||
@@ -2139,7 +2151,7 @@ int AIPlayerBaka::selectAbility()
|
||||
DebugTrace(" Ai knows exactly what mana to use for this ability.");
|
||||
}
|
||||
DebugTrace("AIPlayer:Using Activated ability");
|
||||
if (payTheManaCost(action.ability->getCost(), action.click,abilityPayment))
|
||||
if (payTheManaCost(action.ability->getCost(),action.click->has(Constants::ANYTYPEOFMANAABILITY),action.click,abilityPayment))
|
||||
clickstream.push(NEW AIAction(action));
|
||||
}
|
||||
}
|
||||
@@ -2157,10 +2169,10 @@ int AIPlayerBaka::doAbility(MTGAbility * Specific, MTGCardInstance * withCard)
|
||||
check = dynamic_cast<ExtraManaCost*>(observer->mExtraPayment->costs[0]);
|
||||
if (check)
|
||||
{
|
||||
vector<MTGAbility*> CostToPay = canPayMana(observer->mExtraPayment->source, check->costToPay);
|
||||
vector<MTGAbility*> CostToPay = canPayMana(observer->mExtraPayment->source, check->costToPay, check->source->has(Constants::ANYTYPEOFMANAABILITY));
|
||||
if (CostToPay.size())
|
||||
{
|
||||
payTheManaCost(check->costToPay, check->source, CostToPay);
|
||||
payTheManaCost(check->costToPay, check->source->has(Constants::ANYTYPEOFMANAABILITY), check->source, CostToPay);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2188,7 +2200,7 @@ int AIPlayerBaka::doAbility(MTGAbility * Specific, MTGCardInstance * withCard)
|
||||
//Make sure we can use the ability
|
||||
if (a->getCost() && !a->isReactingToClick(card, totalPotentialMana))//for performance reason only look for specific mana if the payment couldnt be made with potential.
|
||||
{
|
||||
abilityPayment = canPayMana(card, a->getCost());
|
||||
abilityPayment = canPayMana(card, a->getCost(), card->has(Constants::ANYTYPEOFMANAABILITY));
|
||||
}
|
||||
if (a->isReactingToClick(card, totalPotentialMana) || abilityPayment.size())
|
||||
{ //This test is to avoid the huge call to getPotentialManaCost after that
|
||||
@@ -2223,14 +2235,14 @@ int AIPlayerBaka::doAbility(MTGAbility * Specific, MTGCardInstance * withCard)
|
||||
{
|
||||
ManaCost * specificCost = NEW ManaCost(ManaCost::parseManaCost("{0}", NULL, NULL));
|
||||
specificCost->add(0, card->attackCostBackup);
|
||||
abilityPayment = canPayMana(card, specificCost);
|
||||
abilityPayment = canPayMana(card, specificCost, card->has(Constants::ANYTYPEOFMANAABILITY));
|
||||
SAFE_DELETE(specificCost);
|
||||
}
|
||||
else if (a->aType == MTGAbility::BLOCK_COST)
|
||||
{
|
||||
ManaCost * specificCost = NEW ManaCost(ManaCost::parseManaCost("{0}", NULL, NULL));
|
||||
specificCost->add(0, card->blockCostBackup);
|
||||
abilityPayment = canPayMana(card, specificCost);
|
||||
abilityPayment = canPayMana(card, specificCost, card->has(Constants::ANYTYPEOFMANAABILITY));
|
||||
SAFE_DELETE(specificCost);
|
||||
}
|
||||
}
|
||||
@@ -2266,7 +2278,7 @@ int AIPlayerBaka::doAbility(MTGAbility * Specific, MTGCardInstance * withCard)
|
||||
{
|
||||
ManaCost * specificCost = NEW ManaCost(ManaCost::parseManaCost("{0}", NULL, NULL));
|
||||
specificCost->add(0, action.click->attackCostBackup);
|
||||
if (payTheManaCost(specificCost, action.click, abilityPayment))
|
||||
if (payTheManaCost(specificCost, action.click->has(Constants::ANYTYPEOFMANAABILITY), action.click, abilityPayment))
|
||||
clickstream.push(NEW AIAction(action));
|
||||
SAFE_DELETE(specificCost);
|
||||
}
|
||||
@@ -2274,14 +2286,14 @@ int AIPlayerBaka::doAbility(MTGAbility * Specific, MTGCardInstance * withCard)
|
||||
{
|
||||
ManaCost * specificCost = NEW ManaCost(ManaCost::parseManaCost("{0}", NULL, NULL));
|
||||
specificCost->add(0, action.click->blockCostBackup);
|
||||
if (payTheManaCost(specificCost, action.click, abilityPayment))
|
||||
if (payTheManaCost(specificCost, action.click->has(Constants::ANYTYPEOFMANAABILITY), action.click, abilityPayment))
|
||||
clickstream.push(NEW AIAction(action));
|
||||
SAFE_DELETE(specificCost);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (payTheManaCost(action.ability->getCost(), action.click, abilityPayment))
|
||||
if (payTheManaCost(action.ability->getCost(), action.click->has(Constants::ANYTYPEOFMANAABILITY), action.click, abilityPayment))
|
||||
clickstream.push(NEW AIAction(action));
|
||||
}
|
||||
}
|
||||
@@ -2560,8 +2572,8 @@ MTGCardInstance * AIPlayerBaka::FindCardToPlay(ManaCost * pMana, const char * ty
|
||||
{
|
||||
nextCardToPlay = comboCards.back();
|
||||
gotPayments.clear();
|
||||
if((!pMana->canAfford(nextCardToPlay->getManaCost()) || nextCardToPlay->getManaCost()->getKicker() || nextCardToPlay->getManaCost()->getBestow()))
|
||||
gotPayments = canPayMana(nextCardToPlay,nextCardToPlay->getManaCost());
|
||||
if((!pMana->canAfford(nextCardToPlay->getManaCost(),0) || nextCardToPlay->getManaCost()->getKicker() || nextCardToPlay->getManaCost()->getBestow()))
|
||||
gotPayments = canPayMana(nextCardToPlay,nextCardToPlay->getManaCost(),nextCardToPlay->has(Constants::ANYTYPEOFMANA));
|
||||
DebugTrace("ai is doing a combo:" << nextCardToPlay->getName());
|
||||
comboCards.pop_back();
|
||||
if(!comboHint->cardTargets.size() && !comboCards.size())
|
||||
@@ -2628,8 +2640,8 @@ MTGCardInstance * AIPlayerBaka::FindCardToPlay(ManaCost * pMana, const char * ty
|
||||
continue;
|
||||
nextCardToPlay = card;
|
||||
gotPayments.clear();
|
||||
if((!pMana->canAfford(nextCardToPlay->getManaCost()) || nextCardToPlay->getManaCost()->getKicker()))
|
||||
gotPayments = canPayMana(nextCardToPlay,nextCardToPlay->getManaCost());
|
||||
if((!pMana->canAfford(nextCardToPlay->getManaCost(),0) || nextCardToPlay->getManaCost()->getKicker()))
|
||||
gotPayments = canPayMana(nextCardToPlay,nextCardToPlay->getManaCost(),nextCardToPlay->has(Constants::ANYTYPEOFMANA));
|
||||
return activateCombo();
|
||||
}
|
||||
else
|
||||
@@ -2641,10 +2653,10 @@ MTGCardInstance * AIPlayerBaka::FindCardToPlay(ManaCost * pMana, const char * ty
|
||||
int currentCost = card->getManaCost()->getConvertedCost();
|
||||
int hasX = card->getManaCost()->hasX();
|
||||
gotPayments.clear();
|
||||
if((!pMana->canAfford(card->getManaCost()) || card->getManaCost()->getKicker()))
|
||||
gotPayments = canPayMana(card,card->getManaCost());
|
||||
if((!pMana->canAfford(card->getManaCost(),0) || card->getManaCost()->getKicker()))
|
||||
gotPayments = canPayMana(card,card->getManaCost(),card->has(Constants::ANYTYPEOFMANA));
|
||||
//for preformence reason we only look for specific mana if the payment couldn't be made with pmana.
|
||||
if ((currentCost > maxCost || hasX) && (gotPayments.size() || pMana->canAfford(card->getManaCost())))
|
||||
if ((currentCost > maxCost || hasX) && (gotPayments.size() || pMana->canAfford(card->getManaCost(),card->has(Constants::ANYTYPEOFMANA))))
|
||||
{
|
||||
TargetChooserFactory tcf(observer);
|
||||
TargetChooser * tc = tcf.createTargetChooser(card);
|
||||
@@ -2785,8 +2797,8 @@ MTGCardInstance * AIPlayerBaka::FindCardToPlay(ManaCost * pMana, const char * ty
|
||||
continue;
|
||||
nextCardToPlay = card;
|
||||
gotPayments.clear();
|
||||
if((!pMana->canAfford(nextCardToPlay->getManaCost()) || nextCardToPlay->getManaCost()->getKicker()))
|
||||
gotPayments = canPayMana(nextCardToPlay,nextCardToPlay->getManaCost());
|
||||
if((!pMana->canAfford(nextCardToPlay->getManaCost(),0) || nextCardToPlay->getManaCost()->getKicker()))
|
||||
gotPayments = canPayMana(nextCardToPlay,nextCardToPlay->getManaCost(),nextCardToPlay->has(Constants::ANYTYPEOFMANA));
|
||||
return activateCombo();
|
||||
}
|
||||
else
|
||||
@@ -2798,10 +2810,10 @@ MTGCardInstance * AIPlayerBaka::FindCardToPlay(ManaCost * pMana, const char * ty
|
||||
int currentCost = card->getManaCost()->getConvertedCost();
|
||||
int hasX = card->getManaCost()->hasX();
|
||||
gotPayments.clear();
|
||||
if((!pMana->canAfford(card->getManaCost()) || card->getManaCost()->getKicker()))
|
||||
gotPayments = canPayMana(card,card->getManaCost());
|
||||
if((!pMana->canAfford(card->getManaCost(),0) || card->getManaCost()->getKicker()))
|
||||
gotPayments = canPayMana(card,card->getManaCost(),card->has(Constants::ANYTYPEOFMANA));
|
||||
//for preformence reason we only look for specific mana if the payment couldn't be made with pmana.
|
||||
if ((currentCost > maxCost || hasX) && (gotPayments.size() || pMana->canAfford(card->getManaCost())))
|
||||
if ((currentCost > maxCost || hasX) && (gotPayments.size() || pMana->canAfford(card->getManaCost(),card->has(Constants::ANYTYPEOFMANA))))
|
||||
{
|
||||
TargetChooserFactory tcf(observer);
|
||||
TargetChooser * tc = tcf.createTargetChooser(card);
|
||||
@@ -2923,8 +2935,8 @@ MTGCardInstance * AIPlayerBaka::FindCardToPlay(ManaCost * pMana, const char * ty
|
||||
continue;
|
||||
nextCardToPlay = card;
|
||||
gotPayments.clear();
|
||||
if((!pMana->canAfford(nextCardToPlay->getManaCost()) || nextCardToPlay->getManaCost()->getKicker()))
|
||||
gotPayments = canPayMana(nextCardToPlay,nextCardToPlay->getManaCost());
|
||||
if((!pMana->canAfford(nextCardToPlay->getManaCost(),0) || nextCardToPlay->getManaCost()->getKicker()))
|
||||
gotPayments = canPayMana(nextCardToPlay,nextCardToPlay->getManaCost(),nextCardToPlay->has(Constants::ANYTYPEOFMANA));
|
||||
return activateCombo();
|
||||
}
|
||||
else
|
||||
@@ -2936,10 +2948,10 @@ MTGCardInstance * AIPlayerBaka::FindCardToPlay(ManaCost * pMana, const char * ty
|
||||
int currentCost = card->getManaCost()->getConvertedCost();
|
||||
int hasX = card->getManaCost()->hasX();
|
||||
gotPayments.clear();
|
||||
if((!pMana->canAfford(card->getManaCost()) || card->getManaCost()->getKicker()))
|
||||
gotPayments = canPayMana(card,card->getManaCost());
|
||||
if((!pMana->canAfford(card->getManaCost(),0) || card->getManaCost()->getKicker()))
|
||||
gotPayments = canPayMana(card,card->getManaCost(),card->has(Constants::ANYTYPEOFMANA));
|
||||
//for preformence reason we only look for specific mana if the payment couldn't be made with pmana.
|
||||
if ((currentCost > maxCost || hasX) && (gotPayments.size() || pMana->canAfford(card->getManaCost())))
|
||||
if ((currentCost > maxCost || hasX) && (gotPayments.size() || pMana->canAfford(card->getManaCost(),card->has(Constants::ANYTYPEOFMANA))))
|
||||
{
|
||||
TargetChooserFactory tcf(observer);
|
||||
TargetChooser * tc = tcf.createTargetChooser(card);
|
||||
@@ -3072,8 +3084,8 @@ MTGCardInstance * AIPlayerBaka::FindCardToPlay(ManaCost * pMana, const char * ty
|
||||
continue;
|
||||
nextCardToPlay = card;
|
||||
gotPayments.clear();
|
||||
if((!pMana->canAfford(nextCardToPlay->getManaCost()) || nextCardToPlay->getManaCost()->getKicker()))
|
||||
gotPayments = canPayMana(nextCardToPlay,nextCardToPlay->getManaCost());
|
||||
if((!pMana->canAfford(nextCardToPlay->getManaCost(),0) || nextCardToPlay->getManaCost()->getKicker()))
|
||||
gotPayments = canPayMana(nextCardToPlay,nextCardToPlay->getManaCost(),nextCardToPlay->has(Constants::ANYTYPEOFMANA));
|
||||
return activateCombo();
|
||||
}
|
||||
else
|
||||
@@ -3085,10 +3097,10 @@ MTGCardInstance * AIPlayerBaka::FindCardToPlay(ManaCost * pMana, const char * ty
|
||||
int currentCost = card->getManaCost()->getConvertedCost();
|
||||
int hasX = card->getManaCost()->hasX();
|
||||
gotPayments.clear();
|
||||
if((!pMana->canAfford(card->getManaCost()) || card->getManaCost()->getKicker()))
|
||||
gotPayments = canPayMana(card,card->getManaCost());
|
||||
if((!pMana->canAfford(card->getManaCost(),0) || card->getManaCost()->getKicker()))
|
||||
gotPayments = canPayMana(card,card->getManaCost(),card->has(Constants::ANYTYPEOFMANA));
|
||||
//for preformence reason we only look for specific mana if the payment couldn't be made with pmana.
|
||||
if ((currentCost > maxCost || hasX) && (gotPayments.size() || pMana->canAfford(card->getManaCost())))
|
||||
if ((currentCost > maxCost || hasX) && (gotPayments.size() || pMana->canAfford(card->getManaCost(),card->has(Constants::ANYTYPEOFMANA))))
|
||||
{
|
||||
TargetChooserFactory tcf(observer);
|
||||
TargetChooser * tc = tcf.createTargetChooser(card);
|
||||
@@ -3189,8 +3201,8 @@ MTGCardInstance * AIPlayerBaka::FindCardToPlay(ManaCost * pMana, const char * ty
|
||||
}
|
||||
if(nextCardToPlay)
|
||||
{
|
||||
if(!pMana->canAfford(nextCardToPlay->getManaCost()) || nextCardToPlay->getManaCost()->getKicker())
|
||||
gotPayments = canPayMana(nextCardToPlay,nextCardToPlay->getManaCost());
|
||||
if(!pMana->canAfford(nextCardToPlay->getManaCost(),0) || nextCardToPlay->getManaCost()->getKicker())
|
||||
gotPayments = canPayMana(nextCardToPlay,nextCardToPlay->getManaCost(),nextCardToPlay->has(Constants::ANYTYPEOFMANA));
|
||||
DebugTrace(" AI wants to play card." << endl
|
||||
<< "- Next card to play: " << (nextCardToPlay ? nextCardToPlay->name : "None" ) << endl );
|
||||
|
||||
@@ -3226,7 +3238,7 @@ MTGCardInstance * AIPlayerBaka::activateCombo()
|
||||
}
|
||||
SAFE_DELETE(hintTc);
|
||||
}
|
||||
if(payTheManaCost(totalCost,nextCardToPlay,gotPayments))
|
||||
if(payTheManaCost(totalCost,nextCardToPlay->has(Constants::ANYTYPEOFMANA),nextCardToPlay,gotPayments))
|
||||
{
|
||||
if(comboCards.size())
|
||||
{
|
||||
@@ -3350,7 +3362,7 @@ int AIPlayerBaka::computeActions()
|
||||
{
|
||||
if (ipotential)
|
||||
{
|
||||
if(payTheManaCost(nextCardToPlay->getManaCost(),nextCardToPlay,gotPayments))
|
||||
if(payTheManaCost(nextCardToPlay->getManaCost(),nextCardToPlay->has(Constants::ANYTYPEOFMANAABILITY),nextCardToPlay,gotPayments))
|
||||
{
|
||||
AIAction * a = NEW AIAction(this, nextCardToPlay);
|
||||
clickstream.push(a);
|
||||
@@ -3499,7 +3511,7 @@ int AIPlayerBaka::computeActions()
|
||||
//this does not teach it to use manaproducer more effectively, it simply allow it to
|
||||
//use the manaproducers it does understand better on sunburst by force.
|
||||
vector<MTGAbility*>checking = canPaySunBurst(nextCardToPlay->getManaCost());
|
||||
if(payTheManaCost(nextCardToPlay->getManaCost(),NULL,checking))
|
||||
if(payTheManaCost(nextCardToPlay->getManaCost(),0,NULL,checking))
|
||||
{
|
||||
AIAction * a = NEW AIAction(this, nextCardToPlay);
|
||||
clickstream.push(a);
|
||||
@@ -3509,7 +3521,7 @@ int AIPlayerBaka::computeActions()
|
||||
gotPayments.clear();//if any.
|
||||
return 1;
|
||||
}
|
||||
if(payTheManaCost(nextCardToPlay->getManaCost(),nextCardToPlay,gotPayments))
|
||||
if(payTheManaCost(nextCardToPlay->getManaCost(),nextCardToPlay->has(Constants::ANYTYPEOFMANA),nextCardToPlay,gotPayments))
|
||||
{
|
||||
AIAction * a = NEW AIAction(this, nextCardToPlay);
|
||||
clickstream.push(a);
|
||||
@@ -3978,10 +3990,10 @@ int AIPlayerBaka::Act(float dt)
|
||||
check = dynamic_cast<ExtraManaCost*>(observer->mExtraPayment->costs[0]);
|
||||
if(check)
|
||||
{
|
||||
vector<MTGAbility*> CostToPay = canPayMana(observer->mExtraPayment->source,check->costToPay);
|
||||
vector<MTGAbility*> CostToPay = canPayMana(observer->mExtraPayment->source,check->costToPay,check->source->has(Constants::ANYTYPEOFMANAABILITY));
|
||||
if(CostToPay.size())
|
||||
{
|
||||
payTheManaCost(check->costToPay,check->source,CostToPay);
|
||||
payTheManaCost(check->costToPay,check->source->has(Constants::ANYTYPEOFMANAABILITY),check->source,CostToPay);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -20,9 +20,9 @@ MTGCardInstance * AIPlayerBakaB::chooseCard(TargetChooser * tc, MTGCardInstance
|
||||
return AIPlayerBaka::chooseCard(tc, source, random);
|
||||
}
|
||||
|
||||
bool AIPlayerBakaB::payTheManaCost(ManaCost * cost, MTGCardInstance * target, vector<MTGAbility*>gotPayments)
|
||||
bool AIPlayerBakaB::payTheManaCost(ManaCost * cost, int anytypeofmana, MTGCardInstance * target, vector<MTGAbility*>gotPayments)
|
||||
{
|
||||
return AIPlayerBaka::payTheManaCost(cost, target, gotPayments);
|
||||
return AIPlayerBaka::payTheManaCost(cost, anytypeofmana, target, gotPayments);
|
||||
}
|
||||
|
||||
int AIPlayerBakaB::getEfficiency(OrderedAIAction * action)
|
||||
|
||||
@@ -81,7 +81,7 @@ int ExtraCost::setPayment(MTGCardInstance * card)
|
||||
target = card;
|
||||
}
|
||||
}
|
||||
if (costToPay && source->controller()->getManaPool()->canAfford(costToPay))
|
||||
if (costToPay && source->controller()->getManaPool()->canAfford(costToPay,card->has(Constants::ANYTYPEOFMANAABILITY)))
|
||||
{
|
||||
result = 1;
|
||||
}
|
||||
@@ -106,7 +106,7 @@ int ExtraManaCost::tryToSetPayment(MTGCardInstance * card)
|
||||
|
||||
int ExtraManaCost::isPaymentSet()
|
||||
{
|
||||
if (!source->controller()->getManaPool()->canAfford(costToPay))
|
||||
if (!source->controller()->getManaPool()->canAfford(costToPay,source->has(Constants::ANYTYPEOFMANAABILITY)))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -115,7 +115,7 @@ int ExtraManaCost::isPaymentSet()
|
||||
|
||||
int ExtraManaCost::canPay()
|
||||
{
|
||||
if(!source->controller()->getManaPool()->canAfford(costToPay))
|
||||
if(!source->controller()->getManaPool()->canAfford(costToPay,source->has(Constants::ANYTYPEOFMANAABILITY)))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -124,7 +124,7 @@ int ExtraManaCost::canPay()
|
||||
|
||||
int ExtraManaCost::doPay()
|
||||
{
|
||||
if (!source->controller()->getManaPool()->canAfford(costToPay))
|
||||
if (!source->controller()->getManaPool()->canAfford(costToPay,source->has(Constants::ANYTYPEOFMANAABILITY)))
|
||||
return 0;
|
||||
|
||||
source->controller()->getManaPool()->pay(costToPay);
|
||||
@@ -156,13 +156,13 @@ int SnowCost::isPaymentSet()
|
||||
result += source->controller()->snowManaC;
|
||||
if (result)
|
||||
{
|
||||
if ((source->controller()->snowManaC && source->controller()->getManaPool()->canAfford(ManaCost::parseManaCost("{1}",NULL,source))) ||
|
||||
(source->controller()->snowManaG && source->controller()->getManaPool()->canAfford(ManaCost::parseManaCost("{g}",NULL,source))) ||
|
||||
(source->controller()->snowManaU && source->controller()->getManaPool()->canAfford(ManaCost::parseManaCost("{u}",NULL,source))) ||
|
||||
(source->controller()->snowManaR && source->controller()->getManaPool()->canAfford(ManaCost::parseManaCost("{r}",NULL,source))) ||
|
||||
(source->controller()->snowManaB && source->controller()->getManaPool()->canAfford(ManaCost::parseManaCost("{b}",NULL,source))) ||
|
||||
(source->controller()->snowManaW && source->controller()->getManaPool()->canAfford(ManaCost::parseManaCost("{w}",NULL,source))) ||
|
||||
(source->controller()->snowManaC && source->controller()->getManaPool()->canAfford(ManaCost::parseManaCost("{c}",NULL,source))))
|
||||
if ((source->controller()->snowManaC && source->controller()->getManaPool()->canAfford(ManaCost::parseManaCost("{1}",NULL,source),source->has(Constants::ANYTYPEOFMANAABILITY))) ||
|
||||
(source->controller()->snowManaG && source->controller()->getManaPool()->canAfford(ManaCost::parseManaCost("{g}",NULL,source),source->has(Constants::ANYTYPEOFMANAABILITY))) ||
|
||||
(source->controller()->snowManaU && source->controller()->getManaPool()->canAfford(ManaCost::parseManaCost("{u}",NULL,source),source->has(Constants::ANYTYPEOFMANAABILITY))) ||
|
||||
(source->controller()->snowManaR && source->controller()->getManaPool()->canAfford(ManaCost::parseManaCost("{r}",NULL,source),source->has(Constants::ANYTYPEOFMANAABILITY))) ||
|
||||
(source->controller()->snowManaB && source->controller()->getManaPool()->canAfford(ManaCost::parseManaCost("{b}",NULL,source),source->has(Constants::ANYTYPEOFMANAABILITY))) ||
|
||||
(source->controller()->snowManaW && source->controller()->getManaPool()->canAfford(ManaCost::parseManaCost("{w}",NULL,source),source->has(Constants::ANYTYPEOFMANAABILITY))) ||
|
||||
(source->controller()->snowManaC && source->controller()->getManaPool()->canAfford(ManaCost::parseManaCost("{c}",NULL,source),source->has(Constants::ANYTYPEOFMANAABILITY))))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
@@ -190,37 +190,37 @@ int SnowCost::doPay()
|
||||
if (result)
|
||||
{
|
||||
// Avoided double payments for Snow Mana cost
|
||||
if (source->controller()->snowManaC && source->controller()->getManaPool()->canAfford(ManaCost::parseManaCost("{1}",NULL,source)))
|
||||
if (source->controller()->snowManaC && source->controller()->getManaPool()->canAfford(ManaCost::parseManaCost("{1}",NULL,source),source->has(Constants::ANYTYPEOFMANAABILITY)))
|
||||
{
|
||||
//source->controller()->getManaPool()->pay(ManaCost::parseManaCost("{1}",NULL,source));
|
||||
source->controller()->snowManaC -= 1;
|
||||
}
|
||||
else if (source->controller()->snowManaG && source->controller()->getManaPool()->canAfford(ManaCost::parseManaCost("{g}",NULL,source)))
|
||||
else if (source->controller()->snowManaG && source->controller()->getManaPool()->canAfford(ManaCost::parseManaCost("{g}",NULL,source),source->has(Constants::ANYTYPEOFMANAABILITY)))
|
||||
{
|
||||
//source->controller()->getManaPool()->pay(ManaCost::parseManaCost("{g}",NULL,source));
|
||||
source->controller()->snowManaG -= 1;
|
||||
}
|
||||
else if (source->controller()->snowManaU && source->controller()->getManaPool()->canAfford(ManaCost::parseManaCost("{u}",NULL,source)))
|
||||
else if (source->controller()->snowManaU && source->controller()->getManaPool()->canAfford(ManaCost::parseManaCost("{u}",NULL,source),source->has(Constants::ANYTYPEOFMANAABILITY)))
|
||||
{
|
||||
//source->controller()->getManaPool()->pay(ManaCost::parseManaCost("{u}",NULL,source));
|
||||
source->controller()->snowManaU -= 1;
|
||||
}
|
||||
else if (source->controller()->snowManaR && source->controller()->getManaPool()->canAfford(ManaCost::parseManaCost("{r}",NULL,source)))
|
||||
else if (source->controller()->snowManaR && source->controller()->getManaPool()->canAfford(ManaCost::parseManaCost("{r}",NULL,source),source->has(Constants::ANYTYPEOFMANAABILITY)))
|
||||
{
|
||||
//source->controller()->getManaPool()->pay(ManaCost::parseManaCost("{r}",NULL,source));
|
||||
source->controller()->snowManaR -= 1;
|
||||
}
|
||||
else if (source->controller()->snowManaB && source->controller()->getManaPool()->canAfford(ManaCost::parseManaCost("{b}",NULL,source)))
|
||||
else if (source->controller()->snowManaB && source->controller()->getManaPool()->canAfford(ManaCost::parseManaCost("{b}",NULL,source),source->has(Constants::ANYTYPEOFMANAABILITY)))
|
||||
{
|
||||
//source->controller()->getManaPool()->pay(ManaCost::parseManaCost("{b}",NULL,source));
|
||||
source->controller()->snowManaB -= 1;
|
||||
}
|
||||
else if (source->controller()->snowManaW && source->controller()->getManaPool()->canAfford(ManaCost::parseManaCost("{w}",NULL,source)))
|
||||
else if (source->controller()->snowManaW && source->controller()->getManaPool()->canAfford(ManaCost::parseManaCost("{w}",NULL,source),source->has(Constants::ANYTYPEOFMANAABILITY)))
|
||||
{
|
||||
//source->controller()->getManaPool()->pay(ManaCost::parseManaCost("{w}",NULL,source));
|
||||
source->controller()->snowManaW -= 1;
|
||||
}
|
||||
else if (source->controller()->snowManaC && source->controller()->getManaPool()->canAfford(ManaCost::parseManaCost("{c}",NULL,source)))
|
||||
else if (source->controller()->snowManaC && source->controller()->getManaPool()->canAfford(ManaCost::parseManaCost("{c}",NULL,source),source->has(Constants::ANYTYPEOFMANAABILITY)))
|
||||
{
|
||||
//source->controller()->getManaPool()->pay(ManaCost::parseManaCost("{c}",NULL,source));
|
||||
source->controller()->snowManaC -= 1;
|
||||
@@ -383,9 +383,9 @@ int LifeorManaCost::canPay()
|
||||
_target->controller()->opponent()->game->battlefield->hasAbility(Constants::CANTPAYLIFE) ||
|
||||
_target->controller()->game->battlefield->hasAbility(Constants::CANTPAYLIFE))
|
||||
{
|
||||
return _target->controller()->getManaPool()->canAfford(getManaCost());
|
||||
return _target->controller()->getManaPool()->canAfford(getManaCost(),_target->has(Constants::ANYTYPEOFMANAABILITY));
|
||||
}
|
||||
else if((_target->controller()->life > 1 || _target->controller()->getManaPool()->canAfford(getManaCost())) &&
|
||||
else if((_target->controller()->life > 1 || _target->controller()->getManaPool()->canAfford(getManaCost(),_target->has(Constants::ANYTYPEOFMANAABILITY))) &&
|
||||
(!_target->controller()->inPlay()->hasAbility(Constants::CANTCHANGELIFE) &&
|
||||
!_target->controller()->opponent()->game->battlefield->hasAbility(Constants::CANTPAYLIFE) &&
|
||||
!_target->controller()->game->battlefield->hasAbility(Constants::CANTPAYLIFE)))
|
||||
@@ -401,7 +401,7 @@ int LifeorManaCost::doPay()
|
||||
return 0;
|
||||
|
||||
MTGCardInstance * _target = (MTGCardInstance *) target;
|
||||
if (_target->controller()->getManaPool()->canAfford(&manaCost))
|
||||
if (_target->controller()->getManaPool()->canAfford(&manaCost,_target->has(Constants::ANYTYPEOFMANAABILITY)))
|
||||
{
|
||||
_target->controller()->getManaPool()->pay(&manaCost);
|
||||
}
|
||||
@@ -1056,13 +1056,13 @@ int Convoke::isPaymentSet()
|
||||
return 0;
|
||||
}
|
||||
ManaCost * toReduce = getReduction();
|
||||
if (target && (!source->controller()->getManaPool()->canAfford(toReduce)))
|
||||
if (target && (!source->controller()->getManaPool()->canAfford(toReduce,target->has(Constants::ANYTYPEOFMANAABILITY))))
|
||||
{
|
||||
target = NULL;
|
||||
SAFE_DELETE(toReduce);
|
||||
return 0;
|
||||
}
|
||||
if (target && (source->controller()->getManaPool()->canAfford(toReduce)))
|
||||
if (target && (source->controller()->getManaPool()->canAfford(toReduce,target->has(Constants::ANYTYPEOFMANAABILITY))))
|
||||
{
|
||||
SAFE_DELETE(toReduce);
|
||||
return 1;
|
||||
@@ -1099,7 +1099,7 @@ ManaCost * Convoke::getReduction()
|
||||
}
|
||||
}
|
||||
//if we didnt find it payable one way, lets try again backwards.
|
||||
if (!source->controller()->getManaPool()->canAfford(toReduce))
|
||||
if (!source->controller()->getManaPool()->canAfford(toReduce,source->has(Constants::ANYTYPEOFMANAABILITY)))
|
||||
{
|
||||
SAFE_DELETE(toReduce);
|
||||
toReduce = NEW ManaCost(source->getManaCost());
|
||||
@@ -1176,13 +1176,13 @@ int Delve::isPaymentSet()
|
||||
{
|
||||
toReduce->remove(Constants::MTG_COLOR_ARTIFACT, tc->getNbTargets());
|
||||
}
|
||||
if (target && (!source->controller()->getManaPool()->canAfford(toReduce)))
|
||||
if (target && (!source->controller()->getManaPool()->canAfford(toReduce,source->has(Constants::ANYTYPEOFMANAABILITY))))
|
||||
{
|
||||
target = NULL;
|
||||
SAFE_DELETE(toReduce);
|
||||
return 0;
|
||||
}
|
||||
if (target && (source->controller()->getManaPool()->canAfford(toReduce)))
|
||||
if (target && (source->controller()->getManaPool()->canAfford(toReduce,source->has(Constants::ANYTYPEOFMANAABILITY))))
|
||||
{
|
||||
if (target->getObserver()->guiOpenDisplay)
|
||||
target->getObserver()->ButtonPressed(target->getObserver()->guiOpenDisplay);
|
||||
@@ -1244,13 +1244,13 @@ int Improvise::isPaymentSet()
|
||||
{
|
||||
toReduce->remove(Constants::MTG_COLOR_ARTIFACT, tc->getNbTargets());
|
||||
}
|
||||
if (target && (!source->controller()->getManaPool()->canAfford(toReduce)))
|
||||
if (target && (!source->controller()->getManaPool()->canAfford(toReduce,target->has(Constants::ANYTYPEOFMANAABILITY))))
|
||||
{
|
||||
target = NULL;
|
||||
SAFE_DELETE(toReduce);
|
||||
return 0;
|
||||
}
|
||||
if (target && (source->controller()->getManaPool()->canAfford(toReduce)))
|
||||
if (target && (source->controller()->getManaPool()->canAfford(toReduce,target->has(Constants::ANYTYPEOFMANAABILITY))))
|
||||
{
|
||||
/*if (target->getObserver()->guiOpenDisplay)
|
||||
target->getObserver()->ButtonPressed(target->getObserver()->guiOpenDisplay);*/
|
||||
@@ -1312,14 +1312,14 @@ int Offering::canPay()
|
||||
reduced->extraCosts = NULL;
|
||||
reduced->remove(Constants::MTG_COLOR_ARTIFACT, target->getManaCost()->getConvertedCost());
|
||||
|
||||
if (target && (!source->controller()->getManaPool()->canAfford(reduced)))
|
||||
if (target && (!source->controller()->getManaPool()->canAfford(reduced,source->has(Constants::ANYTYPEOFMANAABILITY))))
|
||||
{
|
||||
tc->removeTarget(target);
|
||||
target = NULL;
|
||||
SAFE_DELETE(reduced);
|
||||
return 0;
|
||||
}
|
||||
if (target && source->controller()->getManaPool()->canAfford(reduced))
|
||||
if (target && source->controller()->getManaPool()->canAfford(reduced,source->has(Constants::ANYTYPEOFMANAABILITY)))
|
||||
{
|
||||
SAFE_DELETE(reduced);
|
||||
return 1;
|
||||
@@ -1332,14 +1332,14 @@ int Offering::canPay()
|
||||
if (target)
|
||||
{
|
||||
ManaCost * diff = source->getManaCost()->Diff(target->getManaCost());
|
||||
if (target && (!source->controller()->getManaPool()->canAfford(source->getManaCost()->Diff(target->getManaCost()))))
|
||||
if (target && (!source->controller()->getManaPool()->canAfford(source->getManaCost()->Diff(target->getManaCost()),source->has(Constants::ANYTYPEOFMANAABILITY))))
|
||||
{
|
||||
SAFE_DELETE(diff);
|
||||
tc->removeTarget(target);
|
||||
target = NULL;
|
||||
return 0;
|
||||
}
|
||||
if (target && (source->controller()->getManaPool()->canAfford(source->getManaCost()->Diff(target->getManaCost()))))
|
||||
if (target && (source->controller()->getManaPool()->canAfford(source->getManaCost()->Diff(target->getManaCost()),source->has(Constants::ANYTYPEOFMANAABILITY))))
|
||||
{
|
||||
SAFE_DELETE(diff);
|
||||
return 1;
|
||||
@@ -1359,14 +1359,14 @@ int Offering::isPaymentSet()
|
||||
reduced->extraCosts = NULL;
|
||||
reduced->remove(Constants::MTG_COLOR_ARTIFACT, target->getManaCost()->getConvertedCost());
|
||||
|
||||
if (target && (!source->controller()->getManaPool()->canAfford(reduced)))
|
||||
if (target && (!source->controller()->getManaPool()->canAfford(reduced,source->has(Constants::ANYTYPEOFMANAABILITY))))
|
||||
{
|
||||
tc->removeTarget(target);
|
||||
target = NULL;
|
||||
SAFE_DELETE(reduced);
|
||||
return 0;
|
||||
}
|
||||
if (target && source->controller()->getManaPool()->canAfford(reduced))
|
||||
if (target && source->controller()->getManaPool()->canAfford(reduced,source->has(Constants::ANYTYPEOFMANAABILITY)))
|
||||
{
|
||||
SAFE_DELETE(reduced);
|
||||
return 1;
|
||||
@@ -1379,14 +1379,14 @@ int Offering::isPaymentSet()
|
||||
if (target)
|
||||
{
|
||||
ManaCost * diff = source->getManaCost()->Diff(target->getManaCost());
|
||||
if (target && (!source->controller()->getManaPool()->canAfford(diff)))
|
||||
if (target && (!source->controller()->getManaPool()->canAfford(diff,source->has(Constants::ANYTYPEOFMANAABILITY))))
|
||||
{
|
||||
SAFE_DELETE(diff);
|
||||
tc->removeTarget(target);
|
||||
target = NULL;
|
||||
return 0;
|
||||
}
|
||||
if (target && (source->controller()->getManaPool()->canAfford(diff)))
|
||||
if (target && (source->controller()->getManaPool()->canAfford(diff,source->has(Constants::ANYTYPEOFMANAABILITY))))
|
||||
{
|
||||
SAFE_DELETE(diff);
|
||||
return 1;
|
||||
|
||||
@@ -532,11 +532,11 @@ bool GameObserver::operator==(const GameObserver& aGame)
|
||||
{
|
||||
error++;
|
||||
}
|
||||
if (!p->getManaPool()->canAfford(players[i]->getManaPool()))
|
||||
if (!p->getManaPool()->canAfford(players[i]->getManaPool(),0))
|
||||
{
|
||||
error++;
|
||||
}
|
||||
if (!players[i]->getManaPool()->canAfford(p->getManaPool()))
|
||||
if (!players[i]->getManaPool()->canAfford(p->getManaPool(),0))
|
||||
{
|
||||
error++;
|
||||
}
|
||||
@@ -1196,8 +1196,8 @@ void GameObserver::Affinity()
|
||||
if(card->model->data->getManaCost()->getBestow())
|
||||
checkAuraP = true;
|
||||
|
||||
//change cost to colorless for anytypeofmana ability
|
||||
if(card->has(Constants::ANYTYPEOFMANA))
|
||||
//change cost to colorless for anytypeofmana ability (Obsolete code)
|
||||
/*if(card->has(Constants::ANYTYPEOFMANA))
|
||||
{
|
||||
card->anymanareplacement = true;
|
||||
int convertedC = card->getManaCost()->getConvertedCost();
|
||||
@@ -1214,7 +1214,7 @@ void GameObserver::Affinity()
|
||||
card->getManaCost()->changeCostTo( card->model->data->getManaCost() );
|
||||
card->anymanareplacement = false;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
if (card->has(Constants::TRINISPHERE))
|
||||
{
|
||||
|
||||
@@ -560,7 +560,7 @@ int AbilityFactory::parseCastRestrictions(MTGCardInstance * card, Player * playe
|
||||
{
|
||||
ManaCost * costToCheck = ManaCost::parseManaCost(restriction[i]);
|
||||
ManaCost * spent = card->getManaCost()->getManaUsedToCast();
|
||||
if(spent && costToCheck && !spent->canAfford(costToCheck))
|
||||
if(spent && costToCheck && !spent->canAfford(costToCheck,0))
|
||||
{
|
||||
SAFE_DELETE(costToCheck);
|
||||
return 0;
|
||||
@@ -6196,7 +6196,7 @@ int ActivatedAbility::isReactingToClick(MTGCardInstance * card, ManaCost * mana)
|
||||
|
||||
if (!mana)
|
||||
mana = player->getManaPool();
|
||||
if (!mana->canAfford(cost))
|
||||
if (!mana->canAfford(cost,card->has(Constants::ANYTYPEOFMANAABILITY)))
|
||||
return 0;
|
||||
if (!cost->canPayExtra())
|
||||
return 0;
|
||||
@@ -7106,7 +7106,7 @@ int AManaProducer::isReactingToClick(MTGCardInstance * _card, ManaCost * mana)
|
||||
if (!source->isPhased)
|
||||
{
|
||||
ManaCost * cost = getCost();
|
||||
if (!cost || (mana->canAfford(cost) && (!cost->extraCosts || cost->extraCosts->canPay())))/*counter cost bypass react to click*/
|
||||
if (!cost || (mana->canAfford(cost,_card->has(Constants::ANYTYPEOFMANAABILITY)) && (!cost->extraCosts || cost->extraCosts->canPay())))/*counter cost bypass react to click*/
|
||||
{
|
||||
result = 1;
|
||||
}
|
||||
|
||||
@@ -205,7 +205,8 @@ const char* Constants::MTGBasicAbilities[] = {
|
||||
"gainedexiledeath", //It goes to exile after death (use just to give add ability to instants and sorceries which originally have not, e.g. with transforms keyword)
|
||||
"gainedhanddeath", //It goes to hand after death (use just to give add ability to instants and sorceries which originally have not, e.g. with transforms keyword)
|
||||
"cycling", //It has cycling ability
|
||||
"foretell" //It has foretell cost
|
||||
"foretell", //It has foretell cost
|
||||
"anytypeofmanaability" //It allows to spend mana as it were of any color to activate abilities.
|
||||
};
|
||||
|
||||
map<string,int> Constants::MTGBasicAbilitiesMap;
|
||||
|
||||
@@ -349,11 +349,17 @@ int MTGPutInPlayRule::isReactingToClick(MTGCardInstance * card, ManaCost *)
|
||||
#ifdef WIN32
|
||||
cost->Dump();
|
||||
#endif
|
||||
if (playerMana->canAfford(cost))
|
||||
if (playerMana->canAfford(cost,card->has(Constants::ANYTYPEOFMANA)))
|
||||
{
|
||||
//-------
|
||||
if (card->has(Constants::SUNBURST))
|
||||
{
|
||||
if(card->has(Constants::ANYTYPEOFMANA) > 0 && card->sunburst == 0){
|
||||
int convertedC = card->getManaCost()->getConvertedCost();
|
||||
card->getManaCost()->changeCostTo( NEW ManaCost(ManaCost::parseManaCost("{0}", NULL, card)) );
|
||||
for (int jj = 0; jj < convertedC; jj++)
|
||||
card->getManaCost()->add(Constants::MTG_COLOR_ARTIFACT, 1);
|
||||
}
|
||||
for (int i = 1; i != 6; i++)
|
||||
{
|
||||
if (player->getManaPool()->hasColor(i))
|
||||
@@ -450,7 +456,7 @@ int MTGPutInPlayRule::reactToClick(MTGCardInstance * card)
|
||||
Xcost->copy(cost);
|
||||
Xcost->add(Constants::MTG_COLOR_ARTIFACT, card->setX);
|
||||
Xcost->remove(7, 1);
|
||||
if (playerMana->canAfford(Xcost))
|
||||
if (playerMana->canAfford(Xcost,card->has(Constants::ANYTYPEOFMANA)))
|
||||
{
|
||||
cost->copy(Xcost);
|
||||
SAFE_DELETE(Xcost);
|
||||
@@ -490,7 +496,7 @@ int MTGPutInPlayRule::reactToClick(MTGCardInstance * card)
|
||||
card->kicked = 0;
|
||||
if (card->getManaCost()->getKicker()->isMulti)
|
||||
{
|
||||
while(previousManaPool->canAfford(withKickerCost))
|
||||
while(previousManaPool->canAfford(withKickerCost,card->has(Constants::ANYTYPEOFMANA)))
|
||||
{
|
||||
withKickerCost->add(withKickerCost->getKicker());
|
||||
card->kicked += 1;
|
||||
@@ -500,7 +506,7 @@ int MTGPutInPlayRule::reactToClick(MTGCardInstance * card)
|
||||
payResult = ManaCost::MANA_PAID_WITH_KICKER;
|
||||
card->alternateCostPaid[ManaCost::MANA_PAID_WITH_KICKER] = 1;
|
||||
}
|
||||
else if (previousManaPool->canAfford(withKickerCost))
|
||||
else if (previousManaPool->canAfford(withKickerCost,card->has(Constants::ANYTYPEOFMANA)))
|
||||
{
|
||||
player->getManaPool()->pay(card->getManaCost()->getKicker());
|
||||
payResult = ManaCost::MANA_PAID_WITH_KICKER;
|
||||
@@ -515,7 +521,7 @@ int MTGPutInPlayRule::reactToClick(MTGCardInstance * card)
|
||||
withBestowCost->add(withBestowCost->getBestow());
|
||||
|
||||
DebugTrace("AltCost BESTOW " << withBestowCost);
|
||||
if (previousManaPool->canAfford(withBestowCost))
|
||||
if (previousManaPool->canAfford(withBestowCost,card->has(Constants::ANYTYPEOFMANA)))
|
||||
{
|
||||
player->getManaPool()->pay(card->getManaCost()->getBestow());
|
||||
payResult = ManaCost::MANA_PAID_WITH_BESTOW;
|
||||
@@ -618,7 +624,7 @@ int MTGKickerRule::isReactingToClick(MTGCardInstance * card, ManaCost *)
|
||||
#ifdef WIN32
|
||||
withKickerCost->Dump();
|
||||
#endif
|
||||
if (playerMana->canAfford(withKickerCost))
|
||||
if (playerMana->canAfford(withKickerCost,card->has(Constants::ANYTYPEOFMANA)))
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
@@ -657,7 +663,7 @@ int MTGKickerRule::reactToClick(MTGCardInstance * card)
|
||||
card->kicked = 0;
|
||||
if (card->getManaCost()->getKicker()->isMulti)
|
||||
{
|
||||
while(previousManaPool->canAfford(withKickerCost))
|
||||
while(previousManaPool->canAfford(withKickerCost,card->has(Constants::ANYTYPEOFMANA)))
|
||||
{
|
||||
withKickerCost->add(withKickerCost->getKicker());
|
||||
card->kicked += 1;
|
||||
@@ -667,7 +673,7 @@ int MTGKickerRule::reactToClick(MTGCardInstance * card)
|
||||
payResult = ManaCost::MANA_PAID_WITH_KICKER;
|
||||
card->alternateCostPaid[ManaCost::MANA_PAID_WITH_KICKER] = 1;
|
||||
}
|
||||
else if (previousManaPool->canAfford(withKickerCost))
|
||||
else if (previousManaPool->canAfford(withKickerCost,card->has(Constants::ANYTYPEOFMANA)))
|
||||
{
|
||||
player->getManaPool()->pay(card->getManaCost()->getKicker());
|
||||
payResult = ManaCost::MANA_PAID_WITH_KICKER;
|
||||
@@ -682,7 +688,7 @@ int MTGKickerRule::reactToClick(MTGCardInstance * card)
|
||||
ManaCost * withBestowCost= NEW ManaCost(card->getManaCost());
|
||||
withBestowCost->add(withBestowCost->getBestow());
|
||||
|
||||
if (previousManaPool->canAfford(withBestowCost))
|
||||
if (previousManaPool->canAfford(withBestowCost,card->has(Constants::ANYTYPEOFMANA)))
|
||||
{
|
||||
player->getManaPool()->pay(card->getManaCost()->getBestow());
|
||||
payResult = ManaCost::MANA_PAID_WITH_BESTOW;
|
||||
@@ -827,7 +833,7 @@ int MTGAlternativeCostRule::isReactingToClick(MTGCardInstance * card, ManaCost *
|
||||
ManaCost * cost = card->getManaCost();
|
||||
cost->Dump();
|
||||
#endif
|
||||
if (alternateManaCost->extraCosts && !playerMana->canAfford(card->getManaCost()))
|
||||
if (alternateManaCost->extraCosts && !playerMana->canAfford(card->getManaCost(),card->has(Constants::ANYTYPEOFMANA)))
|
||||
{
|
||||
//offerings handle thier own casting and cost payments.
|
||||
//we add this condiational here because offering can also have a completely different
|
||||
@@ -851,7 +857,7 @@ int MTGAlternativeCostRule::isReactingToClick(MTGCardInstance * card, ManaCost *
|
||||
}
|
||||
}
|
||||
|
||||
if (playerMana->canAfford(alternateManaCost))
|
||||
if (playerMana->canAfford(alternateManaCost,card->has(Constants::ANYTYPEOFMANA)))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
@@ -921,7 +927,7 @@ int MTGAlternativeCostRule::reactToClick(MTGCardInstance * card, ManaCost *alter
|
||||
Xcost->add(Constants::MTG_COLOR_ARTIFACT, card->setX);
|
||||
card->X = card->setX; // Fix to don't loose X value on alternative cast
|
||||
Xcost->remove(7, 1);//remove the X
|
||||
if (playerMana->canAfford(Xcost))
|
||||
if (playerMana->canAfford(Xcost,card->has(Constants::ANYTYPEOFMANA)))
|
||||
{
|
||||
alternateCost->copy(Xcost);
|
||||
SAFE_DELETE(Xcost);
|
||||
@@ -1294,13 +1300,13 @@ int MTGSuspendRule::reactToClick(MTGCardInstance * card)
|
||||
ManaCost * playerMana = player->getManaPool();
|
||||
ManaCost * alternateCost = card->getManaCost()->getSuspend();
|
||||
//this handles extra cost payments at the moment a card is played.
|
||||
if (playerMana->canAfford(alternateCost))
|
||||
if (playerMana->canAfford(alternateCost,card->has(Constants::ANYTYPEOFMANA)))
|
||||
{
|
||||
if(alternateCost->hasX())
|
||||
{
|
||||
ManaCost * checkXnotZero = NEW ManaCost(alternateCost);//suspend cards with x cost, x can not be zero.
|
||||
checkXnotZero->add(0,1);
|
||||
if (!playerMana->canAfford(checkXnotZero))
|
||||
if (!playerMana->canAfford(checkXnotZero,card->has(Constants::ANYTYPEOFMANA)))
|
||||
{
|
||||
SAFE_DELETE(checkXnotZero);
|
||||
return 0;
|
||||
@@ -1402,7 +1408,7 @@ int MTGMorphCostRule::isReactingToClick(MTGCardInstance * card, ManaCost *)
|
||||
#endif
|
||||
|
||||
//cost of card.
|
||||
if (playerMana->canAfford(morph))
|
||||
if (playerMana->canAfford(morph,card->has(Constants::ANYTYPEOFMANA)))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
@@ -1425,7 +1431,7 @@ int MTGMorphCostRule::reactToClick(MTGCardInstance * card)
|
||||
morph->extraCosts->costs[i]->setSource(card);
|
||||
}
|
||||
//this handles extra cost payments at the moment a card is played.
|
||||
if (playerMana->canAfford(morph))
|
||||
if (playerMana->canAfford(morph,card->has(Constants::ANYTYPEOFMANA)))
|
||||
{
|
||||
if (cost->getMorph()->isExtraPaymentSet())
|
||||
{
|
||||
@@ -1720,7 +1726,7 @@ int MTGAttackCostRule::isReactingToClick(MTGCardInstance * card, ManaCost * aiCh
|
||||
{
|
||||
attackcost->extraCosts->costs[i]->setSource(card);
|
||||
}
|
||||
if ((aiCheck && aiCheck->canAfford(attackcost)) || playerMana->canAfford(attackcost))
|
||||
if ((aiCheck && aiCheck->canAfford(attackcost,card->has(Constants::ANYTYPEOFMANAABILITY))) || playerMana->canAfford(attackcost,card->has(Constants::ANYTYPEOFMANAABILITY)))
|
||||
{
|
||||
SAFE_DELETE(attackcost);
|
||||
return 1;
|
||||
@@ -1800,7 +1806,7 @@ int MTGBlockCostRule::isReactingToClick(MTGCardInstance * card, ManaCost * aiChe
|
||||
{
|
||||
blockcost->extraCosts->costs[i]->setSource(card);
|
||||
}
|
||||
if ((aiCheck && aiCheck->canAfford(blockcost)) || playerMana->canAfford(blockcost))
|
||||
if ((aiCheck && aiCheck->canAfford(blockcost,card->has(Constants::ANYTYPEOFMANAABILITY))) || playerMana->canAfford(blockcost,card->has(Constants::ANYTYPEOFMANAABILITY)))
|
||||
{
|
||||
SAFE_DELETE(blockcost);
|
||||
return 1;
|
||||
|
||||
@@ -1020,6 +1020,19 @@ int ManaCost::pay(ManaCost * _cost)
|
||||
{
|
||||
cost[i] = diff->getCost(i);
|
||||
}
|
||||
for (unsigned int i = 0; i < cost.size(); i++){ // Added to avoid negative values in Manapool (e.g. anytypeofmana)
|
||||
while(cost[i] < 0){
|
||||
for (int j = 0; j < Constants::NB_Colors; j++){
|
||||
if((unsigned int)j != i && cost[j] > 0 && cost[j] <= abs(cost[i])){
|
||||
cost[i] += cost[j];
|
||||
cost[j] = 0;
|
||||
} else if((unsigned int)j != i && cost[j] > 0 && cost[j] > abs(cost[i])){
|
||||
cost[j] += cost[i];
|
||||
cost[i] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
delete diff;
|
||||
delete toPay;
|
||||
return result;
|
||||
@@ -1027,9 +1040,17 @@ int ManaCost::pay(ManaCost * _cost)
|
||||
}
|
||||
|
||||
//return 1 if _cost can be paid with current data, 0 otherwise
|
||||
int ManaCost::canAfford(ManaCost * _cost)
|
||||
int ManaCost::canAfford(ManaCost * _cost, int anytypeofmana)
|
||||
{
|
||||
ManaCost * diff = Diff(_cost);
|
||||
if(anytypeofmana > 0){
|
||||
int convertedC = _cost->getConvertedCost();
|
||||
ManaCost * tmp = NEW ManaCost(ManaCost::parseManaCost("{0}", NULL, NULL));
|
||||
for (int jj = 0; jj < convertedC; jj++)
|
||||
tmp->add(Constants::MTG_COLOR_ARTIFACT, 1);
|
||||
diff = Diff(tmp);
|
||||
delete tmp;
|
||||
}
|
||||
int positive = diff->isPositive();
|
||||
delete diff;
|
||||
if (positive)
|
||||
|
||||
@@ -376,14 +376,14 @@ void TestSuiteGame::assertGame()
|
||||
endState.players[i]->poisonCount, p->poisonCount);
|
||||
Log(result);
|
||||
error++;
|
||||
} if (!p->getManaPool()->canAfford(endState.players[i]->getManaPool()))
|
||||
} if (!p->getManaPool()->canAfford(endState.players[i]->getManaPool(),0))
|
||||
{
|
||||
sprintf(result, "<span class=\"error\">==Mana problem. Was expecting %i but got %i for player %i==</span><br />",
|
||||
endState.players[i]->getManaPool()->getConvertedCost(), p->getManaPool()->getConvertedCost(), i);
|
||||
Log(result);
|
||||
error++;
|
||||
}
|
||||
if (!endState.players[i]->getManaPool()->canAfford(p->getManaPool()))
|
||||
if (!endState.players[i]->getManaPool()->canAfford(p->getManaPool(),0))
|
||||
{
|
||||
sprintf(result, "<span class=\"error\">==Mana problem. Was expecting %i but got %i for player %i==</span><br />",
|
||||
endState.players[i]->getManaPool()->getConvertedCost(), p->getManaPool()->getConvertedCost(), i);
|
||||
|
||||
Reference in New Issue
Block a user