Erwan
-fixed bugs with lifelink
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user