diff --git a/projects/mtg/src/MTGRules.cpp b/projects/mtg/src/MTGRules.cpp index 4d820959a..3b994dbbd 100644 --- a/projects/mtg/src/MTGRules.cpp +++ b/projects/mtg/src/MTGRules.cpp @@ -1477,130 +1477,526 @@ HUDDisplay::~HUDDisplay(){ a->isClone = 1; return a; } - //------------------------------------------------------------------- - //Affinity rule------------------------------------------------------ -//this rule is for Affinity cards. - - MTGAffinityRule::MTGAffinityRule(int _id):MTGAbility(_id,NULL){}; - int MTGAffinityRule::receiveEvent(WEvent * event){ - if (event->type == WEvent::CHANGE_ZONE){ - WEventZoneChange * e = (WEventZoneChange *) event; - MTGCardInstance * card = e->card->previous; - int color = -1; - string type = ""; - int ok = 0; - for (int i = 0; i < 2 ; i++){ - Player * p = game->players[i]; - if (e->to == p->game->hand) ok = 1;//affinity card enters hand -//--------- -//when cards with affinity enter you hand from anywhere a redux is applied to them for the artifacts in play. - if(ok == 1){//enters play from anywhere - if (e->from == p->game->graveyard || e->from == p->game->hand || e->from == p->game->library || e->from == p->game->exile || e->from == p->game->stack || e->from == p->opponent()->game->battlefield || e->from == p->game->temp){ - if(card && card->has(Constants::AFFINITYARTIFACTS)) {color = 0 ; type = "artifact";ok = 1;} - if(card && card->has(Constants::AFFINITYSWAMP)) {color = 0 ; type = "swamp";} - if(card && card->has(Constants::AFFINITYMOUNTAIN)) {color = 0 ; type = "mountain";} - if(card && card->has(Constants::AFFINITYPLAINS)) {color = 0 ; type = "plains";} - if(card && card->has(Constants::AFFINITYISLAND)) {color = 0 ; type = "island";} - if(card && card->has(Constants::AFFINITYFOREST)) {color = 0 ; type = "forest";} - if(card && card->has(Constants::AFFINITYGREENCREATURES)) {color = 1 ; type = "creature";} - //--redux effect - MTGGameZone * z = card->controller()->game->battlefield; - int nbcards = z->nb_cards; - for (int j = 0; j < nbcards; ++j){ - MTGCardInstance * c = z->cards[j]; - int check = e->card->getManaCost()->getConvertedCost(); - if (c->hasSubtype(type)){ - if( check > 0){ - if(color > 0 && !c->hasColor(color)){//do nothing if its colored redux and the cards dont have the color - }else{//do normal redux - e->card->getManaCost()->remove(color,1); - }//one less colorless to cast - } - } - }//--end of redux bracket - } - } -//------------- - } - //maintaining cost - - - ok = 0; - for (int i = 0; i < 2 ; i++){ - Player * p = game->players[i]; - if (e->to == p->game->battlefield) ok = 1; - if (e->to == p->game->graveyard || e->to == p->game->hand || e->to == p->game->library || e->to == p->game->exile || e->to == p->game->stack || e->to == p->opponent()->game->battlefield) ok = 2;//artifact leaves play -//---------above are the triggers "to" markers... - if(ok == 1){//enters play from anywhere - if (e->from == p->game->graveyard || e->from == p->game->hand || e->from == p->game->library || e->from == p->game->exile || e->from == p->game->stack || e->from == p->opponent()->game->battlefield || e->from == p->game->temp){ - //--redux effect - int affinitytype = 0; - int colored = 0; - if (card && card->hasSubtype("artifact")){affinitytype = Constants::AFFINITYARTIFACTS;} - if (card && card->hasSubtype("swamp")){affinitytype = Constants::AFFINITYSWAMP;} - if (card && card->hasSubtype("mountain")){affinitytype = Constants::AFFINITYMOUNTAIN;} - if (card && card->hasSubtype("plains")){affinitytype = Constants::AFFINITYPLAINS;} - if (card && card->hasSubtype("island")){affinitytype = Constants::AFFINITYISLAND;} - if (card && card->hasSubtype("forest")){affinitytype = Constants::AFFINITYFOREST;} - if (card && card->hasSubtype("creature") && card->hasColor(1)){affinitytype = Constants::AFFINITYGREENCREATURES; colored = 1;} - - MTGGameZone * z = card->controller()->game->hand; - int nbcards = z->nb_cards; - for (int j = 0; j < nbcards; ++j){ - MTGCardInstance * c = z->cards[j]; - if (c->has(affinitytype)){ - if(c->getManaCost()->getConvertedCost() > 0){ - c->getManaCost()->remove(colored,1);//one less colorless to cast - }else{c->reduxamount += 1;} - } - }//--end of redux bracket - } - } -//--------- - if(ok == 2){//leave play from your battlefield - if (e->from == p->game->battlefield){ - int affinitytype = 0; - int colored = 0; - if (card && card->hasSubtype("artifact")){affinitytype = Constants::AFFINITYARTIFACTS;} - if (card && card->hasSubtype("swamp")){affinitytype = Constants::AFFINITYSWAMP;} - if (card && card->hasSubtype("mountain")){affinitytype = Constants::AFFINITYMOUNTAIN;} - if (card && card->hasSubtype("plains")){affinitytype = Constants::AFFINITYPLAINS;} - if (card && card->hasSubtype("island")){affinitytype = Constants::AFFINITYISLAND;} - if (card && card->hasSubtype("forest")){affinitytype = Constants::AFFINITYFOREST;} - if (card && card->hasSubtype("creature") && card->hasColor(1)){affinitytype = Constants::AFFINITYGREENCREATURES; colored = 1;} - //-- - MTGGameZone * z = card->controller()->game->hand; - int nbcards = z->nb_cards; - //check my battlefield and opponents - for (int j = 0; j < nbcards; ++j){ - MTGCardInstance * c = z->cards[j]; - if (c->has(affinitytype)){ - if(c->reduxamount > 0){ c->reduxamount -= 1;} - else{ - c->getManaCost()->add(colored,1); - } - } - } - //-- - } - } -//--------- - } - //---------------------------------------- - } - return 0; - } - ostream& MTGAffinityRule::toString(ostream& out) const - { - out << "MTGAffinityRule ::: ("; - return MTGAbility::toString(out) << ")"; - } - int MTGAffinityRule::testDestroy(){return 0;} - MTGAffinityRule * MTGAffinityRule::clone() const{ - MTGAffinityRule * a = NEW MTGAffinityRule(*this); - a->isClone = 1; - return a; - } + //------------------------------------------------------------------- + //Affinity rule------------------------------------------------------ +//this rule is for Affinity cards. + + MTGAffinityRule::MTGAffinityRule(int _id):MTGAbility(_id,NULL){}; + int MTGAffinityRule::receiveEvent(WEvent * event){ + if (event->type == WEvent::CHANGE_ZONE){ + WEventZoneChange * e = (WEventZoneChange *) event; + MTGCardInstance * card = e->card->previous; + +//when cards with affinity enter you hand from anywhere a redux is applied to them for the artifacts in play. + if(card && card->has(Constants::AFFINITYARTIFACTS)){ + int ok = 0; + for (int i = 0; i < 2 ; i++){ + Player * p = game->players[i]; + if (e->to == p->game->hand) ok = 3;//affinity card enters hand +//--------- + if(ok == 3){//enters play from anywhere + if (e->from == p->game->graveyard || e->from == p->game->hand || e->from == p->game->library || e->from == p->game->exile || e->from == p->game->stack || e->from == p->opponent()->game->battlefield || e->from == p->game->temp){ + //--redux effect + MTGGameZone * z = card->controller()->game->battlefield; + int nbcards = z->nb_cards; + for (int j = 0; j < nbcards; ++j){ + MTGCardInstance * c = z->cards[j]; + int check = e->card->getManaCost()->getConvertedCost(); + if (c->hasSubtype("artifact")){ + if( check > 0){ + e->card->getManaCost()->remove(0,1);//one less colorless to cast + } + } + }//--end of redux bracket + } + } +//------------- + } + }//this bracket end first redux artifacts + //---------------------------------------- + //the following handles redux of land affinities. + if(card && card->has(Constants::AFFINITYSWAMP)){ + int ok = 0; + for (int i = 0; i < 2 ; i++){ + Player * p = game->players[i]; + if (e->to == p->game->hand) ok = 4;//affinity card enters hand +//--------- + if(ok == 4){//enters play from anywhere + if (e->from == p->game->graveyard || e->from == p->game->hand || e->from == p->game->library || e->from == p->game->exile || e->from == p->game->stack || e->from == p->opponent()->game->battlefield || e->from == p->game->temp){ + //--redux effect + MTGGameZone * z = card->controller()->game->battlefield; + int nbcards = z->nb_cards; + for (int j = 0; j < nbcards; ++j){ + MTGCardInstance * c = z->cards[j]; + if (c->hasSubtype("swamp")){ + e->card->getManaCost()->remove(0,1);//one less colorless to cast + } + }//--end of redux bracket + } + } +//------------- + } + }//this bracket end first redux swamp + //---------------------------------------- + if(card && card->has(Constants::AFFINITYMOUNTAIN)){ + int ok = 0; + for (int i = 0; i < 2 ; i++){ + Player * p = game->players[i]; + if (e->to == p->game->hand) ok = 5;//affinity card enters hand +//--------- + if(ok == 5){//enters play from anywhere + if (e->from == p->game->graveyard || e->from == p->game->hand || e->from == p->game->library || e->from == p->game->exile || e->from == p->game->stack || e->from == p->opponent()->game->battlefield || e->from == p->game->temp){ + //--redux effect + MTGGameZone * z = card->controller()->game->battlefield; + int nbcards = z->nb_cards; + for (int j = 0; j < nbcards; ++j){ + MTGCardInstance * c = z->cards[j]; + if (c->hasSubtype("mountain")){ + e->card->getManaCost()->remove(0,1);//one less colorless to cast + } + }//--end of redux bracket + } + } +//------------- + } + }//this bracket end first redux mountains + //---------------------------------------- + if(card && card->has(Constants::AFFINITYPLAINS)){ + int ok = 0; + for (int i = 0; i < 2 ; i++){ + Player * p = game->players[i]; + if (e->to == p->game->hand) ok = 6;//affinity card enters hand +//--------- + if(ok == 6){//enters play from anywhere + if (e->from == p->game->graveyard || e->from == p->game->hand || e->from == p->game->library || e->from == p->game->exile || e->from == p->game->stack || e->from == p->opponent()->game->battlefield || e->from == p->game->temp){ + //--redux effect + MTGGameZone * z = card->controller()->game->battlefield; + int nbcards = z->nb_cards; + for (int j = 0; j < nbcards; ++j){ + MTGCardInstance * c = z->cards[j]; + if (c->hasSubtype("plains")){ + e->card->getManaCost()->remove(0,1);//one less colorless to cast + } + }//--end of redux bracket + } + } +//------------- + } + }//this bracket end first redux plains + //---------------------------------------- + if(card && card->has(Constants::AFFINITYISLAND)){ + int ok = 0; + for (int i = 0; i < 2 ; i++){ + Player * p = game->players[i]; + if (e->to == p->game->hand) ok = 7;//affinity card enters hand +//--------- + if(ok == 7){//enters play from anywhere + if (e->from == p->game->graveyard || e->from == p->game->hand || e->from == p->game->library || e->from == p->game->exile || e->from == p->game->stack || e->from == p->opponent()->game->battlefield || e->from == p->game->temp){ + //--redux effect + MTGGameZone * z = card->controller()->game->battlefield; + int nbcards = z->nb_cards; + for (int j = 0; j < nbcards; ++j){ + MTGCardInstance * c = z->cards[j]; + if (c->hasSubtype("island")){ + e->card->getManaCost()->remove(0,1);//one less colorless to cast + } + }//--end of redux bracket + } + } +//------------- + } + }//this bracket end first redux island + //---------------------------------------- + if(card && card->has(Constants::AFFINITYFOREST)){ + int ok = 0; + for (int i = 0; i < 2 ; i++){ + Player * p = game->players[i]; + if (e->to == p->game->hand) ok = 8;//affinity card enters hand +//--------- + if(ok == 8){//enters play from anywhere + if (e->from == p->game->graveyard || e->from == p->game->hand || e->from == p->game->library || e->from == p->game->exile || e->from == p->game->stack || e->from == p->opponent()->game->battlefield || e->from == p->game->temp){ + //--redux effect + MTGGameZone * z = card->controller()->game->battlefield; + int nbcards = z->nb_cards; + for (int j = 0; j < nbcards; ++j){ + MTGCardInstance * c = z->cards[j]; + if (c->hasSubtype("forest")){ + e->card->getManaCost()->remove(0,1);//one less colorless to cast + } + }//--end of redux bracket + } + } +//------------- + } + }//this bracket end first redux forest + //---------------------------------------- + if(card && card->has(Constants::AFFINITYGREENCREATURES)){ + int ok = 0; + for (int i = 0; i < 2 ; i++){ + Player * p = game->players[i]; + if (e->to == p->game->hand) ok = 21;//affinity card enters hand +//--------- + if(ok == 21){//enters play from anywhere + if (e->from == p->game->graveyard || e->from == p->game->hand || e->from == p->game->library || e->from == p->game->exile || e->from == p->game->stack || e->from == p->opponent()->game->battlefield || e->from == p->game->temp){ + //--redux effect + MTGGameZone * z = card->controller()->game->battlefield; + int nbcards = z->nb_cards; + for (int j = 0; j < nbcards; ++j){ + MTGCardInstance * c = z->cards[j]; + if (c->hasSubtype("creature") && c->hasColor(1)){ + e->card->getManaCost()->remove(1,1);//one less colorless to cast + } + }//--end of redux bracket + } + } +//------------- + } + }//this bracket end first redux greencreatures + //---------------------------------------- + + + + //section 2, maintaining proper manacost +//---------this section takes care of increasing and reducing cost when artifacts enter or leave play + if (card && card->hasSubtype("artifact")){ + int ok = 0; + for (int i = 0; i < 2 ; i++){ + Player * p = game->players[i]; + if (e->to == p->game->battlefield) ok = 1;//artifact enters play in your battlefield + if (e->to == p->game->graveyard || e->to == p->game->hand || e->to == p->game->library || e->to == p->game->exile || e->to == p->game->stack || e->to == p->opponent()->game->battlefield) ok = 2;//artifact leaves play +//---------above are the triggers "to" markers... + if(ok == 1){//enters play from anywhere + if (e->from == p->game->graveyard || e->from == p->game->hand || e->from == p->game->library || e->from == p->game->exile || e->from == p->game->stack || e->from == p->opponent()->game->battlefield || e->from == p->game->temp){ + //--redux effect + MTGGameZone * z = card->controller()->game->hand; + int nbcards = z->nb_cards; + for (int j = 0; j < nbcards; ++j){ + MTGCardInstance * c = z->cards[j]; + if (c->has(Constants::AFFINITYARTIFACTS)){ + if(c->getManaCost()->getConvertedCost() > 0){ + c->getManaCost()->remove(0,1);//one less colorless to cast + }else{c->reduxamount += 1;} + } + }//--end of redux bracket + } + } +//--------- + if(ok == 2){//leave play from your battlefield + if (e->from == p->game->battlefield){ + //-- + MTGGameZone * z = card->controller()->game->hand; + int nbcards = z->nb_cards; + //check my battlefield and opponents + for (int j = 0; j < nbcards; ++j){ + MTGCardInstance * c = z->cards[j]; + if (c->has(Constants::AFFINITYARTIFACTS)){ + if(c->reduxamount > 0){ + c->reduxamount -= 1;}else{ + c->getManaCost()->add(0,1); + } + } + } + //-- + } + } +//--------- + } + }//this bracket ends check for artifacts + //---------------------------------------- +//the following maintains cost other then artifacts +//----swamps + if (card && card->hasSubtype("swamp")){ + int ok = 0; + for (int i = 0; i < 2 ; i++){ + Player * p = game->players[i]; + if (e->to == p->game->battlefield) ok = 9;//swamp enters play in your battlefield + if (e->to == p->game->graveyard || e->to == p->game->hand || e->to == p->game->library || e->to == p->game->exile || e->to == p->game->stack || e->to == p->opponent()->game->battlefield) ok = 10;//artifact leaves play +//---------above are the triggers "to" markers... + if(ok == 9){//enters play from anywhere + if (e->from == p->game->graveyard || e->from == p->game->hand || e->from == p->game->library || e->from == p->game->exile || e->from == p->game->stack || e->from == p->opponent()->game->battlefield || e->from == p->game->temp){ + //--redux effect + MTGGameZone * z = card->controller()->game->hand; + int nbcards = z->nb_cards; + for (int j = 0; j < nbcards; ++j){ + MTGCardInstance * c = z->cards[j]; + if (c->has(Constants::AFFINITYSWAMP)){ + if(c->getManaCost()->getConvertedCost() > 0){ + c->getManaCost()->remove(0,1);//one less colorless to cast + }else{c->reduxamount += 1;} + } + }//--end of redux bracket + } + } +//--------- + if(ok == 10){//leave play from your battlefield + if (e->from == p->game->battlefield){ + //-- + MTGGameZone * z = card->controller()->game->hand; + int nbcards = z->nb_cards; + //check my battlefield and opponents + for (int j = 0; j < nbcards; ++j){ + MTGCardInstance * c = z->cards[j]; + if (c->has(Constants::AFFINITYSWAMP)){ + if(c->reduxamount > 0){ c->reduxamount -= 1;} + else{ + c->getManaCost()->add(0,1); + } + } + } + //-- + } + } +//--------- + } + }//this bracket ends check for swamps + //---------------------------------------- +//----mountain + if (card && card->hasSubtype("mountain")){ + int ok = 0; + for (int i = 0; i < 2 ; i++){ + Player * p = game->players[i]; + if (e->to == p->game->battlefield) ok = 11;//moutain enters play in your battlefield + if (e->to == p->game->graveyard || e->to == p->game->hand || e->to == p->game->library || e->to == p->game->exile || e->to == p->game->stack || e->to == p->opponent()->game->battlefield) ok = 12;//artifact leaves play +//---------above are the triggers "to" markers... + if(ok == 11){//enters play from anywhere + if (e->from == p->game->graveyard || e->from == p->game->hand || e->from == p->game->library || e->from == p->game->exile || e->from == p->game->stack || e->from == p->opponent()->game->battlefield || e->from == p->game->temp){ + //--redux effect + MTGGameZone * z = card->controller()->game->hand; + int nbcards = z->nb_cards; + for (int j = 0; j < nbcards; ++j){ + MTGCardInstance * c = z->cards[j]; + if (c->has(Constants::AFFINITYMOUNTAIN)){ + if(c->getManaCost()->getConvertedCost() > 0){ + c->getManaCost()->remove(0,1);//one less colorless to cast + }else{c->reduxamount += 1;} + } + }//--end of redux bracket + } + } +//--------- + if(ok == 12){//leave play from your battlefield + if (e->from == p->game->battlefield){ + //-- + MTGGameZone * z = card->controller()->game->hand; + int nbcards = z->nb_cards; + //check my battlefield and opponents + for (int j = 0; j < nbcards; ++j){ + MTGCardInstance * c = z->cards[j]; + if (c->has(Constants::AFFINITYMOUNTAIN)){ + if(c->reduxamount > 0){c->reduxamount -= 1;} + else{ + c->getManaCost()->add(0,1); + } + } + } + //-- + } + } +//--------- + } + }//this bracket ends check for mountains + //---------------------------------------- +//----plains + if (card && card->hasSubtype("plains")){ + int ok = 0; + for (int i = 0; i < 2 ; i++){ + Player * p = game->players[i]; + if (e->to == p->game->battlefield) ok = 13;//plains enters play in your battlefield + if (e->to == p->game->graveyard || e->to == p->game->hand || e->to == p->game->library || e->to == p->game->exile || e->to == p->game->stack || e->to == p->opponent()->game->battlefield) ok = 14;//artifact leaves play +//---------above are the triggers "to" markers... + if(ok == 13){//enters play from anywhere + if (e->from == p->game->graveyard || e->from == p->game->hand || e->from == p->game->library || e->from == p->game->exile || e->from == p->game->stack || e->from == p->opponent()->game->battlefield || e->from == p->game->temp){ + //--redux effect + MTGGameZone * z = card->controller()->game->hand; + int nbcards = z->nb_cards; + for (int j = 0; j < nbcards; ++j){ + MTGCardInstance * c = z->cards[j]; + if (c->has(Constants::AFFINITYPLAINS)){ + if(c->getManaCost()->getConvertedCost() > 0){ + c->getManaCost()->remove(0,1);//one less colorless to cast + }else{c->reduxamount += 1;} + } + }//--end of redux bracket + } + } +//--------- + if(ok == 14){//leave play from your battlefield + if (e->from == p->game->battlefield){ + //-- + MTGGameZone * z = card->controller()->game->hand; + int nbcards = z->nb_cards; + //check my battlefield and opponents + for (int j = 0; j < nbcards; ++j){ + MTGCardInstance * c = z->cards[j]; + if (c->has(Constants::AFFINITYPLAINS)){ + if(c->reduxamount > 0){c->reduxamount -= 1;} + else{ + c->getManaCost()->add(0,1); + } + } + } + //-- + } + } +//--------- + } + }//this bracket ends check for plains + //---------------------------------------- +//----island + if (card && card->hasSubtype("island")){ + int ok = 0; + for (int i = 0; i < 2 ; i++){ + Player * p = game->players[i]; + if (e->to == p->game->battlefield) ok = 15;//island enters play in your battlefield + + if (e->to == p->game->graveyard || e->to == p->game->hand || e->to == p->game->library || e->to == p->game->exile || e->to == p->game->stack || e->to == p->opponent()->game->battlefield) ok = 16;//artifact leaves play +//---------above are the triggers "to" markers... + if(ok == 15){//enters play from anywhere + if (e->from == p->game->graveyard || e->from == p->game->hand || e->from == p->game->library || e->from == p->game->exile || e->from == p->game->stack || e->from == p->opponent()->game->battlefield || e->from == p->game->temp){ + //--redux effect + MTGGameZone * z = card->controller()->game->hand; + int nbcards = z->nb_cards; + for (int j = 0; j < nbcards; ++j){ + MTGCardInstance * c = z->cards[j]; + if (c->has(Constants::AFFINITYISLAND)){ + if(c->getManaCost()->getConvertedCost() > 0){ + c->getManaCost()->remove(0,1);//one less colorless to cast + }else{c->reduxamount += 1;} + } + }//--end of redux bracket + } + } +//--------- + if(ok == 16){//leave play from your battlefield + if (e->from == p->game->battlefield){ + //-- + MTGGameZone * z = card->controller()->game->hand; + int nbcards = z->nb_cards; + //check my battlefield and opponents + for (int j = 0; j < nbcards; ++j){ + MTGCardInstance * c = z->cards[j]; + if (c->has(Constants::AFFINITYISLAND)){ + if(c->reduxamount > 0){c->reduxamount -= 1;} + else{ + c->getManaCost()->add(0,1); + } + } + } + //-- + } + } +//--------- + } + }//this bracket ends check for islands + //---------------------------------------- +//----forest + if (card && card->hasSubtype("forest")){ + int ok = 0; + for (int i = 0; i < 2 ; i++){ + Player * p = game->players[i]; + if (e->to == p->game->battlefield) ok = 17;//island enters play in your battlefield + + if (e->to == p->game->graveyard || e->to == p->game->hand || e->to == p->game->library || e->to == p->game->exile || e->to == p->game->stack || e->to == p->opponent()->game->battlefield) ok = 18;//artifact leaves play +//---------above are the triggers "to" markers... + if(ok == 17){//enters play from anywhere + if (e->from == p->game->graveyard || e->from == p->game->hand || e->from == p->game->library || e->from == p->game->exile || e->from == p->game->stack || e->from == p->opponent()->game->battlefield || e->from == p->game->temp){ + //--redux effect + MTGGameZone * z = card->controller()->game->hand; + int nbcards = z->nb_cards; + for (int j = 0; j < nbcards; ++j){ + MTGCardInstance * c = z->cards[j]; + if (c->has(Constants::AFFINITYFOREST)){ + if(c->getManaCost()->getConvertedCost() > 0){ + c->getManaCost()->remove(0,1);//one less colorless to cast + }else{c->reduxamount += 1;} + } + }//--end of redux bracket + } + } +//--------- + if(ok == 18){//leave play from your battlefield + if (e->from == p->game->battlefield){ + //-- + MTGGameZone * z = card->controller()->game->hand; + int nbcards = z->nb_cards; + //check my battlefield and opponents + for (int j = 0; j < nbcards; ++j){ + MTGCardInstance * c = z->cards[j]; + if (c->has(Constants::AFFINITYFOREST)){ + if(c->reduxamount > 0){c->reduxamount -= 1;} + else{ + c->getManaCost()->add(0,1); + } + } + } + //-- + } + } +//--------- + } + }//this bracket ends check for forest + //---------------------------------------- + //----greencreatureaffinity + if (card && card->hasSubtype("creature") && card->hasColor(1)){ + int ok = 0; + for (int i = 0; i < 2 ; i++){ + Player * p = game->players[i]; + if (e->to == p->game->battlefield) ok = 19;//island enters play in your battlefield + + if (e->to == p->game->graveyard || e->to == p->game->hand || e->to == p->game->library || e->to == p->game->exile || e->to == p->game->stack || e->to == p->opponent()->game->battlefield) ok = 20;//artifact leaves play +//---------above are the triggers "to" markers... + if(ok == 19){//enters play from anywhere + if (e->from == p->game->graveyard || e->from == p->game->hand || e->from == p->game->library || e->from == p->game->exile || e->from == p->game->stack || e->from == p->opponent()->game->battlefield || e->from == p->game->temp){ + //--redux effect + MTGGameZone * z = card->controller()->game->hand; + int nbcards = z->nb_cards; + for (int j = 0; j < nbcards; ++j){ + MTGCardInstance * c = z->cards[j]; + if (c->has(Constants::AFFINITYGREENCREATURES)){ + if(c->getManaCost()->getConvertedCost() > 0){ + c->getManaCost()->remove(1,1);//one less colorless to cast + }else{c->reduxamount += 1;} + } + }//--end of redux bracket + } + } +//--------- + if(ok == 20){//leave play from your battlefield + if (e->from == p->game->battlefield){ + //-- + MTGGameZone * z = card->controller()->game->hand; + int nbcards = z->nb_cards; + //check my battlefield and opponents + for (int j = 0; j < nbcards; ++j){ + MTGCardInstance * c = z->cards[j]; + if (c->has(Constants::AFFINITYGREENCREATURES)){ + if(c->reduxamount > 0){c->reduxamount -= 1;} + else{ + c->getManaCost()->add(1,1); + } + } + } + //-- + } + } +//--------- + } + }//this bracket ends check for greencreatures + //---------------------------------------- + } + return 0; + } + ostream& MTGAffinityRule::toString(ostream& out) const + { + out << "MTGAffinityRule ::: ("; + return MTGAbility::toString(out) << ")"; + } + int MTGAffinityRule::testDestroy(){return 0;} + MTGAffinityRule * MTGAffinityRule::clone() const{ + MTGAffinityRule * a = NEW MTGAffinityRule(*this); + a->isClone = 1; + return a; + } //------------------------------------------------------------------- MTGTokensCleanup::MTGTokensCleanup(int _id):MTGAbility(_id, NULL){}