-fix issue 33
This commit is contained in:
wagic.the.homebrew@gmail.com
2009-09-25 14:06:31 +00:00
parent eabb99c675
commit 1534397f2b
4 changed files with 13 additions and 6 deletions
+4
View File
@@ -129,6 +129,10 @@ class MTGCardInstance: public MTGCard, public Damageable {
JSample * getSample(); JSample * getSample();
ostream& toString(ostream&) const; ostream& toString(ostream&) const;
static MTGCardInstance AnyCard;
static MTGCardInstance NoCard;
}; };
ostream& operator<<(ostream&, const MTGCardInstance&); ostream& operator<<(ostream&, const MTGCardInstance&);
+4 -4
View File
@@ -112,21 +112,21 @@ MTGCardInstance * CardDescriptor::match(MTGCardInstance * card){
if (attacker == 1){ if (attacker == 1){
if ((int)defenser == 1){ if (defenser == &AnyCard){
if (!card->attacker && !card->defenser) match = NULL; if (!card->attacker && !card->defenser) match = NULL;
}else{ }else{
if (!card->attacker) match = NULL; if (!card->attacker) match = NULL;
} }
}else if (attacker == -1){ }else if (attacker == -1){
if ((int)defenser == -1){ if (defenser == &NoCard){
if (card->attacker || card->defenser) match = NULL; if (card->attacker || card->defenser) match = NULL;
}else{ }else{
if (card->attacker) match = NULL; if (card->attacker) match = NULL;
} }
}else{ }else{
if ((int)defenser == -1){ if (defenser == &NoCard){
if (card->defenser) match = NULL; if (card->defenser) match = NULL;
}else if ((int)defenser == 1){ }else if (defenser == &AnyCard){
if (!card->defenser) match = NULL; if (!card->defenser) match = NULL;
}else{ }else{
// we don't care about the attack/blocker state // we don't care about the attack/blocker state
+3
View File
@@ -12,6 +12,9 @@
#include <algorithm> #include <algorithm>
using namespace std; using namespace std;
MTGCardInstance MTGCardInstance::AnyCard = MTGCardInstance();
MTGCardInstance MTGCardInstance::NoCard = MTGCardInstance();
MTGCardInstance::MTGCardInstance(): MTGCard(), Damageable(0), view(NULL){ MTGCardInstance::MTGCardInstance(): MTGCard(), Damageable(0), view(NULL){
LOG("==Creating MTGCardInstance=="); LOG("==Creating MTGCardInstance==");
initMTGCI(); initMTGCI();
+2 -2
View File
@@ -124,9 +124,9 @@ TargetChooser * TargetChooserFactory::createTargetChooser(string s, MTGCardInsta
//Blocker //Blocker
}else if (attribute.find("blocking") != string::npos){ }else if (attribute.find("blocking") != string::npos){
if (minus){ if (minus){
cd->defenser = (MTGCardInstance *)-1; //Oh yeah, that's ugly.... cd->defenser = & MTGCardInstance::NoCard;
}else{ }else{
cd->defenser = (MTGCardInstance *)1; cd->defenser = & MTGCardInstance::AnyCard;
} }
//Tapped, untapped //Tapped, untapped
}else if (attribute.find("tapped") != string::npos){ }else if (attribute.find("tapped") != string::npos){