-fixed "lord changes controller" bug
This commit is contained in:
wagic.the.homebrew@gmail.com
2009-07-05 04:49:21 +00:00
parent 20a0322ebb
commit ddc4636bf6
9 changed files with 310 additions and 116 deletions
+1
View File
@@ -47,6 +47,7 @@ clone2.txt
composite_golem.txt
control_magic.txt
control_magic2.txt
control_magic3.txt
counsel_of_the_soratami.txt
counterspell.txt
counterspell2.txt
@@ -0,0 +1,26 @@
#Bug: control magic on a "lord" creature does not update its values
# testing on a nightmare
[INIT]
FIRSTMAIN
[PLAYER1]
hand:control magic,lightning bolt
inplay:mountain,129754,129755
manapool:{2}{U}{U}
[PLAYER2]
inplay:nightmare,129756,129757,1373,1375
[DO]
control magic
nightmare
mountain
lightning bolt
nightmare
[ASSERT]
FIRSTMAIN
[PLAYER1]
graveyard:control magic,lightning bolt
manapool:{0}
inplay:mountain,129754,129755
[PLAYER2]
graveyard:nightmare
inplay:129756,129757,1373,1375
[END]
+4 -4
View File
@@ -1251,7 +1251,7 @@ class ALord:public ListMaintainerAbility{
map<MTGCardInstance *, MTGAbility *> regenerations;
ALord(int _id, MTGCardInstance * card, TargetChooser * _tc, int _includeSelf, int _power = 0 , int _toughness = 0, int _ability = -1, ManaCost * _regenCost = NULL, int _modifier = 1):ListMaintainerAbility(_id,card){
tc = _tc;
tc->source = NULL;
tc->targetter = NULL;
includeSelf = _includeSelf;
power = _power;
toughness = _toughness;
@@ -1334,7 +1334,7 @@ class AForeach:public ListMaintainerAbility{
int includeSelf;
AForeach(int _id, MTGCardInstance * card,MTGCardInstance * _target, TargetChooser * _tc, int _includeSelf, int _power = 0 , int _toughness = 0):ListMaintainerAbility(_id,card,_target){
tc = _tc;
tc->source = NULL;
tc->targetter = NULL;
includeSelf = _includeSelf;
power = _power;
toughness = _toughness;
@@ -1673,7 +1673,7 @@ class AAladdinsLamp: public TargetAbility{
cost = NEW ManaCost();
cost->x();
cd = CardDisplay(1,game,SCREEN_WIDTH/2, SCREEN_HEIGHT/2,NULL);
MTGGameZone * zones[] = {game->currentPlayer->game->library};
int zones[] = {MTGGameZone::MY_LIBRARY};
tc = NEW TargetZoneChooser(zones,1,source);
nbcards = 0;
init = 0;
@@ -2038,7 +2038,7 @@ class ADingusEgg: public ListMaintainerAbility{
class ADisruptingScepter:public TargetAbility{
public:
ADisruptingScepter(int id, MTGCardInstance * _source):TargetAbility(id,_source){
MTGGameZone * zones[] = {GameObserver::GetInstance()->opponent()->game->hand};
int zones[] = {MTGGameZone::OPPONENT_HAND};
tc = NEW TargetZoneChooser(zones,1,_source);
int _cost[] = {Constants::MTG_COLOR_ARTIFACT, 3};
cost = NEW ManaCost(_cost,1);
+48
View File
@@ -18,6 +18,52 @@ class MTGGameZone {
protected:
public:
enum{
MY_GRAVEYARD = 11,
OPPONENT_GRAVEYARD = 12,
TARGET_OWNER_GRAVEYARD = 13,
TARGET_CONTROLLER_GRAVEYARD = 14,
GRAVEYARD = 15,
OWNER_GRAVEYARD = 16,
MY_BATTLEFIELD = 21,
OPPONENT_BATTLEFIELD = 22,
TARGET_OWNER_BATTLEFIELD = 23,
TARGET_CONTROLLER_BATTLEFIELD = 24,
BATTLEFIELD = 25,
OWNER_BATTLEFIELD = 26,
MY_HAND = 31,
OPPONENT_HAND = 32,
TARGET_OWNER_HAND = 33,
TARGET_CONTROLLER_HAND = 34,
HAND = 35,
OWNER_HAND = 36,
MY_EXILE = 41,
OPPONENT_EXILE = 42,
TARGET_OWNER_EXILE = 43,
TARGET_CONTROLLER_EXILE = 44,
EXILE = 45,
OWNER_EXILE = 46,
MY_LIBRARY = 51,
OPPONENT_LIBRARY = 52,
TARGET_OWNER_LIBRARY = 53,
TARGET_CONTROLLER_LIBRARY = 54,
LIBRARY = 55,
OWNER_LIBRARY = 56,
MY_STACK = 61,
OPPONENT_STACK = 62,
TARGET_OWNER_STACK = 63,
TARGET_CONTROLLER_STACK = 64,
STACK = 65,
OWNER_STACK = 66,
};
Player * owner;
//Both cards and cardsMap contain the cards of a zone. The long term objective is to get rid of the array
vector<MTGCardInstance *> cards; //[MTG_MAX_PLAYER_CARDS];
@@ -37,6 +83,8 @@ class MTGGameZone {
void setOwner(Player * player);
MTGCardInstance * lastCardDrawn;
static MTGGameZone * stringToZone(string zoneName, MTGCardInstance * source, MTGCardInstance * target);
static int zoneStringToId(string zoneName);
static MTGGameZone *intToZone(int zoneId, MTGCardInstance * source = NULL,MTGCardInstance * target = NULL);
};
class MTGLibrary: public MTGGameZone {
+9 -8
View File
@@ -29,7 +29,8 @@ class TargetChooser: public TargetsList {
public:
TargetChooser(MTGCardInstance * card = NULL, int _maxtargets = -1);
MTGCardInstance * source; //Optionnal source, used for protection from...
MTGCardInstance * source;
MTGCardInstance * targetter; //Optional, usually equals source, used for protection from...
int maxtargets; //Set to -1 for "unlimited"
virtual int targetsZone(MTGGameZone * z){return 0;};
int ForceTargetListReady();
@@ -64,12 +65,12 @@ public:
class TargetZoneChooser:public TargetChooser{
public:
MTGGameZone * zones[10];
int zones[10];
int nbzones;
int init(MTGGameZone ** _zones, int _nbzones);
int init(int * _zones, int _nbzones);
int targetsZone(MTGGameZone * z);
TargetZoneChooser(MTGCardInstance * card = NULL, int _maxtargets = 1);
TargetZoneChooser(MTGGameZone ** _zones, int _nbzones, MTGCardInstance * card = NULL, int _maxtargets = 1);
TargetZoneChooser(int * _zones, int _nbzones, MTGCardInstance * card = NULL, int _maxtargets = 1);
virtual int canTarget(Targetable * _card);
};
@@ -77,7 +78,7 @@ class CreatureTargetChooser:public TargetZoneChooser{
public:
int maxpower;
int maxtoughness;
CreatureTargetChooser(MTGGameZone ** _zones, int _nbzones,MTGCardInstance * card = NULL, int _maxtargets = 1);
CreatureTargetChooser(int * _zones, int _nbzones,MTGCardInstance * card = NULL, int _maxtargets = 1);
CreatureTargetChooser(MTGCardInstance * card = NULL, int _maxtargets = 1);
virtual int canTarget(Targetable * _card);
@@ -86,7 +87,7 @@ class CreatureTargetChooser:public TargetZoneChooser{
class DamageableTargetChooser:public CreatureTargetChooser{
public:
DamageableTargetChooser(MTGGameZone ** _zones, int _nbzones,MTGCardInstance * card = NULL, int _maxtargets = 1):CreatureTargetChooser( _zones,_nbzones, card, _maxtargets){};
DamageableTargetChooser(int * _zones, int _nbzones,MTGCardInstance * card = NULL, int _maxtargets = 1):CreatureTargetChooser( _zones,_nbzones, card, _maxtargets){};
DamageableTargetChooser(MTGCardInstance * card = NULL, int _maxtargets = 1):CreatureTargetChooser(card, _maxtargets){};
virtual int canTarget(Targetable * target);
};
@@ -105,7 +106,7 @@ class TypeTargetChooser:public TargetZoneChooser{
int nbtypes;
int types[10];
TypeTargetChooser(const char * _type, MTGCardInstance * card = NULL, int _maxtargets = 1);
TypeTargetChooser(const char * _type, MTGGameZone ** _zones, int nbzones, MTGCardInstance * card = NULL, int _maxtargets = 1);
TypeTargetChooser(const char * _type, int * _zones, int nbzones, MTGCardInstance * card = NULL, int _maxtargets = 1);
void addType(int type);
void addType(const char * type);
virtual int canTarget(Targetable * targe);
@@ -115,7 +116,7 @@ class DescriptorTargetChooser:public TargetZoneChooser{
public:
CardDescriptor * cd;
DescriptorTargetChooser(CardDescriptor * _cd, MTGCardInstance * card = NULL, int _maxtargets = 1);
DescriptorTargetChooser(CardDescriptor * _cd, MTGGameZone ** _zones, int nbzones, MTGCardInstance * card = NULL, int _maxtargets = 1);
DescriptorTargetChooser(CardDescriptor * _cd, int * _zones, int nbzones, MTGCardInstance * card = NULL, int _maxtargets = 1);
virtual int canTarget(Targetable * target);
~DescriptorTargetChooser();
};
+3 -3
View File
@@ -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;
}
+18 -18
View File
@@ -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;
}
+167 -46
View File
@@ -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);
}
+34 -37
View File
@@ -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;
}