- moved all "loseLife/gainLife" duplicated code into 1 Player method
This commit is contained in:
wagic.the.homebrew@gmail.com
2011-01-23 06:59:00 +00:00
parent 14f2e9b0f2
commit f63aa379e7
9 changed files with 88 additions and 92 deletions
+3 -11
View File
@@ -719,11 +719,8 @@ public:
return 0;
if (!tc->canTarget(e->player)) return 0;
if (fromTc && !fromTc->canTarget(e->player)) return 0;
if (type == 1 && (e->amount > 0 || e->Ltype == 0)) return 0;
if (type == 0 && (e->amount < 0 || e->Ltype == 1)) return 0;
if(type != 1)
e->player->thatmuch = e->amount;
else
if (type == 1 && (e->amount > 0)) return 0;
if (type == 0 && (e->amount < 0)) return 0;
e->player->thatmuch = abs(e->amount);
return 1;
}
@@ -5742,12 +5739,7 @@ public:
MTGCardInstance * card = d->source;
if (d->damage > 0 && card && (card == source || card == source->target))
{
source->owner->life += d->damage;
source->owner->thatmuch = d->damage;
WEvent * lifed = NULL;
lifed = NEW WEventLife(source->owner,d->damage);
GameObserver * game = GameObserver::GetInstance();
game->receiveEvent(lifed);
source->owner->gainLife(d->damage);
return 1;
}
}
+5
View File
@@ -62,6 +62,11 @@ public:
}
int afterDamage();
int gainLife(int value);
int loseLife(int value);
int gainOrLoseLife(int value);
int poisoned();
int damaged();
int prevented();
+1 -2
View File
@@ -54,8 +54,7 @@ struct WEventDamage : public WEvent {
struct WEventLife : public WEvent {
Player * player;
int amount;
int Ltype;
WEventLife(Player * player,int amount,int Ltype = 0);
WEventLife(Player * player,int amount);
virtual Targetable * getTarget(int target);
};