-fix issue 209 (Clone loops AI)
This commit is contained in:
wagic.the.homebrew@gmail.com
2010-01-15 16:49:17 +00:00
parent 187e108cdb
commit 11ed497ebb
7 changed files with 78 additions and 61 deletions
-1
View File
@@ -22,7 +22,6 @@ class AIAction{
protected:
int efficiency;
static int currentId;
static MTGAbility * getCoreAbility(MTGAbility * a);
public:
MTGAbility * ability;
Player * player;
+31 -30
View File
@@ -438,6 +438,35 @@ class GenericActivatedAbility:public ActivatedAbility{
};
//Copier. ActivatedAbility
class AACopier:public ActivatedAbility{
public:
AACopier(int _id, MTGCardInstance * _source, MTGCardInstance * _target = NULL, ManaCost * _cost=NULL):ActivatedAbility(_id,_source,_cost,0,0){
target = _target;
}
int resolve(){
MTGCardInstance * _target = (MTGCardInstance *) target;
if(_target){
source->copy(_target);
return 1;
}
return 0;
}
const char * getMenuText(){
return "Copy";
}
AACopier * clone() const{
AACopier * a = NEW AACopier(*this);
a->isClone = 1;
return a;
}
};
/* Generic TargetAbility */
class GenericTargetAbility:public TargetAbility{
@@ -447,6 +476,8 @@ public:
MTGGameZone * activeZone;
GenericTargetAbility(int _id, MTGCardInstance * _source, TargetChooser * _tc,MTGAbility * a, ManaCost * _cost = NULL, int _tap=0, int limit = 0, int restrictions = 0, MTGGameZone * dest = NULL):TargetAbility(_id,_source, _tc,_cost,restrictions,_tap),limitPerTurn(limit), activeZone(dest){
ability = a;
MTGAbility * core = AbilityFactory::getCoreAbility(a);
if (dynamic_cast<AACopier *>(core)) tc->other = true; //http://code.google.com/p/wagic/issues/detail?id=209 (avoid inifinite loop)
counters = 0;
}
@@ -750,36 +781,6 @@ public:
};
//Copier. ActivatedAbility
class AACopier:public ActivatedAbility{
public:
AACopier(int _id, MTGCardInstance * _source, MTGCardInstance * _target = NULL, ManaCost * _cost=NULL):ActivatedAbility(_id,_source,_cost,0,0){
target = _target;
}
int resolve(){
MTGCardInstance * _target = (MTGCardInstance *) target;
if(_target){
source->copy(_target);
return 1;
}
return 0;
}
const char * getMenuText(){
return "Copy";
}
AACopier * clone() const{
AACopier * a = NEW AACopier(*this);
a->isClone = 1;
return a;
}
};
class AADestroyer:public ActivatedAbility{
public:
int bury;
+1
View File
@@ -229,6 +229,7 @@ class AbilityFactory{
int abilityEfficiency(MTGAbility * a, Player * p, int mode = MODE_ABILITY, TargetChooser * tc = NULL);
int magicText(int id, Spell * spell, MTGCardInstance * card = NULL, int mode = MODE_PUTINTOPLAY, TargetChooser * tc = NULL, MTGGameZone * dest = NULL);
static int computeX(Spell * spell, MTGCardInstance * card);
static MTGAbility * getCoreAbility(MTGAbility * a);
int destroyAllInPlay(TargetChooser * tc, int bury = 0);
int moveAll(TargetChooser * tc, string destinationZone);
int damageAll(TargetChooser * tc, int damage);
+1 -2
View File
@@ -25,7 +25,6 @@ class CardDescriptor;
class TargetChooser: public TargetsList {
protected:
int forceTargetListReady;
bool other;
public:
enum{
@@ -34,7 +33,7 @@ class TargetChooser: public TargetsList {
CONTROLLER = 1,
TARGET_CONTROLLER = 2
};
bool other;
TargetChooser(MTGCardInstance * card = NULL, int _maxtargets = -1, bool other = false);