Erwan
-fixed "lord changes controller" bug
This commit is contained in:
@@ -14,18 +14,18 @@ ExtraCost::~ExtraCost(){
|
||||
|
||||
int ExtraCost::setSource(MTGCardInstance * _source){
|
||||
source=_source;
|
||||
if (tc){ tc->source = _source;}
|
||||
if (tc){ tc->source = _source; tc->targetter = _source;}
|
||||
return 1;
|
||||
}
|
||||
|
||||
SacrificeCost::SacrificeCost(TargetChooser *_tc):ExtraCost(_tc){
|
||||
if (tc) tc->source = NULL; //Sacrificing is not targetting, protections do not apply
|
||||
if (tc) tc->targetter = NULL; //Sacrificing is not targetting, protections do not apply
|
||||
target = NULL;
|
||||
}
|
||||
|
||||
int SacrificeCost::setSource(MTGCardInstance * card){
|
||||
ExtraCost::setSource(card);
|
||||
if (tc) tc->source = NULL; //Sacrificing is not targetting, protections do not apply
|
||||
if (tc) tc->targetter = NULL; //Sacrificing is not targetting, protections do not apply
|
||||
if (!tc) target = card;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -36,8 +36,8 @@ int AbilityFactory::countCards(TargetChooser * tc, Player * player, int option){
|
||||
}
|
||||
|
||||
int AbilityFactory::destroyAllInPlay(TargetChooser * tc, int bury){
|
||||
MTGCardInstance * source = tc->source;
|
||||
tc->source = NULL; // This is to prevent protection from... as objects that destroy all do not actually target
|
||||
MTGCardInstance * targetter = tc->targetter;
|
||||
tc->targetter = NULL; // This is to prevent protection from... as objects that destroy all do not actually target
|
||||
GameObserver * game = GameObserver::GetInstance();
|
||||
for (int i = 0; i < 2 ; i++){
|
||||
Player * p = game->players[i];
|
||||
@@ -49,7 +49,7 @@ int AbilityFactory::destroyAllInPlay(TargetChooser * tc, int bury){
|
||||
}
|
||||
}
|
||||
}
|
||||
tc->source = source; //restore source
|
||||
tc->targetter = targetter; //restore targetter
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -67,25 +67,25 @@ int AbilityFactory::CantBlock(TargetChooser * tc){
|
||||
}
|
||||
|
||||
int AbilityFactory::damageAll(TargetChooser * tc, int damage){
|
||||
MTGCardInstance * source = tc->source;
|
||||
tc->source = NULL; // This is to prevent protection from... as objects that destroy all do not actually target
|
||||
MTGCardInstance * targetter = tc->targetter;
|
||||
tc->targetter = NULL; // This is to prevent protection from... as objects that destroy all do not actually target
|
||||
GameObserver * g = GameObserver::GetInstance();
|
||||
for (int i = 0; i < 2 ; i++){
|
||||
if (tc->canTarget(g->players[i])) g->mLayers->stackLayer()->addDamage(source,g->players[i], damage);
|
||||
if (tc->canTarget(g->players[i])) g->mLayers->stackLayer()->addDamage(tc->source,g->players[i], damage);
|
||||
for (int j = g->players[i]->game->inPlay->nb_cards-1; j >=0 ; j--){
|
||||
MTGCardInstance * current = g->players[i]->game->inPlay->cards[j];
|
||||
if (tc->canTarget(current)){
|
||||
g->mLayers->stackLayer()->addDamage(source,current, damage);
|
||||
g->mLayers->stackLayer()->addDamage(tc->source,current, damage);
|
||||
}
|
||||
}
|
||||
}
|
||||
tc->source = source; //restore source
|
||||
tc->targetter = targetter; //restore source
|
||||
return 1;
|
||||
}
|
||||
|
||||
int AbilityFactory::moveAll(TargetChooser * tc, string destinationZone){
|
||||
MTGCardInstance * source = tc->source;
|
||||
tc->source = NULL; // This is to prevent protection from... as objects that destroy all do not actually target
|
||||
MTGCardInstance * targetter = tc->targetter;
|
||||
tc->targetter = NULL; // This is to prevent protection from... as objects that destroy all do not actually target
|
||||
GameObserver * g = GameObserver::GetInstance();
|
||||
for (int i = 0; i < 2 ; i++){
|
||||
MTGGameZone * zones[] = {g->players[i]->game->inPlay,g->players[i]->game->graveyard,g->players[i]->game->hand};
|
||||
@@ -93,12 +93,12 @@ int AbilityFactory::moveAll(TargetChooser * tc, string destinationZone){
|
||||
for (int j = zones[k]->nb_cards-1; j >=0 ; j--){
|
||||
MTGCardInstance * current = zones[k]->cards[j];
|
||||
if (tc->canTarget(current)){
|
||||
AZoneMover::moveTarget(current,destinationZone , source);
|
||||
AZoneMover::moveTarget(current,destinationZone , tc->source);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
tc->source = source; //restore source
|
||||
tc->targetter = targetter; //restore source
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -106,8 +106,8 @@ int AbilityFactory::moveAll(TargetChooser * tc, string destinationZone){
|
||||
|
||||
|
||||
int AbilityFactory::TapAll(TargetChooser * tc){
|
||||
MTGCardInstance * source = tc->source;
|
||||
tc->source = NULL; // This is to prevent protection from...
|
||||
MTGCardInstance * targetter = tc->targetter;
|
||||
tc->targetter = NULL; // This is to prevent protection from...
|
||||
GameObserver * g = GameObserver::GetInstance();
|
||||
for (int i = 0; i < 2 ; i++){
|
||||
for (int j = g->players[i]->game->inPlay->nb_cards-1; j >=0 ; j--){
|
||||
@@ -117,13 +117,13 @@ int AbilityFactory::TapAll(TargetChooser * tc){
|
||||
}
|
||||
}
|
||||
}
|
||||
tc->source = source; //restore source
|
||||
tc->targetter = targetter; //restore source
|
||||
return 1;
|
||||
}
|
||||
|
||||
int AbilityFactory::UntapAll(TargetChooser * tc){
|
||||
MTGCardInstance * source = tc->source;
|
||||
tc->source = NULL; // This is to prevent protection from...
|
||||
MTGCardInstance * targetter = tc->targetter;
|
||||
tc->targetter = NULL; // This is to prevent protection from...
|
||||
GameObserver * g = GameObserver::GetInstance();
|
||||
for (int i = 0; i < 2 ; i++){
|
||||
for (int j = g->players[i]->game->inPlay->nb_cards-1; j >=0 ; j--){
|
||||
@@ -133,7 +133,7 @@ int AbilityFactory::UntapAll(TargetChooser * tc){
|
||||
}
|
||||
}
|
||||
}
|
||||
tc->source = source; //restore source
|
||||
tc->targetter = targetter; //restore source
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -138,10 +138,17 @@ MTGCardInstance * MTGPlayerCards::putInZone(MTGCardInstance * card, MTGGameZone
|
||||
GameObserver *g = GameObserver::GetInstance();
|
||||
if (!from || !to) return card; //Error check
|
||||
|
||||
if ((copy = from->removeCard(card))){
|
||||
int doCopy = 1;
|
||||
//When a card is moved from inPlay to inPlay (controller change, for example), it is still the same object
|
||||
if ((to == g->players[0]->game->inPlay || to == g->players[1]->game->inPlay) &&
|
||||
(from == g->players[0]->game->inPlay || from == g->players[1]->game->inPlay)){
|
||||
doCopy = 0;
|
||||
}
|
||||
|
||||
if ((copy = from->removeCard(card,doCopy))){
|
||||
|
||||
if (GameOptions::GetInstance()->values[OPTIONS_SFXVOLUME].getIntValue() > 0){
|
||||
if (to == graveyard){
|
||||
if (to == g->players[0]->game->graveyard || to == g->players[1]->game->graveyard){
|
||||
if (card->isACreature()){
|
||||
JSample * sample = SampleCache::GetInstance()->getSample("sound/sfx/graveyard.wav");
|
||||
if (sample) JSoundSystem::GetInstance()->PlaySample(sample);
|
||||
@@ -387,7 +394,7 @@ void MTGLibrary::shuffleTopToBottom(int nbcards){
|
||||
}
|
||||
|
||||
|
||||
MTGGameZone * MTGGameZone::stringToZone(string zoneName, MTGCardInstance * source,MTGCardInstance * target){
|
||||
MTGGameZone * MTGGameZone::intToZone(int zoneId, MTGCardInstance * source,MTGCardInstance * target){
|
||||
Player *p, *p2;
|
||||
GameObserver * g = GameObserver::GetInstance();
|
||||
if (!source) p = g->currentlyActing();
|
||||
@@ -397,53 +404,167 @@ MTGGameZone * MTGGameZone::stringToZone(string zoneName, MTGCardInstance * sourc
|
||||
target = source;//hack ?
|
||||
}
|
||||
else p2 = target->controller();
|
||||
if(zoneName.compare("mygraveyard") == 0)return p->game->graveyard;
|
||||
if(zoneName.compare("opponentgraveyard") == 0) return p->opponent()->game->graveyard;
|
||||
if(zoneName.compare("targetownergraveyard") == 0) return target->owner->game->graveyard;
|
||||
if(zoneName.compare("targetcontrollergraveyard") == 0) return p2->game->graveyard;
|
||||
if(zoneName.compare("ownergraveyard") == 0) return target->owner->game->graveyard;
|
||||
if(zoneName.compare("graveyard") == 0) return target->owner->game->graveyard;
|
||||
|
||||
if(zoneName.compare("myinplay") == 0)return p->game->inPlay;
|
||||
if(zoneName.compare("opponentinplay") == 0) return p->opponent()->game->inPlay;
|
||||
if(zoneName.compare("targetownerinplay") == 0) return target->owner->game->inPlay;
|
||||
if(zoneName.compare("targetcontrollerinplay") == 0) return p2->game->inPlay;
|
||||
if(zoneName.compare("ownerinplay") == 0) return target->owner->game->inPlay;
|
||||
if(zoneName.compare("inplay") == 0) return p->game->inPlay;
|
||||
switch(zoneId){
|
||||
case MY_GRAVEYARD: return p->game->graveyard;
|
||||
case OPPONENT_GRAVEYARD: return p->opponent()->game->graveyard;
|
||||
case TARGET_OWNER_GRAVEYARD : return target->owner->game->graveyard;
|
||||
case TARGET_CONTROLLER_GRAVEYARD: return p2->game->graveyard;
|
||||
case GRAVEYARD : return target->owner->game->graveyard;
|
||||
case OWNER_GRAVEYARD : return target->owner->game->graveyard;
|
||||
|
||||
if(zoneName.compare("mybattlefield") == 0)return p->game->inPlay;
|
||||
if(zoneName.compare("opponentbattlefield") == 0) return p->opponent()->game->inPlay;
|
||||
if(zoneName.compare("targetownerbattlefield") == 0) return target->owner->game->inPlay;
|
||||
if(zoneName.compare("targetcontrollerbattlefield") == 0) return p2->game->inPlay;
|
||||
if(zoneName.compare("ownerbattlefield") == 0) return target->owner->game->inPlay;
|
||||
if(zoneName.compare("battlefield") == 0) return p->game->inPlay;
|
||||
case MY_BATTLEFIELD : return p->game->inPlay;
|
||||
case OPPONENT_BATTLEFIELD : return p->opponent()->game->inPlay;
|
||||
case TARGET_OWNER_BATTLEFIELD : return target->owner->game->inPlay;
|
||||
case TARGET_CONTROLLER_BATTLEFIELD : return p2->game->inPlay;
|
||||
case BATTLEFIELD : return p->game->inPlay;
|
||||
case OWNER_BATTLEFIELD : return target->owner->game->inPlay;
|
||||
|
||||
if(zoneName.compare("myhand") == 0)return p->game->hand;
|
||||
if(zoneName.compare("opponenthand") == 0) return p->opponent()->game->hand;
|
||||
if(zoneName.compare("targetcontrollerhand") == 0) return p2->game->hand;
|
||||
if(zoneName.compare("targetownerhand") == 0) return target->owner->game->hand;
|
||||
if(zoneName.compare("ownerhand") == 0) return target->owner->game->hand;
|
||||
if(zoneName.compare("hand") == 0) return target->owner->game->hand;
|
||||
case MY_HAND : return p->game->hand;
|
||||
case OPPONENT_HAND : return p->opponent()->game->hand;
|
||||
case TARGET_OWNER_HAND : return target->owner->game->hand;
|
||||
case TARGET_CONTROLLER_HAND : return p2->game->hand;
|
||||
case HAND : return target->owner->game->hand;
|
||||
case OWNER_HAND : return target->owner->game->hand;
|
||||
|
||||
if(zoneName.compare("myremovedfromgame") == 0)return p->game->removedFromGame;
|
||||
if(zoneName.compare("opponentremovedfromgame") == 0) return p->opponent()->game->removedFromGame;
|
||||
if(zoneName.compare("targetcontrollerremovedfromgame") == 0) return p2->game->removedFromGame;
|
||||
if(zoneName.compare("targetownerremovedfromgame") == 0) return target->owner->game->removedFromGame;
|
||||
if(zoneName.compare("ownerremovedfromgame") == 0) return target->owner->game->removedFromGame;
|
||||
if(zoneName.compare("removedfromgame") == 0) return target->owner->game->removedFromGame;
|
||||
case MY_EXILE : return p->game->removedFromGame;
|
||||
case OPPONENT_EXILE : return p->opponent()->game->removedFromGame;
|
||||
case TARGET_OWNER_EXILE : return target->owner->game->removedFromGame;
|
||||
case TARGET_CONTROLLER_EXILE : return p2->game->removedFromGame;
|
||||
case EXILE : return target->owner->game->removedFromGame;
|
||||
case OWNER_EXILE : return target->owner->game->removedFromGame;
|
||||
|
||||
if(zoneName.compare("myexile") == 0)return p->game->removedFromGame;
|
||||
if(zoneName.compare("opponentexile") == 0) return p->opponent()->game->removedFromGame;
|
||||
if(zoneName.compare("targetcontrollerexile") == 0) return p2->game->removedFromGame;
|
||||
if(zoneName.compare("targetownerexile") == 0) return target->owner->game->removedFromGame;
|
||||
if(zoneName.compare("ownerexile") == 0) return target->owner->game->removedFromGame;
|
||||
if(zoneName.compare("exile") == 0) return target->owner->game->removedFromGame;
|
||||
case MY_LIBRARY : return p->game->library;
|
||||
case OPPONENT_LIBRARY : return p->opponent()->game->library;
|
||||
case TARGET_OWNER_LIBRARY : return target->owner->game->library;
|
||||
case TARGET_CONTROLLER_LIBRARY : return p2->game->library;
|
||||
case LIBRARY : return p->game->library;
|
||||
case OWNER_LIBRARY: return target->owner->game->library;
|
||||
|
||||
if(zoneName.compare("mylibrary") == 0)return p->game->library;
|
||||
if(zoneName.compare("opponentlibrary") == 0) return p->opponent()->game->library;
|
||||
if(zoneName.compare("targetownerlibrary") == 0) return target->owner->game->library;
|
||||
if(zoneName.compare("targetcontrollerlibrary") == 0) return p2->game->library;
|
||||
if(zoneName.compare("ownerlibrary") == 0) return target->owner->game->library;
|
||||
if(zoneName.compare("library") == 0) return p->game->library;
|
||||
return NULL;
|
||||
case MY_STACK : return p->game->stack;
|
||||
case OPPONENT_STACK : return p->opponent()->game->stack;
|
||||
case TARGET_OWNER_STACK : return target->owner->game->stack;
|
||||
case TARGET_CONTROLLER_STACK : return p2->game->stack;
|
||||
case STACK : return p->game->stack;
|
||||
case OWNER_STACK: return target->owner->game->stack;
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
int MTGGameZone::zoneStringToId(string zoneName){
|
||||
const char * strings[] = {
|
||||
"mygraveyard",
|
||||
"opponentgraveyard",
|
||||
"targetownergraveyard",
|
||||
"targetcontrollergraveyard",
|
||||
"ownergraveyard",
|
||||
"graveyard",
|
||||
|
||||
"myinplay",
|
||||
"opponentinplay",
|
||||
"targetownerinplay",
|
||||
"targetcontrollerinplay",
|
||||
"ownerinplay",
|
||||
"inplay",
|
||||
|
||||
"mybattlefield",
|
||||
"opponentbattlefield",
|
||||
"targetownerbattlefield",
|
||||
"targetcontrollerbattlefield",
|
||||
"ownerbattlefield",
|
||||
"battlefield",
|
||||
|
||||
"myhand",
|
||||
"opponenthand",
|
||||
"targetownerhand",
|
||||
"targetcontrollerhand",
|
||||
"ownerhand",
|
||||
"hand",
|
||||
|
||||
"mylibrary",
|
||||
"opponentlibrary",
|
||||
"targetownerlibrary",
|
||||
"targetcontrollerlibrary",
|
||||
"ownerlibrary",
|
||||
"library",
|
||||
|
||||
"myremovedfromgame",
|
||||
"opponentremovedfromgame",
|
||||
"targetownerremovedfromgame",
|
||||
"targetcontrollerremovedfromgame",
|
||||
"ownerremovedfromgame",
|
||||
"removedfromgame",
|
||||
|
||||
"myexile",
|
||||
"opponentexile",
|
||||
"targetownerexile",
|
||||
"targetcontrollerexile",
|
||||
"ownerexile",
|
||||
"exile",
|
||||
};
|
||||
|
||||
int values[] = {
|
||||
MY_GRAVEYARD,
|
||||
OPPONENT_GRAVEYARD,
|
||||
TARGET_OWNER_GRAVEYARD ,
|
||||
TARGET_CONTROLLER_GRAVEYARD,
|
||||
OWNER_GRAVEYARD ,
|
||||
GRAVEYARD,
|
||||
|
||||
MY_BATTLEFIELD,
|
||||
OPPONENT_BATTLEFIELD,
|
||||
TARGET_OWNER_BATTLEFIELD ,
|
||||
TARGET_CONTROLLER_BATTLEFIELD,
|
||||
OWNER_BATTLEFIELD ,
|
||||
BATTLEFIELD,
|
||||
|
||||
MY_BATTLEFIELD,
|
||||
OPPONENT_BATTLEFIELD,
|
||||
TARGET_OWNER_BATTLEFIELD ,
|
||||
TARGET_CONTROLLER_BATTLEFIELD,
|
||||
OWNER_BATTLEFIELD ,
|
||||
BATTLEFIELD,
|
||||
|
||||
MY_HAND,
|
||||
OPPONENT_HAND,
|
||||
TARGET_OWNER_HAND ,
|
||||
TARGET_CONTROLLER_HAND,
|
||||
OWNER_HAND ,
|
||||
HAND,
|
||||
|
||||
MY_LIBRARY,
|
||||
OPPONENT_LIBRARY,
|
||||
TARGET_OWNER_LIBRARY ,
|
||||
TARGET_CONTROLLER_LIBRARY,
|
||||
OWNER_LIBRARY ,
|
||||
LIBRARY,
|
||||
|
||||
MY_EXILE,
|
||||
OPPONENT_EXILE,
|
||||
TARGET_OWNER_EXILE ,
|
||||
TARGET_CONTROLLER_EXILE,
|
||||
OWNER_EXILE ,
|
||||
EXILE,
|
||||
|
||||
MY_EXILE,
|
||||
OPPONENT_EXILE,
|
||||
TARGET_OWNER_EXILE ,
|
||||
TARGET_CONTROLLER_EXILE,
|
||||
OWNER_EXILE ,
|
||||
EXILE,
|
||||
};
|
||||
|
||||
int max = sizeof(values) / sizeof*(values);
|
||||
|
||||
for (int i = 0; i < max; ++i){
|
||||
if(zoneName.compare(strings[i]) == 0){
|
||||
return values[i];
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
MTGGameZone * MTGGameZone::stringToZone(string zoneName, MTGCardInstance * source,MTGCardInstance * target){
|
||||
return intToZone(zoneStringToId(zoneName), source,target);
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ TargetChooser * TargetChooserFactory::createTargetChooser(string s, MTGCardInsta
|
||||
if (!s.size()) return NULL;
|
||||
|
||||
GameObserver * game = GameObserver::GetInstance();
|
||||
MTGGameZone * zones[10];
|
||||
int zones[10];
|
||||
int nbzones = 0;
|
||||
unsigned int found;
|
||||
|
||||
@@ -41,23 +41,23 @@ TargetChooser * TargetChooserFactory::createTargetChooser(string s, MTGCardInsta
|
||||
zoneName = s2;
|
||||
s2 = "";
|
||||
}
|
||||
zones[nbzones] = game->currentlyActing()->game->inPlay;
|
||||
zones[nbzones] = MTGGameZone::MY_BATTLEFIELD;
|
||||
|
||||
//Graveyards
|
||||
if(zoneName.compare("graveyard") == 0){
|
||||
zones[nbzones] = game->players[0]->game->graveyard;
|
||||
zones[nbzones] = MTGGameZone::MY_GRAVEYARD;
|
||||
nbzones++;
|
||||
zones[nbzones] = game->players[1]->game->graveyard;
|
||||
zones[nbzones] = MTGGameZone::OPPONENT_GRAVEYARD;
|
||||
}else if(zoneName.compare("battlefield") == 0 || zoneName.compare("inplay") == 0){
|
||||
zones[nbzones] = game->players[0]->game->inPlay;
|
||||
zones[nbzones] = MTGGameZone::MY_BATTLEFIELD;
|
||||
nbzones++;
|
||||
zones[nbzones] = game->players[1]->game->inPlay;
|
||||
zones[nbzones] = MTGGameZone::OPPONENT_BATTLEFIELD;
|
||||
}else if(zoneName.compare("stack") == 0){
|
||||
zones[nbzones] = game->players[0]->game->stack;
|
||||
zones[nbzones] = MTGGameZone::MY_STACK;
|
||||
nbzones++;
|
||||
zones[nbzones] = game->players[1]->game->stack;
|
||||
zones[nbzones] = MTGGameZone::OPPONENT_STACK;
|
||||
}else{
|
||||
MTGGameZone * zone = MTGGameZone::stringToZone(zoneName, card,card);
|
||||
int zone = MTGGameZone::zoneStringToId(zoneName);
|
||||
if (zone) zones[nbzones] = zone;
|
||||
}
|
||||
nbzones++;
|
||||
@@ -65,8 +65,8 @@ TargetChooser * TargetChooserFactory::createTargetChooser(string s, MTGCardInsta
|
||||
}else{
|
||||
s1 = s;
|
||||
nbzones = 2;
|
||||
zones[0]= game->players[0]->game->inPlay;
|
||||
zones[1]= game->players[1]->game->inPlay;
|
||||
zones[0]= MTGGameZone::MY_BATTLEFIELD;
|
||||
zones[1]= MTGGameZone::OPPONENT_BATTLEFIELD;
|
||||
}
|
||||
|
||||
TargetChooser * tc = NULL;
|
||||
@@ -266,17 +266,18 @@ TargetChooser * TargetChooserFactory::createTargetChooser(MTGCardInstance * card
|
||||
TargetChooser::TargetChooser(MTGCardInstance * card, int _maxtargets): TargetsList(){
|
||||
forceTargetListReady = 0;
|
||||
source = card;
|
||||
targetter = card;
|
||||
maxtargets = _maxtargets;
|
||||
}
|
||||
|
||||
//Default targetter : every card can be targetted, unless it is protected from the source card
|
||||
// For spells that do not "target" a specific card, set source to NULL
|
||||
//Default targetter : every card can be targetted, unless it is protected from the targetter card
|
||||
// For spells that do not "target" a specific card, set targetter to NULL
|
||||
int TargetChooser::canTarget(Targetable * target){
|
||||
if (target->typeAsTarget() == TARGET_CARD){
|
||||
MTGCardInstance * card = (MTGCardInstance *) target;
|
||||
if (source && card->isInPlay() && (card->has(Constants::SHROUD)|| card->protectedAgainst(source) )) return 0;
|
||||
if (source && card->isInPlay() && (source->controller() != card->controller()) && (card->has(Constants::OPPONENTSHROUD)|| card->protectedAgainst(source) )) return 0;
|
||||
return 1;
|
||||
if (targetter && card->isInPlay() && (card->has(Constants::SHROUD)|| card->protectedAgainst(targetter) )) return 0;
|
||||
if (source && targetter && card->isInPlay() && (source->controller() != card->controller()) && (card->has(Constants::OPPONENTSHROUD)|| card->protectedAgainst(targetter) )) return 0;
|
||||
return 1;
|
||||
}else if (target->typeAsTarget() == TARGET_STACKACTION){
|
||||
return 1;
|
||||
}
|
||||
@@ -354,17 +355,17 @@ TypeTargetChooser::TypeTargetChooser(const char * _type, MTGCardInstance * card,
|
||||
nbtypes = 0;
|
||||
addType(id);
|
||||
GameObserver * game = GameObserver::GetInstance();
|
||||
MTGGameZone * default_zones[] = {game->players[0]->game->inPlay, game->players[1]->game->inPlay};
|
||||
int default_zones[] = {MTGGameZone::MY_BATTLEFIELD, MTGGameZone::OPPONENT_BATTLEFIELD};
|
||||
init(default_zones,2);
|
||||
}
|
||||
|
||||
TypeTargetChooser::TypeTargetChooser(const char * _type, MTGGameZone ** _zones, int nbzones, MTGCardInstance * card, int _maxtargets):TargetZoneChooser(card, _maxtargets){
|
||||
TypeTargetChooser::TypeTargetChooser(const char * _type, int * _zones, int nbzones, MTGCardInstance * card, int _maxtargets):TargetZoneChooser(card, _maxtargets){
|
||||
int id = Subtypes::subtypesList->Add(_type);
|
||||
nbtypes = 0;
|
||||
addType(id);
|
||||
GameObserver * game = GameObserver::GetInstance();
|
||||
if (nbzones == 0){
|
||||
MTGGameZone * default_zones[] = {game->players[0]->game->inPlay, game->players[1]->game->inPlay};
|
||||
int default_zones[] = {MTGGameZone::MY_BATTLEFIELD, MTGGameZone::OPPONENT_BATTLEFIELD};
|
||||
init(default_zones,2);
|
||||
}else{
|
||||
init(_zones, nbzones);
|
||||
@@ -411,15 +412,15 @@ int TypeTargetChooser::canTarget(Targetable * target ){
|
||||
**/
|
||||
DescriptorTargetChooser::DescriptorTargetChooser(CardDescriptor * _cd, MTGCardInstance * card, int _maxtargets):TargetZoneChooser(card, _maxtargets){
|
||||
GameObserver * game = GameObserver::GetInstance();
|
||||
MTGGameZone * default_zones[] = {game->players[0]->game->inPlay, game->players[1]->game->inPlay};
|
||||
int default_zones[] = {MTGGameZone::MY_BATTLEFIELD, MTGGameZone::OPPONENT_BATTLEFIELD};
|
||||
init(default_zones,2);
|
||||
cd = _cd;
|
||||
}
|
||||
|
||||
DescriptorTargetChooser::DescriptorTargetChooser(CardDescriptor * _cd, MTGGameZone ** _zones, int nbzones, MTGCardInstance * card, int _maxtargets):TargetZoneChooser(card, _maxtargets){
|
||||
DescriptorTargetChooser::DescriptorTargetChooser(CardDescriptor * _cd, int * _zones, int nbzones, MTGCardInstance * card, int _maxtargets):TargetZoneChooser(card, _maxtargets){
|
||||
GameObserver * game = GameObserver::GetInstance();
|
||||
if (nbzones == 0){
|
||||
MTGGameZone * default_zones[] = {game->players[0]->game->inPlay, game->players[1]->game->inPlay};
|
||||
int default_zones[] = {MTGGameZone::MY_BATTLEFIELD, MTGGameZone::OPPONENT_BATTLEFIELD};
|
||||
init(default_zones,2);
|
||||
}else{
|
||||
init(_zones, nbzones);
|
||||
@@ -453,16 +454,16 @@ DescriptorTargetChooser::~DescriptorTargetChooser(){
|
||||
|
||||
CreatureTargetChooser::CreatureTargetChooser( MTGCardInstance * card, int _maxtargets):TargetZoneChooser(card, _maxtargets){
|
||||
GameObserver * game = GameObserver::GetInstance();
|
||||
MTGGameZone * default_zones[] = {game->players[0]->game->inPlay, game->players[1]->game->inPlay};
|
||||
int default_zones[] = {MTGGameZone::MY_BATTLEFIELD, MTGGameZone::OPPONENT_BATTLEFIELD};
|
||||
init(default_zones,2);
|
||||
maxpower= -1;
|
||||
maxtoughness= -1;
|
||||
}
|
||||
|
||||
CreatureTargetChooser::CreatureTargetChooser(MTGGameZone ** _zones, int nbzones, MTGCardInstance * card, int _maxtargets):TargetZoneChooser(card, _maxtargets){
|
||||
CreatureTargetChooser::CreatureTargetChooser(int * _zones, int nbzones, MTGCardInstance * card, int _maxtargets):TargetZoneChooser(card, _maxtargets){
|
||||
GameObserver * game = GameObserver::GetInstance();
|
||||
if (nbzones == 0){
|
||||
MTGGameZone * default_zones[] = {game->players[0]->game->inPlay, game->players[1]->game->inPlay};
|
||||
int default_zones[] = {MTGGameZone::MY_BATTLEFIELD, MTGGameZone::OPPONENT_BATTLEFIELD};
|
||||
init(default_zones,2);
|
||||
}else{
|
||||
init(_zones, nbzones);
|
||||
@@ -485,19 +486,15 @@ int CreatureTargetChooser::canTarget(Targetable * target){
|
||||
|
||||
|
||||
/* TargetzoneChooser targets everything in a given zone */
|
||||
TargetZoneChooser::TargetZoneChooser(MTGCardInstance * card, int _maxtargets){
|
||||
TargetZoneChooser::TargetZoneChooser(MTGCardInstance * card, int _maxtargets):TargetChooser(card,_maxtargets){
|
||||
init(NULL,0);
|
||||
source = card;
|
||||
maxtargets = _maxtargets;
|
||||
}
|
||||
|
||||
TargetZoneChooser::TargetZoneChooser(MTGGameZone ** _zones, int _nbzones,MTGCardInstance * card, int _maxtargets){
|
||||
TargetZoneChooser::TargetZoneChooser(int * _zones, int _nbzones,MTGCardInstance * card, int _maxtargets):TargetChooser(card,_maxtargets){
|
||||
init(_zones, _nbzones);
|
||||
source = card;
|
||||
maxtargets = _maxtargets;
|
||||
}
|
||||
|
||||
int TargetZoneChooser::init(MTGGameZone ** _zones, int _nbzones){
|
||||
int TargetZoneChooser::init(int * _zones, int _nbzones){
|
||||
for (int i = 0; i < _nbzones; i++){
|
||||
zones[i] = _zones[i];
|
||||
}
|
||||
@@ -510,7 +507,7 @@ int TargetZoneChooser::canTarget(Targetable * target){
|
||||
if (target->typeAsTarget() == TARGET_CARD){
|
||||
MTGCardInstance * card = (MTGCardInstance *) target;
|
||||
for (int i = 0; i<nbzones; i++){
|
||||
if (zones[i]->hasCard(card)) return 1;
|
||||
if (MTGGameZone::intToZone(zones[i],source,card)->hasCard(card)) return 1;
|
||||
}
|
||||
}else if (target->typeAsTarget() == TARGET_STACKACTION){
|
||||
OutputDebugString ("CHECKING INTERRUPTIBLE\n");
|
||||
@@ -519,7 +516,7 @@ OutputDebugString ("CHECKING INTERRUPTIBLE\n");
|
||||
Spell * spell = (Spell *) action;
|
||||
MTGCardInstance * card = spell->source;
|
||||
for (int i = 0; i<nbzones; i++){
|
||||
if (zones[i]->hasCard(card)) return 1;
|
||||
if (MTGGameZone::intToZone(zones[i],source,card)->hasCard(card)) return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -529,7 +526,7 @@ OutputDebugString ("CHECKING INTERRUPTIBLE\n");
|
||||
|
||||
int TargetZoneChooser::targetsZone(MTGGameZone * z){
|
||||
for (int i = 0; i < nbzones; i++){
|
||||
if (zones[i] == z) return 1;
|
||||
if (MTGGameZone::intToZone(zones[i],source) == z) return 1;
|
||||
|
||||
}
|
||||
return 0;
|
||||
@@ -588,7 +585,7 @@ int SpellTargetChooser::canTarget(Targetable * target){
|
||||
/*Spell or Permanent */
|
||||
SpellOrPermanentTargetChooser::SpellOrPermanentTargetChooser(MTGCardInstance * card,int _color, int _maxtargets):TargetZoneChooser(card, _maxtargets){
|
||||
GameObserver * game = GameObserver::GetInstance();
|
||||
MTGGameZone * default_zones[] = {game->players[0]->game->inPlay, game->players[1]->game->inPlay};
|
||||
int default_zones[] = {MTGGameZone::MY_BATTLEFIELD, MTGGameZone::OPPONENT_BATTLEFIELD};
|
||||
init(default_zones,2);
|
||||
color = _color;
|
||||
}
|
||||
@@ -638,7 +635,7 @@ int DamageTargetChooser::canTarget(Targetable * target){
|
||||
/*Damage or Permanent */
|
||||
DamageOrPermanentTargetChooser::DamageOrPermanentTargetChooser(MTGCardInstance * card,int _color, int _maxtargets):TargetZoneChooser(card, _maxtargets){
|
||||
GameObserver * game = GameObserver::GetInstance();
|
||||
MTGGameZone * default_zones[] = {game->players[0]->game->inPlay, game->players[1]->game->inPlay};
|
||||
int default_zones[] = {MTGGameZone::MY_BATTLEFIELD, MTGGameZone::OPPONENT_BATTLEFIELD};
|
||||
init(default_zones,2);
|
||||
color = _color;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user