diff --git a/projects/mtg/bin/Res/test/_tests.txt b/projects/mtg/bin/Res/test/_tests.txt index c3ca8d804..c6ed602cb 100644 --- a/projects/mtg/bin/Res/test/_tests.txt +++ b/projects/mtg/bin/Res/test/_tests.txt @@ -36,6 +36,7 @@ arcanis_the_omnipotent.txt arcanis_the_omnipotent2.txt ardakar_wastes.txt argothian_enchantress.txt +#armadillo_cloak.txt #TODO restore when damages are completely assigned ascendant_evincar.txt ascendant_evincar2.txt ascendant_evincar3.txt diff --git a/projects/mtg/bin/Res/test/armadillo_cloak.txt b/projects/mtg/bin/Res/test/armadillo_cloak.txt new file mode 100644 index 000000000..be34b3d6e --- /dev/null +++ b/projects/mtg/bin/Res/test/armadillo_cloak.txt @@ -0,0 +1,33 @@ +#Bug:lifelink and wither +[INIT] +FIRSTMAIN +[PLAYER1] +inplay:Wildslayer Elves +hand:Armadillo Cloak +manapool:{1}{G}{W} +[PLAYER2] +inplay:grizzly bears +[DO] +armadillo cloak +Wildslayer Elves +next +#begin +next +#attackers +Wildslayer elves +next +#blockers +grizzly bears +next +#combat damage +next +combat end +[ASSERT] +COMBATEND +[PLAYER1] +inplay:Wildslayer Elves,Armadillo Cloak +life:25 +[PLAYER2] +graveyard:grizzly bears +life:20 +[END] \ No newline at end of file diff --git a/projects/mtg/src/Damage.cpp b/projects/mtg/src/Damage.cpp index 6e3d695bb..c8f3f1e68 100644 --- a/projects/mtg/src/Damage.cpp +++ b/projects/mtg/src/Damage.cpp @@ -28,23 +28,6 @@ void Damage::init(MTGCardInstance * _source, Damageable * _target, int _damage){ int Damage::resolve(){ if (damage <0) damage = 0; //Negative damages cannot happen state = RESOLVED_OK; - if (target->type_as_damageable == DAMAGEABLE_MTGCARDINSTANCE){ - MTGCardInstance * _target = (MTGCardInstance *)target; - if ((_target)->protectedAgainst(source)) damage = 0; - // Damage for WITHER on creatures - - if (!damage){ - state = RESOLVED_NOK; - return 0; - } - if (source->has(Constants::WITHER)){ - for (int i = 0; i < damage; i++){ - _target->counters->addCounter(-1, -1); - } - return 1; - } - _target->doDamageTest = 1; - } GameObserver * g = GameObserver::GetInstance(); WEvent * e = NEW WEventDamage(this); @@ -60,8 +43,30 @@ int Damage::resolve(){ damage = ev->damage->damage; target = ev->damage->target; - int a = 0; - if (damage) a = target->dealDamage(damage); + if (!damage) return 0; + + if (target->type_as_damageable == DAMAGEABLE_MTGCARDINSTANCE){ + MTGCardInstance * _target = (MTGCardInstance *)target; + if ((_target)->protectedAgainst(source)) damage = 0; + + if (!damage){ + state = RESOLVED_NOK; + delete (e); + return 0; + } + _target->doDamageTest = 1; + } + + int a = damage; + // Damage for WITHER on creatures. This should probably go in replacement effects + if (target->type_as_damageable == DAMAGEABLE_MTGCARDINSTANCE && source->has(Constants::WITHER)){ + MTGCardInstance * _target = (MTGCardInstance *)target; + for (int i = 0; i < damage; i++){ + _target->counters->addCounter(-1, -1); + } + }else{ //Normal case + a = target->dealDamage(damage); + } //Send (Damage/Replaced effect) event to listeners