-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
+7
View File
@@ -2,6 +2,7 @@
#include "../include/Damage.h"
#include "../include/MTGCardInstance.h"
#include "../include/Counters.h"
#include "../include/WEvent.h"
Damage::Damage(int id, MTGCardInstance * _source, Damageable * _target): Interruptible(id){
init(_source, _target, _source->getPower());
@@ -44,6 +45,12 @@ int Damage::resolve(){
}
int a = target->dealDamage(damage);
//Send Damage event to listeners
WEventDamage * e = NEW WEventDamage(this);
GameObserver::GetInstance()->mLayers->actionLayer()->receiveEvent(e);
delete e;
return a;
}
+1
View File
@@ -24,6 +24,7 @@ void DuelLayers::init(){
actionLayer->Add(NEW MTGBlockRule(-1));
actionLayer->Add(NEW MTGLegendRule(-1));
actionLayer->Add(NEW MTGPersistRule(-1));
actionLayer->Add(NEW MTGLifelinkRule(-1));
//2 Hand Layer
MTGGuiHand * mGuiHand = NEW MTGGuiHand(3, GameObserver::GetInstance());
+3 -6
View File
@@ -460,9 +460,9 @@ int AbilityFactory::magicText(int id, Spell * spell, MTGCardInstance * card){
}
//gain/lose life
found = s.find("life");
found = s.find("life:");
if (found != string::npos){
unsigned int start = s.find(":",found);
unsigned int start = found+4;
unsigned int end = s.find(" ",start);
int life;
if (end != string::npos){
@@ -1516,10 +1516,7 @@ void AbilityFactory::addAbilities(int _id, Spell * spell){
* For example, setting LIFELINK for a creature is not enough right now...
* It shouldn't be necessary to add an object. State based abilities could do the trick
*/
if (card->basicAbilities[Constants::LIFELINK]){
ALifeLink * ability = NEW ALifeLink(_id, card);
game->addObserver(ability);
}
for (int i=Constants::PROTECTIONGREEN; i <= Constants::PROTECTIONWHITE; i++){
if (card->basicAbilities[i]){
+5
View File
@@ -1,6 +1,7 @@
#include "../include/WEvent.h"
#include "../include/MTGCardInstance.h"
#include "../include/MTGGameZones.h"
#include "../include/Damage.h"
WEvent::WEvent(int _type){
type=_type;
@@ -10,4 +11,8 @@ WEventZoneChange::WEventZoneChange(MTGCardInstance * _card, MTGGameZone * _from,
card = _card;
from = _from;
to = _to;
}
WEventDamage::WEventDamage(Damage *_damage):WEvent(DAMAGE){
damage = _damage;
}