Added new prmitives from MOM set, fixed primitives, improved flipacoin ability, imporved battle cards defeated trigger, added new filters for event to check permanents on graveyard.
This commit is contained in:
@@ -2613,7 +2613,7 @@ AACounter::AACounter(GameObserver* observer, int id, MTGCardInstance * source, M
|
||||
if(_target->getCurrentZone() != _target->controller()->game->battlefield ||
|
||||
_target->getCurrentZone() != _target->controller()->opponent()->game->battlefield)
|
||||
{
|
||||
if(power||toughness)
|
||||
if(!_target->isFlipped && (power||toughness)) // Skipped control for flipped card to solve a bug on double faces cards (e.g. "Ashen Reaper").
|
||||
{
|
||||
if(_target->previousZone == _target->controller()->game->battlefield ||
|
||||
_target->previousZone == _target->controller()->opponent()->game->battlefield)
|
||||
@@ -3416,8 +3416,8 @@ AASetNameChosen::~AASetNameChosen()
|
||||
|
||||
//
|
||||
//choosing flip coin
|
||||
GenericFlipACoin::GenericFlipACoin(GameObserver* observer, int id, MTGCardInstance * source, Targetable *,string _toAdd, ManaCost * cost) :
|
||||
ActivatedAbility(observer, id, source, cost, 0), baseAbility(_toAdd)
|
||||
GenericFlipACoin::GenericFlipACoin(GameObserver* observer, int id, MTGCardInstance * source, Targetable *,string _toAdd, ManaCost * cost, int userchoice) :
|
||||
ActivatedAbility(observer, id, source, cost, 0), baseAbility(_toAdd), userchoice(userchoice)
|
||||
{
|
||||
this->GetId();
|
||||
setCoin = NULL;
|
||||
@@ -3428,15 +3428,23 @@ int GenericFlipACoin::resolve()
|
||||
if (!target)
|
||||
return 0;
|
||||
vector<MTGAbility*>selection;
|
||||
for (int i = 0; i <2; ++i)
|
||||
{
|
||||
setCoin = NEW AASetCoin(game, game->mLayers->actionLayer()->getMaxId(), source,(MTGCardInstance*)target, i, baseAbility);
|
||||
if(userchoice > 0 && userchoice <= 2){
|
||||
setCoin = NEW AASetCoin(game, game->mLayers->actionLayer()->getMaxId(), source,(MTGCardInstance*)target, userchoice, baseAbility);
|
||||
MTGAbility * set = setCoin->clone();
|
||||
set->oneShot = true;
|
||||
selection.push_back(set);
|
||||
game->mLayers->actionLayer()->currentActionCard = (MTGCardInstance *)target;
|
||||
set->resolve();
|
||||
SAFE_DELETE(setCoin);
|
||||
} else{
|
||||
for (int i = 1; i <=2; ++i)
|
||||
{
|
||||
setCoin = NEW AASetCoin(game, game->mLayers->actionLayer()->getMaxId(), source,(MTGCardInstance*)target, i, baseAbility);
|
||||
MTGAbility * set = setCoin->clone();
|
||||
set->oneShot = true;
|
||||
selection.push_back(set);
|
||||
SAFE_DELETE(setCoin);
|
||||
}
|
||||
}
|
||||
|
||||
if(selection.size())
|
||||
{
|
||||
MTGAbility * a1 = NEW MenuAbility(game, this->GetId(), target, source,false,selection);
|
||||
@@ -3463,7 +3471,7 @@ GenericFlipACoin::~GenericFlipACoin()
|
||||
}
|
||||
|
||||
//set coin result
|
||||
AASetCoin::AASetCoin(GameObserver* observer, int id, MTGCardInstance * source, MTGCardInstance * _target,int _side , string toAlter):
|
||||
AASetCoin::AASetCoin(GameObserver* observer, int id, MTGCardInstance * source, MTGCardInstance * _target, int _side, string toAlter):
|
||||
InstantAbility(observer, id, source),side(_side), abilityToAlter(toAlter)
|
||||
{
|
||||
this->target = _target;
|
||||
@@ -3475,7 +3483,7 @@ int AASetCoin::resolve()
|
||||
MTGCardInstance * _target = (MTGCardInstance *)target;
|
||||
_target->coinSide = side;
|
||||
|
||||
int flip = game->getRandomGenerator()->random() % 2;
|
||||
int flip = 1 + game->getRandomGenerator()->random() % 2;
|
||||
_target->lastFlipResult = flip;
|
||||
WEvent * e = NEW WEventCardFlipCoin(_target, source->controller()->getDisplayName());
|
||||
game->receiveEvent(e);
|
||||
|
||||
@@ -461,6 +461,58 @@ int AbilityFactory::parseCastRestrictions(MTGCardInstance * card, Player * playe
|
||||
if(!isMorbid)
|
||||
return 0;
|
||||
}
|
||||
check = restriction[i].find("deadpermanent");
|
||||
if(check != string::npos)
|
||||
{
|
||||
bool isMorbid = false;
|
||||
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->isPermanent() &&
|
||||
((checkCard->previousZone == checkCurrent->game->battlefield)||
|
||||
(checkCard->previousZone == checkCurrent->opponent()->game->battlefield))//died from battlefield
|
||||
)
|
||||
{
|
||||
isMorbid = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(isMorbid)
|
||||
break;
|
||||
}
|
||||
if(!isMorbid)
|
||||
return 0;
|
||||
}
|
||||
check = restriction[i].find("deadcreart");
|
||||
if(check != string::npos)
|
||||
{
|
||||
bool isMorbid = false;
|
||||
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->isCreature() || checkCard->hasType(Subtypes::TYPE_ARTIFACT)) &&
|
||||
((checkCard->previousZone == checkCurrent->game->battlefield)||
|
||||
(checkCard->previousZone == checkCurrent->opponent()->game->battlefield))//died from battlefield
|
||||
)
|
||||
{
|
||||
isMorbid = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(isMorbid)
|
||||
break;
|
||||
}
|
||||
if(!isMorbid)
|
||||
return 0;
|
||||
}
|
||||
check = restriction[i].find("zerodead");
|
||||
if(check != string::npos)//returns true if zero
|
||||
{
|
||||
@@ -1358,6 +1410,10 @@ TriggeredAbility * AbilityFactory::parseTrigger(string s, string, int id, Spell
|
||||
if (TargetChooser * tc = parseSimpleTC(s, "boasted", card))
|
||||
return NEW TrCardBoasted(observer, id, card, tc, once, limitOnceATurn);
|
||||
|
||||
//a battle card has been defeated
|
||||
if (TargetChooser * tc = parseSimpleTC(s, "defeated", card))
|
||||
return NEW TrCardDefeated(observer, id, card, tc, once, limitOnceATurn);
|
||||
|
||||
//Surveil has been performed from a card
|
||||
if (TargetChooser * tc = parseSimpleTC(s, "surveiled", card))
|
||||
return NEW TrCardSurveiled(observer, id, card, tc, once, limitOnceATurn);
|
||||
@@ -2871,7 +2927,12 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
|
||||
if (splitFlipCoin.size())
|
||||
{
|
||||
string a1 = splitFlipCoin[1];
|
||||
MTGAbility * a = NEW GenericFlipACoin(observer, id, card, target, a1);
|
||||
int userchoice = 0;
|
||||
if(a1[0] >= 48 && a1[0] <= 57){
|
||||
userchoice = (a1[0] - 48);
|
||||
a1 = a1.substr(2);
|
||||
}
|
||||
MTGAbility * a = NEW GenericFlipACoin(observer, id, card, target, a1, NULL, userchoice);
|
||||
a->oneShot = 1;
|
||||
a->canBeInterrupted = false;
|
||||
return a;
|
||||
|
||||
@@ -233,6 +233,7 @@ void MTGCardInstance::initMTGCI()
|
||||
isMorphed = false;
|
||||
MeldedFrom = "";
|
||||
isFlipped = 0;
|
||||
isDefeated = false;
|
||||
isPhased = false;
|
||||
isCascaded = false;
|
||||
phasedTurn = -1;
|
||||
|
||||
@@ -557,9 +557,23 @@ MTGCardInstance * MTGPlayerCards::putInZone(MTGCardInstance * card, MTGGameZone
|
||||
copy->getManaCost()->getManaUsedToCast()->copy(card->getManaCost()->getManaUsedToCast());
|
||||
}
|
||||
|
||||
if(!card->hasType(Subtypes::TYPE_LEGENDARY) && copy->hasType(Subtypes::TYPE_LEGENDARY)) // This fix issue when cloning a card with nolegend option (e.g. Double Major)
|
||||
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);
|
||||
|
||||
std::vector<int> realTypes;
|
||||
if(card->name == copy->backSide){ // This fix issue types problem when card dies as its backside (e.g. "Incubator" and "Phyrexian").
|
||||
for (int i = ((int)copy->types.size())-1; i >= 0; --i){
|
||||
realTypes.push_back(copy->types[i]);
|
||||
copy->removeType(copy->types[i]);
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
// Copy all the counters of the original card... (solving the bug on comparison cards with counter before zone changing events)
|
||||
if(card->counters && doCopy && !asCopy && !inplaytoinplay){
|
||||
for (unsigned int i = 0; i < card->counters->counters.size(); i++){
|
||||
@@ -757,6 +771,16 @@ MTGCardInstance * MTGPlayerCards::putInZone(MTGCardInstance * card, MTGGameZone
|
||||
if(doCopy && !inplaytoinplay && copy->has(Constants::ISPREY))
|
||||
copy->basicAbilities[Constants::ISPREY] = 0;
|
||||
|
||||
if(realTypes.size() && card->name == copy->backSide){ // Reset original types when card dies as its backside (e.g. "Incubator" and "Phyrexian").
|
||||
copy->types.clear();
|
||||
for (int i = 0; i < ((int)realTypes.size()); 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;
|
||||
}
|
||||
}
|
||||
|
||||
// Erasing counters from copy after the event has been triggered (no counter can survive to a zone changing except the perpetual ones)
|
||||
if(doCopy && !inplaytoinplay && copy->counters && copy->counters->mCount > 0){
|
||||
for (unsigned int i = 0; i < copy->counters->counters.size(); i++){
|
||||
|
||||
@@ -3992,6 +3992,16 @@ int MTGPlaneswalkerDamage::receiveEvent(WEvent * event)
|
||||
removel->targetCard->toGrave(true);
|
||||
return 1;
|
||||
}
|
||||
if(removel->removed && removel->targetCard && removel->targetCard->hasType(Subtypes::TYPE_BATTLE))
|
||||
if(!removel->targetCard->counters->hasCounter("defense", 0, 0))
|
||||
{
|
||||
if(!removel->targetCard->isDefeated){
|
||||
removel->targetCard->isDefeated = true;
|
||||
WEvent * e = NEW WEventCardDefeated(removel->targetCard);
|
||||
game->receiveEvent(e);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -322,6 +322,11 @@ WEventCardBoasted::WEventCardBoasted(MTGCardInstance * card) :
|
||||
{
|
||||
}
|
||||
|
||||
WEventCardDefeated::WEventCardDefeated(MTGCardInstance * card) :
|
||||
WEventCardUpdate(card)
|
||||
{
|
||||
}
|
||||
|
||||
WEventCardSurveiled::WEventCardSurveiled(MTGCardInstance * card) :
|
||||
WEventCardUpdate(card)
|
||||
{
|
||||
@@ -590,6 +595,12 @@ Targetable * WEventCardBoasted::getTarget(int target)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Targetable * WEventCardDefeated::getTarget(int target)
|
||||
{
|
||||
if (target) return card;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Targetable * WEventCardSurveiled::getTarget(int target)
|
||||
{
|
||||
if (target) return card;
|
||||
|
||||
Reference in New Issue
Block a user