- Removed "isClone" flag. This flag was error prone. The "core" classes now have decent copy constructors, and ideally long term we should create copy constructors for the abilities that have additional pointers in them.

-- The test suite passes but this is a big change. I might have introduced some memory leaks or bugs. I might have fixed some bugs, too
This commit is contained in:
wagic.the.homebrew
2011-07-27 14:31:27 +00:00
parent a26125ee4c
commit ef5e011e23
14 changed files with 520 additions and 610 deletions

View File

@@ -369,6 +369,13 @@ ThisCounter::~ThisCounter()
SAFE_DELETE(counter);
}
ThisCounter* ThisCounter::clone() const
{
ThisCounter * a = NEW ThisCounter(*this);
a->counter = NEW Counter(NULL, counter->name.c_str(), counter->power, counter->toughness);
return a;
}
ThisOpponentlife::ThisOpponentlife(int olife)
{
comparisonCriterion = olife;
@@ -379,6 +386,11 @@ int ThisOpponentlife::match(MTGCardInstance * card)
return matchValue(card->controller()->opponent()->life);
}
ThisOpponentlife* ThisOpponentlife::clone() const
{
return NEW ThisOpponentlife(*this);
}
ThisControllerlife::ThisControllerlife(int life)
{
comparisonCriterion = life;
@@ -389,6 +401,11 @@ int ThisControllerlife::match(MTGCardInstance * card)
return matchValue(card->controller()->life);
}
ThisControllerlife* ThisControllerlife::clone() const
{
return NEW ThisControllerlife(*this);
}
ThisPower::ThisPower(int power)
{
comparisonCriterion = power;
@@ -399,6 +416,11 @@ int ThisPower::match(MTGCardInstance * card)
return matchValue(card->power);
}
ThisPower* ThisPower::clone() const
{
return NEW ThisPower(*this);
}
ThisEquip::ThisEquip(int equipment)
{
comparisonCriterion = equipment;
@@ -408,6 +430,11 @@ int ThisEquip::match(MTGCardInstance * card)
return matchValue(card->equipment);
}
ThisEquip* ThisEquip::clone() const
{
return NEW ThisEquip(*this);
}
ThisAuras::ThisAuras(int auras)
{
comparisonCriterion = auras;
@@ -417,6 +444,11 @@ int ThisAuras::match(MTGCardInstance * card)
return matchValue(card->auras);
}
ThisAuras* ThisAuras::clone() const
{
return NEW ThisAuras(*this);
}
ThisOpponentDamageAmount::ThisOpponentDamageAmount(int damagecount)
{
comparisonCriterion = damagecount;
@@ -426,6 +458,11 @@ int ThisOpponentDamageAmount::match(MTGCardInstance * card)
return matchValue(card->controller()->opponent()->damageCount);
}
ThisOpponentDamageAmount* ThisOpponentDamageAmount::clone() const
{
return NEW ThisOpponentDamageAmount(*this);
}
ThisUntapped::ThisUntapped(int untapped)
{
comparisonCriterion = untapped;
@@ -435,6 +472,11 @@ int ThisUntapped::match(MTGCardInstance * card)
return matchValue(!card->isTapped());
}
ThisUntapped* ThisUntapped::clone() const
{
return NEW ThisUntapped(*this);
}
ThisTapped::ThisTapped(int tapped)
{
comparisonCriterion = tapped;
@@ -444,6 +486,11 @@ int ThisTapped::match(MTGCardInstance * card)
return matchValue(card->isTapped());
}
ThisTapped* ThisTapped::clone() const
{
return NEW ThisTapped(*this);
}
ThisAttacked::ThisAttacked(int attack)
{
@@ -456,6 +503,11 @@ int ThisAttacked::match(MTGCardInstance * card)
return matchValue(card->didattacked);
}
ThisAttacked* ThisAttacked::clone() const
{
return NEW ThisAttacked(*this);
}
ThisBlocked::ThisBlocked(int block)
{
@@ -468,6 +520,11 @@ int ThisBlocked::match(MTGCardInstance * card)
return matchValue(card->didblocked);
}
ThisBlocked* ThisBlocked::clone() const
{
return NEW ThisBlocked(*this);
}
ThisNotBlocked::ThisNotBlocked(int unblocked)
{
@@ -480,6 +537,11 @@ int ThisNotBlocked::match(MTGCardInstance * card)
return matchValue(card->notblocked);
}
ThisNotBlocked* ThisNotBlocked::clone() const
{
return NEW ThisNotBlocked(*this);
}
ThisDamaged::ThisDamaged(int wasDealtDamage)
{
@@ -494,6 +556,11 @@ result = 1;
return matchValue(result);
}
ThisDamaged* ThisDamaged::clone() const
{
return NEW ThisDamaged(*this);
}
ThisToughness::ThisToughness(int toughness)
{
comparisonCriterion = toughness;
@@ -504,6 +571,11 @@ int ThisToughness::match(MTGCardInstance * card)
return matchValue(card->toughness);
}
ThisToughness* ThisToughness::clone() const
{
return NEW ThisToughness(*this);
}
ThisCounterAny::ThisCounterAny(int nb)
{
comparisonCriterion = nb;
@@ -519,6 +591,11 @@ int ThisCounterAny::match(MTGCardInstance * card)
return matchValue(result);
}
ThisCounterAny * ThisCounterAny::clone() const
{
return NEW ThisCounterAny(*this);
}
ThisX::ThisX(int x)
{
comparisonCriterion = x;
@@ -528,3 +605,8 @@ int ThisX::match(MTGCardInstance * card)
{
return matchValue(card->X);
}
ThisX * ThisX::clone() const
{
return NEW ThisX(*this);
}