Erwan
- fixed a few memory leaks (but Wagic still crashes on the PSP after a few games :( )
This commit is contained in:
20
JGE/Makefile.hge
Normal file
20
JGE/Makefile.hge
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
PSPSDK=$(shell psp-config --pspsdk-path)
|
||||||
|
PSPDIR=$(shell psp-config --psp-prefix)
|
||||||
|
TARGET_LIB = libhgetools.a
|
||||||
|
OBJS = src/hge/hgecolor.o src/hge/hgeparticle.o \
|
||||||
|
src/hge/hgerect.o src/hge/hgevector.o \
|
||||||
|
src/hge/hgedistort.o src/hge/hgefont.o
|
||||||
|
|
||||||
|
|
||||||
|
INCDIR = include/psp include/psp/freetype2
|
||||||
|
LIBDIR = lib/psp
|
||||||
|
|
||||||
|
CFLAGS = -O2 -G0 -Wall
|
||||||
|
|
||||||
|
LIBS = -lgif -lfreetype -ljpeg -lpng -lz -lmikmod -lpsppower -lpspmpeg -lpspaudiocodec -lpspaudiolib -lpspaudio -lpspgum -lpspgu -lpsprtc -lm -lstdc++ -ljge300
|
||||||
|
|
||||||
|
include $(PSPSDK)/lib/build.mak
|
||||||
|
|
||||||
|
install: $(TARGET_LIB)
|
||||||
|
@cp libhgetools.a lib/psp
|
||||||
|
@echo "Done"
|
||||||
@@ -843,6 +843,10 @@ class AProtectionFrom:public MTGAbility{
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
~AProtectionFrom(){
|
||||||
|
delete(cd);
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
//Aura Enchantments that provide controller of target life or damages at a given phase of their turn
|
//Aura Enchantments that provide controller of target life or damages at a given phase of their turn
|
||||||
@@ -979,7 +983,6 @@ class AConvertLandToCreatures:public ListMaintainerAbility{
|
|||||||
//Lords (Merfolk lord...) give power and toughness to OTHER creatures of their type, they can give them special abilities, regeneration
|
//Lords (Merfolk lord...) give power and toughness to OTHER creatures of their type, they can give them special abilities, regeneration
|
||||||
class ALord:public ListMaintainerAbility{
|
class ALord:public ListMaintainerAbility{
|
||||||
public:
|
public:
|
||||||
TargetChooser * tc;
|
|
||||||
int power, toughness;
|
int power, toughness;
|
||||||
int ability;
|
int ability;
|
||||||
int modifier;
|
int modifier;
|
||||||
@@ -1035,7 +1038,6 @@ class ALord:public ListMaintainerAbility{
|
|||||||
//Foreach (plague rats...)
|
//Foreach (plague rats...)
|
||||||
class AForeach:public ListMaintainerAbility{
|
class AForeach:public ListMaintainerAbility{
|
||||||
public:
|
public:
|
||||||
TargetChooser * tc;
|
|
||||||
int power, toughness;
|
int power, toughness;
|
||||||
int includeSelf;
|
int includeSelf;
|
||||||
AForeach(int _id, MTGCardInstance * card,MTGCardInstance * _target, TargetChooser * _tc, int _includeSelf, int _power = 0 , int _toughness = 0):ListMaintainerAbility(_id,card,_target){
|
AForeach(int _id, MTGCardInstance * card,MTGCardInstance * _target, TargetChooser * _tc, int _includeSelf, int _power = 0 , int _toughness = 0):ListMaintainerAbility(_id,card,_target){
|
||||||
@@ -2780,7 +2782,6 @@ class AMinionofLeshrac: public TargetAbility{
|
|||||||
//Generic Kird Ape
|
//Generic Kird Ape
|
||||||
class AKirdApe:public ListMaintainerAbility{
|
class AKirdApe:public ListMaintainerAbility{
|
||||||
public:
|
public:
|
||||||
TargetChooser * tc;
|
|
||||||
int power;
|
int power;
|
||||||
int toughness;
|
int toughness;
|
||||||
int ability;
|
int ability;
|
||||||
@@ -2822,9 +2823,6 @@ class AKirdApe:public ListMaintainerAbility{
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
~AKirdApe(){
|
|
||||||
delete tc;
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -95,7 +95,6 @@ class ActivatedAbility:public MTGAbility{
|
|||||||
virtual int isReactingToClick(MTGCardInstance * card, ManaCost * mana = NULL);
|
virtual int isReactingToClick(MTGCardInstance * card, ManaCost * mana = NULL);
|
||||||
virtual int reactToTargetClick(Targetable * object);
|
virtual int reactToTargetClick(Targetable * object);
|
||||||
virtual int resolve() = 0;
|
virtual int resolve() = 0;
|
||||||
virtual ~ActivatedAbility();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class TargetAbility:public ActivatedAbility{
|
class TargetAbility:public ActivatedAbility{
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ class TargetChooser: public TargetsList {
|
|||||||
virtual int canTarget(Targetable * _target);
|
virtual int canTarget(Targetable * _target);
|
||||||
virtual int full(){if (maxtargets != -1 && cursor>=maxtargets) {return 1;} else{return 0;}};
|
virtual int full(){if (maxtargets != -1 && cursor>=maxtargets) {return 1;} else{return 0;}};
|
||||||
virtual int ready(){return cursor;};
|
virtual int ready(){return cursor;};
|
||||||
|
virtual ~TargetChooser(){};
|
||||||
int targetListSet();
|
int targetListSet();
|
||||||
|
|
||||||
|
|
||||||
@@ -103,6 +104,7 @@ class DescriptorTargetChooser:public TargetZoneChooser{
|
|||||||
DescriptorTargetChooser(CardDescriptor * _cd, MTGCardInstance * card = NULL, int _maxtargets = 1);
|
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, MTGGameZone ** _zones, int nbzones, MTGCardInstance * card = NULL, int _maxtargets = 1);
|
||||||
virtual int canTarget(Targetable * target);
|
virtual int canTarget(Targetable * target);
|
||||||
|
~DescriptorTargetChooser();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ AIPlayer::~AIPlayer(){
|
|||||||
stats->save();
|
stats->save();
|
||||||
SAFE_DELETE(stats);
|
SAFE_DELETE(stats);
|
||||||
}
|
}
|
||||||
|
//TODO delete clickstream!
|
||||||
}
|
}
|
||||||
MTGCardInstance * AIPlayer::chooseCard(TargetChooser * tc, MTGCardInstance * source, int random){
|
MTGCardInstance * AIPlayer::chooseCard(TargetChooser * tc, MTGCardInstance * source, int random){
|
||||||
for (int i = 0; i < game->hand->nb_cards; i++){
|
for (int i = 0; i < game->hand->nb_cards; i++){
|
||||||
|
|||||||
@@ -66,8 +66,8 @@ void ActionLayer::Update(float dt){
|
|||||||
if (mObjects[i]!= NULL){
|
if (mObjects[i]!= NULL){
|
||||||
ActionElement * currentAction = (ActionElement *)mObjects[i];
|
ActionElement * currentAction = (ActionElement *)mObjects[i];
|
||||||
if (currentAction->testDestroy()){
|
if (currentAction->testDestroy()){
|
||||||
currentAction->destroy();
|
currentAction->destroy();
|
||||||
Remove(currentAction);
|
Remove(currentAction);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -221,7 +221,7 @@ void GameApp::Update()
|
|||||||
if (mNextState != NULL)
|
if (mNextState != NULL)
|
||||||
{
|
{
|
||||||
if (mCurrentState != NULL)
|
if (mCurrentState != NULL)
|
||||||
mCurrentState->End();
|
mCurrentState->End();
|
||||||
|
|
||||||
mCurrentState = mNextState;
|
mCurrentState = mNextState;
|
||||||
mCurrentState->Start();
|
mCurrentState->Start();
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ void GameStateDuel::Start()
|
|||||||
|
|
||||||
|
|
||||||
#ifdef TESTSUITE
|
#ifdef TESTSUITE
|
||||||
if (testSuite) delete testSuite;
|
SAFE_DELETE(testSuite);
|
||||||
testSuite = NEW TestSuite(RESPATH"/test/_tests.txt",mParent->collection);
|
testSuite = NEW TestSuite(RESPATH"/test/_tests.txt",mParent->collection);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ Trigger * AbilityFactory::parseTrigger(string magicText){
|
|||||||
for (int i = 0; i < Constants::NB_MTG_PHASES; i++){
|
for (int i = 0; i < Constants::NB_MTG_PHASES; i++){
|
||||||
found = magicText.find(Constants::MTGPhaseCodeNames[i]);
|
found = magicText.find(Constants::MTGPhaseCodeNames[i]);
|
||||||
if (found != string::npos){
|
if (found != string::npos){
|
||||||
return NEW TriggerNextPhase(i);
|
return NEW TriggerNextPhase(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -102,6 +102,9 @@ Trigger * AbilityFactory::parseTrigger(string magicText){
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//Some basic functionalities that can be added automatically in the text file
|
//Some basic functionalities that can be added automatically in the text file
|
||||||
/*
|
/*
|
||||||
* Several objects are computed from the text string, and have a direct influence on what action we should take
|
* Several objects are computed from the text string, and have a direct influence on what action we should take
|
||||||
@@ -114,6 +117,9 @@ Trigger * AbilityFactory::parseTrigger(string magicText){
|
|||||||
int AbilityFactory::magicText(int id, Spell * spell, MTGCardInstance * card){
|
int AbilityFactory::magicText(int id, Spell * spell, MTGCardInstance * card){
|
||||||
int dryMode = 0;
|
int dryMode = 0;
|
||||||
if (!spell) dryMode = 1;
|
if (!spell) dryMode = 1;
|
||||||
|
int dryModeResultSet = 0;
|
||||||
|
int dryModeResult = 0;
|
||||||
|
|
||||||
GameObserver * game = GameObserver::GetInstance();
|
GameObserver * game = GameObserver::GetInstance();
|
||||||
if (!card) card = spell->source;
|
if (!card) card = spell->source;
|
||||||
MTGCardInstance * target = card->target;
|
MTGCardInstance * target = card->target;
|
||||||
@@ -165,6 +171,9 @@ int AbilityFactory::magicText(int id, Spell * spell, MTGCardInstance * card){
|
|||||||
//Tap in the cost ?
|
//Tap in the cost ?
|
||||||
if (line.find("{t}") != string::npos) doTap = 1;
|
if (line.find("{t}") != string::npos) doTap = 1;
|
||||||
|
|
||||||
|
TargetChooser * tc;
|
||||||
|
TargetChooser * lordTargets;
|
||||||
|
Trigger * trigger;
|
||||||
while (line.size()){
|
while (line.size()){
|
||||||
string s;
|
string s;
|
||||||
found = line.find("&&");
|
found = line.find("&&");
|
||||||
@@ -173,8 +182,10 @@ int AbilityFactory::magicText(int id, Spell * spell, MTGCardInstance * card){
|
|||||||
line = line.substr(found+2);
|
line = line.substr(found+2);
|
||||||
if (!multi){
|
if (!multi){
|
||||||
OutputDebugString("Multi initializing\n");
|
OutputDebugString("Multi initializing\n");
|
||||||
multi = NEW MultiAbility(id, card, cost,doTap);
|
if (!dryMode) {
|
||||||
game->addObserver(multi);
|
multi = NEW MultiAbility(id, card, cost,doTap);
|
||||||
|
game->addObserver(multi);
|
||||||
|
}
|
||||||
OutputDebugString("Multi initialized\n");
|
OutputDebugString("Multi initialized\n");
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
@@ -182,14 +193,13 @@ int AbilityFactory::magicText(int id, Spell * spell, MTGCardInstance * card){
|
|||||||
line = "";
|
line = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
TargetChooser * tc = NULL;
|
tc = NULL;
|
||||||
|
lordTargets = NULL;
|
||||||
TargetChooser * lordTargets = NULL;
|
|
||||||
int lordIncludeSelf = 1;
|
int lordIncludeSelf = 1;
|
||||||
int lordType = 0;
|
int lordType = 0;
|
||||||
string lordTargetsString;
|
string lordTargetsString;
|
||||||
|
|
||||||
Trigger * trigger = parseTrigger(s);
|
trigger = parseTrigger(s);
|
||||||
//Dirty way to remove the trigger text (could get in the way)
|
//Dirty way to remove the trigger text (could get in the way)
|
||||||
if (trigger){
|
if (trigger){
|
||||||
found = s.find(":");
|
found = s.find(":");
|
||||||
@@ -210,7 +220,11 @@ int AbilityFactory::magicText(int id, Spell * spell, MTGCardInstance * card){
|
|||||||
//Lord
|
//Lord
|
||||||
found = s.find("lord(");
|
found = s.find("lord(");
|
||||||
if (found != string::npos){
|
if (found != string::npos){
|
||||||
if (dryMode) return BAKA_EFFECT_GOOD;
|
if (dryMode) {
|
||||||
|
dryModeResult = BAKA_EFFECT_GOOD;
|
||||||
|
dryModeResultSet = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
unsigned int end = s.find(")", found+5);
|
unsigned int end = s.find(")", found+5);
|
||||||
if (end != string::npos){
|
if (end != string::npos){
|
||||||
lordTargetsString = s.substr(found+5,end-found-5).c_str();
|
lordTargetsString = s.substr(found+5,end-found-5).c_str();
|
||||||
@@ -219,7 +233,11 @@ int AbilityFactory::magicText(int id, Spell * spell, MTGCardInstance * card){
|
|||||||
}
|
}
|
||||||
found = s.find("foreach(");
|
found = s.find("foreach(");
|
||||||
if (found != string::npos){
|
if (found != string::npos){
|
||||||
if (dryMode) return BAKA_EFFECT_GOOD;
|
if (dryMode) {
|
||||||
|
dryModeResult = BAKA_EFFECT_GOOD;
|
||||||
|
dryModeResultSet = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
unsigned int end = s.find(")", found+8);
|
unsigned int end = s.find(")", found+8);
|
||||||
if (end != string::npos){
|
if (end != string::npos){
|
||||||
lordTargetsString = s.substr(found+8,end-found-8).c_str();
|
lordTargetsString = s.substr(found+8,end-found-8).c_str();
|
||||||
@@ -228,7 +246,11 @@ int AbilityFactory::magicText(int id, Spell * spell, MTGCardInstance * card){
|
|||||||
}
|
}
|
||||||
found = s.find("aslongas(");
|
found = s.find("aslongas(");
|
||||||
if (found != string::npos){
|
if (found != string::npos){
|
||||||
if (dryMode) return BAKA_EFFECT_GOOD;
|
if (dryMode) {
|
||||||
|
dryModeResult = BAKA_EFFECT_GOOD;
|
||||||
|
dryModeResultSet = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
unsigned int end = s.find(")", found+9);
|
unsigned int end = s.find(")", found+9);
|
||||||
if (end != string::npos){
|
if (end != string::npos){
|
||||||
lordTargetsString = s.substr(found+9,end-found-9).c_str();
|
lordTargetsString = s.substr(found+9,end-found-9).c_str();
|
||||||
@@ -245,7 +267,11 @@ int AbilityFactory::magicText(int id, Spell * spell, MTGCardInstance * card){
|
|||||||
//Untapper (Ley Druid...)
|
//Untapper (Ley Druid...)
|
||||||
found = s.find("untap");
|
found = s.find("untap");
|
||||||
if (found != string::npos){
|
if (found != string::npos){
|
||||||
if (dryMode) return BAKA_EFFECT_GOOD;
|
if (dryMode) {
|
||||||
|
dryModeResult = BAKA_EFFECT_GOOD;
|
||||||
|
dryModeResultSet = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
if (tc){
|
if (tc){
|
||||||
game->addObserver(NEW AUntaper(id, card, cost, tc));
|
game->addObserver(NEW AUntaper(id, card, cost, tc));
|
||||||
}else{
|
}else{
|
||||||
@@ -259,7 +285,11 @@ int AbilityFactory::magicText(int id, Spell * spell, MTGCardInstance * card){
|
|||||||
//Regeneration
|
//Regeneration
|
||||||
found = s.find("}:regenerate");
|
found = s.find("}:regenerate");
|
||||||
if (found != string::npos){
|
if (found != string::npos){
|
||||||
if (dryMode) return BAKA_EFFECT_GOOD;
|
if (dryMode) {
|
||||||
|
dryModeResult = BAKA_EFFECT_GOOD;
|
||||||
|
dryModeResultSet = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (lordTargets){
|
if (lordTargets){
|
||||||
game->addObserver(NEW ALord(id,card,lordTargets,lordIncludeSelf,0,0,-1,cost));
|
game->addObserver(NEW ALord(id,card,lordTargets,lordIncludeSelf,0,0,-1,cost));
|
||||||
@@ -279,7 +309,11 @@ int AbilityFactory::magicText(int id, Spell * spell, MTGCardInstance * card){
|
|||||||
//Token creator. Name, type, p/t, abilities
|
//Token creator. Name, type, p/t, abilities
|
||||||
found = s.find("token(");
|
found = s.find("token(");
|
||||||
if (found != string::npos){
|
if (found != string::npos){
|
||||||
if (dryMode) return BAKA_EFFECT_GOOD;
|
if (dryMode) {
|
||||||
|
dryModeResult = BAKA_EFFECT_GOOD;
|
||||||
|
dryModeResultSet = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
int end = s.find(",", found);
|
int end = s.find(",", found);
|
||||||
string sname = s.substr(found + 6,end - found - 6);
|
string sname = s.substr(found + 6,end - found - 6);
|
||||||
int previous = end+1;
|
int previous = end+1;
|
||||||
@@ -310,7 +344,11 @@ int AbilityFactory::magicText(int id, Spell * spell, MTGCardInstance * card){
|
|||||||
//MoveTo Move a card from a zone to another
|
//MoveTo Move a card from a zone to another
|
||||||
found = s.find("moveto(");
|
found = s.find("moveto(");
|
||||||
if (found != string::npos){
|
if (found != string::npos){
|
||||||
if (dryMode) return BAKA_EFFECT_BAD; //TODO : depends on where from, where to...
|
if (dryMode) {
|
||||||
|
dryModeResult = BAKA_EFFECT_BAD;
|
||||||
|
dryModeResultSet = 1;
|
||||||
|
break;
|
||||||
|
} //TODO : depends on where from, where to...
|
||||||
int end = s.find(")",found+1);
|
int end = s.find(")",found+1);
|
||||||
string szone = s.substr(found + 7,end - found - 7);
|
string szone = s.substr(found + 7,end - found - 7);
|
||||||
if (tc){
|
if (tc){
|
||||||
@@ -343,7 +381,11 @@ int AbilityFactory::magicText(int id, Spell * spell, MTGCardInstance * card){
|
|||||||
//Copy a target
|
//Copy a target
|
||||||
found = s.find("copy ");
|
found = s.find("copy ");
|
||||||
if (found != string::npos){
|
if (found != string::npos){
|
||||||
if (dryMode) return BAKA_EFFECT_GOOD; //TODO :
|
if (dryMode) {
|
||||||
|
dryModeResult = BAKA_EFFECT_GOOD;
|
||||||
|
dryModeResultSet = 1;
|
||||||
|
break;
|
||||||
|
} //TODO :
|
||||||
if (tc){
|
if (tc){
|
||||||
ACopier * a = NEW ACopier(id,card,tc,cost);
|
ACopier * a = NEW ACopier(id,card,tc,cost);
|
||||||
if (may){
|
if (may){
|
||||||
@@ -363,7 +405,11 @@ int AbilityFactory::magicText(int id, Spell * spell, MTGCardInstance * card){
|
|||||||
found = s.find("bury");
|
found = s.find("bury");
|
||||||
if (found != string::npos){
|
if (found != string::npos){
|
||||||
if (trigger){
|
if (trigger){
|
||||||
if (dryMode) return BAKA_EFFECT_BAD;
|
if (dryMode) {
|
||||||
|
dryModeResult = BAKA_EFFECT_BAD;
|
||||||
|
dryModeResultSet = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
BuryEvent * action = NEW BuryEvent();
|
BuryEvent * action = NEW BuryEvent();
|
||||||
game->addObserver(NEW GenericTriggeredAbility(id, card,trigger,action));
|
game->addObserver(NEW GenericTriggeredAbility(id, card,trigger,action));
|
||||||
}else{
|
}else{
|
||||||
@@ -379,8 +425,9 @@ int AbilityFactory::magicText(int id, Spell * spell, MTGCardInstance * card){
|
|||||||
int myCardsPower = countCards(targetAll,card->controller(),COUNT_POWER);
|
int myCardsPower = countCards(targetAll,card->controller(),COUNT_POWER);
|
||||||
int opponentCardsPower = countCards(targetAll, card->controller()->opponent(),COUNT_POWER);
|
int opponentCardsPower = countCards(targetAll, card->controller()->opponent(),COUNT_POWER);
|
||||||
delete targetAll;
|
delete targetAll;
|
||||||
if (myNbCards < opponentNbCards || myCardsPower < opponentCardsPower) return BAKA_EFFECT_GOOD;
|
if (myNbCards < opponentNbCards || myCardsPower < opponentCardsPower) dryModeResult = BAKA_EFFECT_GOOD;
|
||||||
return BAKA_EFFECT_BAD;
|
else dryModeResult = BAKA_EFFECT_BAD;
|
||||||
|
break;
|
||||||
}else{
|
}else{
|
||||||
if (cost){
|
if (cost){
|
||||||
game->addObserver(NEW AAllDestroyer(id, card,targetAll,1,cost,doTap));
|
game->addObserver(NEW AAllDestroyer(id, card,targetAll,1,cost,doTap));
|
||||||
@@ -390,7 +437,10 @@ int AbilityFactory::magicText(int id, Spell * spell, MTGCardInstance * card){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
if (dryMode) return BAKA_EFFECT_BAD;
|
if (dryMode){
|
||||||
|
dryModeResult = BAKA_EFFECT_BAD;
|
||||||
|
break;
|
||||||
|
}
|
||||||
if (tc){
|
if (tc){
|
||||||
game->addObserver(NEW ABurier(id, card,tc));
|
game->addObserver(NEW ABurier(id, card,tc));
|
||||||
}else{
|
}else{
|
||||||
@@ -418,8 +468,9 @@ int AbilityFactory::magicText(int id, Spell * spell, MTGCardInstance * card){
|
|||||||
int myCardsPower = countCards(targetAll,card->controller(),COUNT_POWER);
|
int myCardsPower = countCards(targetAll,card->controller(),COUNT_POWER);
|
||||||
int opponentCardsPower = countCards(targetAll, card->controller()->opponent(),COUNT_POWER);
|
int opponentCardsPower = countCards(targetAll, card->controller()->opponent(),COUNT_POWER);
|
||||||
delete targetAll;
|
delete targetAll;
|
||||||
if (myNbCards < opponentNbCards || myCardsPower < opponentCardsPower) return BAKA_EFFECT_GOOD;
|
if (myNbCards < opponentNbCards || myCardsPower < opponentCardsPower) dryModeResult = BAKA_EFFECT_GOOD;
|
||||||
return BAKA_EFFECT_BAD;
|
else dryModeResult = BAKA_EFFECT_BAD;
|
||||||
|
break;
|
||||||
}else{
|
}else{
|
||||||
if (cost){
|
if (cost){
|
||||||
game->addObserver(NEW AAllDestroyer(id, card,targetAll,0,cost,doTap));
|
game->addObserver(NEW AAllDestroyer(id, card,targetAll,0,cost,doTap));
|
||||||
@@ -429,7 +480,10 @@ int AbilityFactory::magicText(int id, Spell * spell, MTGCardInstance * card){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
if (dryMode) return BAKA_EFFECT_BAD;
|
if (dryMode){
|
||||||
|
dryModeResult = BAKA_EFFECT_BAD;
|
||||||
|
break;
|
||||||
|
}
|
||||||
if (tc){
|
if (tc){
|
||||||
game->addObserver(NEW ADestroyer(id, card,tc,0,cost));
|
game->addObserver(NEW ADestroyer(id, card,tc,0,cost));
|
||||||
}else{
|
}else{
|
||||||
@@ -452,7 +506,10 @@ int AbilityFactory::magicText(int id, Spell * spell, MTGCardInstance * card){
|
|||||||
}else{
|
}else{
|
||||||
damage = atoi(s.substr(start+1).c_str());
|
damage = atoi(s.substr(start+1).c_str());
|
||||||
}
|
}
|
||||||
if (dryMode) return BAKA_EFFECT_BAD;
|
if (dryMode){
|
||||||
|
dryModeResult = BAKA_EFFECT_BAD;
|
||||||
|
break;
|
||||||
|
}
|
||||||
if (tc){
|
if (tc){
|
||||||
MTGAbility * a = NEW ADamager(id, card, cost, damage, tc,doTap);
|
MTGAbility * a = NEW ADamager(id, card, cost, damage, tc,doTap);
|
||||||
if (multi){
|
if (multi){
|
||||||
@@ -485,7 +542,10 @@ int AbilityFactory::magicText(int id, Spell * spell, MTGCardInstance * card){
|
|||||||
}else{
|
}else{
|
||||||
life = atoi(s.substr(start+1).c_str());
|
life = atoi(s.substr(start+1).c_str());
|
||||||
}
|
}
|
||||||
if (dryMode) return BAKA_EFFECT_GOOD;
|
if (dryMode){
|
||||||
|
dryModeResult = BAKA_EFFECT_GOOD;
|
||||||
|
break;
|
||||||
|
}
|
||||||
if (tc){
|
if (tc){
|
||||||
//TODO ?
|
//TODO ?
|
||||||
}else{
|
}else{
|
||||||
@@ -510,7 +570,10 @@ int AbilityFactory::magicText(int id, Spell * spell, MTGCardInstance * card){
|
|||||||
}else{
|
}else{
|
||||||
nbcards = atoi(s.substr(start+1).c_str());
|
nbcards = atoi(s.substr(start+1).c_str());
|
||||||
}
|
}
|
||||||
if (dryMode) return BAKA_EFFECT_GOOD;
|
if (dryMode){
|
||||||
|
dryModeResult = BAKA_EFFECT_GOOD;
|
||||||
|
break;
|
||||||
|
}
|
||||||
if (trigger){
|
if (trigger){
|
||||||
DrawEvent * action = NEW DrawEvent(card->controller(),nbcards);
|
DrawEvent * action = NEW DrawEvent(card->controller(),nbcards);
|
||||||
game->addObserver(NEW GenericTriggeredAbility(id, card,trigger,action));
|
game->addObserver(NEW GenericTriggeredAbility(id, card,trigger,action));
|
||||||
@@ -533,8 +596,12 @@ int AbilityFactory::magicText(int id, Spell * spell, MTGCardInstance * card){
|
|||||||
int power, toughness;
|
int power, toughness;
|
||||||
if ( parsePowerToughness(s,&power, &toughness)){
|
if ( parsePowerToughness(s,&power, &toughness)){
|
||||||
if (dryMode){
|
if (dryMode){
|
||||||
if (power >=0 && toughness >= 0 ) return BAKA_EFFECT_GOOD;
|
if (power >=0 && toughness >= 0 ) {
|
||||||
return BAKA_EFFECT_BAD;
|
dryModeResult = BAKA_EFFECT_GOOD;
|
||||||
|
}else{
|
||||||
|
dryModeResult = BAKA_EFFECT_BAD;
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
int limit = 0;
|
int limit = 0;
|
||||||
unsigned int limit_str = s.find("limit:");
|
unsigned int limit_str = s.find("limit:");
|
||||||
@@ -573,7 +640,10 @@ int AbilityFactory::magicText(int id, Spell * spell, MTGCardInstance * card){
|
|||||||
//Mana Producer
|
//Mana Producer
|
||||||
found = s.find("add");
|
found = s.find("add");
|
||||||
if (found != string::npos){
|
if (found != string::npos){
|
||||||
if (dryMode) return BAKA_EFFECT_GOOD;
|
if (dryMode){
|
||||||
|
dryModeResult = BAKA_EFFECT_GOOD;
|
||||||
|
break;
|
||||||
|
}
|
||||||
ManaCost * input = ManaCost::parseManaCost(s.substr(0,found));
|
ManaCost * input = ManaCost::parseManaCost(s.substr(0,found));
|
||||||
ManaCost * output = ManaCost::parseManaCost(s.substr(found));
|
ManaCost * output = ManaCost::parseManaCost(s.substr(found));
|
||||||
if (!input->isNull() || doTap){
|
if (!input->isNull() || doTap){
|
||||||
@@ -604,42 +674,48 @@ int AbilityFactory::magicText(int id, Spell * spell, MTGCardInstance * card){
|
|||||||
if (found > 0 && s[found-1] == '-') modifier = 0;
|
if (found > 0 && s[found-1] == '-') modifier = 0;
|
||||||
if (dryMode){
|
if (dryMode){
|
||||||
if (j == Constants::DEFENDER){
|
if (j == Constants::DEFENDER){
|
||||||
if (modifier == 1) return BAKA_EFFECT_BAD;
|
if (modifier == 1) dryModeResult = BAKA_EFFECT_BAD;
|
||||||
return BAKA_EFFECT_GOOD;
|
else dryModeResult = BAKA_EFFECT_GOOD;
|
||||||
}else{
|
}else{
|
||||||
if (modifier == 1) return BAKA_EFFECT_GOOD;
|
if (modifier == 1) dryModeResult = BAKA_EFFECT_GOOD;
|
||||||
return BAKA_EFFECT_BAD;
|
else dryModeResult = BAKA_EFFECT_BAD;
|
||||||
}
|
}
|
||||||
}
|
dryModeResultSet = 1;
|
||||||
|
break;
|
||||||
if (lordType == PARSER_LORD){
|
|
||||||
game->addObserver(NEW ALord(id,card,lordTargets,lordIncludeSelf,0,0,j,0,modifier));
|
|
||||||
}else if (lordType == PARSER_ASLONGAS){
|
|
||||||
game->addObserver(NEW AKirdApe(id,card,lordTargets,lordIncludeSelf,0,0,j,modifier));
|
|
||||||
}else{
|
}else{
|
||||||
if (tc){
|
if (lordType == PARSER_LORD){
|
||||||
game->addObserver(NEW ABasicAbilityModifierUntilEOT(id, card, j, cost,tc, modifier));
|
game->addObserver(NEW ALord(id,card,lordTargets,lordIncludeSelf,0,0,j,0,modifier));
|
||||||
}else{
|
}else if (lordType == PARSER_ASLONGAS){
|
||||||
if (!cost){
|
game->addObserver(NEW AKirdApe(id,card,lordTargets,lordIncludeSelf,0,0,j,modifier));
|
||||||
if(card->hasType("enchantment")){
|
}else{
|
||||||
game->addObserver(NEW ABasicAbilityModifier(id, card,target, j,modifier));
|
if (tc){
|
||||||
}else{
|
game->addObserver(NEW ABasicAbilityModifierUntilEOT(id, card, j, cost,tc, modifier));
|
||||||
game->addObserver(NEW AInstantBasicAbilityModifierUntilEOT(id, card,target, j,modifier));
|
|
||||||
}
|
|
||||||
}else{
|
}else{
|
||||||
game->addObserver(NEW ABasicAbilityAuraModifierUntilEOT(id, card,target, cost,j,modifier));
|
if (!cost){
|
||||||
|
if(card->hasType("enchantment")){
|
||||||
|
game->addObserver(NEW ABasicAbilityModifier(id, card,target, j,modifier));
|
||||||
|
}else{
|
||||||
|
game->addObserver(NEW AInstantBasicAbilityModifierUntilEOT(id, card,target, j,modifier));
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
game->addObserver(NEW ABasicAbilityAuraModifierUntilEOT(id, card,target, cost,j,modifier));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
result++;
|
||||||
result++;
|
continue;
|
||||||
continue;
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (dryModeResultSet) break;
|
||||||
|
|
||||||
//Tapper (icy manipulator)
|
//Tapper (icy manipulator)
|
||||||
found = s.find("tap");
|
found = s.find("tap");
|
||||||
if (found != string::npos){
|
if (found != string::npos){
|
||||||
if (dryMode) return BAKA_EFFECT_GOOD;
|
if (dryMode){
|
||||||
|
dryModeResult = BAKA_EFFECT_GOOD;
|
||||||
|
break;
|
||||||
|
}
|
||||||
if (tc){
|
if (tc){
|
||||||
game->addObserver(NEW ATapper(id, card, cost, tc));
|
game->addObserver(NEW ATapper(id, card, cost, tc));
|
||||||
}else{
|
}else{
|
||||||
@@ -653,8 +729,17 @@ int AbilityFactory::magicText(int id, Spell * spell, MTGCardInstance * card){
|
|||||||
sprintf(buf, "AUTO ACTION PARSED: %s\n", line.c_str());
|
sprintf(buf, "AUTO ACTION PARSED: %s\n", line.c_str());
|
||||||
OutputDebugString(buf);
|
OutputDebugString(buf);
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
if (dryMode){
|
||||||
|
SAFE_DELETE(tc);
|
||||||
|
SAFE_DELETE(lordTargets);
|
||||||
|
SAFE_DELETE(multi);
|
||||||
|
SAFE_DELETE(cost);
|
||||||
|
SAFE_DELETE(trigger);
|
||||||
|
return dryModeResult;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1597,7 +1682,7 @@ MTGAbility::MTGAbility(int id, MTGCardInstance * _source,Damageable * _target ):
|
|||||||
}
|
}
|
||||||
|
|
||||||
MTGAbility::~MTGAbility(){
|
MTGAbility::~MTGAbility(){
|
||||||
|
SAFE_DELETE(cost);
|
||||||
}
|
}
|
||||||
|
|
||||||
//returns 1 if this ability needs to be removed from the list of active abilities
|
//returns 1 if this ability needs to be removed from the list of active abilities
|
||||||
@@ -1687,9 +1772,6 @@ int ActivatedAbility::reactToTargetClick(Targetable * object){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ActivatedAbility::~ActivatedAbility(){
|
|
||||||
if (cost) delete cost;
|
|
||||||
}
|
|
||||||
|
|
||||||
//The whole targetAbility mechanism is messed up, mainly because of its interactions with
|
//The whole targetAbility mechanism is messed up, mainly because of its interactions with
|
||||||
// the ActionLayer, GameObserver, and parent class ActivatedAbility.
|
// the ActionLayer, GameObserver, and parent class ActivatedAbility.
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ void MTGCardInstance::initMTGCI(){
|
|||||||
doDamageTest = 1;
|
doDamageTest = 1;
|
||||||
belongs_to=NULL;
|
belongs_to=NULL;
|
||||||
tapped = 0;
|
tapped = 0;
|
||||||
blockers = NEW Blockers();
|
blockers = NULL;
|
||||||
untapping = 0;
|
untapping = 0;
|
||||||
summoningSickness = 0;
|
summoningSickness = 0;
|
||||||
target = NULL;
|
target = NULL;
|
||||||
@@ -110,6 +110,7 @@ void MTGCardInstance::addType(int type){
|
|||||||
}
|
}
|
||||||
|
|
||||||
Blockers * MTGCardInstance::getBlockers(){
|
Blockers * MTGCardInstance::getBlockers(){
|
||||||
|
if (!blockers) blockers = NEW Blockers();
|
||||||
return blockers;
|
return blockers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,220 +8,204 @@
|
|||||||
|
|
||||||
|
|
||||||
TargetChooser * TargetChooserFactory::createTargetChooser(string s, MTGCardInstance * card){
|
TargetChooser * TargetChooserFactory::createTargetChooser(string s, MTGCardInstance * card){
|
||||||
|
if (!s.size()) return NULL;
|
||||||
|
|
||||||
GameObserver * game = GameObserver::GetInstance();
|
GameObserver * game = GameObserver::GetInstance();
|
||||||
MTGGameZone * zones[10];
|
MTGGameZone * zones[10];
|
||||||
int nbzones = 0;
|
int nbzones = 0;
|
||||||
int size = s.size();
|
unsigned int found;
|
||||||
if (size != 0){
|
|
||||||
unsigned int found;
|
found = s.find("player");
|
||||||
found = s.find("player");
|
if (found != string::npos){
|
||||||
if (found != string::npos){
|
int maxtargets = 1;
|
||||||
int maxtargets = 1;
|
unsigned int several = s.find_first_of('s',5);
|
||||||
unsigned int several = s.find_first_of('s',5);
|
if (several != string::npos) maxtargets = -1;
|
||||||
if (several != string::npos) maxtargets = -1;
|
found = s.find("creature");
|
||||||
found = s.find("creature");
|
if (found != string::npos) return NEW DamageableTargetChooser(card,maxtargets); //Any Damageable target (player, creature)
|
||||||
|
return NEW PlayerTargetChooser(card,maxtargets); //Any player
|
||||||
|
}
|
||||||
|
|
||||||
|
string s1;
|
||||||
|
found = s.find("|");
|
||||||
|
if (found != string::npos){
|
||||||
|
string s2;
|
||||||
|
s1 = s.substr(0,found);
|
||||||
|
s2 = s.substr(found+1);
|
||||||
|
while(s2.size()){
|
||||||
|
found = s2.find(",");
|
||||||
|
string zoneName;
|
||||||
if (found != string::npos){
|
if (found != string::npos){
|
||||||
return NEW DamageableTargetChooser(card,maxtargets); //Any Damageable target (player, creature)
|
zoneName = s2.substr(0,found);
|
||||||
|
s2 = s2.substr(found+1);
|
||||||
}else{
|
}else{
|
||||||
return NEW PlayerTargetChooser(card,maxtargets); //Any player
|
zoneName = s2;
|
||||||
|
s2 = "";
|
||||||
|
}
|
||||||
|
zones[nbzones] = game->currentlyActing()->game->inPlay;
|
||||||
|
|
||||||
|
//Graveyards
|
||||||
|
if(zoneName.compare("graveyard") == 0){
|
||||||
|
zones[nbzones] = game->players[0]->game->graveyard;
|
||||||
|
nbzones++;
|
||||||
|
zones[nbzones] = game->players[1]->game->graveyard;
|
||||||
|
}else if(zoneName.compare("inplay") == 0){
|
||||||
|
zones[nbzones] = game->players[0]->game->inPlay;
|
||||||
|
nbzones++;
|
||||||
|
zones[nbzones] = game->players[1]->game->inPlay;
|
||||||
|
}else{
|
||||||
|
MTGGameZone * zone = MTGGameZone::stringToZone(zoneName, card,card);
|
||||||
|
if (zone) zones[nbzones] = zone;
|
||||||
|
}
|
||||||
|
nbzones++;
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
s1 = s;
|
||||||
|
nbzones = 2;
|
||||||
|
zones[0]= game->players[0]->game->inPlay;
|
||||||
|
zones[1]= game->players[1]->game->inPlay;
|
||||||
|
}
|
||||||
|
|
||||||
|
TargetChooser * tc = NULL;
|
||||||
|
int maxtargets = 1;
|
||||||
|
CardDescriptor * cd = NULL;
|
||||||
|
|
||||||
|
while(s1.size()){
|
||||||
|
found = s1.find(",");
|
||||||
|
string typeName;
|
||||||
|
if (found != string::npos){
|
||||||
|
typeName = s1.substr(0,found);
|
||||||
|
s1 = s1.substr(found+1);
|
||||||
|
}else{
|
||||||
|
typeName = s1;
|
||||||
|
s1 = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
//Advanced cards caracteristics ?
|
||||||
|
found = typeName.find("[");
|
||||||
|
if (found != string::npos){
|
||||||
|
int nbminuses = 0;
|
||||||
|
int end = typeName.find("]");
|
||||||
|
#ifdef WIN32
|
||||||
|
OutputDebugString("Advanced Attributes 1 \n");
|
||||||
|
#endif
|
||||||
|
string attributes = typeName.substr(found+1,end-found-1);
|
||||||
|
#ifdef WIN32
|
||||||
|
OutputDebugString(attributes.c_str());
|
||||||
|
OutputDebugString("\n");
|
||||||
|
#endif
|
||||||
|
cd = NEW CardDescriptor();
|
||||||
|
while(attributes.size()){
|
||||||
|
unsigned int found2 = attributes.find(";");
|
||||||
|
string attribute;
|
||||||
|
if (found2 != string::npos){
|
||||||
|
attribute = attributes.substr(0,found2);
|
||||||
|
attributes = attributes.substr(found2+1);
|
||||||
|
}else{
|
||||||
|
attribute = attributes;
|
||||||
|
attributes = "";
|
||||||
|
}
|
||||||
|
int minus = 0;
|
||||||
|
if (attribute[0] == '-'){
|
||||||
|
#ifdef WIN32
|
||||||
|
OutputDebugString("MINUS\n");
|
||||||
|
#endif
|
||||||
|
minus = 1;
|
||||||
|
nbminuses++;
|
||||||
|
attribute=attribute.substr(1);
|
||||||
|
}
|
||||||
|
#ifdef WIN32
|
||||||
|
OutputDebugString(attribute.c_str());
|
||||||
|
OutputDebugString("\n");
|
||||||
|
#endif
|
||||||
|
//Attacker
|
||||||
|
if (attribute.find("attacking") != string::npos){
|
||||||
|
if (minus){
|
||||||
|
cd->attacker = -1;
|
||||||
|
}else{
|
||||||
|
cd->attacker = 1;
|
||||||
|
}
|
||||||
|
//Blocker
|
||||||
|
}else if (attribute.find("blocking") != string::npos){
|
||||||
|
if (minus){
|
||||||
|
cd->defenser = (MTGCardInstance *)-1; //Oh yeah, that's ugly....
|
||||||
|
}else{
|
||||||
|
cd->defenser = (MTGCardInstance *)1;
|
||||||
|
}
|
||||||
|
//Tapped, untapped
|
||||||
|
}else if (attribute.find("tapped") != string::npos){
|
||||||
|
if (minus){
|
||||||
|
cd->tapped = -1;
|
||||||
|
}else{
|
||||||
|
cd->tapped = 1;
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
int attributefound = 0;
|
||||||
|
//Colors
|
||||||
|
for (int cid = 0; cid < Constants::MTG_NB_COLORS; cid++){
|
||||||
|
if (attribute.find(Constants::MTGColorStrings[cid]) != string::npos){
|
||||||
|
attributefound = 1;
|
||||||
|
if (minus){
|
||||||
|
cd->colors[cid] = -1;
|
||||||
|
}else{
|
||||||
|
cd->colors[cid] = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!attributefound){
|
||||||
|
//Abilities
|
||||||
|
for (int j = 0; j < Constants::NB_BASIC_ABILITIES; j++){
|
||||||
|
if (attribute.find(Constants::MTGBasicAbilities[j]) != string::npos){
|
||||||
|
attributefound = 1;
|
||||||
|
if (minus){
|
||||||
|
cd->basicAbilities[j] = -1;
|
||||||
|
}else{
|
||||||
|
cd->basicAbilities[j] = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!attributefound){
|
||||||
|
//Subtypes
|
||||||
|
if (minus){
|
||||||
|
cd->setNegativeSubtype(attribute);
|
||||||
|
}else{
|
||||||
|
cd->setSubtype(attribute);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (nbminuses == 0) cd->mode = CD_OR;
|
||||||
|
typeName = typeName.substr(0,found);
|
||||||
|
}
|
||||||
|
//X targets allowed ?
|
||||||
|
if (typeName.at(typeName.length()-1) == 's' && !Subtypes::subtypesList->find(typeName)){
|
||||||
|
typeName = typeName.substr(0,typeName.length()-1);
|
||||||
|
maxtargets = -1;
|
||||||
|
}
|
||||||
|
if (cd){
|
||||||
|
if (!tc){
|
||||||
|
if (typeName.compare("*")!=0) cd->setSubtype(typeName);
|
||||||
|
|
||||||
|
tc = NEW DescriptorTargetChooser(cd,zones,nbzones,card,maxtargets);
|
||||||
|
}else{
|
||||||
|
delete(cd);
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
string s1;
|
if (!tc){
|
||||||
found = s.find("|");
|
if (typeName.compare("*")==0){
|
||||||
if (found != string::npos){
|
return NEW TargetZoneChooser(zones, nbzones,card, maxtargets);
|
||||||
string s2;
|
}else{
|
||||||
s1 = s.substr(0,found);
|
tc = NEW TypeTargetChooser(typeName.c_str(), zones, nbzones, card,maxtargets);
|
||||||
s2 = s.substr(found+1);
|
}
|
||||||
while(s2.size()){
|
|
||||||
found = s2.find(",");
|
|
||||||
string zoneName;
|
|
||||||
if (found != string::npos){
|
|
||||||
zoneName = s2.substr(0,found);
|
|
||||||
s2 = s2.substr(found+1);
|
|
||||||
}else{
|
|
||||||
zoneName = s2;
|
|
||||||
s2 = "";
|
|
||||||
}
|
|
||||||
zones[nbzones] = game->currentlyActing()->game->inPlay;
|
|
||||||
|
|
||||||
//Graveyards
|
|
||||||
if(zoneName.compare("graveyard") == 0){
|
|
||||||
zones[nbzones] = game->players[0]->game->graveyard;
|
|
||||||
nbzones++;
|
|
||||||
zones[nbzones] = game->players[1]->game->graveyard;
|
|
||||||
}else if(zoneName.compare("inplay") == 0){
|
|
||||||
zones[nbzones] = game->players[0]->game->inPlay;
|
|
||||||
nbzones++;
|
|
||||||
zones[nbzones] = game->players[1]->game->inPlay;
|
|
||||||
}else{
|
|
||||||
MTGGameZone * zone = MTGGameZone::stringToZone(zoneName, card,card);
|
|
||||||
if (zone) zones[nbzones] = zone;
|
|
||||||
}
|
|
||||||
nbzones++;
|
|
||||||
}
|
|
||||||
}else{
|
}else{
|
||||||
s1 = s;
|
((TypeTargetChooser *)tc)->addType(typeName.c_str());
|
||||||
nbzones = 2;
|
tc->maxtargets = maxtargets;
|
||||||
zones[0]= game->players[0]->game->inPlay;
|
|
||||||
zones[1]= game->players[1]->game->inPlay;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TargetChooser * tc = NULL;
|
|
||||||
int maxtargets = 1;
|
|
||||||
CardDescriptor * cd = NULL;
|
|
||||||
|
|
||||||
while(s1.size()){
|
|
||||||
found = s1.find(",");
|
|
||||||
string typeName;
|
|
||||||
if (found != string::npos){
|
|
||||||
typeName = s1.substr(0,found);
|
|
||||||
s1 = s1.substr(found+1);
|
|
||||||
}else{
|
|
||||||
typeName = s1;
|
|
||||||
s1 = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
//Advanced cards caracteristics ?
|
|
||||||
found = typeName.find("[");
|
|
||||||
if (found != string::npos){
|
|
||||||
int nbminuses = 0;
|
|
||||||
int end = typeName.find("]");
|
|
||||||
#ifdef WIN32
|
|
||||||
OutputDebugString("Advanced Attributes 1 \n");
|
|
||||||
#endif
|
|
||||||
string attributes = typeName.substr(found+1,end-found-1);
|
|
||||||
#ifdef WIN32
|
|
||||||
OutputDebugString(attributes.c_str());
|
|
||||||
OutputDebugString("\n");
|
|
||||||
#endif
|
|
||||||
cd = NEW CardDescriptor();
|
|
||||||
while(attributes.size()){
|
|
||||||
unsigned int found2 = attributes.find(";");
|
|
||||||
string attribute;
|
|
||||||
if (found2 != string::npos){
|
|
||||||
attribute = attributes.substr(0,found2);
|
|
||||||
attributes = attributes.substr(found2+1);
|
|
||||||
}else{
|
|
||||||
attribute = attributes;
|
|
||||||
attributes = "";
|
|
||||||
}
|
|
||||||
int minus = 0;
|
|
||||||
if (attribute[0] == '-'){
|
|
||||||
#ifdef WIN32
|
|
||||||
OutputDebugString("MINUS\n");
|
|
||||||
#endif
|
|
||||||
minus = 1;
|
|
||||||
nbminuses++;
|
|
||||||
attribute=attribute.substr(1);
|
|
||||||
}
|
|
||||||
#ifdef WIN32
|
|
||||||
OutputDebugString(attribute.c_str());
|
|
||||||
OutputDebugString("\n");
|
|
||||||
#endif
|
|
||||||
//Attacker
|
|
||||||
if (attribute.find("attacking") != string::npos){
|
|
||||||
if (minus){
|
|
||||||
cd->attacker = -1;
|
|
||||||
}else{
|
|
||||||
cd->attacker = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Blocker
|
|
||||||
}else if (attribute.find("blocking") != string::npos){
|
|
||||||
if (minus){
|
|
||||||
cd->defenser = (MTGCardInstance *)-1; //Oh yeah, that's ugly....
|
|
||||||
}else{
|
|
||||||
cd->defenser = (MTGCardInstance *)1;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Tapped, untapped
|
|
||||||
}else if (attribute.find("tapped") != string::npos){
|
|
||||||
if (minus){
|
|
||||||
cd->tapped = -1;
|
|
||||||
}else{
|
|
||||||
cd->tapped = 1;
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
int attributefound = 0;
|
|
||||||
//Colors
|
|
||||||
for (int cid = 0; cid < Constants::MTG_NB_COLORS; cid++){
|
|
||||||
if (attribute.find(Constants::MTGColorStrings[cid]) != string::npos){
|
|
||||||
attributefound = 1;
|
|
||||||
if (minus){
|
|
||||||
cd->colors[cid] = -1;
|
|
||||||
}else{
|
|
||||||
cd->colors[cid] = 1;
|
|
||||||
#ifdef WIN32
|
|
||||||
OutputDebugString("COLOR FOUND !!!");
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!attributefound){
|
|
||||||
//Abilities
|
|
||||||
for (int j = 0; j < Constants::NB_BASIC_ABILITIES; j++){
|
|
||||||
if (attribute.find(Constants::MTGBasicAbilities[j]) != string::npos){
|
|
||||||
attributefound = 1;
|
|
||||||
if (minus){
|
|
||||||
cd->basicAbilities[j] = -1;
|
|
||||||
}else{
|
|
||||||
cd->basicAbilities[j] = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!attributefound){
|
|
||||||
//Subtypes
|
|
||||||
if (minus){
|
|
||||||
cd->setNegativeSubtype(attribute);
|
|
||||||
}else{
|
|
||||||
cd->setSubtype(attribute);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (nbminuses == 0){
|
|
||||||
#ifdef WIN32
|
|
||||||
OutputDebugString("Switching to OR\n");
|
|
||||||
#endif
|
|
||||||
cd->mode = CD_OR;
|
|
||||||
}
|
|
||||||
typeName = typeName.substr(0,found);
|
|
||||||
}
|
|
||||||
//X targets allowed ?
|
|
||||||
if (typeName.at(typeName.length()-1) == 's' && !Subtypes::subtypesList->find(typeName)){
|
|
||||||
typeName = typeName.substr(0,typeName.length()-1);
|
|
||||||
maxtargets = -1;
|
|
||||||
}
|
|
||||||
if (cd){
|
|
||||||
if (!tc){
|
|
||||||
if (typeName.compare("*")!=0) cd->setSubtype(typeName);
|
|
||||||
|
|
||||||
tc = NEW DescriptorTargetChooser(cd,zones,nbzones,card,maxtargets);
|
|
||||||
#ifdef WIN32
|
|
||||||
OutputDebugString("Advanced Attributes 2 \n");
|
|
||||||
#endif
|
|
||||||
}else{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
if (!tc){
|
|
||||||
if (typeName.compare("*")==0){
|
|
||||||
return NEW TargetZoneChooser(zones, nbzones,card, maxtargets);
|
|
||||||
}else{
|
|
||||||
tc = NEW TypeTargetChooser(typeName.c_str(), zones, nbzones, card,maxtargets);
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
((TypeTargetChooser *)tc)->addType(typeName.c_str());
|
|
||||||
tc->maxtargets = maxtargets;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return tc;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return NULL;
|
return tc;
|
||||||
}
|
}
|
||||||
|
|
||||||
TargetChooser * TargetChooserFactory::createTargetChooser(MTGCardInstance * card){
|
TargetChooser * TargetChooserFactory::createTargetChooser(MTGCardInstance * card){
|
||||||
@@ -421,7 +405,9 @@ int DescriptorTargetChooser::canTarget(Targetable * target){
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DescriptorTargetChooser::~DescriptorTargetChooser(){
|
||||||
|
SAFE_DELETE(cd);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Choose a creature
|
Choose a creature
|
||||||
|
|||||||
Reference in New Issue
Block a user