Replace defines in Damage.h with enums.
This commit is contained in:
@@ -873,8 +873,8 @@ public:
|
||||
return 0;
|
||||
if (!tc->canTarget(e->damage->target)) return 0;
|
||||
if (fromTc && !fromTc->canTarget(e->damage->source)) return 0;
|
||||
if (type == 1 && e->damage->typeOfDamage != DAMAGE_COMBAT) return 0;
|
||||
if (type == 2 && e->damage->typeOfDamage == DAMAGE_COMBAT) return 0;
|
||||
if (type == 1 && e->damage->typeOfDamage != Damage::DAMAGE_COMBAT) return 0;
|
||||
if (type == 2 && e->damage->typeOfDamage == Damage::DAMAGE_COMBAT) return 0;
|
||||
e->damage->target->thatmuch = e->damage->damage;
|
||||
e->damage->source->thatmuch = e->damage->damage;
|
||||
this->source->thatmuch = e->damage->damage;
|
||||
@@ -2577,7 +2577,7 @@ public:
|
||||
}
|
||||
else
|
||||
{
|
||||
if (d->type_as_damageable == DAMAGEABLE_MTGCARDINSTANCE)
|
||||
if (d->type_as_damageable == Damageable::DAMAGEABLE_MTGCARDINSTANCE)
|
||||
{
|
||||
a->source = (MTGCardInstance *) d;
|
||||
}
|
||||
@@ -2725,7 +2725,7 @@ public:
|
||||
}
|
||||
else
|
||||
{
|
||||
if (d->type_as_damageable == DAMAGEABLE_MTGCARDINSTANCE)
|
||||
if (d->type_as_damageable == Damageable::DAMAGEABLE_MTGCARDINSTANCE)
|
||||
{
|
||||
a->source = (MTGCardInstance *) d;
|
||||
}
|
||||
@@ -5549,7 +5549,7 @@ public:
|
||||
{
|
||||
WEventDamage * e = (WEventDamage *) event;
|
||||
Damage * d = e->damage;
|
||||
if (combatonly && e->damage->typeOfDamage != DAMAGE_COMBAT)
|
||||
if (combatonly && e->damage->typeOfDamage != Damage::DAMAGE_COMBAT)
|
||||
return 0;
|
||||
MTGCardInstance * card = d->source;
|
||||
if (d->damage > 0 && card && (card == source || card == source->target))
|
||||
|
||||
@@ -11,17 +11,15 @@ class JGuiObject;
|
||||
class MTGCardInstance;
|
||||
class GameObserver;
|
||||
|
||||
#define DAMAGEABLE_MTGCARDINSTANCE 0
|
||||
#define DAMAGEABLE_PLAYER 1
|
||||
|
||||
#define DAMAGE_ALL_TYPES 0
|
||||
#define DAMAGE_COMBAT 1
|
||||
#define DAMAGE_OTHER 2
|
||||
|
||||
class Damageable:public Targetable
|
||||
{
|
||||
protected:
|
||||
public:
|
||||
enum DamageableType{
|
||||
DAMAGEABLE_MTGCARDINSTANCE = 0,
|
||||
DAMAGEABLE_PLAYER
|
||||
};
|
||||
|
||||
int life;
|
||||
int handsize;
|
||||
int poisonCount;
|
||||
@@ -29,12 +27,14 @@ public:
|
||||
int preventable;
|
||||
int thatmuch;
|
||||
int lifeLostThisTurn;
|
||||
int type_as_damageable;
|
||||
DamageableType type_as_damageable;
|
||||
Damageable(GameObserver* observer, int _life)
|
||||
: Targetable(observer)
|
||||
{life=_life;lifeLostThisTurn = 0;};
|
||||
int getLife(){return life;};
|
||||
virtual int dealDamage(int damage){life-=damage;return life;};
|
||||
: Targetable(observer), life(_life), handsize(0),
|
||||
poisonCount(0), damageCount(0), preventable(0), thatmuch(0),
|
||||
lifeLostThisTurn(0), type_as_damageable(DAMAGEABLE_MTGCARDINSTANCE)
|
||||
{}
|
||||
int getLife(){return life;}
|
||||
virtual int dealDamage(int damage){life-=damage;return life;}
|
||||
virtual int afterDamage(){return 0;}
|
||||
virtual int poisoned(){return 0;}
|
||||
virtual int prevented(){return 0;}
|
||||
@@ -47,17 +47,23 @@ public:
|
||||
|
||||
class Damage: public Interruptible
|
||||
{
|
||||
protected:
|
||||
void init(MTGCardInstance * source, Damageable * target, int damage, int typeOfDamage);
|
||||
public:
|
||||
enum DamageType{
|
||||
DAMAGE_ALL_TYPES = 0,
|
||||
DAMAGE_COMBAT,
|
||||
DAMAGE_OTHER
|
||||
};
|
||||
|
||||
Damageable * target;
|
||||
int typeOfDamage;
|
||||
DamageType typeOfDamage;
|
||||
int damage;
|
||||
void Render();
|
||||
Damage(GameObserver* observer, MTGCardInstance* source, Damageable * target);
|
||||
Damage(GameObserver* observer, MTGCardInstance* source, Damageable * target, int damage, int typeOfDamage = DAMAGE_OTHER);
|
||||
Damage(GameObserver* observer, MTGCardInstance* source, Damageable * target, int damage, DamageType typeOfDamage = DAMAGE_OTHER);
|
||||
int resolve();
|
||||
virtual ostream& toString(ostream& out) const;
|
||||
protected:
|
||||
void init(MTGCardInstance * source, Damageable * target, int damage, DamageType typeOfDamage);
|
||||
};
|
||||
|
||||
class DamageStack : public GuiLayer, public Interruptible
|
||||
|
||||
@@ -29,9 +29,10 @@ protected:
|
||||
TargetChooser * tcTarget;
|
||||
int damage;
|
||||
bool oneShot;
|
||||
int typeOfDamage;
|
||||
Damage::DamageType typeOfDamage;
|
||||
public:
|
||||
REDamagePrevention(MTGAbility * _source, TargetChooser *_tcSource = NULL, TargetChooser *_tcTarget = NULL, int _damage = -1, bool _oneShot = true, int typeOfDamage = DAMAGE_ALL_TYPES);
|
||||
REDamagePrevention(MTGAbility * _source, TargetChooser *_tcSource = NULL, TargetChooser *_tcTarget = NULL,
|
||||
int _damage = -1, bool _oneShot = true, Damage::DamageType typeOfDamage = Damage::DAMAGE_ALL_TYPES);
|
||||
WEvent * replace(WEvent *e);
|
||||
~REDamagePrevention();
|
||||
};
|
||||
|
||||
@@ -47,7 +47,7 @@ void AIStats::updateStatsCard(MTGCardInstance * cardInstance, Damage * damage, f
|
||||
{
|
||||
stat->value += static_cast<int>(multiplier * STATS_PLAYER_MULTIPLIER * damage->damage);
|
||||
}
|
||||
else if (damage->target->type_as_damageable == DAMAGEABLE_MTGCARDINSTANCE)
|
||||
else if (damage->target->type_as_damageable == Damageable::DAMAGEABLE_MTGCARDINSTANCE)
|
||||
{
|
||||
MTGCardInstance * target = (MTGCardInstance *) damage->target;
|
||||
if (target->controller() == player && !target->isInPlay(player->getObserver()))
|
||||
|
||||
@@ -161,7 +161,7 @@ void StackAbility::Render()
|
||||
if (target)
|
||||
{
|
||||
quad = target->getIcon();
|
||||
if (target->type_as_damageable == DAMAGEABLE_MTGCARDINSTANCE)
|
||||
if (target->type_as_damageable == Damageable::DAMAGEABLE_MTGCARDINSTANCE)
|
||||
{
|
||||
alt2 = ((MTGCardInstance *) target)->name;
|
||||
}
|
||||
@@ -400,7 +400,7 @@ void Spell::Render()
|
||||
if (target)
|
||||
{
|
||||
quad = target->getIcon();
|
||||
if (target->type_as_damageable == DAMAGEABLE_MTGCARDINSTANCE)
|
||||
if (target->type_as_damageable == Damageable::DAMAGEABLE_MTGCARDINSTANCE)
|
||||
{
|
||||
alt2 = ((MTGCardInstance *) target)->name;
|
||||
}
|
||||
|
||||
@@ -2351,7 +2351,7 @@ int AALifer::resolve()
|
||||
return 0;
|
||||
|
||||
WParsedInt life(life_s, NULL, source);
|
||||
if (_target->type_as_damageable == DAMAGEABLE_MTGCARDINSTANCE)
|
||||
if (_target->type_as_damageable == Damageable::DAMAGEABLE_MTGCARDINSTANCE)
|
||||
{
|
||||
_target = ((MTGCardInstance *) _target)->controller();
|
||||
}
|
||||
@@ -4380,7 +4380,7 @@ int AAExchangeLife::resolve()
|
||||
int oldlife = player->getLife();
|
||||
int targetOldLife = _target->getLife();
|
||||
int modifier = oldlife > targetOldLife? oldlife - targetOldLife:targetOldLife - oldlife;
|
||||
if (_target->type_as_damageable == DAMAGEABLE_MTGCARDINSTANCE)
|
||||
if (_target->type_as_damageable == Damageable::DAMAGEABLE_MTGCARDINSTANCE)
|
||||
{
|
||||
int increaser = 0;
|
||||
MTGCardInstance * card = ((MTGCardInstance*)_target);
|
||||
@@ -4597,15 +4597,15 @@ int APreventDamageTypes::addToGame()
|
||||
fromTc->targetter = NULL;
|
||||
if (type != 1 && type != 2)
|
||||
{//not adding this creates a memory leak.
|
||||
re = NEW REDamagePrevention(this, fromTc, toTc, -1, false, DAMAGE_COMBAT);
|
||||
re = NEW REDamagePrevention(this, fromTc, toTc, -1, false, Damage::DAMAGE_COMBAT);
|
||||
}
|
||||
else if (type == 1)
|
||||
{
|
||||
re = NEW REDamagePrevention(this, fromTc, toTc, -1, false, DAMAGE_ALL_TYPES);
|
||||
re = NEW REDamagePrevention(this, fromTc, toTc, -1, false, Damage::DAMAGE_ALL_TYPES);
|
||||
}
|
||||
else if (type == 2)
|
||||
{
|
||||
re = NEW REDamagePrevention(this, fromTc, toTc, -1, false, DAMAGE_OTHER);
|
||||
re = NEW REDamagePrevention(this, fromTc, toTc, -1, false, Damage::DAMAGE_OTHER);
|
||||
}
|
||||
game->replacementEffects->add(re);
|
||||
return MTGAbility::addToGame();
|
||||
|
||||
@@ -14,13 +14,13 @@ Damage::Damage(GameObserver* observer, MTGCardInstance * source, Damageable * ta
|
||||
init(source, target, source->getPower(), DAMAGE_OTHER);
|
||||
}
|
||||
|
||||
Damage::Damage(GameObserver* observer, MTGCardInstance * source, Damageable * target, int damage, int _typeOfDamage)
|
||||
Damage::Damage(GameObserver* observer, MTGCardInstance * source, Damageable * target, int damage, DamageType _typeOfDamage)
|
||||
: Interruptible(observer)
|
||||
{
|
||||
init(source, target, damage, _typeOfDamage);
|
||||
}
|
||||
|
||||
void Damage::init(MTGCardInstance * _source, Damageable * _target, int _damage, int _typeOfDamage)
|
||||
void Damage::init(MTGCardInstance * _source, Damageable * _target, int _damage, DamageType _typeOfDamage)
|
||||
{
|
||||
typeOfDamage = _typeOfDamage;
|
||||
target = _target;
|
||||
@@ -69,7 +69,7 @@ int Damage::resolve()
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
if (target->type_as_damageable == DAMAGEABLE_MTGCARDINSTANCE)
|
||||
if (target->type_as_damageable == Damageable::DAMAGEABLE_MTGCARDINSTANCE)
|
||||
{
|
||||
MTGCardInstance * _target = (MTGCardInstance *) target;
|
||||
if ((_target)->protectedAgainst(source))
|
||||
@@ -122,7 +122,7 @@ int Damage::resolve()
|
||||
|
||||
int a = damage;
|
||||
|
||||
if (target->type_as_damageable == DAMAGEABLE_MTGCARDINSTANCE && (source->has(Constants::WITHER) || source->has(
|
||||
if (target->type_as_damageable == Damageable::DAMAGEABLE_MTGCARDINSTANCE && (source->has(Constants::WITHER) || source->has(
|
||||
Constants::INFECT)))
|
||||
{
|
||||
// Damage for WITHER or poison on creatures. This should probably go in replacement effects
|
||||
@@ -134,7 +134,7 @@ int Damage::resolve()
|
||||
if(_target->toughness <= 0 && _target->has(Constants::INDESTRUCTIBLE))
|
||||
_target->controller()->game->putInGraveyard(_target);
|
||||
}
|
||||
else if (target->type_as_damageable == DAMAGEABLE_PLAYER && (source->has(Constants::INFECT)||source->has(Constants::POISONDAMAGER)))
|
||||
else if (target->type_as_damageable == Damageable::DAMAGEABLE_PLAYER && (source->has(Constants::INFECT)||source->has(Constants::POISONDAMAGER)))
|
||||
{
|
||||
// Poison on player
|
||||
Player * _target = (Player *) target;
|
||||
@@ -151,7 +151,7 @@ int Damage::resolve()
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (target->type_as_damageable == DAMAGEABLE_PLAYER && (source->has(Constants::POISONTOXIC) ||
|
||||
else if (target->type_as_damageable == Damageable::DAMAGEABLE_PLAYER && (source->has(Constants::POISONTOXIC) ||
|
||||
source->has(Constants::POISONTWOTOXIC) || source->has(Constants::POISONTHREETOXIC)))
|
||||
{
|
||||
//Damage + 1, 2, or 3 poison counters on player
|
||||
@@ -190,9 +190,9 @@ int Damage::resolve()
|
||||
//return the left over amount after effects have been applied to them.
|
||||
a = target->dealDamage(damage);
|
||||
target->damageCount += damage;//the amount must be the actual damage so i changed this from 1 to damage, this fixes pdcount and odcount
|
||||
if (target->type_as_damageable == DAMAGEABLE_MTGCARDINSTANCE)
|
||||
if (target->type_as_damageable == Damageable::DAMAGEABLE_MTGCARDINSTANCE)
|
||||
((MTGCardInstance*)target)->wasDealtDamage = true;
|
||||
if (target->type_as_damageable == DAMAGEABLE_PLAYER)
|
||||
if (target->type_as_damageable == Damageable::DAMAGEABLE_PLAYER)
|
||||
{
|
||||
if(target == source->controller())
|
||||
{
|
||||
@@ -248,7 +248,7 @@ void Damage::Render()
|
||||
}
|
||||
else
|
||||
{
|
||||
if (target->type_as_damageable == DAMAGEABLE_MTGCARDINSTANCE)
|
||||
if (target->type_as_damageable == Damageable::DAMAGEABLE_MTGCARDINSTANCE)
|
||||
mFont->DrawString(_(((MTGCardInstance *) target)->getName()).c_str(), x + 120, y);
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ void DamagerDamaged::addDamage(int damage, DamagerDamaged* source)
|
||||
return;
|
||||
}
|
||||
if (0 < damage)
|
||||
damages.push_back(Damage(card->getObserver(), source->card, card, damage, DAMAGE_COMBAT));
|
||||
damages.push_back(Damage(card->getObserver(), source->card, card, damage, Damage::DAMAGE_COMBAT));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -526,7 +526,7 @@ int GuiCombat::resolve() // Returns the number of damage objects dealt this turn
|
||||
}
|
||||
|
||||
if (dmg > 0 && ((!attacker->isBlocked()) || attacker->has(Constants::TRAMPLE)))
|
||||
stack->Add(NEW Damage(observer, (*it)->card, (Damageable*)attacker->isAttacking?(Damageable*)attacker->isAttacking:observer->opponent(), dmg, DAMAGE_COMBAT));
|
||||
stack->Add(NEW Damage(observer, (*it)->card, (Damageable*)attacker->isAttacking?(Damageable*)attacker->isAttacking:observer->opponent(), dmg, Damage::DAMAGE_COMBAT));
|
||||
|
||||
for (vector<Damage>::iterator d = (*it)->damages.begin(); d != (*it)->damages.end(); ++d)
|
||||
stack->Add(NEW Damage(*d));
|
||||
|
||||
@@ -4477,7 +4477,7 @@ Player * MTGAbility::getPlayerFromDamageable(Damageable * target)
|
||||
if (!target)
|
||||
return NULL;
|
||||
|
||||
if (target->type_as_damageable == DAMAGEABLE_MTGCARDINSTANCE)
|
||||
if (target->type_as_damageable == Damageable::DAMAGEABLE_MTGCARDINSTANCE)
|
||||
return ((MTGCardInstance *) target)->controller();
|
||||
|
||||
return (Player *) target;
|
||||
|
||||
@@ -2700,7 +2700,7 @@ int MTGDeathtouchRule::receiveEvent(WEvent * event)
|
||||
if (!card)
|
||||
return 0;
|
||||
|
||||
if (d->target->type_as_damageable != DAMAGEABLE_MTGCARDINSTANCE)
|
||||
if (d->target->type_as_damageable != Damageable::DAMAGEABLE_MTGCARDINSTANCE)
|
||||
return 0;
|
||||
MTGCardInstance * _target = (MTGCardInstance *) (d->target);
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include "AllAbilities.h"
|
||||
|
||||
REDamagePrevention::REDamagePrevention(MTGAbility * source, TargetChooser *tcSource, TargetChooser *tcTarget, int damage,
|
||||
bool oneShot, int typeOfDamage) :
|
||||
bool oneShot, Damage::DamageType typeOfDamage) :
|
||||
source(source), tcSource(tcSource), tcTarget(tcTarget), damage(damage), oneShot(oneShot), typeOfDamage(typeOfDamage)
|
||||
{
|
||||
}
|
||||
@@ -18,7 +18,7 @@ WEvent * REDamagePrevention::replace(WEvent *event)
|
||||
WEventDamage * e = dynamic_cast<WEventDamage*> (event);
|
||||
if (!e) return event;
|
||||
Damage *d = e->damage;
|
||||
if (d->typeOfDamage != typeOfDamage && typeOfDamage != DAMAGE_ALL_TYPES) return event;
|
||||
if (d->typeOfDamage != typeOfDamage && typeOfDamage != Damage::DAMAGE_ALL_TYPES) return event;
|
||||
if ((!tcSource || tcSource->canTarget(d->source)) && (!tcTarget || tcTarget->canTarget(d->target)))
|
||||
{
|
||||
if (damage == -1)
|
||||
|
||||
Reference in New Issue
Block a user