added setting the value of X as you cast a spell with X.

this does not cover abilities yet.
This commit is contained in:
zethfoxster
2016-07-02 13:38:07 -04:00
parent fa916c4fab
commit 2489be93a3
5 changed files with 163 additions and 8 deletions
+16
View File
@@ -4358,6 +4358,22 @@ public:
AAUntapper * clone() const; 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.*/ /* set max level up on a levelup creature this is an Ai hint ability, no effect for players.*/
class AAWhatsMax: public ActivatedAbility class AAWhatsMax: public ActivatedAbility
{ {
+1
View File
@@ -55,6 +55,7 @@ public:
Pos* view; Pos* view;
int X; int X;
int castX; int castX;
int setX;
int alternateCostPaid[ManaCost::MANA_PAID_WITH_BESTOW + 1]; int alternateCostPaid[ManaCost::MANA_PAID_WITH_BESTOW + 1];
int paymenttype; 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 */ 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 */
+21
View File
@@ -4412,6 +4412,27 @@ AAWhatsMax * AAWhatsMax::clone() const
{ {
return NEW AAWhatsMax(*this); 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 //count objects on field before doing an effect
AACountObject::AACountObject(GameObserver* observer, int id, MTGCardInstance * card, MTGCardInstance *, ManaCost * _cost, string value) : AACountObject::AACountObject(GameObserver* observer, int id, MTGCardInstance * card, MTGCardInstance *, ManaCost * _cost, string value) :
ActivatedAbility(observer, id, card, _cost, 0), value(value) ActivatedAbility(observer, id, card, _cost, 0), value(value)
+6 -2
View File
@@ -153,12 +153,14 @@ int MTGCardInstance::init()
data = this; data = this;
X = 0; X = 0;
castX = 0; castX = 0;
setX = -1;
return 1; return 1;
} }
void MTGCardInstance::initMTGCI() void MTGCardInstance::initMTGCI()
{ {
X = 0; X = 0;
setX = -1;
sample = ""; sample = "";
model = NULL; model = NULL;
isToken = false; isToken = false;
@@ -779,11 +781,13 @@ int MTGCardInstance::getCurrentToughness()
//check stack //check stack
bool MTGCardInstance::StackIsEmptyandSorcerySpeed() 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) && if((getObserver()->mLayers->stackLayer()->count(0, NOT_RESOLVED) == 0) &&
(getObserver()->getCurrentGamePhase() == MTG_PHASE_FIRSTMAIN || (getObserver()->getCurrentGamePhase() == MTG_PHASE_FIRSTMAIN ||
getObserver()->getCurrentGamePhase() == MTG_PHASE_SECONDMAIN) && getObserver()->getCurrentGamePhase() == MTG_PHASE_SECONDMAIN) &&
controller() == getObserver()->currentPlayer && controller() == whoCurrent &&
!getObserver()->isInterrupting) (!whoInterupts || whoInterupts == whoCurrent))
{ {
return true; return true;
} }
+119 -6
View File
@@ -329,7 +329,6 @@ int MTGPutInPlayRule::isReactingToClick(MTGCardInstance * card, ManaCost *)
#ifdef WIN32 #ifdef WIN32
cost->Dump(); cost->Dump();
#endif #endif
//cost of card.
if (playerMana->canAfford(cost)) if (playerMana->canAfford(cost))
{ {
//------- //-------
@@ -351,9 +350,8 @@ int MTGPutInPlayRule::isReactingToClick(MTGCardInstance * card, ManaCost *)
card->sunburst += 1; card->sunburst += 1;
} }
} }
} }//if (player->getManaPool()->hasColor(i))
//------- }//for (int i = 1; i != 6; i++)
}
} }
return 1;//play if you can afford too. return 1;//play if you can afford too.
} }
@@ -367,6 +365,65 @@ int MTGPutInPlayRule::reactToClick(MTGCardInstance * card)
return 0; return 0;
Player * player = game->currentlyActing(); Player * player = game->currentlyActing();
ManaCost * cost = card->getManaCost(); ManaCost * cost = card->getManaCost();
ManaCost * playerMana = player->getManaPool();
///////announce X cost///////
if ((cost->hasX() || cost->hasSpecificX()) && card->setX == -1)
{
vector<MTGAbility*>selection;
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 isnt 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. //this handles extra cost payments at the moment a card is played.
if (cost->isExtraPaymentSet()) if (cost->isExtraPaymentSet())
{ {
@@ -685,7 +742,6 @@ int MTGAlternativeCostRule::isReactingToClick(MTGCardInstance * card, ManaCost *
ManaCost * cost = card->getManaCost(); ManaCost * cost = card->getManaCost();
cost->Dump(); cost->Dump();
#endif #endif
//cost of card.
if (playerMana->canAfford(alternateManaCost)) if (playerMana->canAfford(alternateManaCost))
{ {
return 1; return 1;
@@ -713,6 +769,62 @@ int MTGAlternativeCostRule::reactToClick(MTGCardInstance * card, ManaCost *alter
Player * player = game->currentlyActing(); Player * player = game->currentlyActing();
ManaPool * playerMana = player->getManaPool(); ManaPool * playerMana = player->getManaPool();
///////announce X cost///////
if ((alternateCost->hasX() || alternateCost->hasSpecificX()) && card->setX == -1)
{
vector<MTGAbility*>selection;
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 isnt 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. //this handles extra cost payments at the moment a card is played.
if(overload) if(overload)
@@ -766,8 +878,9 @@ int MTGAlternativeCostRule::reactToClick(MTGCardInstance * card, ManaCost *alter
}//end of storm }//end of storm
else else
{ {
ManaCost * c = spellCost->Diff(alternateCost); ManaCost * c = spellCost->Diff(alternateCost);
copy->X = c->getCost(Constants::NB_Colors); copy->X = card->setX;
copy->castX = copy->X; copy->castX = copy->X;
delete c; delete c;
} }