Fixed some primitives, added new keyword "hasdead" to allow restrictions based on the death of a specific card type, fixed type sorting on cards changing zones removing the side effect of new lands enter the battlefield on the left.
This commit is contained in:
@@ -468,7 +468,7 @@ int AbilityFactory::parseCastRestrictions(MTGCardInstance * card, Player * playe
|
||||
check = restriction[i].find("deadpermanent");
|
||||
if(check != string::npos)
|
||||
{
|
||||
bool isMorbid = false;
|
||||
bool deadpermanent = false;
|
||||
for(int cp = 0;cp < 2;cp++)
|
||||
{
|
||||
Player * checkCurrent = observer->players[cp];
|
||||
@@ -481,20 +481,20 @@ int AbilityFactory::parseCastRestrictions(MTGCardInstance * card, Player * playe
|
||||
(checkCard->previousZone == checkCurrent->opponent()->game->battlefield))//died from battlefield
|
||||
)
|
||||
{
|
||||
isMorbid = true;
|
||||
deadpermanent = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(isMorbid)
|
||||
if(deadpermanent)
|
||||
break;
|
||||
}
|
||||
if(!isMorbid)
|
||||
if(!deadpermanent)
|
||||
return 0;
|
||||
}
|
||||
check = restriction[i].find("deadcreart");
|
||||
if(check != string::npos)
|
||||
{
|
||||
bool isMorbid = false;
|
||||
bool deadcreart = false;
|
||||
for(int cp = 0;cp < 2;cp++)
|
||||
{
|
||||
Player * checkCurrent = observer->players[cp];
|
||||
@@ -507,14 +507,41 @@ int AbilityFactory::parseCastRestrictions(MTGCardInstance * card, Player * playe
|
||||
(checkCard->previousZone == checkCurrent->opponent()->game->battlefield))//died from battlefield
|
||||
)
|
||||
{
|
||||
isMorbid = true;
|
||||
deadcreart = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(isMorbid)
|
||||
if(deadcreart)
|
||||
break;
|
||||
}
|
||||
if(!isMorbid)
|
||||
if(!deadcreart)
|
||||
return 0;
|
||||
}
|
||||
check = restriction[i].find("hasdead");
|
||||
if(check != string::npos)
|
||||
{
|
||||
bool hasdeadtype = false;
|
||||
string checktype = restriction[i].substr(7);
|
||||
for(int cp = 0;cp < 2;cp++)
|
||||
{
|
||||
Player * checkCurrent = observer->players[cp];
|
||||
MTGGameZone * grave = checkCurrent->game->graveyard;
|
||||
for(unsigned int gy = 0;gy < grave->cardsSeenThisTurn.size();gy++)
|
||||
{
|
||||
MTGCardInstance * checkCard = grave->cardsSeenThisTurn[gy];
|
||||
if(checkCard->hasType(checktype) &&
|
||||
((checkCard->previousZone == checkCurrent->game->battlefield)||
|
||||
(checkCard->previousZone == checkCurrent->opponent()->game->battlefield))//died from battlefield
|
||||
)
|
||||
{
|
||||
hasdeadtype = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(hasdeadtype)
|
||||
break;
|
||||
}
|
||||
if(!hasdeadtype)
|
||||
return 0;
|
||||
}
|
||||
check = restriction[i].find("zerodead");
|
||||
|
||||
@@ -577,21 +577,14 @@ MTGCardInstance * MTGPlayerCards::putInZone(MTGCardInstance * card, MTGGameZone
|
||||
if(card->name == copy->name && !card->hasType(Subtypes::TYPE_LEGENDARY) && copy->hasType(Subtypes::TYPE_LEGENDARY)) // This fix issue when cloning a card with nolegend option (e.g. Double Major)
|
||||
copy->removeType(Subtypes::TYPE_LEGENDARY);
|
||||
|
||||
// This fix issue types problem when card change zone with different card types than its original version (e.g. double face cards).
|
||||
// This fix issue types problem when card change zone with different card types than its original version (e.g. double face cards or cards that gained new types before to change zone).
|
||||
std::vector<int> realTypes;
|
||||
string originame = copy->name;
|
||||
if(doCopy && !asCopy && !inplaytoinplay){
|
||||
for (int i = ((int)copy->types.size())-1; i >= 0; --i){
|
||||
realTypes.push_back(copy->types[i]);
|
||||
copy->removeType(copy->types[i]);
|
||||
}
|
||||
copy->name = originame;
|
||||
for (int i = 0; i < ((int)card->types.size()); i++)
|
||||
copy->addType(card->types[i]);
|
||||
if(copy->types[0] == 1 && copy->types[1] == 7){ // Fix order for Legendary Creatures
|
||||
copy->types[0] = 7;
|
||||
copy->types[1] = 1;
|
||||
}
|
||||
if(doCopy && !asCopy && !inplaytoinplay && !equal(copy->types.begin(), copy->types.end(), card->types.begin()) ){
|
||||
realTypes = copy->types;
|
||||
copy->types = card->types;
|
||||
if(copy->name == "")
|
||||
copy->name = originame;
|
||||
copy->mPropertiesChangedSinceLastUpdate = false;
|
||||
}
|
||||
|
||||
@@ -808,16 +801,11 @@ MTGCardInstance * MTGPlayerCards::putInZone(MTGCardInstance * card, MTGGameZone
|
||||
|
||||
// Reset original types when card change zone with different card types than its original version (e.g. double face cards).
|
||||
if(doCopy && !inplaytoinplay && realTypes.size()){
|
||||
copy->types.clear();
|
||||
for (int i = ((int)realTypes.size())-1; i >= 0; i--)
|
||||
copy->addType(realTypes[i]);
|
||||
if(copy->types[0] == 1 && copy->types[1] == 7){ // Fix order for Legendary Creatures
|
||||
copy->types[0] = 7;
|
||||
copy->types[1] = 1;
|
||||
}
|
||||
copy->name = originame;
|
||||
copy->mPropertiesChangedSinceLastUpdate = false;
|
||||
copy->types = realTypes;
|
||||
realTypes.clear();
|
||||
if(copy->name == "")
|
||||
copy->name = originame;
|
||||
copy->mPropertiesChangedSinceLastUpdate = false;
|
||||
}
|
||||
|
||||
// Erasing counters from copy after the event has been triggered (no counter can survive to a zone changing except the perpetual ones)
|
||||
|
||||
Reference in New Issue
Block a user