Added a new keyword "excessdamage" to retrieve theamount of exceeded damage to creature or planeswalker, fixed an issue on planeswalker damage count, added a new keyword "genrand" to generate a random number between 0 and a specific number (e.g. "genrand3"), improved Flip ability in order to allow the flip back from copy for a generic card name (e.g. "flip(myorigname) undocpy)"

This commit is contained in:
Vittorio Alfieri
2021-01-25 17:24:15 +01:00
parent 4bdc1fdfe1
commit c60f8787d1
7 changed files with 47 additions and 2 deletions

View File

@@ -926,6 +926,11 @@ public:
e->damage->target->thatmuch = e->damage->damage;
e->damage->source->thatmuch = e->damage->damage;
this->source->thatmuch = e->damage->damage;
if(e->damage->target->life < 0){
e->damage->target->exceededDamage = e->damage->target->life;
e->damage->source->exceededDamage = e->damage->target->life;
this->source->exceededDamage = e->damage->target->life;
}
triggeredTurn = game->turn;
return 1;

View File

@@ -53,6 +53,7 @@ public:
vector<string> formattedText;
string text;
string name;
string nameOrig;
int init();
uint8_t colors;

View File

@@ -27,6 +27,7 @@ public:
int nonCombatDamage;
int preventable;
int thatmuch;
int exceededDamage;
int lifeLostThisTurn;
int lifeGainedThisTurn;
DamageableType type_as_damageable;

View File

@@ -1935,6 +1935,7 @@ int AACopier::resolve()
}
else
{
source->nameOrig = source->name; // Saves the orignal card name before become a copy
source->copy(_target);
}
source->isACopier = true;
@@ -4258,6 +4259,8 @@ int AAFlip::resolve()
GameObserver * game = _target->getObserver();
if(flipStats.size())
{
if(flipStats == "myorigname" && _target->nameOrig != "")
flipStats = _target->nameOrig; // Added to undo the copy effect at end of turn for a generic card (es. Shapeshifter transformations).
MTGCard * fcard = MTGCollection()->getCardByName(flipStats);
if(!fcard) return 0;
MTGCardInstance * myFlip = NEW MTGCardInstance(fcard, _target->controller()->game);

View File

@@ -85,6 +85,7 @@ int CardPrimitive::init()
types.clear();
nameOrig = "";
magicText = "";
magicTexts.clear();
spellTargetType = "";
@@ -419,8 +420,8 @@ bool CardPrimitive::hasType(int _type)
{
if (types.size() > 400) {return false;} // Null pointer?
for (size_t i = 0; i < types.size(); i++)
if (types[i] == _type)
return true;
if (types[i] == _type)
return true;
return false;
}

View File

@@ -278,6 +278,18 @@ int Damage::resolve()
}
}
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;
}
}
}
}
//Send (Damage/Replaced effect) event to listeners
observer->receiveEvent(e);
return a;

View File

@@ -531,6 +531,24 @@ void WParsedInt::init(string s, Spell * spell, MTGCardInstance * card)
if(card && card->thatmuch > intValue)
intValue = card->thatmuch;
}
else if (s == "excessdamage") // Return the amount of exceeded damage of a target
{
if(target->exceededDamage < 0)
intValue = target->exceededDamage;
int checkagain = 0;
if(target->hasSubtype(Subtypes::TYPE_AURA) || target->hasSubtype(Subtypes::TYPE_EQUIPMENT)){
if(target->target){
if(target->target->exceededDamage < 0)
checkagain = target->target->exceededDamage;
}
}
if(checkagain < intValue)
intValue = checkagain;
if(card && card->exceededDamage < intValue)
intValue = card->exceededDamage;
if(intValue < 0)
intValue = abs(intValue);
}
else if (s == "lifelost" || s == "oplifelost")
{
intValue = (s == "lifelost")?target->controller()->lifeLostThisTurn:target->controller()->opponent()->lifeLostThisTurn;
@@ -592,6 +610,10 @@ void WParsedInt::init(string s, Spell * spell, MTGCardInstance * card)
}
}
}
else if (s.find("genrand") != string::npos) //Return a random value between 0 and a specific number (minus 1);
{
intValue = std::rand() % atoi(s.substr(7).c_str());
}
else if (s == "manacost") //Return the converted manacost
{
intValue = (target->currentZone == target->controller()->game->stack)?(target->myconvertedcost + target->castX):target->myconvertedcost;//X is 0 except if it's on the stack