diff --git a/projects/mtg/bin/Res/sets/primitives/borderline.txt b/projects/mtg/bin/Res/sets/primitives/borderline.txt index d04270ac0..18dc0d3ea 100644 --- a/projects/mtg/bin/Res/sets/primitives/borderline.txt +++ b/projects/mtg/bin/Res/sets/primitives/borderline.txt @@ -5800,28 +5800,7 @@ type=Instant [card] name=Breeches, Brazen Plunderer abilities=menace,partner -auto=@combatdamagefoeof(player) from(*[pirate]|myBattlefield):moveto(exile) and!( transforms((,canplayfromexile)) ueot )! all(*[zpos=1]|opponentlibrary) -auto={0}:name(Cast creature from exile with manacost 0) activate castcard(normal) target(*[manacost=0;canplayfromexile;fresh]|opponentexile) restriction{type(*[manacost=0;canplayfromexile;fresh]|opponentexile)~morethan~0} -auto={1}:name(Cast creature from exile with manacost 1) activate castcard(normal) target(*[manacost=1;canplayfromexile;fresh]|opponentexile) restriction{type(*[manacost=1;canplayfromexile;fresh]|opponentexile)~morethan~0} -auto={2}:name(Cast creature from exile with manacost 2) activate castcard(normal) target(*[manacost=2;canplayfromexile;fresh]|opponentexile) restriction{type(*[manacost=2;canplayfromexile;fresh]|opponentexile)~morethan~0} -auto={3}:name(Cast creature from exile with manacost 3) activate castcard(normal) target(*[manacost=3;canplayfromexile;fresh]|opponentexile) restriction{type(*[manacost=3;canplayfromexile;fresh]|opponentexile)~morethan~0} -auto={4}:name(Cast creature from exile with manacost 4) activate castcard(normal) target(*[manacost=4;canplayfromexile;fresh]|opponentexile) restriction{type(*[manacost=4;canplayfromexile;fresh]|opponentexile)~morethan~0} -auto={5}:name(Cast creature from exile with manacost 5) activate castcard(normal) target(*[manacost=5;canplayfromexile;fresh]|opponentexile) restriction{type(*[manacost=5;canplayfromexile;fresh]|opponentexile)~morethan~0} -auto={6}:name(Cast creature from exile with manacost 6) activate castcard(normal) target(*[manacost=6;canplayfromexile;fresh]|opponentexile) restriction{type(*[manacost=6;canplayfromexile;fresh]|opponentexile)~morethan~0} -auto={7}:name(Cast creature from exile with manacost 7) activate castcard(normal) target(*[manacost=7;canplayfromexile;fresh]|opponentexile) restriction{type(*[manacost=7;canplayfromexile;fresh]|opponentexile)~morethan~0} -auto={8}:name(Cast creature from exile with manacost 8) activate castcard(normal) target(*[manacost=8;canplayfromexile;fresh]|opponentexile) restriction{type(*[manacost=8;canplayfromexile;fresh]|opponentexile)~morethan~0} -auto={9}:name(Cast creature from exile with manacost 9) activate castcard(normal) target(*[manacost=9;canplayfromexile;fresh]|opponentexile) restriction{type(*[manacost=9;canplayfromexile;fresh]|opponentexile)~morethan~0} -auto={10}:name(Cast creature from exile with manacost 10) activate castcard(normal) target(*[manacost=10;canplayfromexile;fresh]|opponentexile) restriction{type(*[manacost=10;canplayfromexile;fresh]|opponentexile)~morethan~0} -auto={11}:name(Cast creature from exile with manacost 11) activate castcard(normal) target(*[manacost=11;canplayfromexile;fresh]|opponentexile) restriction{type(*[manacost=11;canplayfromexile;fresh]|opponentexile)~morethan~0} -auto={12}:name(Cast creature from exile with manacost 12) activate castcard(normal) target(*[manacost=12;canplayfromexile;fresh]|opponentexile) restriction{type(*[manacost=12;canplayfromexile;fresh]|opponentexile)~morethan~0} -auto={13}:name(Cast creature from exile with manacost 13) activate castcard(normal) target(*[manacost=13;canplayfromexile;fresh]|opponentexile) restriction{type(*[manacost=13;canplayfromexile;fresh]|opponentexile)~morethan~0} -auto={14}:name(Cast creature from exile with manacost 14) activate castcard(normal) target(*[manacost=14;canplayfromexile;fresh]|opponentexile) restriction{type(*[manacost=14;canplayfromexile;fresh]|opponentexile)~morethan~0} -auto={15}:name(Cast creature from exile with manacost 15) activate castcard(normal) target(*[manacost=15;canplayfromexile;fresh]|opponentexile) restriction{type(*[manacost=15;canplayfromexile;fresh]|opponentexile)~morethan~0} -auto={16}:name(Cast creature from exile with manacost 16) activate castcard(normal) target(*[manacost=16;canplayfromexile;fresh]|opponentexile) restriction{type(*[manacost=16;canplayfromexile;fresh]|opponentexile)~morethan~0} -auto={17}:name(Cast creature from exile with manacost 17) activate castcard(normal) target(*[manacost=17;canplayfromexile;fresh]|opponentexile) restriction{type(*[manacost=17;canplayfromexile;fresh]|opponentexile)~morethan~0} -auto={18}:name(Cast creature from exile with manacost 18) activate castcard(normal) target(*[manacost=18;canplayfromexile;fresh]|opponentexile) restriction{type(*[manacost=18;canplayfromexile;fresh]|opponentexile)~morethan~0} -auto={19}:name(Cast creature from exile with manacost 19) activate castcard(normal) target(*[manacost=19;canplayfromexile;fresh]|opponentexile) restriction{type(*[manacost=19;canplayfromexile;fresh]|opponentexile)~morethan~0} -auto={20}:name(Cast creature from exile with manacost 20 or more) activate castcard(normal) target(*[manacost>19;canplayfromexile;fresh]|opponentexile) restriction{type(*[manacost>19;canplayfromexile;fresh]|opponentexile)~morethan~0} +auto=@combatdamagefoeof(player) from(*[pirate]|myBattlefield):all(*[zpos=1]|opponentlibrary) moveto(myexile) and!( transforms((,newability[canplayfromexile],newability[anytypeofmana],newability[phaseaction[endofturn once] moveTo(ownerexile)])) ueot )! text=Menace -- Whenever one or more Pirates you control deal damage to your opponents, exile the top card of each of those opponents' libraries. You may play those cards this turn, and you may spend mana as though it were mana of any color to cast those spells. -- Partner (You can have two commanders if both have partner.) mana={3}{R} type=Legendary Creature @@ -8159,6 +8138,7 @@ toughness=8 [card] name=Chromatic Orrery auto=lord(*|mycastingzone) anytypeofmana +auto=lord(*|myzones) anytypeofmanaability auto={T}:add{C}{C}{C}{C}{C} auto={5}{T}:transforms((,newability[aslongas(*[white]|myBattlefield) draw:1 controller],newability[aslongas(*[blue]|myBattlefield) draw:1 controller],newability[aslongas(*[black]|myBattlefield) draw:1 controller],newability[aslongas(*[red]|myBattlefield) draw:1 controller],newability[aslongas(*[green]|myBattlefield) draw:1 controller])) oneshot text=You may spend mana as though it were mana of any color. -- {T}: Add {C}{C}{C}{C}{C}. -- {5}, {T}: Draw a card for each color among permanents you control. @@ -16831,6 +16811,14 @@ mana={1}{R} type=Instant [/card] [card] +name=Five-Finger Discount +target=*[-land]|battlefield +auto=moveto(myhand) and!( transforms((,newability[anytypeofmana])) forever)! +text=Put target nonland permanent into your hand. You may spend mana as though it were mana of any color the next time you cast that card. +mana={4}{U}{U} +type=Sorcery +[/card] +[card] name=Flaccify target=*|stack auto=transforms((,newability[pay[[{3}]] name(pay 3 mana) donothing?fizzle])) oneshot @@ -22659,7 +22647,7 @@ toughness=4 [/card] [card] name=Hostage Taker -auto=moveto(myhand) target(creature,artifact) forsrc +auto=(blink)forsrc target(creature,artifact) text=When Hostage Taker enters the battlefield, exile another target creature or artifact until Hostage Taker leaves the battlefield. You may cast that card for as long as it remains exiled, and you may spend mana as though it were mana of any type to cast that spell. mana={2}{U}{B} type=Creature @@ -31788,6 +31776,9 @@ auto=lord(*|graveyard) devoid auto=lord(*|exile) devoid auto=lord(*|sideboard) devoid auto=lord(*|mycastingzone) anytypeofmana +auto=lord(*|opponentcastingzone) anytypeofmana +auto=lord(*|myzones) anytypeofmanaability +auto=lord(*|opponentzones) anytypeofmanaability text=All permanents are artifacts in addition to their other types. -- All cards that aren't on the battlefield, spells, and permanents are colorless. -- Players may spend mana as though it were mana of any color. mana={6} type=Artifact @@ -33198,7 +33189,7 @@ toughness=2 [/card] [card] name=North Star -auto={4}{T}:target(*|mycastingzone) anytypeofmana +auto={4}{T}:target(*|mycastingzone) transforms((,newability[anytypeofmana])) ueot text={4}, {T}: For one spell this turn, you may spend mana as though it were mana of any color to pay that spell's mana cost. (Additional costs are still paid normally.) mana={4} type=Artifact @@ -47395,9 +47386,7 @@ type=Sorcery [/card] [card] name=Stolen Strategy -auto=@each my upkeep:all(*[zpos=1]|opponentlibrary) moveto(exile) and!( transforms((,newability[counter(0/0.1.StolenExiled)])) forever )! -auto={0}:name(Cast instants exiled with Stolen Strategy) name(Cast instants exiled with Stolen Strategy) target(instant[fresh;counter{0/0.1.StolenExiled}]|opponentexile) activate castcard(normal) -auto={0}:name(Cast sorceries exiled with Stolen Strategy) name(Cast sorceries exiled with Stolen Strategy) target(sorcery[fresh;counter{0/0.1.StolenExiled}]|opponentexile) activate castcard(normal) +auto=@each my upkeep:all(*[zpos=1]|opponentlibrary) moveto(myexile) and!( transforms((,newability[canplayfromexile],newability[anytypeofmana],newability[phaseaction[endofturn once] moveTo(ownerexile)])) ueot )! text=At the beginning of your upkeep, exile the top card of each opponent's library. Until end of turn, you may cast spells from among those exiled cards, and you may spend mana as though it were mana of any color to cast those spells. mana={4}{R} type=Enchantment @@ -55667,8 +55656,8 @@ toughness=3 name=Whispersteel Dagger auto={3}:equip auto=teach(creature) 2/0 -auto=teach(creature) transforms((,newability[@combatdamageof(player) from(this):may activate castcard(normal) target(creature|mygraveyard)])) -auto=teach(creature) transforms((,newability[@combatdamagefoeof(player) from(this):may activate castcard(normal) target(creature|opponentgraveyard)])) +auto=@combatdamageof(player) from(mytgt):may name(Cast creature from graveyard) target(*[creature]|mygraveyard) transforms((,newability[canplayfromgraveyard],newability[anytypeofmana])) ueot +auto=@combatdamagefoeof(player) from(mytgt):may name(Cast creature from graveyard) target(*[creature]|opponentgraveyard) moveto(mygraveyard) and!( transforms((,newability[canplayfromgraveyard],newability[anytypeofmana],newability[phaseaction[endofturn once] moveTo(ownergraveyard)])) ueot )! text=Equipped creature gets +2/+0. -- Whenever equipped creature deals combat damage to a player, you may cast a creature spell from that player's graveyard this turn, and you may spend mana as though it were mana of any color to cast that spell. -- Equip 3 mana={2}{B} type=Artifact diff --git a/projects/mtg/bin/Res/sets/primitives/unsupported.txt b/projects/mtg/bin/Res/sets/primitives/unsupported.txt index 9d270ce1a..34d3460bc 100644 --- a/projects/mtg/bin/Res/sets/primitives/unsupported.txt +++ b/projects/mtg/bin/Res/sets/primitives/unsupported.txt @@ -4127,12 +4127,6 @@ mana={1}{G} type=Instant [/card] [card] -name=Five-Finger Discount -text=Put target nonland permanent into your hand. You may spend mana as though it were mana of any color the next time you cast that card. -mana={4}{U}{U} -type=Sorcery -[/card] -[card] name=Flames of the Blood Hand text=Flames of the Blood Hand deals 4 damage to target player. The damage can't be prevented. If that player would gain life this turn, that player gains no life instead. mana={2}{R} diff --git a/projects/mtg/include/AIPlayerBaka.h b/projects/mtg/include/AIPlayerBaka.h index 30bc56ba3..3bafc786c 100644 --- a/projects/mtg/include/AIPlayerBaka.h +++ b/projects/mtg/include/AIPlayerBaka.h @@ -84,8 +84,8 @@ class AIPlayerBaka: public AIPlayer{ //Tries to play an ability recommended by the deck creator virtual int selectHintAbility(); - virtual vector canPayMana(MTGCardInstance * card = NULL, ManaCost * mCost = NULL); - virtual vector canPayMana(MTGCardInstance * card, ManaCost * mCost, map &usedCards, bool searchingAgain = false); + virtual vector canPayMana(MTGCardInstance * card, ManaCost * mCost, int anytypeofmana); + virtual vector canPayMana(MTGCardInstance * card, ManaCost * mCost, int anytypeofmana, map &usedCards, bool searchingAgain = false); virtual vector canPaySunBurst(ManaCost * mCost = NULL); virtual MTGCardInstance * chooseCard(TargetChooser * tc, MTGCardInstance * source, int random = 0); @@ -106,7 +106,7 @@ class AIPlayerBaka: public AIPlayer{ //used by MomirPlayer, hence protected instead of private virtual int getEfficiency(OrderedAIAction * action); virtual int getEfficiency(MTGAbility * ability); - virtual bool payTheManaCost(ManaCost * cost, MTGCardInstance * card = NULL,vector gotPayment = vector()); + virtual bool payTheManaCost(ManaCost * cost, int anytypeofmana, MTGCardInstance * card = NULL,vector gotPayment = vector()); virtual int getCreaturesInfo(Player * player, int neededInfo = INFO_NBCREATURES , int untapMode = 0, int canAttack = 0); virtual ManaCost * getPotentialMana(MTGCardInstance * card = NULL); virtual int selectAbility(); @@ -134,7 +134,7 @@ class AIPlayerBaka: public AIPlayer{ virtual int affectCombatDamages(CombatStep step); virtual int canHandleCost(MTGAbility * ability); virtual int chooseTarget(TargetChooser * tc = NULL, Player * forceTarget = NULL,MTGCardInstance * Chosencard = NULL,bool checkonly = false); - virtual vector canPayManaCost(MTGCardInstance * card = NULL, ManaCost * mCost = NULL){ return canPayMana(card, mCost);}; + virtual vector canPayManaCost(MTGCardInstance * card = NULL, ManaCost * mCost = NULL, int anytypeofmana = 0){ return canPayMana(card, mCost, anytypeofmana);}; //used by AIHInts, therefore public instead of private :/ virtual int createAbilityTargets(MTGAbility * a, MTGCardInstance * c, RankingContainer& ranking); diff --git a/projects/mtg/include/AIPlayerBakaB.h b/projects/mtg/include/AIPlayerBakaB.h index 8943578d0..00d637354 100644 --- a/projects/mtg/include/AIPlayerBakaB.h +++ b/projects/mtg/include/AIPlayerBakaB.h @@ -36,7 +36,7 @@ protected: MTGCardInstance * FindCardToPlay(ManaCost * potentialMana, const char * type); - bool payTheManaCost(ManaCost * cost, MTGCardInstance * card = NULL,vector gotPayment = vector()); + bool payTheManaCost(ManaCost * cost, int anytypeofmana, MTGCardInstance * card = NULL,vector gotPayment = vector()); int getCreaturesInfo(Player * player, int neededInfo = INFO_NBCREATURES , int untapMode = 0, int canAttack = 0); ManaCost * getPotentialMana(MTGCardInstance * card = NULL); int selectAbility(); diff --git a/projects/mtg/include/AllAbilities.h b/projects/mtg/include/AllAbilities.h index 1d55b4db4..52dc48819 100644 --- a/projects/mtg/include/AllAbilities.h +++ b/projects/mtg/include/AllAbilities.h @@ -2921,7 +2921,7 @@ public: { if (_card == source && game->currentlyActing()->game->inPlay->hasCard(source)) { - if (game->currentlyActing()->getManaPool()->canAfford(cost)) + if (game->currentlyActing()->getManaPool()->canAfford(cost,_card->has(Constants::ANYTYPEOFMANAABILITY))) { Interruptible * laststackitem = game->mLayers->stackLayer()->getAt(-1); if (laststackitem && laststackitem->type == ACTION_SPELL) @@ -2982,7 +2982,7 @@ public: { if (_card == target && game->currentlyActing()->game->inPlay->hasCard(source) && _card->isTapped()) { - if (game->currentlyActing()->getManaPool()->canAfford(cost)) + if (game->currentlyActing()->getManaPool()->canAfford(cost,_card->has(Constants::ANYTYPEOFMANAABILITY))) { return 1; } @@ -6231,7 +6231,7 @@ public: { if (counters > 0 && _card == source && currentPhase == MTG_PHASE_UPKEEP) { - if (game->currentlyActing()->getManaPool()->canAfford(&cost)) + if (game->currentlyActing()->getManaPool()->canAfford(&cost,_card->has(Constants::ANYTYPEOFMANAABILITY))) { return 1; } @@ -6327,7 +6327,7 @@ public: { if (_card == source && game->currentlyActing()->game->inPlay->hasCard(source) && !_card->isTapped()) { - if (game->currentlyActing()->getManaPool()->canAfford(&cost)) + if (game->currentlyActing()->getManaPool()->canAfford(&cost,_card->has(Constants::ANYTYPEOFMANAABILITY))) { return 1; } @@ -6642,7 +6642,7 @@ public: if (damagesToDealThisTurn && currentPhase == MTG_PHASE_UPKEEP && card == source && _target->controller() == game->currentPlayer) { - if (game->currentPlayer->getManaPool()->canAfford(&cost)) return 1; + if (game->currentPlayer->getManaPool()->canAfford(&cost,card->has(Constants::ANYTYPEOFMANAABILITY))) return 1; } return 0; } diff --git a/projects/mtg/include/MTGDefinitions.h b/projects/mtg/include/MTGDefinitions.h index 2011593c7..acc566a68 100644 --- a/projects/mtg/include/MTGDefinitions.h +++ b/projects/mtg/include/MTGDefinitions.h @@ -299,7 +299,8 @@ class Constants GAINEDHANDDEATH = 172, CYCLING = 173, FORETELL = 174, - NB_BASIC_ABILITIES = 175, + ANYTYPEOFMANAABILITY = 175, + NB_BASIC_ABILITIES = 176, RARITY_S = 'S', //Special Rarity RARITY_M = 'M', //Mythics diff --git a/projects/mtg/include/ManaCost.h b/projects/mtg/include/ManaCost.h index 40addf0aa..4757b7ca5 100644 --- a/projects/mtg/include/ManaCost.h +++ b/projects/mtg/include/ManaCost.h @@ -137,7 +137,7 @@ public: int pay (ManaCost * _cost); //return 1 if _cost can be paid with current data, 0 otherwise - int canAfford(ManaCost * _cost); + int canAfford(ManaCost * _cost, int anytypeofmana); int isPositive(); ManaCost * Diff(ManaCost * _cost); diff --git a/projects/mtg/src/AIMomirPlayer.cpp b/projects/mtg/src/AIMomirPlayer.cpp index 5daaa55b3..97fece804 100644 --- a/projects/mtg/src/AIMomirPlayer.cpp +++ b/projects/mtg/src/AIMomirPlayer.cpp @@ -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; diff --git a/projects/mtg/src/AIPlayerBaka.cpp b/projects/mtg/src/AIPlayerBaka.cpp index 209922ea6..080b12c91 100644 --- a/projects/mtg/src/AIPlayerBaka.cpp +++ b/projects/mtg/src/AIPlayerBaka.cpp @@ -1360,7 +1360,7 @@ MTGCardInstance * AIPlayerBaka::chooseCard(TargetChooser * tc, MTGCardInstance * return NULL; } -bool AIPlayerBaka::payTheManaCost(ManaCost * cost, MTGCardInstance * target,vectorgotPayments) +bool AIPlayerBaka::payTheManaCost(ManaCost * cost, int anytypeofmana, MTGCardInstance * target,vectorgotPayments) { 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 AIPlayerBaka::canPayMana(MTGCardInstance * target,ManaCost * cost) +vector AIPlayerBaka::canPayMana(MTGCardInstance * target, ManaCost * cost, int anytypeofmana) { if(!cost || (cost && !cost->getConvertedCost()) || !target) return vector(); map usedCards; - return canPayMana(target, cost, usedCards); + return canPayMana(target, cost, anytypeofmana, usedCards); } -vector AIPlayerBaka::canPayMana(MTGCardInstance * target,ManaCost * cost, map &used ,bool searchingAgain) +vector AIPlayerBaka::canPayMana(MTGCardInstance * target, ManaCost * _cost, int anytypeofmana, map &used ,bool searchingAgain) { + ManaCost * cost = _cost; + if(!cost->getConvertedCost()) return vector(); ManaCost * result = NEW ManaCost(); @@ -1577,6 +1579,14 @@ vector 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 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 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 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 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 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 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 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 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 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 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(observer->mExtraPayment->costs[0]); if(check) { - vector CostToPay = canPayMana(observer->mExtraPayment->source,check->costToPay); + vector 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(observer->mExtraPayment->costs[0]); if (check) { - vector CostToPay = canPayMana(observer->mExtraPayment->source, check->costToPay); + vector 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. vectorchecking = 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(observer->mExtraPayment->costs[0]); if(check) { - vector CostToPay = canPayMana(observer->mExtraPayment->source,check->costToPay); + vector 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 { diff --git a/projects/mtg/src/AIPlayerBakaB.cpp b/projects/mtg/src/AIPlayerBakaB.cpp index 67675ab21..bbc6e825f 100644 --- a/projects/mtg/src/AIPlayerBakaB.cpp +++ b/projects/mtg/src/AIPlayerBakaB.cpp @@ -20,9 +20,9 @@ MTGCardInstance * AIPlayerBakaB::chooseCard(TargetChooser * tc, MTGCardInstance return AIPlayerBaka::chooseCard(tc, source, random); } -bool AIPlayerBakaB::payTheManaCost(ManaCost * cost, MTGCardInstance * target, vectorgotPayments) +bool AIPlayerBakaB::payTheManaCost(ManaCost * cost, int anytypeofmana, MTGCardInstance * target, vectorgotPayments) { - return AIPlayerBaka::payTheManaCost(cost, target, gotPayments); + return AIPlayerBaka::payTheManaCost(cost, anytypeofmana, target, gotPayments); } int AIPlayerBakaB::getEfficiency(OrderedAIAction * action) diff --git a/projects/mtg/src/ExtraCost.cpp b/projects/mtg/src/ExtraCost.cpp index c9e48f72c..4d3b64a35 100644 --- a/projects/mtg/src/ExtraCost.cpp +++ b/projects/mtg/src/ExtraCost.cpp @@ -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; diff --git a/projects/mtg/src/GameObserver.cpp b/projects/mtg/src/GameObserver.cpp index a62de6a7a..f9c6038c5 100644 --- a/projects/mtg/src/GameObserver.cpp +++ b/projects/mtg/src/GameObserver.cpp @@ -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)) { diff --git a/projects/mtg/src/MTGAbility.cpp b/projects/mtg/src/MTGAbility.cpp index 8f021d54c..9bbc111a6 100644 --- a/projects/mtg/src/MTGAbility.cpp +++ b/projects/mtg/src/MTGAbility.cpp @@ -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; } diff --git a/projects/mtg/src/MTGDefinitions.cpp b/projects/mtg/src/MTGDefinitions.cpp index dbb66a25b..6516c3926 100644 --- a/projects/mtg/src/MTGDefinitions.cpp +++ b/projects/mtg/src/MTGDefinitions.cpp @@ -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 Constants::MTGBasicAbilitiesMap; diff --git a/projects/mtg/src/MTGRules.cpp b/projects/mtg/src/MTGRules.cpp index 6bb460cc7..c93349925 100644 --- a/projects/mtg/src/MTGRules.cpp +++ b/projects/mtg/src/MTGRules.cpp @@ -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; diff --git a/projects/mtg/src/ManaCost.cpp b/projects/mtg/src/ManaCost.cpp index 769c54f8b..c9a2f0768 100644 --- a/projects/mtg/src/ManaCost.cpp +++ b/projects/mtg/src/ManaCost.cpp @@ -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) diff --git a/projects/mtg/src/TestSuiteAI.cpp b/projects/mtg/src/TestSuiteAI.cpp index 51c6f353c..6026e5745 100644 --- a/projects/mtg/src/TestSuiteAI.cpp +++ b/projects/mtg/src/TestSuiteAI.cpp @@ -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, "==Mana problem. Was expecting %i but got %i for player %i==
", 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, "==Mana problem. Was expecting %i but got %i for player %i==
", endState.players[i]->getManaPool()->getConvertedCost(), p->getManaPool()->getConvertedCost(), i);