Added X to the filters for this() and thisforeach(), for use with {X} costed activated abilities, although it should theoretically work with spells as well if necessary.
This commit is contained in:
@@ -1813,6 +1813,7 @@ NestedAbility::NestedAbility(MTGAbility * _ability){
|
||||
|
||||
ActivatedAbility::ActivatedAbility(int id, MTGCardInstance * card, ManaCost * _cost, int restrictions,int tap):MTGAbility(id,card), restrictions(restrictions), needsTapping(tap){
|
||||
cost = _cost;
|
||||
abilityCost = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -1856,13 +1857,17 @@ int ActivatedAbility::isReactingToClick(MTGCardInstance * card, ManaCost * mana)
|
||||
int ActivatedAbility::reactToClick(MTGCardInstance * card){
|
||||
// if (cost) cost->setExtraCostsAction(this, card);
|
||||
if (!isReactingToClick(card)) return 0;
|
||||
Player * player = game->currentlyActing();
|
||||
if (cost){
|
||||
if (!cost->isExtraPaymentSet()){
|
||||
game->waitForExtraPayment = cost->extraCosts;
|
||||
return 0;
|
||||
}
|
||||
ManaCost * previousManaPool = NEW ManaCost(player->getManaPool());
|
||||
game->currentlyActing()->getManaPool()->pay(cost);
|
||||
cost->doPayExtra();
|
||||
abilityCost = previousManaPool->Diff(player->getManaPool());
|
||||
delete previousManaPool;
|
||||
}
|
||||
if (needsTapping && source->isInPlay()) source->tap();
|
||||
fireAbility();
|
||||
@@ -1873,14 +1878,18 @@ int ActivatedAbility::reactToClick(MTGCardInstance * card){
|
||||
|
||||
int ActivatedAbility::reactToTargetClick(Targetable * object){
|
||||
if (!isReactingToTargetClick(object)) return 0;
|
||||
Player * player = game->currentlyActing();
|
||||
if (cost){
|
||||
if (object->typeAsTarget() == TARGET_CARD) cost->setExtraCostsAction(this, (MTGCardInstance *) object);
|
||||
if (!cost->isExtraPaymentSet()){
|
||||
game->waitForExtraPayment = cost->extraCosts;
|
||||
return 0;
|
||||
}
|
||||
ManaCost * previousManaPool = NEW ManaCost(player->getManaPool());
|
||||
game->currentlyActing()->getManaPool()->pay(cost);
|
||||
cost->doPayExtra();
|
||||
abilityCost = previousManaPool->Diff(player->getManaPool());
|
||||
delete previousManaPool;
|
||||
}
|
||||
if (needsTapping && source->isInPlay()) source->tap();
|
||||
fireAbility();
|
||||
@@ -1888,6 +1897,12 @@ int ActivatedAbility::reactToTargetClick(Targetable * object){
|
||||
|
||||
}
|
||||
|
||||
ActivatedAbility::~ActivatedAbility(){
|
||||
if (!isClone){
|
||||
SAFE_DELETE(abilityCost);
|
||||
}
|
||||
}
|
||||
|
||||
ostream& ActivatedAbility::toString(ostream& out) const
|
||||
{
|
||||
out << "ActivatedAbility ::: restrictions : " << restrictions
|
||||
|
||||
@@ -144,15 +144,28 @@ ThisDescriptor * ThisDescriptorFactory::createThisDescriptor(string s){
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// X
|
||||
found = s.find("x");
|
||||
if (found != string::npos) {
|
||||
ThisX * td = NEW ThisX(criterion);
|
||||
if (td){
|
||||
td->comparisonMode = mode;
|
||||
return td;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ThisCounter::ThisCounter(Counter * _counter){
|
||||
compareAbility = 0;
|
||||
counter = _counter;
|
||||
comparisonCriterion = counter->nb;
|
||||
}
|
||||
|
||||
ThisCounter::ThisCounter(int power, int toughness, int nb, const char * name){
|
||||
compareAbility = 0;
|
||||
counter = NEW Counter(NULL,name,power,toughness);
|
||||
comparisonCriterion = nb;
|
||||
}
|
||||
@@ -184,6 +197,7 @@ ThisCounter::~ThisCounter() {
|
||||
}
|
||||
|
||||
ThisPower::ThisPower(int power){
|
||||
compareAbility = 0;
|
||||
comparisonCriterion = power;
|
||||
}
|
||||
|
||||
@@ -192,6 +206,7 @@ int ThisPower::match(MTGCardInstance * card){
|
||||
}
|
||||
|
||||
ThisToughness::ThisToughness(int toughness){
|
||||
compareAbility = 0;
|
||||
comparisonCriterion = toughness;
|
||||
}
|
||||
|
||||
@@ -200,6 +215,7 @@ int ThisToughness::match(MTGCardInstance * card){
|
||||
}
|
||||
|
||||
ThisCounterAny::ThisCounterAny(int nb){
|
||||
compareAbility = 0;
|
||||
comparisonCriterion = nb;
|
||||
}
|
||||
|
||||
@@ -209,4 +225,13 @@ int ThisCounterAny::match(MTGCardInstance * card){
|
||||
result += card->counters->counters[i]->nb;
|
||||
}
|
||||
return matchValue(result);
|
||||
}
|
||||
|
||||
ThisX::ThisX(int x){
|
||||
comparisonCriterion = x;
|
||||
compareAbility = 1;
|
||||
}
|
||||
|
||||
int ThisX::match(MTGAbility * ability){
|
||||
return matchValue(ability->cost->hasX());
|
||||
}
|
||||
Reference in New Issue
Block a user