- fixed a few bugs with the parser for subtypes
- fixed a bug for plague rats
- fixed a bug for P/T parser
- First release for the following sets: Mirrodin, Mirage, Lorwyn
This commit is contained in:
wagic.the.homebrew
2009-03-14 11:00:31 +00:00
parent bb23db4b16
commit 658ef1fb12
22 changed files with 11783 additions and 59 deletions
+24 -6
View File
@@ -13,13 +13,26 @@ int CardDescriptor::init(){
return result;
}
void CardDescriptor::setNegativeSubtype( string value){
int id = Subtypes::subtypesList->Add(value);
addType(-id);
}
MTGCardInstance * CardDescriptor::match_or(MTGCardInstance * card){
int found = 1;
for (int i = 0; i< nb_types; i++){
found = 0;
if (card->hasSubtype(types[i]) || (card->name.compare(Subtypes::subtypesList->find(types[i])) == 0)){
found = 1;
break;
if (types[i] >= 0){
if (card->hasSubtype(types[i]) || (Subtypes::subtypesList->find(card->name) == types[i])){
found = 1;
break;
}
}else{
if (!card->hasSubtype(-types[i])){
found = 1;
break;
}
}
}
if (!found) return NULL;
@@ -47,9 +60,14 @@ MTGCardInstance * CardDescriptor::match_or(MTGCardInstance * card){
MTGCardInstance * CardDescriptor::match_and(MTGCardInstance * card){
MTGCardInstance * match = card;
for (int i = 0; i< nb_types; i++){
if (!card->hasSubtype(types[i]) && !(card->name.compare(Subtypes::subtypesList->find(types[i])) == 0)){
match = NULL;
if (types[i] >= 0){
if (!card->hasSubtype(types[i]) && !(Subtypes::subtypesList->find(card->name) == types[i])){
match = NULL;
}
}else{
if(card->hasSubtype(-types[i])){
match = NULL;
}
}
}
for (int i = 0; i< Constants::MTG_NB_COLORS; i++){
+5 -1
View File
@@ -284,12 +284,16 @@ void CardGui::Render(){
JRenderer * renderer = JRenderer::GetInstance();
JQuad * quad = card->getThumb();
#if defined (WIN32) || defined (LINUX)
//This shouldn't be done for the PSP. Basically it forces the system to load
// The big image if it cannot find the thumbnail. That's great for image quality on a PC,
// But it kills the performance for those who don't have thumbnails on the PSP
if (!quad || quad->mHeight * 2 < mHeight){
JQuad * quad2 = card->getQuad();
if (quad2)
quad = quad2;
}
#endif
float tap = (float)(card->isTapped());
float rotation = M_PI_2 * tap;
float mScale = mHeight / 64;
+4 -2
View File
@@ -67,8 +67,10 @@ Damageable * AbilityFactory::parseCollateralTarget(MTGCardInstance * card, strin
int AbilityFactory::parsePowerToughness(string s, int *power, int *toughness){
size_t found = s.find("/");
if (found != string::npos){
size_t start = s.find(":", found - 4);
if (start == string::npos) start = s.find(" ", found - 4);
int search_from = found - 4;
if (search_from < 0) search_from = 0;
size_t start = s.find(':', search_from);
if (start == string::npos) start = s.find(" ", search_from);
if (start == string::npos) start = -1;
*power = atoi(s.substr(start+1,s.size()-found).c_str());
size_t end = s.find(" ",start);
+5 -12
View File
@@ -178,19 +178,9 @@ void MTGCard::addType(char * _type_text){
}
void MTGCard::setSubtype( string value){
string s = value;
while (s.size()){
unsigned int found = s.find(" ");
if (found != string::npos){
int id = Subtypes::subtypesList->Add(s.substr(0,found));
int id = Subtypes::subtypesList->Add(value);
addType(id);
s = s.substr(found+1);
}else{
int id = Subtypes::subtypesList->Add(s);
addType(id);
s = "";
}
}
}
void MTGCard::addType(int id){
@@ -242,6 +232,9 @@ void MTGCard::addMagicText(string value){
void MTGCard::setName( string value){
name = value;
//This is a bug fix for plague rats and the "foreach ability"
//Right now we add names as types, so that they get recognized
if (value.at(value.length()-1) == 's') Subtypes::subtypesList->Add(value);
}
const char * MTGCard::getName(){
+11 -1
View File
@@ -87,6 +87,7 @@ int MTGAllCards::processConfLine(string s, MTGCard *card){
case 'B'://Basic Land
card->setColor(Constants::MTG_COLOR_LAND);
card->setType("Land");
card->setType("Basic");
break;
case 'L':
card->setColor(Constants::MTG_COLOR_LAND);
@@ -103,7 +104,16 @@ int MTGAllCards::processConfLine(string s, MTGCard *card){
}else if(key.compare("power")==0){
card->setPower (atoi(value.c_str()));
}else if(key.compare("subtype")==0){
card->setSubtype(value);
while (value.size()){
unsigned int found = value.find(" ");
if (found != string::npos){
card->setSubtype(value.substr(0,found));
value = value.substr(found+1);
}else{
card->setSubtype(value);
value = "";
}
}
}else if(key.compare("toughness")==0){
card->setToughness(atoi(value.c_str()));
}else{
+27 -16
View File
@@ -121,6 +121,7 @@ TargetChooser * TargetChooserFactory::createTargetChooser(string s, MTGCardInsta
#endif
minus = 1;
nbminuses++;
attribute=attribute.substr(1);
}
#ifdef WIN32
OutputDebugString(attribute.c_str());
@@ -166,21 +167,30 @@ OutputDebugString("COLOR FOUND !!!");
}
}
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;
}
}
}
}
//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 < 2){
if (nbminuses == 0){
#ifdef WIN32
OutputDebugString("Switching to OR\n");
#endif
@@ -196,6 +206,7 @@ OutputDebugString("COLOR FOUND !!!");
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");
@@ -379,11 +390,11 @@ int TypeTargetChooser::canTarget(Targetable * target ){
if (target->typeAsTarget() == TARGET_CARD){
MTGCardInstance * card = (MTGCardInstance *) target;
if (!TargetZoneChooser::canTarget(card)) return 0;
int result = 0;
for (int i= 0; i < nbtypes; i++){
result += card->hasSubtype(types[i]);
if (card->hasSubtype(types[i])) return 1;
if (Subtypes::subtypesList->find(card->name) == types[i]) return 1;
}
return result;
return 0;
}
return 0;
}