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:
@@ -3962,8 +3962,18 @@ ADrawReplacer::~ADrawReplacer()
|
||||
int AAResetDamage::resolve()
|
||||
{
|
||||
MTGCardInstance * _target = (MTGCardInstance *)target;
|
||||
if(!_target->has(Constants::NODAMAGEREMOVED)) // Added to avoid damage is removed from a card (e.g. "Patient Zero").
|
||||
_target->life = _target->toughness;
|
||||
if(!_target->has(Constants::NODAMAGEREMOVED)){ // Added to avoid damage is removed from a card (e.g. "Patient Zero").
|
||||
if (!_target->isCreature() && _target->hasType(Subtypes::TYPE_PLANESWALKER)){ // Fix life calculation for planeswalker damage.
|
||||
if (_target->counters && _target->counters->hasCounter("loyalty", 0, 0)) {
|
||||
_target->life = _target->counters->hasCounter("loyalty", 0, 0)->nb;
|
||||
}
|
||||
} else if (!_target->isCreature() && _target->hasType(Subtypes::TYPE_BATTLE)){ // Fix life calculation for battle damage.
|
||||
if (_target->counters && _target->counters->hasCounter("defense", 0, 0)) {
|
||||
_target->life = _target->counters->hasCounter("defense", 0, 0)->nb;
|
||||
}
|
||||
} else
|
||||
_target->life = _target->toughness;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -7824,6 +7834,9 @@ int ATransformer::addToGame()
|
||||
else
|
||||
_target->addbaseT(val->getValue());
|
||||
delete val;
|
||||
|
||||
if(_target->isCreature() && (_target->hasType(Subtypes::TYPE_BATTLE) || _target->hasType(Subtypes::TYPE_PLANESWALKER)) && _target->life > _target->toughness)
|
||||
_target->life = _target->toughness; // Fix for a Planeswalker or a Battle that becomes a creature (e.g. "Spark Rupture").
|
||||
}
|
||||
//remove manacost
|
||||
if(removemc)
|
||||
|
||||
@@ -189,7 +189,7 @@ MTGCardInstance * CardDescriptor::match_or(MTGCardInstance * card)
|
||||
if (powerComparisonMode && !valueInRange(powerComparisonMode, card->getPower(), power))
|
||||
return NULL;
|
||||
if (toughnessComparisonMode){ // Toughness comparison has a different meaning for planeswalkers and battles.
|
||||
if(card->counters && (card->hasType(Subtypes::TYPE_PLANESWALKER) || card->hasType(Subtypes::TYPE_BATTLE))){
|
||||
if(!card->isCreature() && card->counters && (card->hasType(Subtypes::TYPE_PLANESWALKER) || card->hasType(Subtypes::TYPE_BATTLE))){
|
||||
for(size_t i = 0; i < card->counters->counters.size(); ++i){
|
||||
if((card->counters->counters[i]->name == "loyalty" && card->hasType(Subtypes::TYPE_PLANESWALKER)) || (card->counters->counters[i]->name == "defense" && card->hasType(Subtypes::TYPE_BATTLE))){
|
||||
if(!valueInRange(toughnessComparisonMode, card->counters->counters[i]->nb, toughness))
|
||||
@@ -246,7 +246,7 @@ MTGCardInstance * CardDescriptor::match_and(MTGCardInstance * card)
|
||||
if (powerComparisonMode && !valueInRange(powerComparisonMode, card->getPower(), power))
|
||||
match = NULL;
|
||||
if (toughnessComparisonMode){ // Toughness comparison has a different meaning for planeswalkers and battles.
|
||||
if(card->counters && (card->hasType(Subtypes::TYPE_PLANESWALKER) || card->hasType(Subtypes::TYPE_BATTLE))){
|
||||
if(!card->isCreature() && card->counters && (card->hasType(Subtypes::TYPE_PLANESWALKER) || card->hasType(Subtypes::TYPE_BATTLE))){
|
||||
for(size_t i = 0; i < card->counters->counters.size(); ++i){
|
||||
if((card->counters->counters[i]->name == "loyalty" && card->hasType(Subtypes::TYPE_PLANESWALKER)) || (card->counters->counters[i]->name == "defense" && card->hasType(Subtypes::TYPE_BATTLE))){
|
||||
if(!valueInRange(toughnessComparisonMode, card->counters->counters[i]->nb, toughness))
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -738,6 +738,17 @@ void GameObserver::gameStateBasedEffects()
|
||||
card->mPropertiesChangedSinceLastUpdate = false;
|
||||
if(card->hasType(Subtypes::TYPE_PLANESWALKER) && (!card->counters||!card->counters->hasCounter("loyalty",0,0)))
|
||||
players[i]->game->putInGraveyard(card);
|
||||
if(card->hasType(Subtypes::TYPE_BATTLE) && (!card->counters||!card->counters->hasCounter("defense",0,0))){
|
||||
if(!card->isDefeated){
|
||||
card->isDefeated = true;
|
||||
WEvent * e = NEW WEventCardDefeated(card);
|
||||
receiveEvent(e);
|
||||
}
|
||||
}
|
||||
if(!card->isCreature() && card->hasType(Subtypes::TYPE_PLANESWALKER) && card->counters->hasCounter("loyalty", 0, 0))
|
||||
card->life = card->counters->hasCounter("loyalty", 0, 0)->nb;
|
||||
if(!card->isCreature() && card->hasType(Subtypes::TYPE_BATTLE) && card->counters->hasCounter("defense", 0, 0))
|
||||
card->life = card->counters->hasCounter("defense", 0, 0)->nb;
|
||||
if(card->myPair && !isInPlay(card->myPair))
|
||||
{
|
||||
card->myPair->myPair = NULL;
|
||||
|
||||
@@ -246,7 +246,9 @@ const char* Constants::MTGBasicAbilities[] = {
|
||||
"nonight", //It can't become night (e.g. "Angel of Eternal Dawn").
|
||||
"nodamageremoved", //Damage is not removed from card (e.g. "Patient Zero").
|
||||
"backgroundpartner", //Can choose a backgorund partner as commander (e.g. "Faceless One").
|
||||
"bottomlibrarydeath" //It goes to bottom of library after death (e.g. "Quintorius, Loremaster").
|
||||
"bottomlibrarydeath", //It goes to bottom of library after death (e.g. "Quintorius, Loremaster").
|
||||
"noloyaltydamage", //Damage does not cause loyalty counter to be removed from a Planeswalker (e.g. "Spark Rupture").
|
||||
"nodefensedamage" //Damage does not cause defense counter to be removed from a Battle.
|
||||
};
|
||||
|
||||
map<string,int> Constants::MTGBasicAbilitiesMap;
|
||||
|
||||
@@ -3970,8 +3970,11 @@ int MTGPlaneswalkerDamage::receiveEvent(WEvent * event)
|
||||
int howMany = d->damage;
|
||||
for(int k = 0; k < howMany; k++)
|
||||
{
|
||||
card->counters->removeCounter("loyalty", 0, 0);
|
||||
if(!card->basicAbilities[Constants::NOLOYALTYDAMAGE])
|
||||
card->counters->removeCounter("loyalty", 0, 0);
|
||||
}
|
||||
if(!card->isCreature() && card->counters->hasCounter("loyalty", 0, 0))
|
||||
card->life = card->counters->hasCounter("loyalty", 0, 0)->nb;
|
||||
return 1;
|
||||
}
|
||||
if (d->damage > 0 && card && card->hasType(Subtypes::TYPE_BATTLE))
|
||||
@@ -3979,8 +3982,11 @@ int MTGPlaneswalkerDamage::receiveEvent(WEvent * event)
|
||||
int howMany = d->damage;
|
||||
for(int k = 0; k < howMany; k++)
|
||||
{
|
||||
card->counters->removeCounter("defense", 0, 0);
|
||||
if(!card->basicAbilities[Constants::NODEFENSEDAMAGE])
|
||||
card->counters->removeCounter("defense", 0, 0);
|
||||
}
|
||||
if(!card->isCreature() && card->counters->hasCounter("defense", 0, 0))
|
||||
card->life = card->counters->hasCounter("defense", 0, 0)->nb;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user