diff --git a/projects/mtg/include/AllAbilities.h b/projects/mtg/include/AllAbilities.h index 0f48ceeee..ad4036ced 100644 --- a/projects/mtg/include/AllAbilities.h +++ b/projects/mtg/include/AllAbilities.h @@ -4358,6 +4358,22 @@ public: AAUntapper * clone() const; }; +/*announce card X*/ +class AAWhatsX : public ActivatedAbility +{ +public: + int value; + MTGAbility * costRule; + AAWhatsX(GameObserver* observer, int id, MTGCardInstance * card, MTGCardInstance * source, int value = 0, MTGAbility * costRule = NULL); + int resolve(); + const string getMenuText() + { + sprintf(menuText, "%i", value); + return menuText; + }; + AAWhatsX * clone() const; +}; + /* set max level up on a levelup creature this is an Ai hint ability, no effect for players.*/ class AAWhatsMax: public ActivatedAbility { diff --git a/projects/mtg/include/MTGCardInstance.h b/projects/mtg/include/MTGCardInstance.h index 2f1923635..cefa5a5d4 100644 --- a/projects/mtg/include/MTGCardInstance.h +++ b/projects/mtg/include/MTGCardInstance.h @@ -55,6 +55,7 @@ public: Pos* view; int X; int castX; + int setX; int alternateCostPaid[ManaCost::MANA_PAID_WITH_BESTOW + 1]; int paymenttype; int castMethod; /* Tells if the card reached its current zone by being cast or not (brought into the zone by an effect). non 0 == cast, 0 == not cast */ diff --git a/projects/mtg/src/AllAbilities.cpp b/projects/mtg/src/AllAbilities.cpp index 496d9c33c..0152993f2 100644 --- a/projects/mtg/src/AllAbilities.cpp +++ b/projects/mtg/src/AllAbilities.cpp @@ -4412,6 +4412,27 @@ AAWhatsMax * AAWhatsMax::clone() const { return NEW AAWhatsMax(*this); } +//set X value +AAWhatsX::AAWhatsX(GameObserver* observer, int id, MTGCardInstance * card, MTGCardInstance *, int value, MTGAbility * _costRule) : + ActivatedAbility(observer, id, card, NULL, 0), value(value),costRule(_costRule) +{ +} + +int AAWhatsX::resolve() +{ + if (source) + { + source->setX = value; + + } + costRule->reactToClick(source); + return 1; +} + +AAWhatsX * AAWhatsX::clone() const +{ + return NEW AAWhatsX(*this); +} //count objects on field before doing an effect AACountObject::AACountObject(GameObserver* observer, int id, MTGCardInstance * card, MTGCardInstance *, ManaCost * _cost, string value) : ActivatedAbility(observer, id, card, _cost, 0), value(value) diff --git a/projects/mtg/src/MTGCardInstance.cpp b/projects/mtg/src/MTGCardInstance.cpp index b44c178b2..1c89311f5 100644 --- a/projects/mtg/src/MTGCardInstance.cpp +++ b/projects/mtg/src/MTGCardInstance.cpp @@ -153,12 +153,14 @@ int MTGCardInstance::init() data = this; X = 0; castX = 0; + setX = -1; return 1; } void MTGCardInstance::initMTGCI() { X = 0; + setX = -1; sample = ""; model = NULL; isToken = false; @@ -779,11 +781,13 @@ int MTGCardInstance::getCurrentToughness() //check stack bool MTGCardInstance::StackIsEmptyandSorcerySpeed() { + Player * whoInterupts = getObserver()->isInterrupting;//leave this so we can actually debug who is interupting/current. + Player * whoCurrent = getObserver()->currentPlayer; if((getObserver()->mLayers->stackLayer()->count(0, NOT_RESOLVED) == 0) && (getObserver()->getCurrentGamePhase() == MTG_PHASE_FIRSTMAIN || getObserver()->getCurrentGamePhase() == MTG_PHASE_SECONDMAIN) && - controller() == getObserver()->currentPlayer && - !getObserver()->isInterrupting) + controller() == whoCurrent && + (!whoInterupts || whoInterupts == whoCurrent)) { return true; } diff --git a/projects/mtg/src/MTGRules.cpp b/projects/mtg/src/MTGRules.cpp index fc67729fa..753cf3a1f 100644 --- a/projects/mtg/src/MTGRules.cpp +++ b/projects/mtg/src/MTGRules.cpp @@ -329,7 +329,6 @@ int MTGPutInPlayRule::isReactingToClick(MTGCardInstance * card, ManaCost *) #ifdef WIN32 cost->Dump(); #endif - //cost of card. if (playerMana->canAfford(cost)) { //------- @@ -351,9 +350,8 @@ int MTGPutInPlayRule::isReactingToClick(MTGCardInstance * card, ManaCost *) card->sunburst += 1; } } - } - //------- - } + }//if (player->getManaPool()->hasColor(i)) + }//for (int i = 1; i != 6; i++) } return 1;//play if you can afford too. } @@ -367,6 +365,65 @@ int MTGPutInPlayRule::reactToClick(MTGCardInstance * card) return 0; Player * player = game->currentlyActing(); ManaCost * cost = card->getManaCost(); + ManaCost * playerMana = player->getManaPool(); + ///////announce X cost/////// + if ((cost->hasX() || cost->hasSpecificX()) && card->setX == -1) + { + vectorselection; + int options = cost->hasSpecificX() ? 20 : (playerMana->getConvertedCost() - cost->getConvertedCost()) + 1; + //you can set up to 20 for specific X, if you cant afford it, it cancels. I couldnt think of a equation that would + //give me the correct amount sorry. + for (int i = 0; i < options; ++i) + { + + MTGAbility * setX = NEW AAWhatsX(game, game->mLayers->actionLayer()->getMaxId(), card, card, i, this); + MTGAbility * setCardX = setX->clone(); + setCardX->oneShot = true; + selection.push_back(setCardX); + SAFE_DELETE(setX); + } + if (selection.size()) + { + MTGAbility * a1 = NEW MenuAbility(game, this->GetId(), card, card, false, selection); + game->mLayers->actionLayer()->currentActionCard = card; + a1->resolve(); + } + return 0; + } + /////////////////////////////////////////////////////////////////////////////////////// + //////X is set, below we set sunburst for X if needed and cast or reset the card.////// + //////107.3a If a spell or activated ability has a mana cost, alternative cost, ////// + //////additional cost, and / or activation cost with an{ X }, [-X], or X in it, ////// + //////and the value of X isn’t defined by the text of that spell or ability, the ////// + //////controller of that spell or ability chooses and announces the value of X as////// + //////part of casting the spell or activating the ability. ////// + //////(See rule 601, “Casting Spells.”) While a spell is on the stack, any X in ////// + //////its mana cost or in any alternative cost or additional cost it has equals ////// + //////the announced value.While an activated ability is on the stack, any X in ////// + //////its activation cost equals the announced value. ////// + /////////////////////////////////////////////////////////////////////////////////////// + if (card->setX > -1) + { + ManaCost * Xcost = NEW ManaCost(); + Xcost->copy(cost); + Xcost->add(Constants::MTG_COLOR_ARTIFACT, card->setX); + Xcost->remove(7, 1); + if (playerMana->canAfford(Xcost)) + { + cost->copy(Xcost); + SAFE_DELETE(Xcost); + } + else + { + if (card->setX > -1) + card->setX = -1; + SAFE_DELETE(Xcost); + return 0; + } + } + ////////////////////////////////////////// + ////cards without X contenue from here//// + ////////////////////////////////////////// //this handles extra cost payments at the moment a card is played. if (cost->isExtraPaymentSet()) { @@ -685,7 +742,6 @@ int MTGAlternativeCostRule::isReactingToClick(MTGCardInstance * card, ManaCost * ManaCost * cost = card->getManaCost(); cost->Dump(); #endif - //cost of card. if (playerMana->canAfford(alternateManaCost)) { return 1; @@ -713,6 +769,62 @@ int MTGAlternativeCostRule::reactToClick(MTGCardInstance * card, ManaCost *alter Player * player = game->currentlyActing(); ManaPool * playerMana = player->getManaPool(); + ///////announce X cost/////// + if ((alternateCost->hasX() || alternateCost->hasSpecificX()) && card->setX == -1) + { + vectorselection; + int options = alternateCost->hasSpecificX()? 20 : (playerMana->getConvertedCost() - alternateCost->getConvertedCost()) + 1; + //you can set up to 20 for specific X, if you cant afford it, it cancels. I couldnt think of a equation that would + //give me the correct amount sorry. + for (int i = 0; i < options; ++i) + { + + MTGAbility * setX = NEW AAWhatsX(game, game->mLayers->actionLayer()->getMaxId(), card, card, i, this); + MTGAbility * setCardX = setX->clone(); + setCardX->oneShot = true; + selection.push_back(setCardX); + SAFE_DELETE(setX); + } + if (selection.size()) + { + MTGAbility * a1 = NEW MenuAbility(game, this->GetId(), card, card, false, selection); + game->mLayers->actionLayer()->currentActionCard = card; + a1->resolve(); + } + return 0; + } + /////////////////////////////////////////////////////////////////////////////////////// + //////X is set, below we set sunburst for X if needed and cast or reset the card.////// + //////107.3a If a spell or activated ability has a mana cost, alternative cost, ////// + //////additional cost, and / or activation cost with an{ X }, [-X], or X in it, ////// + //////and the value of X isn’t defined by the text of that spell or ability, the ////// + //////controller of that spell or ability chooses and announces the value of X as////// + //////part of casting the spell or activating the ability. ////// + //////(See rule 601, “Casting Spells.”) While a spell is on the stack, any X in ////// + //////its mana cost or in any alternative cost or additional cost it has equals ////// + //////the announced value.While an activated ability is on the stack, any X in ////// + //////its activation cost equals the announced value. ////// + /////////////////////////////////////////////////////////////////////////////////////// + if (card->setX > -1) + { + ManaCost * Xcost = NEW ManaCost(); + Xcost->copy(alternateCost); + Xcost->add(Constants::MTG_COLOR_ARTIFACT, card->setX); + Xcost->remove(7, 1);//remove the X + if (playerMana->canAfford(Xcost)) + { + alternateCost->copy(Xcost); + SAFE_DELETE(Xcost); + } + else + { + if (card->setX > -1) + card->setX = -1; + SAFE_DELETE(Xcost); + return 0; + } + } + //this handles extra cost payments at the moment a card is played. if(overload) @@ -766,8 +878,9 @@ int MTGAlternativeCostRule::reactToClick(MTGCardInstance * card, ManaCost *alter }//end of storm else { + ManaCost * c = spellCost->Diff(alternateCost); - copy->X = c->getCost(Constants::NB_Colors); + copy->X = card->setX; copy->castX = copy->X; delete c; }