reverting changes made by request of Zethfox. code needs more testing.

This commit is contained in:
techdragon.nguyen
2010-09-24 11:26:35 +00:00
parent d3b96a8723
commit f7d2b774e3
+520 -124
View File
@@ -1477,130 +1477,526 @@ HUDDisplay::~HUDDisplay(){
a->isClone = 1; a->isClone = 1;
return a; return a;
} }
//------------------------------------------------------------------- //-------------------------------------------------------------------
//Affinity rule------------------------------------------------------ //Affinity rule------------------------------------------------------
//this rule is for Affinity cards. //this rule is for Affinity cards.
MTGAffinityRule::MTGAffinityRule(int _id):MTGAbility(_id,NULL){}; MTGAffinityRule::MTGAffinityRule(int _id):MTGAbility(_id,NULL){};
int MTGAffinityRule::receiveEvent(WEvent * event){ int MTGAffinityRule::receiveEvent(WEvent * event){
if (event->type == WEvent::CHANGE_ZONE){ if (event->type == WEvent::CHANGE_ZONE){
WEventZoneChange * e = (WEventZoneChange *) event; WEventZoneChange * e = (WEventZoneChange *) event;
MTGCardInstance * card = e->card->previous; MTGCardInstance * card = e->card->previous;
int color = -1;
string type = ""; //when cards with affinity enter you hand from anywhere a redux is applied to them for the artifacts in play.
int ok = 0; if(card && card->has(Constants::AFFINITYARTIFACTS)){
for (int i = 0; i < 2 ; i++){ int ok = 0;
Player * p = game->players[i]; for (int i = 0; i < 2 ; i++){
if (e->to == p->game->hand) ok = 1;//affinity card enters hand Player * p = game->players[i];
//--------- if (e->to == p->game->hand) ok = 3;//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(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){ 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;} //--redux effect
if(card && card->has(Constants::AFFINITYSWAMP)) {color = 0 ; type = "swamp";} MTGGameZone * z = card->controller()->game->battlefield;
if(card && card->has(Constants::AFFINITYMOUNTAIN)) {color = 0 ; type = "mountain";} int nbcards = z->nb_cards;
if(card && card->has(Constants::AFFINITYPLAINS)) {color = 0 ; type = "plains";} for (int j = 0; j < nbcards; ++j){
if(card && card->has(Constants::AFFINITYISLAND)) {color = 0 ; type = "island";} MTGCardInstance * c = z->cards[j];
if(card && card->has(Constants::AFFINITYFOREST)) {color = 0 ; type = "forest";} int check = e->card->getManaCost()->getConvertedCost();
if(card && card->has(Constants::AFFINITYGREENCREATURES)) {color = 1 ; type = "creature";} if (c->hasSubtype("artifact")){
//--redux effect if( check > 0){
MTGGameZone * z = card->controller()->game->battlefield; e->card->getManaCost()->remove(0,1);//one less colorless to cast
int nbcards = z->nb_cards; }
for (int j = 0; j < nbcards; ++j){ }
MTGCardInstance * c = z->cards[j]; }//--end of redux bracket
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 }//this bracket end first redux artifacts
e->card->getManaCost()->remove(color,1); //----------------------------------------
}//one less colorless to cast //the following handles redux of land affinities.
} if(card && card->has(Constants::AFFINITYSWAMP)){
} int ok = 0;
}//--end of redux bracket 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
//maintaining cost 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;
ok = 0; int nbcards = z->nb_cards;
for (int i = 0; i < 2 ; i++){ for (int j = 0; j < nbcards; ++j){
Player * p = game->players[i]; MTGCardInstance * c = z->cards[j];
if (e->to == p->game->battlefield) ok = 1; if (c->hasSubtype("swamp")){
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 e->card->getManaCost()->remove(0,1);//one less colorless to cast
//---------above are the triggers "to" markers... }
if(ok == 1){//enters play from anywhere }//--end of redux bracket
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;} }//this bracket end first redux swamp
if (card && card->hasSubtype("swamp")){affinitytype = Constants::AFFINITYSWAMP;} //----------------------------------------
if (card && card->hasSubtype("mountain")){affinitytype = Constants::AFFINITYMOUNTAIN;} if(card && card->has(Constants::AFFINITYMOUNTAIN)){
if (card && card->hasSubtype("plains")){affinitytype = Constants::AFFINITYPLAINS;} int ok = 0;
if (card && card->hasSubtype("island")){affinitytype = Constants::AFFINITYISLAND;} for (int i = 0; i < 2 ; i++){
if (card && card->hasSubtype("forest")){affinitytype = Constants::AFFINITYFOREST;} Player * p = game->players[i];
if (card && card->hasSubtype("creature") && card->hasColor(1)){affinitytype = Constants::AFFINITYGREENCREATURES; colored = 1;} if (e->to == p->game->hand) ok = 5;//affinity card enters hand
//---------
MTGGameZone * z = card->controller()->game->hand; if(ok == 5){//enters play from anywhere
int nbcards = z->nb_cards; 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){
for (int j = 0; j < nbcards; ++j){ //--redux effect
MTGCardInstance * c = z->cards[j]; MTGGameZone * z = card->controller()->game->battlefield;
if (c->has(affinitytype)){ int nbcards = z->nb_cards;
if(c->getManaCost()->getConvertedCost() > 0){ for (int j = 0; j < nbcards; ++j){
c->getManaCost()->remove(colored,1);//one less colorless to cast MTGCardInstance * c = z->cards[j];
}else{c->reduxamount += 1;} if (c->hasSubtype("mountain")){
} e->card->getManaCost()->remove(0,1);//one less colorless to cast
}//--end of redux bracket }
} }//--end of redux bracket
} }
//--------- }
if(ok == 2){//leave play from your battlefield //-------------
if (e->from == p->game->battlefield){ }
int affinitytype = 0; }//this bracket end first redux mountains
int colored = 0; //----------------------------------------
if (card && card->hasSubtype("artifact")){affinitytype = Constants::AFFINITYARTIFACTS;} if(card && card->has(Constants::AFFINITYPLAINS)){
if (card && card->hasSubtype("swamp")){affinitytype = Constants::AFFINITYSWAMP;} int ok = 0;
if (card && card->hasSubtype("mountain")){affinitytype = Constants::AFFINITYMOUNTAIN;} for (int i = 0; i < 2 ; i++){
if (card && card->hasSubtype("plains")){affinitytype = Constants::AFFINITYPLAINS;} Player * p = game->players[i];
if (card && card->hasSubtype("island")){affinitytype = Constants::AFFINITYISLAND;} if (e->to == p->game->hand) ok = 6;//affinity card enters hand
if (card && card->hasSubtype("forest")){affinitytype = Constants::AFFINITYFOREST;} //---------
if (card && card->hasSubtype("creature") && card->hasColor(1)){affinitytype = Constants::AFFINITYGREENCREATURES; colored = 1;} 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){
MTGGameZone * z = card->controller()->game->hand; //--redux effect
int nbcards = z->nb_cards; MTGGameZone * z = card->controller()->game->battlefield;
//check my battlefield and opponents int nbcards = z->nb_cards;
for (int j = 0; j < nbcards; ++j){ for (int j = 0; j < nbcards; ++j){
MTGCardInstance * c = z->cards[j]; MTGCardInstance * c = z->cards[j];
if (c->has(affinitytype)){ if (c->hasSubtype("plains")){
if(c->reduxamount > 0){ c->reduxamount -= 1;} e->card->getManaCost()->remove(0,1);//one less colorless to cast
else{ }
c->getManaCost()->add(colored,1); }//--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];
return 0; if (e->to == p->game->hand) ok = 7;//affinity card enters hand
} //---------
ostream& MTGAffinityRule::toString(ostream& out) const 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){
out << "MTGAffinityRule ::: ("; //--redux effect
return MTGAbility::toString(out) << ")"; MTGGameZone * z = card->controller()->game->battlefield;
} int nbcards = z->nb_cards;
int MTGAffinityRule::testDestroy(){return 0;} for (int j = 0; j < nbcards; ++j){
MTGAffinityRule * MTGAffinityRule::clone() const{ MTGCardInstance * c = z->cards[j];
MTGAffinityRule * a = NEW MTGAffinityRule(*this); if (c->hasSubtype("island")){
a->isClone = 1; e->card->getManaCost()->remove(0,1);//one less colorless to cast
return a; }
} }//--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){} MTGTokensCleanup::MTGTokensCleanup(int _id):MTGAbility(_id, NULL){}