fixed issue 632,633 ...

converted {t} into a extra cost. almost all original code to handle it outside remains intact, i plan on slowly migrating to just using the cost...but even just what i changed was a massive headache...anyways as a cost you wont ever have an random bugs where cards don't tap when the ability had {t} in its cost.
while i was at it, i added {q} untap cost.
This commit is contained in:
omegablast2002@yahoo.com
2011-04-18 17:21:06 +00:00
parent 388da9e4bb
commit bf68009674
6 changed files with 152 additions and 36 deletions
+23 -16
View File
@@ -2144,6 +2144,7 @@ public:
card->power = 1; card->power = 1;
card->setToughness(1); card->setToughness(1);
card->setSubtype("creature"); card->setSubtype("creature");
card->summoningSickness = 0;
return 1; return 1;
} }
@@ -4411,30 +4412,36 @@ public:
attackedThisTurn = 1; attackedThisTurn = 1;
} }
void Update(float dt) void Update(float dt)
{
if (newPhase != currentPhase)
{ {
Player * controller = source->controller(); if (newPhase != currentPhase)
if (newPhase == Constants::MTG_PHASE_COMBATDAMAGE && game->currentPlayer == controller)
{ {
if (source->isAttacker()) Player * controller = source->controller();
if(newPhase == Constants::MTG_PHASE_ENDOFTURN)
{ {
attackedThisTurn = 1; if(!attackedThisTurn && game->currentPlayer == source->controller() && !source->fresh)
game->mLayers->stackLayer()->addDamage(source, controller, 2);
} }
} else if (newPhase == Constants::MTG_PHASE_UNTAP)
else if (newPhase == Constants::MTG_PHASE_UNTAP)
{
if (game->currentPlayer != controller && !attackedThisTurn)
{ {
game->mLayers->stackLayer()->addDamage(source, controller, 2);
} if (game->currentPlayer == controller)
else if (game->currentPlayer == controller) {
{ attackedThisTurn = 0;
attackedThisTurn = 0; }
} }
} }
} }
int receiveEvent(WEvent * event)
{
WEventCardAttacked * attacked = dynamic_cast<WEventCardAttacked *> (event);
if (attacked && !attacked->card->didblocked && attacked->card == source)
{
attackedThisTurn = 1;
return 1;
}
return 0;
} }
AErgRaiders * clone() const AErgRaiders * clone() const
+18 -1
View File
@@ -110,7 +110,24 @@ public:
MillExileCost(TargetChooser *_tc = NULL); MillExileCost(TargetChooser *_tc = NULL);
virtual int doPay(); virtual int doPay();
}; };
//tap cost
class TapCost: public ExtraCost{
public:
TapCost();
virtual int isPaymentSet();
virtual int canPay();
virtual int doPay();
virtual TapCost * clone() const;
};
//untap cost
class UnTapCost: public ExtraCost{
public:
UnTapCost();
virtual int isPaymentSet();
virtual int canPay();
virtual int doPay();
virtual UnTapCost * clone() const;
};
//tap other cost //tap other cost
class TapTargetCost: public ExtraCost{ class TapTargetCost: public ExtraCost{
public: public:
+73
View File
@@ -312,6 +312,79 @@ int MillExileCost::doPay()
return 0; return 0;
} }
//Tap cost
TapCost * TapCost::clone() const
{
TapCost * ec = NEW TapCost(*this);
return ec;
}
TapCost::TapCost() :
ExtraCost("Tap")
{
}
int TapCost::isPaymentSet()
{
if (source && (source->isTapped() || source->hasSummoningSickness()))
{
return 0;
}
return 1;
}
int TapCost::canPay()
{
return isPaymentSet();
}
int TapCost::doPay()
{
MTGCardInstance * _source = (MTGCardInstance *) source;
if (_source)
{
_source->tap();
return 1;
}
return 0;
}
//unTap cost
UnTapCost * UnTapCost::clone() const
{
UnTapCost * ec = NEW UnTapCost(*this);
return ec;
}
UnTapCost::UnTapCost() :
ExtraCost("UnTap")
{
}
int UnTapCost::isPaymentSet()
{
if (source && !source->isTapped())
{
return 0;
}
return 1;
}
int UnTapCost::canPay()
{
return isPaymentSet();
}
int UnTapCost::doPay()
{
MTGCardInstance * _source = (MTGCardInstance *) source;
if (_source)
{
_source->untap();
return 1;
}
return 0;
}
//Tap target cost //Tap target cost
TapTargetCost * TapTargetCost::clone() const TapTargetCost * TapTargetCost::clone() const
{ {
+31 -17
View File
@@ -10,6 +10,7 @@
#include "MTGDeck.h" #include "MTGDeck.h"
#include "Translate.h" #include "Translate.h"
#include "ThisDescriptor.h" #include "ThisDescriptor.h"
#include "ExtraCost.h"
//const string kPreLordKeywords[] = { "foreach(", "lord(", "aslongas(", "teach(", "all(" }; //const string kPreLordKeywords[] = { "foreach(", "lord(", "aslongas(", "teach(", "all(" };
const string kLordKeywords[] = { "lord(", "foreach(", "aslongas(", "teach(", "all(" }; const string kLordKeywords[] = { "lord(", "foreach(", "aslongas(", "teach(", "all(" };
@@ -815,8 +816,13 @@ int AbilityFactory::parseRestriction(string s)
// When abilities encapsulate each other, gets the deepest one (it is the one likely to have the most relevant information) // When abilities encapsulate each other, gets the deepest one (it is the one likely to have the most relevant information)
MTGAbility * AbilityFactory::getCoreAbility(MTGAbility * a) MTGAbility * AbilityFactory::getCoreAbility(MTGAbility * a)
{ {
if (AForeach * fea = dynamic_cast<AForeach*>(a)) AForeach * fea = dynamic_cast<AForeach*>(a);
return fea->ability; if(fea)
return getCoreAbility(fea->ability);
AAsLongAs * aea = dynamic_cast<AAsLongAs*>(a);
if(aea)
return getCoreAbility(aea->ability);
GenericTargetAbility * gta = dynamic_cast<GenericTargetAbility*> (a); GenericTargetAbility * gta = dynamic_cast<GenericTargetAbility*> (a);
if (gta) if (gta)
@@ -4105,29 +4111,39 @@ int ActivatedAbility::reactToTargetClick(Targetable * object)
int ActivatedAbility::activateAbility() int ActivatedAbility::activateAbility()
{ {
MTGAbility * fmp = NULL; MTGAbility * fmp = NULL;
if(GenericActivatedAbility * gaa = dynamic_cast<GenericActivatedAbility*>(this)) bool wasTappedForMana = false;
{
AForeach * fea = dynamic_cast<AForeach*>(gaa->ability);
if(fea)
fmp = fea->ability;
}
//taking foreach manaproducers off the stack and sending tapped for mana events. //taking foreach manaproducers off the stack and sending tapped for mana events.
AManaProducer * amp = dynamic_cast<AManaProducer *> (fmp); AbilityFactory af;
if(amp) fmp = af.getCoreAbility(this);
AManaProducer * amp = dynamic_cast<AManaProducer *> (this);
AManaProducer * femp = dynamic_cast<AManaProducer *> (fmp);
if((amp||femp) && cost && cost->extraCosts)
{ {
needsTapping = amp->tap; for(unsigned int i = 0; i < cost->extraCosts->costs.size();i++)
{
ExtraCost * tapper = dynamic_cast<TapCost*>(cost->extraCosts->costs[i]);
if(tapper)
needsTapping = 1;
wasTappedForMana = true;
}
} }
if (needsTapping && source->isInPlay()) else if(amp||femp)
{ {
if (amp) if(amp)
needsTapping = amp->tap;
else
needsTapping = femp->tap;
}
if (needsTapping && (source->isInPlay()|| wasTappedForMana))
{
if (amp||femp)
{ {
GameObserver *g = GameObserver::GetInstance(); GameObserver *g = GameObserver::GetInstance();
WEvent * e = NEW WEventCardTappedForMana(source, 0, 1); WEvent * e = NEW WEventCardTappedForMana(source, 0, 1);
g->receiveEvent(e); g->receiveEvent(e);
} }
source->tap();
} }
if (amp) if (amp||femp)
{ {
counters++; counters++;
if(sideEffect && usesBeforeSideEffects.size()) if(sideEffect && usesBeforeSideEffects.size())
@@ -4137,8 +4153,6 @@ int ActivatedAbility::activateAbility()
this->resolve(); this->resolve();
return 1; return 1;
} }
if (needsTapping && source->isInPlay())
source->tap();
counters++; counters++;
if(sideEffect && usesBeforeSideEffects.size()) if(sideEffect && usesBeforeSideEffects.size())
{ {
+1 -1
View File
@@ -397,7 +397,7 @@ int MTGPutInPlayRule::reactToClick(MTGCardInstance * card)
} }
ManaCost * previousManaPool = NEW ManaCost(player->getManaPool()); ManaCost * previousManaPool = NEW ManaCost(player->getManaPool());
int payResult = player->getManaPool()->pay(cost); int payResult = player->getManaPool()->pay(card->getManaCost());
card->getManaCost()->doPayExtra(); card->getManaCost()->doPayExtra();
ManaCost * spellCost = previousManaPool->Diff(player->getManaPool()); ManaCost * spellCost = previousManaPool->Diff(player->getManaPool());
+6 -1
View File
@@ -93,7 +93,7 @@ ManaCost * ManaCost::parseManaCost(string s, ManaCost * _manaCost, MTGCardInstan
case 't': //Tap case 't': //Tap
if (value == "t") if (value == "t")
{ {
//default Tap is handled outside of Manacost manaCost->addExtraCost(NEW TapCost);
} }
else else
{ {
@@ -153,6 +153,11 @@ ManaCost * ManaCost::parseManaCost(string s, ManaCost * _manaCost, MTGCardInstan
manaCost->addExtraCost(NEW LifeorManaCost(NULL,manaType)); manaCost->addExtraCost(NEW LifeorManaCost(NULL,manaType));
break; break;
} }
case 'q':
{
manaCost->addExtraCost(NEW UnTapCost);
break;
}
case 'c': //Counters case 'c': //Counters
{ {
size_t counter_start = value.find("("); size_t counter_start = value.find("(");