Merge pull request #918 from kevlahnota/master
Refactor PW Rule & some bug fixes
This commit is contained in:
@@ -25239,8 +25239,7 @@ type=Sorcery
|
|||||||
name=Dark Depths
|
name=Dark Depths
|
||||||
auto=counter(0/0,10,Ice)
|
auto=counter(0/0,10,Ice)
|
||||||
auto={3}:counter(0/0,-1,Ice) all(this)
|
auto={3}:counter(0/0,-1,Ice) all(this)
|
||||||
auto=this(counter{0/0.1.Ice}<1)while sacrifice
|
auto=this(counter{0/0.1.Ice}<1)while sacrifice and!( token(Marit Lage,legendary creature avatar, 20/20,flying,indestructible,black) )! notatarget(this)
|
||||||
auto=this(counter{0/0.1.Ice}<1)while token(Marit Lage,legendary creature avatar, 20/20,flying,indestructible,black)
|
|
||||||
text=Dark Depths enters the battlefield with ten ice counters on it. -- {3}: Remove an ice counter from Dark Depths. -- When Dark Depths has no ice counters on it, sacrifice it. If you do, put a legendary 20/20 black Avatar creature token with flying and "This creature is indestructible" named Marit Lage onto the battlefield.
|
text=Dark Depths enters the battlefield with ten ice counters on it. -- {3}: Remove an ice counter from Dark Depths. -- When Dark Depths has no ice counters on it, sacrifice it. If you do, put a legendary 20/20 black Avatar creature token with flying and "This creature is indestructible" named Marit Lage onto the battlefield.
|
||||||
type=Legendary Snow Land
|
type=Legendary Snow Land
|
||||||
[/card]
|
[/card]
|
||||||
|
|||||||
@@ -427,7 +427,7 @@ public:
|
|||||||
* that player chooses one of them, and the rest are put into their owners’ graveyards.
|
* that player chooses one of them, and the rest are put into their owners’ graveyards.
|
||||||
* This is called the “legend rule.”
|
* This is called the “legend rule.”
|
||||||
*/
|
*/
|
||||||
class MTGLegendRule: public PermanentAbility
|
class MTGLegendRule: public ListMaintainerAbility
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TargetChooser * tcL;
|
TargetChooser * tcL;
|
||||||
@@ -435,13 +435,20 @@ public:
|
|||||||
MTGAbility * LegendruleAbility;
|
MTGAbility * LegendruleAbility;
|
||||||
MTGAbility * LegendruleGeneric;
|
MTGAbility * LegendruleGeneric;
|
||||||
MTGLegendRule(GameObserver* observer, int _id);
|
MTGLegendRule(GameObserver* observer, int _id);
|
||||||
int receiveEvent(WEvent * event);
|
int canBeInList(MTGCardInstance * card);
|
||||||
|
int added(MTGCardInstance * card);
|
||||||
|
int removed(MTGCardInstance * card);
|
||||||
|
int testDestroy();
|
||||||
virtual ostream& toString(ostream& out) const;
|
virtual ostream& toString(ostream& out) const;
|
||||||
virtual MTGLegendRule * clone() const;
|
virtual MTGLegendRule * clone() const;
|
||||||
};
|
};
|
||||||
class MTGPlaneWalkerRule: public ListMaintainerAbility
|
class MTGPlaneWalkerRule: public ListMaintainerAbility
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
TargetChooser * tcP;
|
||||||
|
MTGAbility * PWrule;
|
||||||
|
MTGAbility * PWruleAbility;
|
||||||
|
MTGAbility * PWruleGeneric;
|
||||||
MTGPlaneWalkerRule(GameObserver* observer, int _id);
|
MTGPlaneWalkerRule(GameObserver* observer, int _id);
|
||||||
int canBeInList(MTGCardInstance * card);
|
int canBeInList(MTGCardInstance * card);
|
||||||
int added(MTGCardInstance * card);
|
int added(MTGCardInstance * card);
|
||||||
|
|||||||
@@ -3347,6 +3347,7 @@ InstantAbility(observer, id, card, _target),flipStats(flipStats),isflipcard(isfl
|
|||||||
int AAFlip::resolve()
|
int AAFlip::resolve()
|
||||||
{
|
{
|
||||||
int cdaDamage = 0;
|
int cdaDamage = 0;
|
||||||
|
int activatedanyability = 0;
|
||||||
MTGCardInstance * Flipper = (MTGCardInstance*)source;
|
MTGCardInstance * Flipper = (MTGCardInstance*)source;
|
||||||
this->oneShot = true;
|
this->oneShot = true;
|
||||||
if(Flipper->isFlipped)
|
if(Flipper->isFlipped)
|
||||||
@@ -3397,6 +3398,17 @@ int AAFlip::resolve()
|
|||||||
_target->setMTGId(myFlip->getMTGId());
|
_target->setMTGId(myFlip->getMTGId());
|
||||||
_target->setId = myFlip->setId;
|
_target->setId = myFlip->setId;
|
||||||
}
|
}
|
||||||
|
//check pw
|
||||||
|
if(_target->hasType(Subtypes::TYPE_PLANESWALKER))
|
||||||
|
{
|
||||||
|
for(unsigned int k = 0;k < _target->cardsAbilities.size();++k)
|
||||||
|
{
|
||||||
|
ActivatedAbility * check = dynamic_cast<ActivatedAbility*>(_target->cardsAbilities[k]);
|
||||||
|
if(check && check->counters)
|
||||||
|
activatedanyability++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
for(unsigned int i = 0;i < _target->cardsAbilities.size();i++)
|
for(unsigned int i = 0;i < _target->cardsAbilities.size();i++)
|
||||||
{
|
{
|
||||||
MTGAbility * a = dynamic_cast<MTGAbility *>(_target->cardsAbilities[i]);
|
MTGAbility * a = dynamic_cast<MTGAbility *>(_target->cardsAbilities[i]);
|
||||||
@@ -3428,6 +3440,19 @@ int AAFlip::resolve()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//limit pw abi
|
||||||
|
if(activatedanyability)
|
||||||
|
{
|
||||||
|
if(_target->hasType(Subtypes::TYPE_PLANESWALKER))
|
||||||
|
{
|
||||||
|
for(unsigned int k = 0;k < _target->cardsAbilities.size();++k)
|
||||||
|
{
|
||||||
|
ActivatedAbility * check = dynamic_cast<ActivatedAbility*>(_target->cardsAbilities[k]);
|
||||||
|
if(check)//is there a better way?
|
||||||
|
check->counters++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
//power
|
//power
|
||||||
int powerMod = 0;
|
int powerMod = 0;
|
||||||
int toughMod = 0;
|
int toughMod = 0;
|
||||||
|
|||||||
@@ -3205,7 +3205,7 @@ MTGTokensCleanup * MTGTokensCleanup::clone() const
|
|||||||
|
|
||||||
/* Legend Rule */
|
/* Legend Rule */
|
||||||
MTGLegendRule::MTGLegendRule(GameObserver* observer, int _id) :
|
MTGLegendRule::MTGLegendRule(GameObserver* observer, int _id) :
|
||||||
PermanentAbility(observer, _id)
|
ListMaintainerAbility(observer, _id)
|
||||||
{
|
{
|
||||||
tcL = NULL;
|
tcL = NULL;
|
||||||
Legendrule = NULL;
|
Legendrule = NULL;
|
||||||
@@ -3214,50 +3214,67 @@ PermanentAbility(observer, _id)
|
|||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
int MTGLegendRule::receiveEvent(WEvent * event)
|
int MTGLegendRule::canBeInList(MTGCardInstance * card)
|
||||||
{
|
{
|
||||||
WEventGameStateBasedChecked * e = dynamic_cast<WEventGameStateBasedChecked*> (event);
|
if(card->isPhased)
|
||||||
if (e)
|
return 0;
|
||||||
|
if (card->hasType(Subtypes::TYPE_LEGENDARY) && card->controller()->game->inPlay->hasCard(card))
|
||||||
{
|
{
|
||||||
for (int i = 0; i < 2; i++)
|
if(card->has(Constants::NOLEGEND)||card->controller()->opponent()->inPlay()->hasAbility(Constants::NOLEGENDRULE)||card->controller()->inPlay()->hasAbility(Constants::NOLEGENDRULE))
|
||||||
{
|
return 0;
|
||||||
MTGGameZone * zone = game->players[i]->game->inPlay;
|
else
|
||||||
for (int k = zone->nb_cards - 1; k >= 0; k--)
|
return 1;
|
||||||
{
|
|
||||||
MTGCardInstance * card = zone->cards[k];
|
|
||||||
if (card && card->hasType(Subtypes::TYPE_LEGENDARY) && !card->isPhased)
|
|
||||||
{
|
|
||||||
bool condition = (card->has(Constants::NOLEGEND)||card->controller()->opponent()->inPlay()->hasAbility(Constants::NOLEGENDRULE)||card->controller()->inPlay()->hasAbility(Constants::NOLEGENDRULE))?false:true;
|
|
||||||
if(condition && card->countDuplicateCardNames() > 1)
|
|
||||||
{
|
|
||||||
vector<MTGAbility*>selection;
|
|
||||||
TargetChooserFactory tfL(game);
|
|
||||||
tcL = tfL.createTargetChooser("*[share!name!]|mybattlefield",card);
|
|
||||||
tcL->targetter = NULL;
|
|
||||||
tcL->maxtargets = card->countDuplicateCardNames()-1;
|
|
||||||
Legendrule = NEW AAMover(game, game->mLayers->actionLayer()->getMaxId(), card, NULL,"ownergraveyard","Put in Graveyard");
|
|
||||||
Legendrule->oneShot = true;
|
|
||||||
Legendrule->canBeInterrupted = false;
|
|
||||||
LegendruleAbility = NEW GenericTargetAbility(game, "","",game->mLayers->actionLayer()->getMaxId(), card,tcL, Legendrule->clone());
|
|
||||||
SAFE_DELETE(Legendrule);
|
|
||||||
LegendruleAbility->oneShot = true;
|
|
||||||
LegendruleAbility->canBeInterrupted = false;
|
|
||||||
LegendruleGeneric = NEW GenericAddToGame(game, game->mLayers->actionLayer()->getMaxId(), card,NULL,LegendruleAbility->clone());
|
|
||||||
SAFE_DELETE(LegendruleAbility);
|
|
||||||
LegendruleGeneric->oneShot = true;
|
|
||||||
selection.push_back(LegendruleGeneric->clone());
|
|
||||||
SAFE_DELETE(LegendruleGeneric);
|
|
||||||
MTGAbility * menuChoice = NEW MenuAbility(game, game->mLayers->actionLayer()->getMaxId(), card, card,true,selection,card->controller(),"Legendary Rule");
|
|
||||||
menuChoice->addToGame();
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int MTGLegendRule::added(MTGCardInstance * card)
|
||||||
|
{
|
||||||
|
map<MTGCardInstance *, bool>::iterator it;
|
||||||
|
int destroy = 0;
|
||||||
|
|
||||||
|
for (it = cards.begin(); it != cards.end(); it++)
|
||||||
|
{
|
||||||
|
MTGCardInstance * comparison = (*it).first;
|
||||||
|
if (comparison != card && comparison->controller() == card->controller() && !(comparison->getName().compare(card->getName())))
|
||||||
|
destroy = 1;
|
||||||
|
}
|
||||||
|
if(destroy)
|
||||||
|
{
|
||||||
|
vector<MTGAbility*>selection;
|
||||||
|
MTGCardInstance * myClone = NEW MTGCardInstance(card, card->controller()->game);
|
||||||
|
TargetChooserFactory tfL(game);
|
||||||
|
tcL = tfL.createTargetChooser("*[share!name!]|mybattlefield",myClone);
|
||||||
|
tcL->targetter = NULL;
|
||||||
|
tcL->maxtargets = 1;
|
||||||
|
Legendrule = NEW AAMover(game, game->mLayers->actionLayer()->getMaxId(), myClone, NULL,"ownergraveyard","Put in Graveyard");
|
||||||
|
Legendrule->oneShot = true;
|
||||||
|
Legendrule->canBeInterrupted = false;
|
||||||
|
LegendruleAbility = NEW GenericTargetAbility(game, "","",game->mLayers->actionLayer()->getMaxId(), myClone,tcL, Legendrule->clone());
|
||||||
|
SAFE_DELETE(Legendrule);
|
||||||
|
LegendruleAbility->oneShot = true;
|
||||||
|
LegendruleAbility->canBeInterrupted = false;
|
||||||
|
LegendruleGeneric = NEW GenericAddToGame(game, game->mLayers->actionLayer()->getMaxId(), myClone,NULL,LegendruleAbility->clone());
|
||||||
|
SAFE_DELETE(LegendruleAbility);
|
||||||
|
LegendruleGeneric->oneShot = true;
|
||||||
|
selection.push_back(LegendruleGeneric->clone());
|
||||||
|
SAFE_DELETE(LegendruleGeneric);
|
||||||
|
MTGAbility * menuChoice = NEW MenuAbility(game, game->mLayers->actionLayer()->getMaxId(), NULL, myClone,true,selection,card->controller(),"Legendary Rule");
|
||||||
|
menuChoice->addToGame();
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int MTGLegendRule::removed(MTGCardInstance *)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int MTGLegendRule::testDestroy()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
ostream& MTGLegendRule::toString(ostream& out) const
|
ostream& MTGLegendRule::toString(ostream& out) const
|
||||||
{
|
{
|
||||||
return out << "MTGLegendRule :::";
|
return out << "MTGLegendRule :::";
|
||||||
@@ -3271,6 +3288,10 @@ MTGLegendRule * MTGLegendRule::clone() const
|
|||||||
MTGPlaneWalkerRule::MTGPlaneWalkerRule(GameObserver* observer, int _id) :
|
MTGPlaneWalkerRule::MTGPlaneWalkerRule(GameObserver* observer, int _id) :
|
||||||
ListMaintainerAbility(observer, _id)
|
ListMaintainerAbility(observer, _id)
|
||||||
{
|
{
|
||||||
|
tcP = NULL;
|
||||||
|
PWrule = NULL;
|
||||||
|
PWruleAbility = NULL;
|
||||||
|
PWruleGeneric = NULL;
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
@@ -3294,36 +3315,29 @@ int MTGPlaneWalkerRule::added(MTGCardInstance * card)
|
|||||||
{
|
{
|
||||||
MTGCardInstance * comparison = (*it).first;
|
MTGCardInstance * comparison = (*it).first;
|
||||||
if (comparison != card && comparison->types == card->types && comparison->controller() == card->controller())
|
if (comparison != card && comparison->types == card->types && comparison->controller() == card->controller())
|
||||||
{
|
|
||||||
oldCards.push_back(comparison);
|
|
||||||
destroy = 1;
|
destroy = 1;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (game->mLayers->stackLayer()->count(0, NOT_RESOLVED) != 0)
|
|
||||||
destroy = 0;
|
|
||||||
if (game->mLayers->actionLayer()->menuObject)
|
|
||||||
destroy = 0;
|
|
||||||
if (game->getCurrentTargetChooser() || game->mLayers->actionLayer()->isWaitingForAnswer())
|
|
||||||
destroy = 0;
|
|
||||||
if (destroy)
|
if (destroy)
|
||||||
{
|
{
|
||||||
vector<MTGAbility*>selection;
|
vector<MTGAbility*>selection;
|
||||||
|
MTGCardInstance * myClone = NEW MTGCardInstance(card, card->controller()->game);
|
||||||
MultiAbility * multi = NEW MultiAbility(game,game->mLayers->actionLayer()->getMaxId(), card, card, NULL);
|
TargetChooserFactory tfL(game);
|
||||||
for(unsigned int i = 0;i < oldCards.size();i++)
|
tcP = tfL.createTargetChooser("planeswalker[share!types!]|mybattlefield",myClone);
|
||||||
{
|
tcP->targetter = NULL;
|
||||||
AAMover *a = NEW AAMover(game, game->mLayers->actionLayer()->getMaxId(), card, oldCards[i],"ownergraveyard","Keep New");
|
tcP->maxtargets = 1;
|
||||||
a->oneShot = true;
|
PWrule = NEW AAMover(game, game->mLayers->actionLayer()->getMaxId(), myClone, NULL,"ownergraveyard","Put in Graveyard");
|
||||||
multi->Add(a);
|
PWrule->oneShot = true;
|
||||||
}
|
PWrule->canBeInterrupted = false;
|
||||||
multi->oneShot = 1;
|
PWruleAbility = NEW GenericTargetAbility(game, "","",game->mLayers->actionLayer()->getMaxId(), myClone,tcP, PWrule->clone());
|
||||||
MTGAbility * a1 = multi;
|
SAFE_DELETE(PWrule);
|
||||||
selection.push_back(a1);
|
PWruleAbility->oneShot = true;
|
||||||
AAMover *b = NEW AAMover(game, game->mLayers->actionLayer()->getMaxId(), card, card,"ownergraveyard","Keep Old");
|
PWruleAbility->canBeInterrupted = false;
|
||||||
b->oneShot = true;
|
PWruleGeneric = NEW GenericAddToGame(game, game->mLayers->actionLayer()->getMaxId(), myClone,NULL,PWruleAbility->clone());
|
||||||
MTGAbility * b1 = b;
|
SAFE_DELETE(PWruleAbility);
|
||||||
selection.push_back(b1);
|
PWruleGeneric->oneShot = true;
|
||||||
MTGAbility * menuChoice = NEW MenuAbility(game, game->mLayers->actionLayer()->getMaxId(), card, card,true,selection,card->controller(),"Planeswalker Rule");
|
selection.push_back(PWruleGeneric->clone());
|
||||||
|
SAFE_DELETE(PWruleGeneric);
|
||||||
|
MTGAbility * menuChoice = NEW MenuAbility(game, game->mLayers->actionLayer()->getMaxId(), NULL, myClone,true,selection,card->controller(),"Planeswalker Uniqueness Rule");
|
||||||
menuChoice->addToGame();
|
menuChoice->addToGame();
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
|
|||||||
Reference in New Issue
Block a user