diff --git a/projects/mtg/include/AllAbilities.h b/projects/mtg/include/AllAbilities.h index ac3a791b0..dd2653ef1 100644 --- a/projects/mtg/include/AllAbilities.h +++ b/projects/mtg/include/AllAbilities.h @@ -3423,17 +3423,6 @@ string menu; ~AADYNAMIC(); }; -/* removes a card and all with the same name as it from the game */ -class AAEradicate: public ActivatedAbility -{ -public: -int type; - AAEradicate(int id, MTGCardInstance * card, MTGCardInstance * _target,int type = 0, ManaCost * _cost = NULL, int doTap = 0); - int resolve(); - const char * getMenuText(); - AAEradicate * clone() const; -}; - /* switch power and toughness of target */ class ASwapPT: public InstantAbility { diff --git a/projects/mtg/include/CardDescriptor.h b/projects/mtg/include/CardDescriptor.h index 42a7530c7..36cb3ab3f 100644 --- a/projects/mtg/include/CardDescriptor.h +++ b/projects/mtg/include/CardDescriptor.h @@ -55,6 +55,10 @@ class CardDescriptor: public MTGCardInstance{ MTGCardInstance * match(MTGCardInstance * card); MTGCardInstance * match(MTGGameZone * zone); MTGCardInstance * nextmatch(MTGGameZone * zone, MTGCardInstance * previous); + + int nameComparisonMode; + int colorComparisonMode; + string compareName; }; #endif diff --git a/projects/mtg/src/AllAbilities.cpp b/projects/mtg/src/AllAbilities.cpp index 54330761c..4f43f45ec 100644 --- a/projects/mtg/src/AllAbilities.cpp +++ b/projects/mtg/src/AllAbilities.cpp @@ -1246,95 +1246,6 @@ AADYNAMIC::~AADYNAMIC() SAFE_DELETE(storedAbility); } -// Eradicate -AAEradicate::AAEradicate(int id, MTGCardInstance * card, MTGCardInstance * _target,int type, ManaCost * _cost, int doTap) : - ActivatedAbility(id, card, _cost, 0, doTap),type(type) -{ - target = _target; -} - -int AAEradicate::resolve() -{ - MTGCardInstance * _target = (MTGCardInstance *) target; - if (_target) - { - while (_target->next) - _target = _target->next; //This is for cards such as rampant growth - - string name= _target->name; - int cardtotal = _target->controller()->game->battlefield->nb_cards - + _target->controller()->game->hand->nb_cards - +_target->controller()->game->graveyard->nb_cards - +_target->controller()->game->library->nb_cards; - - Player * victem = _target->controller(); - victem->game->putInExile(_target); - - MTGGameZone * g = victem->game->graveyard; - MTGGameZone * l = victem->game->library; - MTGGameZone * h = victem->game->hand; - MTGGameZone * i = victem->game->inPlay; - - while(_target->controller()->inPlay()->hasName(name) || _target->controller()->game->graveyard->hasName(name)|| _target->controller()->game->library->hasName(name)|| _target->controller()->game->hand->hasName(name)) - { - for (int k = 0; k < g->nb_cards; k++) - { - MTGCardInstance * card = g->cards[k]; - if(card->name == name) - victem->game->putInZone(card,g,card->controller()->game->exile); - if(k > g->nb_cards) - { - k = 0; - } - } - for (int t = 0; t < l->nb_cards; t++) - { - MTGCardInstance * card = l->cards[t]; - if(card->name == name) - victem->game->putInZone(card,l,card->controller()->game->exile); - if(t > l->nb_cards) - { - t = 0; - } - } - for (int w = 0; w < h->nb_cards; w++) - { - MTGCardInstance * card = h->cards[w]; - if(card->name == name) - victem->game->putInZone(card,h,card->controller()->game->exile); - if(w > h->nb_cards) - { - w = 0; - } - } - for (int o = 0; o < i->nb_cards; o++) - { - MTGCardInstance * card = i->cards[o]; - if(card->name == name) - victem->game->putInZone(card,i,card->controller()->game->exile); - if(o > i->nb_cards) - { - o = 0; - } - } - } - - } - return 1; -} - -const char * AAEradicate::getMenuText() -{ - return "eradicate"; -} - -AAEradicate * AAEradicate::clone() const -{ - AAEradicate * a = NEW AAEradicate(*this); - a->isClone = 1; - return a; -} - //AALifer AALifer::AALifer(int _id, MTGCardInstance * card, Targetable * _target, string life_s, WParsedInt * life, ManaCost * _cost, int _tap, int who) : ActivatedAbilityTP(_id, card, _target, _cost, _tap, who),life_s(life_s), life(life) diff --git a/projects/mtg/src/CardDescriptor.cpp b/projects/mtg/src/CardDescriptor.cpp index 79b486846..7ec433fe3 100644 --- a/projects/mtg/src/CardDescriptor.cpp +++ b/projects/mtg/src/CardDescriptor.cpp @@ -17,6 +17,9 @@ CardDescriptor::CardDescriptor() : MTGCardInstance() manacostComparisonMode = COMPARISON_NONE; counterComparisonMode = COMPARISON_NONE; convertedManacost = -1; + compareName =""; + nameComparisonMode = COMPARISON_NONE; + colorComparisonMode = COMPARISON_NONE; } int CardDescriptor::init() @@ -154,7 +157,8 @@ MTGCardInstance * CardDescriptor::match_or(MTGCardInstance * card) return NULL; if (manacostComparisonMode && !valueInRange(manacostComparisonMode, card->getManaCost()->getConvertedCost(), convertedManacost)) return NULL; - + if (nameComparisonMode && compareName != card->name) + return NULL; return card; } @@ -192,7 +196,23 @@ MTGCardInstance * CardDescriptor::match_and(MTGCardInstance * card) match = NULL; if (manacostComparisonMode && !valueInRange(manacostComparisonMode, card->getManaCost()->getConvertedCost(), convertedManacost)) match = NULL; - + if(nameComparisonMode && compareName != card->name) + match = NULL; + if(colorComparisonMode) + { + bool hasMatch = false; + for (int i=0;i< Constants::MTG_NB_COLORS;i++) + { + if (card->hasColor(i) && colors[i] > 0) + { + hasMatch = true; + } + } + if( !hasMatch ) + { + match = NULL; + } + } return match; } diff --git a/projects/mtg/src/MTGAbility.cpp b/projects/mtg/src/MTGAbility.cpp index dccb8cee4..a9623e597 100644 --- a/projects/mtg/src/MTGAbility.cpp +++ b/projects/mtg/src/MTGAbility.cpp @@ -2579,15 +2579,6 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG return a; } - //eradicate - found = s.find("eradicate"); - if (found != string::npos) - { - MTGAbility * a = NEW AAEradicate(id, card, target,1); - a->oneShot = 1; - return a; - } - //identify what a leveler creature will max out at. found = s.find("maxlevel:"); if (found != string::npos) diff --git a/projects/mtg/src/MTGGameZones.cpp b/projects/mtg/src/MTGGameZones.cpp index 4e869a61f..0ec564802 100644 --- a/projects/mtg/src/MTGGameZones.cpp +++ b/projects/mtg/src/MTGGameZones.cpp @@ -785,8 +785,19 @@ MTGGameZone * MTGGameZone::intToZone(int zoneId, MTGCardInstance * source, MTGCa p = source->controller(); if (!target) { - p2 = p; - target = source;//hack ? + if(source->target) + { + //bug case, this is a patchwork fix for now + //we need to find the root cause of why the 2nd variable is not returning the target. + p2 = source->target->controller(); + target = source->target; + } + else + { + //bug or bug case default to + p2 = source->controller(); + target = source; + } } else p2 = target->controller(); diff --git a/projects/mtg/src/TargetChooser.cpp b/projects/mtg/src/TargetChooser.cpp index 312cd3bcb..ade4bd452 100644 --- a/projects/mtg/src/TargetChooser.cpp +++ b/projects/mtg/src/TargetChooser.cpp @@ -446,6 +446,52 @@ TargetChooser * TargetChooserFactory::createTargetChooser(string s, MTGCardInsta cd->manacostComparisonMode = comparisonMode; //Counter Restrictions } + else if (attribute.find("share!") != string::npos) + { + size_t start = attribute.find("share!"); + size_t end = attribute.find("!"); + string CDtype = attribute.substr(start + 6,end - start); + if( CDtype.find("name") != string::npos ) + { + if(card->target) + cd->compareName = card->target->name; + else + cd->compareName = card->name; + + cd->nameComparisonMode = COMPARISON_EQUAL; + } + else if( CDtype.find("color") != string::npos ) + { + for(int i = 0; i < Constants::MTG_NB_COLORS; i++) + { + if(card->target) + cd->colors[i] = card->target->colors[i]; + else + cd->colors[i] = card->colors[i]; + } + cd->mode = CD_OR; + } + else if( CDtype.find("types") != string::npos ) + { + if(card->target) + { + cd->types = card->target->types; + //remove main types because we only care about subtypes here. + cd->removeType("artifact"); + cd->removeType("land"); + cd->removeType("enchantment"); + cd->removeType("instant"); + cd->removeType("sorcery"); + cd->removeType("legendary"); + cd->removeType("creature"); + } + else + { + cd->types = card->types; + } + cd->mode = CD_OR; + } + } else if (attribute.find("counter") != string::npos) { if (attribute.find("{any}") != string::npos)