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:
@@ -926,6 +926,11 @@ public:
|
|||||||
e->damage->target->thatmuch = e->damage->damage;
|
e->damage->target->thatmuch = e->damage->damage;
|
||||||
e->damage->source->thatmuch = e->damage->damage;
|
e->damage->source->thatmuch = e->damage->damage;
|
||||||
this->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;
|
triggeredTurn = game->turn;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ public:
|
|||||||
vector<string> formattedText;
|
vector<string> formattedText;
|
||||||
string text;
|
string text;
|
||||||
string name;
|
string name;
|
||||||
|
string nameOrig;
|
||||||
int init();
|
int init();
|
||||||
|
|
||||||
uint8_t colors;
|
uint8_t colors;
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ public:
|
|||||||
int nonCombatDamage;
|
int nonCombatDamage;
|
||||||
int preventable;
|
int preventable;
|
||||||
int thatmuch;
|
int thatmuch;
|
||||||
|
int exceededDamage;
|
||||||
int lifeLostThisTurn;
|
int lifeLostThisTurn;
|
||||||
int lifeGainedThisTurn;
|
int lifeGainedThisTurn;
|
||||||
DamageableType type_as_damageable;
|
DamageableType type_as_damageable;
|
||||||
|
|||||||
@@ -1935,6 +1935,7 @@ int AACopier::resolve()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
source->nameOrig = source->name; // Saves the orignal card name before become a copy
|
||||||
source->copy(_target);
|
source->copy(_target);
|
||||||
}
|
}
|
||||||
source->isACopier = true;
|
source->isACopier = true;
|
||||||
@@ -4258,6 +4259,8 @@ int AAFlip::resolve()
|
|||||||
GameObserver * game = _target->getObserver();
|
GameObserver * game = _target->getObserver();
|
||||||
if(flipStats.size())
|
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);
|
MTGCard * fcard = MTGCollection()->getCardByName(flipStats);
|
||||||
if(!fcard) return 0;
|
if(!fcard) return 0;
|
||||||
MTGCardInstance * myFlip = NEW MTGCardInstance(fcard, _target->controller()->game);
|
MTGCardInstance * myFlip = NEW MTGCardInstance(fcard, _target->controller()->game);
|
||||||
|
|||||||
@@ -85,6 +85,7 @@ int CardPrimitive::init()
|
|||||||
|
|
||||||
types.clear();
|
types.clear();
|
||||||
|
|
||||||
|
nameOrig = "";
|
||||||
magicText = "";
|
magicText = "";
|
||||||
magicTexts.clear();
|
magicTexts.clear();
|
||||||
spellTargetType = "";
|
spellTargetType = "";
|
||||||
@@ -419,8 +420,8 @@ bool CardPrimitive::hasType(int _type)
|
|||||||
{
|
{
|
||||||
if (types.size() > 400) {return false;} // Null pointer?
|
if (types.size() > 400) {return false;} // Null pointer?
|
||||||
for (size_t i = 0; i < types.size(); i++)
|
for (size_t i = 0; i < types.size(); i++)
|
||||||
if (types[i] == _type)
|
if (types[i] == _type)
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
//Send (Damage/Replaced effect) event to listeners
|
||||||
observer->receiveEvent(e);
|
observer->receiveEvent(e);
|
||||||
return a;
|
return a;
|
||||||
|
|||||||
@@ -531,6 +531,24 @@ void WParsedInt::init(string s, Spell * spell, MTGCardInstance * card)
|
|||||||
if(card && card->thatmuch > intValue)
|
if(card && card->thatmuch > intValue)
|
||||||
intValue = card->thatmuch;
|
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")
|
else if (s == "lifelost" || s == "oplifelost")
|
||||||
{
|
{
|
||||||
intValue = (s == "lifelost")?target->controller()->lifeLostThisTurn:target->controller()->opponent()->lifeLostThisTurn;
|
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
|
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
|
intValue = (target->currentZone == target->controller()->game->stack)?(target->myconvertedcost + target->castX):target->myconvertedcost;//X is 0 except if it's on the stack
|
||||||
|
|||||||
Reference in New Issue
Block a user