-fixed bugs with lifelink
This commit is contained in:
wagic.the.homebrew@gmail.com
2009-04-05 09:01:31 +00:00
parent d5cf601ec7
commit 34c139a15d
10 changed files with 101 additions and 38 deletions
-32
View File
@@ -715,38 +715,6 @@ class ASpellCounterEnchantment:public TargetAbility{
};
/* Lifelink Ability */
class ALifeLink:public MTGAbility{
public:
int nbdamagesthisturn;
Damage * lastDamage;
ALifeLink(int _id, MTGCardInstance * _source):MTGAbility(_id, _source){
nbdamagesthisturn = 0;
lastDamage = NULL;
}
void Update(float dt){
ActionStack * as = game->mLayers->stackLayer();
int totaldamages = as->count(ACTION_DAMAGE,RESOLVED_OK);
if ( totaldamages > nbdamagesthisturn){
Damage * damage = ((Damage * )as->getNext(lastDamage,ACTION_DAMAGE, RESOLVED_OK));
while(damage){
lastDamage = damage;
if (damage->source == source){
source->controller()->life+= damage->damage;
}
damage = ((Damage * )as->getNext(lastDamage,ACTION_DAMAGE, RESOLVED_OK));
}
}else if (totaldamages ==0){
lastDamage = NULL;
}
nbdamagesthisturn = totaldamages;
}
};
//Circle of Protections
class ACircleOfProtection: public TargetAbility{
public:
+24
View File
@@ -134,4 +134,28 @@ public:
const char * getMenuText(){return "Momir";}
};
/* LifeLink */
class MTGLifelinkRule:public MTGAbility{
public:
MTGLifelinkRule(int _id):MTGAbility(_id,NULL){};
int receiveEvent(WEvent * event){
if (event->type == WEvent::DAMAGE){
WEventDamage * e = (WEventDamage *) event;
Damage * d = e->damage;
MTGCardInstance * card = d->source;
if (d->damage>0 && card && card->basicAbilities[Constants::LIFELINK]){
card->controller()->life+= d->damage;
return 1;
}
}
return 0;
}
int testDestroy(){return 0;}
};
#endif
+9
View File
@@ -3,11 +3,13 @@
class MTGCardInstance;
class MTGGameZone;
class Damage;
class WEvent{
public:
enum{
CHANGE_ZONE = 1,
DAMAGE = 2,
};
int type;
WEvent(int _type);
@@ -21,4 +23,11 @@ public:
WEventZoneChange(MTGCardInstance * _card, MTGGameZone * _from, MTGGameZone *_to);
};
class WEventDamage: public WEvent{
public:
Damage * damage;
WEventDamage(Damage * _damage);
};
#endif