Fixed some primitives, fixed several bug on damage management for planeswalkers and battle cards, added new keywords "noloyaltydamage" and "nodefensedamage" to avoid damage remove counters,

This commit is contained in:
Vittorio Alfieri
2023-05-22 01:19:15 +02:00
parent dd28f274d1
commit 2374b00dfd
10 changed files with 53 additions and 38 deletions

View File

@@ -297,32 +297,6 @@ int Damage::resolve()
observer->setLoser(((MTGCardInstance*)source)->controller()->opponent());
}
}
if (target->type_as_damageable == Damageable::DAMAGEABLE_MTGCARDINSTANCE && ((MTGCardInstance*)target)->hasType(Subtypes::TYPE_PLANESWALKER)){ // Fix life calculation for planeswalker damage.
if (((MTGCardInstance*)target)->counters){
Counters * counters = ((MTGCardInstance*)target)->counters;
for(size_t i = 0; i < counters->counters.size(); ++i){
Counter * counter = counters->counters[i];
if(counter->name == "loyalty"){
target->life = counter->nb - target->damageCount;
break;
}
}
}
}
if (target->type_as_damageable == Damageable::DAMAGEABLE_MTGCARDINSTANCE && ((MTGCardInstance*)target)->hasType(Subtypes::TYPE_BATTLE)){ // Fix life calculation for battle damage.
if (((MTGCardInstance*)target)->counters){
Counters * counters = ((MTGCardInstance*)target)->counters;
for(size_t i = 0; i < counters->counters.size(); ++i){
Counter * counter = counters->counters[i];
if(counter->name == "defense"){
target->life = counter->nb - target->damageCount;
break;
}
}
}
}
//Send (Damage/Replaced effect) event to listeners
observer->receiveEvent(e);
return a;