Added/fixed primitives, improved "TurnSide", "Morph" and "Flip" abilities when dealing with Commanders, added "fresh" attribute to cards just put in Sideboard, added a put back rule when a Commander is put in Sideboard, allowed to cast a card with kicker or alternative or morph cost from the CommandZone: in case of Morphed or DoubleFace cards (e.g. "Tergrid, God of Fright"), they will be put in play but they won't be Commander, but when they will be put elsewhere (e.g. destroyed) they may be back to the CommandZone with the usual Commander put back rule.

This commit is contained in:
Vittorio Alfieri
2021-08-24 22:43:55 +02:00
parent 6331b1daf4
commit c7c2025fc9
12 changed files with 218 additions and 113 deletions
+26 -5
View File
@@ -4564,9 +4564,16 @@ int AATurnSide::resolve()
if(sideCard->getManaCost()){
if(_target->getManaCost()->getAlternative()){
sideCard->getManaCost()->setAlternative(NEW ManaCost());
sideCard->getManaCost()->getAlternative()->copy(_target->getManaCost()->getAlternative()); // Keep orignal alternative cost to cast card with other.
sideCard->getManaCost()->getAlternative()->copy(_target->getManaCost()->getAlternative()); // Keep orignal alternative cost to cast the original card with other.
}
if(_target->getManaCost()->getMorph()){
sideCard->getManaCost()->setMorph(NEW ManaCost());
sideCard->getManaCost()->getMorph()->copy(_target->getManaCost()->getMorph()); // Keep orignal morph cost to cast the original card with morph.
}
_target->getManaCost()->copy(sideCard->getManaCost()); // Show the other side cost mana symbols.
if(_target->numofcastfromcommandzone > 0){ //In case you turn side of a previuosly casted commander
_target->getManaCost()->add(Constants::MTG_COLOR_ARTIFACT,2*_target->numofcastfromcommandzone);
}
}
} else {
fcard = MTGCollection()->getCardByName(_target->nameOrig);
@@ -4579,6 +4586,13 @@ int AATurnSide::resolve()
if(sideCard->getManaCost()){
_target->getManaCost()->resetCosts();
_target->getManaCost()->copy(sideCard->getManaCost()); // Restore the original side cost mana symbols.
if(_target->numofcastfromcommandzone > 0){ //In case you turn side of a previuosly casted commander
_target->getManaCost()->add(Constants::MTG_COLOR_ARTIFACT,2*_target->numofcastfromcommandzone);
if(_target->getManaCost()->getAlternative())
_target->getManaCost()->getAlternative()->add(Constants::MTG_COLOR_ARTIFACT,2*_target->numofcastfromcommandzone);
if(_target->getManaCost()->getMorph())
_target->getManaCost()->getMorph()->add(Constants::MTG_COLOR_ARTIFACT,2*_target->numofcastfromcommandzone);
}
}
}
if(_target->owner->playMode != Player::MODE_TEST_SUITE)
@@ -4587,7 +4601,6 @@ int AATurnSide::resolve()
_target->setId = sideCard->setId;
}
_target->power = sideCard->power;
_target->life = sideCard->life;
_target->toughness = sideCard->toughness;
_target->origpower = sideCard->origpower;
_target->origtoughness = sideCard->origtoughness;
@@ -4598,7 +4611,6 @@ int AATurnSide::resolve()
_target->formattedText = sideCard->formattedText;
_target->magicText = sideCard->magicText;
_target->colors = sideCard->colors;
_target->basicAbilities = sideCard->basicAbilities;
_target->isFlipped = !_target->isFlipped;
_target->mPropertiesChangedSinceLastUpdate = true;
SAFE_DELETE(sideCard);
@@ -4699,8 +4711,17 @@ int AAFlip::resolve()
_target->basicAbilities[i] = 1;
}
SAFE_DELETE(myOrig);
} else
_target->basicAbilities = myFlip->model->data->basicAbilities;
} else{
if(_target->has(Constants::ISCOMMANDER)){
_target->basicAbilities[Constants::WASCOMMANDER] = 1;
_target->basicAbilities[Constants::ISCOMMANDER] = 0;
}
for(size_t i = 0; i < _target->basicAbilities.size(); i++) {
if(i != Constants::WASCOMMANDER && i != Constants::GAINEDEXILEDEATH && i != Constants::GAINEDHANDDEATH && i != Constants::GAINEDDOUBLEFACEDEATH &&
i != Constants::DUNGEONCOMPLETED && i != Constants::PERPETUALDEATHTOUCH && i != Constants::PERPETUALLIFELINK)
_target->basicAbilities[i] = myFlip->model->data->basicAbilities[i]; // Try to keep the original special abilities on card flip.
}
}
cdaDamage = _target->damageCount;
_target->copiedID = myFlip->getMTGId();//for copier
if(_target->owner->playMode != Player::MODE_TEST_SUITE)
+6
View File
@@ -1061,6 +1061,12 @@ void GameObserver::gameStateBasedEffects()
MTGCardInstance * card = fl->cards[k];
card->fresh = 0; // Remove fresh attribute to cards put in library last turn
}
MTGGameZone * fs = p->game->sideboard;
for (int k = 0; k < fs->nb_cards; k++)
{
MTGCardInstance * card = fs->cards[k];
card->fresh = 0; // Remove fresh attribute to cards put in sideboard last turn
}
}
if (z->nb_cards == 0)
{
+11 -4
View File
@@ -5450,7 +5450,15 @@ int AbilityFactory::getAbilities(vector<MTGAbility *> * v, Spell * spell, MTGCar
card->types.clear();
string cre = "Creature";
card->setType(cre.c_str());
card->basicAbilities.reset();
if(card->has(Constants::ISCOMMANDER)){
card->basicAbilities[Constants::WASCOMMANDER] = 1;
card->basicAbilities[Constants::ISCOMMANDER] = 0;
}
for(size_t i = 0; i < card->basicAbilities.size(); i++) {
if(i != Constants::WASCOMMANDER && i != Constants::GAINEDEXILEDEATH && i != Constants::GAINEDHANDDEATH && i != Constants::GAINEDDOUBLEFACEDEATH &&
i != Constants::DUNGEONCOMPLETED && i != Constants::PERPETUALDEATHTOUCH && i != Constants::PERPETUALLIFELINK)
card->basicAbilities[i] = 0; // Try to keep the original special abilities on card morph.
}
card->getManaCost()->resetCosts();
}
else if(card && !card->morphed && card->turningOver)
@@ -5462,16 +5470,15 @@ int AbilityFactory::getAbilities(vector<MTGAbility *> * v, Spell * spell, MTGCar
card->name = card->model->data->name;
card->types = card->model->data->types;
card->colors = card->model->data->colors;
card->basicAbilities |= card->model->data->basicAbilities;
card->basicAbilities[Constants::ISCOMMANDER] = card->basicAbilities[Constants::WASCOMMANDER];
card->basicAbilities[Constants::WASCOMMANDER] = 0;
ManaCost * copyCost = card->model->data->getManaCost();
card->getManaCost()->copy(copyCost);
magicText = card->model->data->magicText;
string faceupC= card->magicTexts["faceup"];
magicText.append("\n");
magicText.append(faceupC);
}
else if(card && card->hasType(Subtypes::TYPE_EQUIPMENT) && card->target)
{
+2 -1
View File
@@ -224,7 +224,8 @@ const char* Constants::MTGBasicAbilities[] = {
"perpetuallifelink", //It gains lifelink perpetually
"perpetualdeathtouch", //It gains deathtouch perpetually
"noncombatvigor", //instead of taking non-combat damage the source gains +1/+1 counters (e.g. Stormwild Capridor)
"nomovetrigger" //no trigger when playing these cards (e.g. fake ability cards such as Davriel Conditions, Davriel Offers, Annihilation Rooms)
"nomovetrigger", //no trigger when playing these cards (e.g. fake ability cards such as Davriel Conditions, Davriel Offers, Annihilation Rooms)
"wascommander", //It was the current commander (e.g. after it flipped or morphed)
};
map<string,int> Constants::MTGBasicAbilitiesMap;
+8 -5
View File
@@ -569,10 +569,13 @@ MTGCardInstance * MTGPlayerCards::putInZone(MTGCardInstance * card, MTGGameZone
}
}
//Commander is going back to Command Zone, so we recalculate cost according to how many times it has been casted from there.
if(to == g->players[0]->game->commandzone || to == g->players[1]->game->commandzone){
for(int i = 0; i < copy->numofcastfromcommandzone; i++)
copy->getManaCost()->add(Constants::MTG_COLOR_ARTIFACT,2);
//Commander is going back to Command Zone, so we recalculate costs according to how many times it has been casted from there.
if((to == g->players[0]->game->commandzone || to == g->players[1]->game->commandzone) && copy->numofcastfromcommandzone > 0){
copy->getManaCost()->add(Constants::MTG_COLOR_ARTIFACT,2*copy->numofcastfromcommandzone);
if(copy->getManaCost()->getAlternative())
copy->getManaCost()->getAlternative()->add(Constants::MTG_COLOR_ARTIFACT,2*copy->numofcastfromcommandzone);
if(copy->getManaCost()->getMorph())
copy->getManaCost()->getMorph()->add(Constants::MTG_COLOR_ARTIFACT,2*copy->numofcastfromcommandzone);
}
if (card->miracle)
@@ -871,7 +874,7 @@ MTGCardInstance * MTGGameZone::removeCard(MTGCardInstance * card, int createCopy
copy->storedSourceCard = card->storedSourceCard;
copy->lastController = card->controller();
copy->previousController = card->controller();
copy->basicAbilities[Constants::ISCOMMANDER] = card->basicAbilities[Constants::ISCOMMANDER];
copy->basicAbilities[Constants::ISCOMMANDER] = (card->basicAbilities[Constants::ISCOMMANDER] | card->basicAbilities[Constants::WASCOMMANDER]);
copy->basicAbilities[Constants::GAINEDEXILEDEATH] = card->basicAbilities[Constants::GAINEDEXILEDEATH];
copy->basicAbilities[Constants::GAINEDHANDDEATH] = card->basicAbilities[Constants::GAINEDHANDDEATH];
copy->basicAbilities[Constants::GAINEDDOUBLEFACEDEATH] = card->basicAbilities[Constants::GAINEDDOUBLEFACEDEATH];
+20 -9
View File
@@ -631,7 +631,7 @@ int MTGKickerRule::isReactingToClick(MTGCardInstance * card, ManaCost *)
if(OptionKicker::KICKER_ALWAYS == options[Options::KICKERPAYMENT].number)
return 0;
Player * player = game->currentlyActing();
if (!player->game->hand->hasCard(card) && !player->game->graveyard->hasCard(card) && !player->game->exile->hasCard(card) && !player->game->library->hasCard(card))
if (!player->game->hand->hasCard(card) && !player->game->graveyard->hasCard(card) && !player->game->exile->hasCard(card) && !player->game->library->hasCard(card) && !game->currentlyActing()->game->commandzone->hasCard(card))
return 0;
if ((player->game->library->hasCard(card) && !card->canPlayFromLibrary()) || (player->game->graveyard->hasCard(card) && !card->has(Constants::CANPLAYFROMGRAVEYARD)) || (player->game->exile->hasCard(card) && !card->has(Constants::CANPLAYFROMEXILE)))
return 0;
@@ -822,7 +822,7 @@ int MTGAlternativeCostRule::isReactingToClick(MTGCardInstance * card, ManaCost *
{
alternateCost->extraCosts->costs[i]->setSource(card);
}
if (!game->currentlyActing()->game->hand->hasCard(card) && !game->currentlyActing()->game->graveyard->hasCard(card) && !game->currentlyActing()->game->exile->hasCard(card) && !game->currentlyActing()->game->library->hasCard(card))
if (!game->currentlyActing()->game->hand->hasCard(card) && !game->currentlyActing()->game->graveyard->hasCard(card) && !game->currentlyActing()->game->exile->hasCard(card) && !game->currentlyActing()->game->library->hasCard(card) && !game->currentlyActing()->game->commandzone->hasCard(card))
return 0;
if ((game->currentlyActing()->game->library->hasCard(card) && !card->canPlayFromLibrary()) || (game->currentlyActing()->game->graveyard->hasCard(card) && !card->has(Constants::CANPLAYFROMGRAVEYARD)) || (game->currentlyActing()->game->exile->hasCard(card) && !card->has(Constants::CANPLAYFROMEXILE)))
return 0;
@@ -1466,7 +1466,7 @@ int MTGMorphCostRule::isReactingToClick(MTGCardInstance * card, ManaCost *)
Player * player = game->currentlyActing();
//Player * currentPlayer = game->currentPlayer;
if (!player->game->library->hasCard(card) && !player->game->graveyard->hasCard(card) && !player->game->exile->hasCard(card) && !player->game->hand->hasCard(card))
if (!player->game->library->hasCard(card) && !player->game->graveyard->hasCard(card) && !player->game->exile->hasCard(card) && !player->game->hand->hasCard(card) && !player->game->commandzone->hasCard(card))
return 0;
if ((!card->canPlayFromLibrary() && player->game->library->hasCard(card))||(!card->has(Constants::CANPLAYFROMGRAVEYARD) && player->game->graveyard->hasCard(card))||(!card->has(Constants::CANPLAYFROMEXILE) && player->game->exile->hasCard(card)))
return 0;
@@ -1512,11 +1512,10 @@ int MTGMorphCostRule::reactToClick(MTGCardInstance * card)
ManaCost * cost = card->getManaCost();
ManaCost * playerMana = player->getManaPool();
ManaCost * morph = card->getManaCost()->getMorph();
if(morph->extraCosts)
for(unsigned int i = 0; i < morph->extraCosts->costs.size();i++)
{
morph->extraCosts->costs[i]->setSource(card);
}
if(morph->extraCosts){
for(unsigned int i = 0; i < morph->extraCosts->costs.size();i++)
morph->extraCosts->costs[i]->setSource(card);
}
//this handles extra cost payments at the moment a card is played.
if (playerMana->canAfford(morph,card->has(Constants::ANYTYPEOFMANA)))
{
@@ -1555,13 +1554,21 @@ int MTGMorphCostRule::reactToClick(MTGCardInstance * card)
card->getManaCost()->setManaUsedToCast(NEW ManaCost());
card->getManaCost()->getManaUsedToCast()->copy(spellCost);
}
int iscommander = card->has(Constants::ISCOMMANDER);
card->basicAbilities[Constants::ISCOMMANDER] = 0;//Morph is not a commander on stack
MTGCardInstance * copy = player->game->putInZone(card, card->currentZone, player->game->stack);
if(iscommander > 0)
copy->basicAbilities[Constants::ISCOMMANDER] = 1;
copy->getManaCost()->resetCosts();//Morph has no ManaCost on stack
copy->setColor(0,1);
copy->types.clear();
string cre = "Creature";
copy->setType(cre.c_str());
copy->basicAbilities.reset();
for(size_t i = 0; i < copy->basicAbilities.size(); i++) {
if(i != Constants::ISCOMMANDER && i != Constants::GAINEDEXILEDEATH && i != Constants::GAINEDHANDDEATH && i != Constants::GAINEDDOUBLEFACEDEATH &&
i != Constants::DUNGEONCOMPLETED && i != Constants::PERPETUALDEATHTOUCH && i != Constants::PERPETUALLIFELINK)
copy->basicAbilities[i] = 0; // Try to keep the original special abilities on card morph.
}
Spell * spell = NULL;
spell = game->mLayers->stackLayer()->addSpell(copy, NULL, spellCost, payResult, 0);
spell->source->morphed = true;
@@ -3432,6 +3439,10 @@ int MTGUnearthRule::receiveEvent(WEvent * event)
{
e->card->fresh = 1;
}
if (e->to == e->card->controller()->game->sideboard) // Apply fresh attribute for cards just put in sideboard
{
e->card->fresh = 1;
}
if (card && card->basicAbilities[(int)Constants::UNEARTH])
{
+2 -4
View File
@@ -262,7 +262,6 @@ TargetChooser * TargetChooserFactory::createTargetChooser(string s, MTGCardInsta
zones[nbzones++] = MTGGameZone::MY_LIBRARY;
zones[nbzones++] = MTGGameZone::MY_HAND;
zones[nbzones++] = MTGGameZone::MY_EXILE;
zones[nbzones++] = MTGGameZone::MY_SIDEBOARD;
zones[nbzones++] = MTGGameZone::MY_COMMANDZONE;
}
else if (zoneName.compare("myrestrictedcastingzone") == 0)
@@ -276,7 +275,6 @@ TargetChooser * TargetChooserFactory::createTargetChooser(string s, MTGCardInsta
zones[nbzones++] = MTGGameZone::OPPONENT_LIBRARY;
zones[nbzones++] = MTGGameZone::OPPONENT_HAND;
zones[nbzones++] = MTGGameZone::OPPONENT_EXILE;
zones[nbzones++] = MTGGameZone::OPPONENT_SIDEBOARD;
zones[nbzones++] = MTGGameZone::OPPONENT_COMMANDZONE;
}
else if (zoneName.compare("opponentrestrictedcastingzone") == 0)
@@ -2322,9 +2320,9 @@ bool EqpChooser::canTarget(Targetable * target,bool withoutProtections)
return false;
if(!card->isInPlay(observer))
return false;
if(card->parentCards.size())
if(card->parentCards.size())
{
if((card->parentCards.at(0)) == source && (card->hasType(Subtypes::TYPE_EQUIPMENT)))
if((card->parentCards.at(0)) == source && (card->hasType(Subtypes::TYPE_EQUIPMENT)))
return true;
}
return false;