Erwan
- IMPORTANT: Legendary is not an ability anymore, creating cards with super types should be much more natural. You can now say "type=Snow Land", and stuff like that. No backward compatibility!!!
This commit is contained in:
@@ -622,7 +622,7 @@ MTGCardInstance * AIPlayerBaka::FindCardToPlay(ManaCost * pMana, const char * ty
|
||||
card = NULL;
|
||||
while((card = cd.nextmatch(game->hand, card))){
|
||||
if (card->hasType(Subtypes::TYPE_LAND) && !this->canPutLandsIntoPlay) continue;
|
||||
if (card->has(Constants::LEGENDARY) && game->inPlay->findByName(card->name)) continue;
|
||||
if (card->hasType(Subtypes::TYPE_LEGENDARY) && game->inPlay->findByName(card->name)) continue;
|
||||
int currentCost = card->getManaCost()->getConvertedCost();
|
||||
int hasX = card->getManaCost()->hasX();
|
||||
if ((currentCost > maxCost || hasX) && pMana->canAfford(card->getManaCost())){
|
||||
|
||||
@@ -355,10 +355,10 @@ int MTGCardInstance::canBlock(MTGCardInstance * opponent){
|
||||
if (opponent->protectedAgainst(this)) return 0;
|
||||
if (opponent->cantBeBlockedBy(this)) return 0;
|
||||
if (opponent->basicAbilities[Constants::UNBLOCKABLE]) return 0;
|
||||
if (opponent->basicAbilities[Constants::FEAR] && !(hasColor(Constants::MTG_COLOR_ARTIFACT) || hasColor(Constants::MTG_COLOR_BLACK))) return 0;
|
||||
if (opponent->basicAbilities[Constants::FEAR] && !(hasType(Subtypes::TYPE_ARTIFACT) || hasColor(Constants::MTG_COLOR_BLACK))) return 0;
|
||||
|
||||
//intimidate
|
||||
if (opponent->basicAbilities[Constants::INTIMIDATE] && !(hasColor(Constants::MTG_COLOR_ARTIFACT))){
|
||||
if (opponent->basicAbilities[Constants::INTIMIDATE] && !(hasType(Subtypes::TYPE_ARTIFACT))){
|
||||
int canblock = 0;
|
||||
for (int i = Constants::MTG_COLOR_GREEN; i <= Constants::MTG_COLOR_WHITE; ++i){
|
||||
if(hasColor(i) && opponent->hasColor(i)){
|
||||
|
||||
+129
-134
@@ -1,6 +1,7 @@
|
||||
#include "../include/config.h"
|
||||
#include "../include/MTGDeck.h"
|
||||
#include "../include/utils.h"
|
||||
#include "../include/Subtypes.h"
|
||||
#include "../include/Translate.h"
|
||||
#include <algorithm>
|
||||
#include <string>
|
||||
@@ -15,10 +16,10 @@ using std::string;
|
||||
|
||||
//MTGAllCards
|
||||
int MTGAllCards::processConfLine(string s, MTGCard *card, CardPrimitive * primitive){
|
||||
if (s.size() && s[0] == '#') return 0;
|
||||
unsigned int i = s.find_first_of("=");
|
||||
if (i == string::npos){
|
||||
#if defined (_DEBUG)
|
||||
if (s.size() && s[0] == '#') return 0;
|
||||
char buffer[4096];
|
||||
sprintf(buffer, "MTGDECK: Bad Line:\n %s\n", s.c_str());
|
||||
OutputDebugString(buffer);
|
||||
@@ -27,145 +28,133 @@ int MTGAllCards::processConfLine(string s, MTGCard *card, CardPrimitive * primit
|
||||
}
|
||||
string key = s.substr(0,i);
|
||||
string value = s.substr(i+1);
|
||||
if (!key.size()) return 0;
|
||||
|
||||
if(key.compare( "auto")==0){
|
||||
if(!primitive) primitive = NEW CardPrimitive();
|
||||
primitive->addMagicText(value);
|
||||
}
|
||||
else if(key.find("auto") == 0){
|
||||
if(!primitive) primitive = NEW CardPrimitive();
|
||||
primitive->addMagicText(value,key.substr(4));
|
||||
}
|
||||
else if(key.compare( "alias")==0){
|
||||
if(!primitive) primitive = NEW CardPrimitive();
|
||||
primitive->alias=atoi(value.c_str());
|
||||
}
|
||||
else if(key.compare( "target")==0){
|
||||
if(!primitive) primitive = NEW CardPrimitive();
|
||||
std::transform( value.begin(), value.end(), value.begin(),::tolower );
|
||||
primitive->spellTargetType=value;
|
||||
}
|
||||
else if(key.compare( "text")==0){
|
||||
if(!primitive) primitive = NEW CardPrimitive();
|
||||
primitive->setText(value);
|
||||
}else if (key.compare("abilities")==0){
|
||||
if(!primitive) primitive = NEW CardPrimitive();
|
||||
//Specific Abilities
|
||||
std::transform( value.begin(), value.end(), value.begin(),::tolower );
|
||||
while (value.size()){
|
||||
string attribute;
|
||||
size_t found2 = value.find(",");
|
||||
if (found2 != string::npos){
|
||||
attribute = value.substr(0,found2);
|
||||
value = value.substr(found2+1);
|
||||
}else{
|
||||
attribute = value;
|
||||
value = "";
|
||||
}
|
||||
for (int j = Constants::NB_BASIC_ABILITIES-1; j >=0 ; j--){
|
||||
size_t found = attribute.find(Constants::MTGBasicAbilities[j]);
|
||||
if (found != string::npos){
|
||||
primitive->basicAbilities[j] = 1;
|
||||
break;
|
||||
switch(key[0]) {
|
||||
case 'a':
|
||||
if(key.compare( "auto")==0){
|
||||
if(!primitive) primitive = NEW CardPrimitive();
|
||||
primitive->addMagicText(value);
|
||||
} else if(key.find("auto") == 0){
|
||||
if(!primitive) primitive = NEW CardPrimitive();
|
||||
primitive->addMagicText(value,key.substr(4));
|
||||
} else if(key.compare( "alias")==0){
|
||||
if(!primitive) primitive = NEW CardPrimitive();
|
||||
primitive->alias=atoi(value.c_str());
|
||||
} else if (key.compare("abilities")==0){
|
||||
if(!primitive) primitive = NEW CardPrimitive();
|
||||
//Specific Abilities
|
||||
std::transform( value.begin(), value.end(), value.begin(),::tolower );
|
||||
while (value.size()){
|
||||
string attribute;
|
||||
size_t found2 = value.find(",");
|
||||
if (found2 != string::npos){
|
||||
attribute = value.substr(0,found2);
|
||||
value = value.substr(found2+1);
|
||||
}else{
|
||||
attribute = value;
|
||||
value = "";
|
||||
}
|
||||
for (int j = Constants::NB_BASIC_ABILITIES-1; j >=0 ; j--){
|
||||
size_t found = attribute.find(Constants::MTGBasicAbilities[j]);
|
||||
if (found != string::npos){
|
||||
primitive->basicAbilities[j] = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}else if(key.compare("id")==0){
|
||||
if (!card) card = NEW MTGCard();
|
||||
card->setMTGId(atoi(value.c_str()));
|
||||
}else if(key.compare("name")==0){
|
||||
if(!primitive) primitive = NEW CardPrimitive();
|
||||
primitive->setName(value);
|
||||
}else if(key.compare("rarity")==0){
|
||||
if (!card) card = NEW MTGCard();
|
||||
card->setRarity (value.c_str()[0]);
|
||||
}else if(key.compare("mana")==0){
|
||||
if(!primitive) primitive = NEW CardPrimitive();
|
||||
std::transform( value.begin(), value.end(), value.begin(),::tolower );
|
||||
primitive->setManaCost(value);
|
||||
} else if(key.compare("color")==0){
|
||||
if(!primitive) primitive = NEW CardPrimitive();
|
||||
std::transform( value.begin(), value.end(), value.begin(),::tolower );
|
||||
primitive->setColor(value,1);
|
||||
}else if(key.compare("type")==0){
|
||||
if(!primitive) primitive = NEW CardPrimitive();
|
||||
switch(value.c_str()[0]){
|
||||
case 'C':
|
||||
case 'c':
|
||||
primitive->setType( "Creature");
|
||||
break;
|
||||
case 'A':
|
||||
case 'a':
|
||||
primitive->setType( "Artifact");
|
||||
primitive->setColor(Constants::MTG_COLOR_ARTIFACT);
|
||||
if (value.c_str()[8] == ' ' && value.c_str()[9] == 'C')
|
||||
primitive->setSubtype("Creature");
|
||||
break;
|
||||
case 'E':
|
||||
case 'e':
|
||||
primitive->setType( "Enchantment");
|
||||
break;
|
||||
case 'S':
|
||||
case 's':
|
||||
primitive->setType( "Sorcery");
|
||||
break;
|
||||
case 'B'://Basic Land
|
||||
case 'b':
|
||||
primitive->setColor(Constants::MTG_COLOR_LAND);
|
||||
primitive->setType("Land");
|
||||
primitive->setType("Basic");
|
||||
break;
|
||||
case 'L':
|
||||
case 'l':
|
||||
primitive->setColor(Constants::MTG_COLOR_LAND);
|
||||
primitive->setType( "Land");
|
||||
break;
|
||||
case 'I':
|
||||
case 'i':
|
||||
primitive->setType( "Instant");
|
||||
break;
|
||||
default:
|
||||
primitive->setType( "Error");
|
||||
#if defined (_DEBUG)
|
||||
if (primitive) {
|
||||
char buffer[4096];
|
||||
sprintf(buffer, "MTGDECK: Bad Card Type\n %s\n", s.c_str());
|
||||
OutputDebugString(buffer);
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
|
||||
}
|
||||
}else if(key.compare("power")==0){
|
||||
if(!primitive) primitive = NEW CardPrimitive();
|
||||
primitive->setPower (atoi(value.c_str()));
|
||||
}else if(key.compare("subtype")==0){
|
||||
if(!primitive) primitive = NEW CardPrimitive();
|
||||
while (value.size()){
|
||||
unsigned int found = value.find(" ");
|
||||
if (found != string::npos){
|
||||
primitive->setSubtype(value.substr(0,found));
|
||||
value = value.substr(found+1);
|
||||
}else{
|
||||
primitive->setSubtype(value);
|
||||
value = "";
|
||||
case 'c': //color
|
||||
if(!primitive) primitive = NEW CardPrimitive();
|
||||
std::transform( value.begin(), value.end(), value.begin(),::tolower );
|
||||
primitive->setColor(value,1);
|
||||
break;
|
||||
|
||||
case 'k': //kicker
|
||||
if(!primitive) primitive = NEW CardPrimitive();
|
||||
std::transform( value.begin(), value.end(), value.begin(),::tolower );
|
||||
if (ManaCost * cost = primitive->getManaCost()){
|
||||
cost->kicker = ManaCost::parseManaCost(value);
|
||||
}
|
||||
}
|
||||
}else if(key.compare("toughness")==0){
|
||||
if(!primitive) primitive = NEW CardPrimitive();
|
||||
primitive->setToughness(atoi(value.c_str()));
|
||||
}else if(key.compare("kicker")==0){
|
||||
if(!primitive) primitive = NEW CardPrimitive();
|
||||
std::transform( value.begin(), value.end(), value.begin(),::tolower );
|
||||
if (ManaCost * cost = primitive->getManaCost()){
|
||||
cost->kicker = ManaCost::parseManaCost(value);
|
||||
}
|
||||
}else if(key.compare("primitive")==0){
|
||||
if(!card) card = NEW MTGCard();
|
||||
card->setPrimitive(primitives[value]);
|
||||
}else{
|
||||
string error = "MTGDECK Parsing Error:" + s + "\n";
|
||||
OutputDebugString(error.c_str());
|
||||
break;
|
||||
|
||||
case 'i': //id
|
||||
if (!card) card = NEW MTGCard();
|
||||
card->setMTGId(atoi(value.c_str()));
|
||||
break;
|
||||
|
||||
case 'm': //mana
|
||||
if(!primitive) primitive = NEW CardPrimitive();
|
||||
std::transform( value.begin(), value.end(), value.begin(),::tolower );
|
||||
primitive->setManaCost(value);
|
||||
break;
|
||||
|
||||
case 'n': //name
|
||||
if(!primitive) primitive = NEW CardPrimitive();
|
||||
primitive->setName(value);
|
||||
break;
|
||||
|
||||
case 'p':
|
||||
if(key.compare("primitive")==0){
|
||||
if(!card) card = NEW MTGCard();
|
||||
card->setPrimitive(primitives[value]);
|
||||
} else { //power
|
||||
if(!primitive) primitive = NEW CardPrimitive();
|
||||
primitive->setPower (atoi(value.c_str()));
|
||||
}
|
||||
break;
|
||||
|
||||
case 'r': //rarity
|
||||
if (!card) card = NEW MTGCard();
|
||||
card->setRarity (value.c_str()[0]);
|
||||
break;
|
||||
|
||||
case 's': //subtype
|
||||
if(!primitive) primitive = NEW CardPrimitive();
|
||||
while (value.size()){
|
||||
unsigned int found = value.find(" ");
|
||||
if (found != string::npos){
|
||||
primitive->setSubtype(value.substr(0,found));
|
||||
value = value.substr(found+1);
|
||||
}else{
|
||||
primitive->setSubtype(value);
|
||||
value = "";
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 't':
|
||||
if(key.compare( "target")==0){
|
||||
if(!primitive) primitive = NEW CardPrimitive();
|
||||
std::transform( value.begin(), value.end(), value.begin(),::tolower );
|
||||
primitive->spellTargetType=value;
|
||||
}else if(key.compare( "text")==0){
|
||||
if(!primitive) primitive = NEW CardPrimitive();
|
||||
primitive->setText(value);
|
||||
}else if (key.compare("type")==0) {
|
||||
if(!primitive) primitive = NEW CardPrimitive();
|
||||
while (value.size()){
|
||||
unsigned int found = value.find(" ");
|
||||
if (found != string::npos){
|
||||
primitive->setType(value.substr(0,found).c_str());
|
||||
value = value.substr(found+1);
|
||||
}else{
|
||||
primitive->setType(value.c_str());
|
||||
value = "";
|
||||
}
|
||||
}
|
||||
}else if(key.compare("toughness")==0){
|
||||
if(!primitive) primitive = NEW CardPrimitive();
|
||||
primitive->setToughness(atoi(value.c_str()));
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
string error = "MTGDECK Parsing Error:" + s + "\n";
|
||||
OutputDebugString(error.c_str());
|
||||
break;
|
||||
}
|
||||
|
||||
tempPrimitive = primitive;
|
||||
@@ -338,6 +327,12 @@ bool MTGAllCards::addPrimitive(CardPrimitive * primitive, MTGCard * card){
|
||||
OutputDebugString(primitive->name.c_str());
|
||||
OutputDebugString("\n");
|
||||
}
|
||||
|
||||
//Legacy:
|
||||
//For the Deck editor, we need Lands and Artifact to be colors...
|
||||
if (primitive->hasType(Subtypes::TYPE_LAND)) primitive->setColor(Constants::MTG_COLOR_LAND);
|
||||
if (primitive->hasType(Subtypes::TYPE_ARTIFACT)) primitive->setColor(Constants::MTG_COLOR_ARTIFACT);
|
||||
|
||||
primitives[key] = primitive;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ const char* Constants::MTGBasicAbilities[] = {
|
||||
"persist",
|
||||
"retrace",
|
||||
"exalted",
|
||||
"legendary",
|
||||
"nofizzle",
|
||||
"shadow",
|
||||
"reachshadow",
|
||||
"foresthome",
|
||||
@@ -55,7 +55,6 @@ const char* Constants::MTGBasicAbilities[] = {
|
||||
"deathtouch",
|
||||
"horsemanship",
|
||||
"cantregenerate",
|
||||
"nofizzle",
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "../include/config.h"
|
||||
#include "../include/MTGRules.h"
|
||||
#include "../include/Translate.h"
|
||||
#include "../include/Subtypes.h"
|
||||
#include "../include/GameOptions.h"
|
||||
|
||||
MTGPutInPlayRule::MTGPutInPlayRule(int _id):MTGAbility(_id, NULL){
|
||||
@@ -519,7 +520,7 @@ HUDDisplay::~HUDDisplay(){
|
||||
MTGLegendRule::MTGLegendRule(int _id):ListMaintainerAbility(_id){};
|
||||
|
||||
int MTGLegendRule::canBeInList(MTGCardInstance * card){
|
||||
if (card->basicAbilities[Constants::LEGENDARY] && game->isInPlay(card)){
|
||||
if (card->hasType(Subtypes::TYPE_LEGENDARY) && game->isInPlay(card)){
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
|
||||
@@ -15,6 +15,7 @@ Subtypes::Subtypes(){
|
||||
find("Instant");
|
||||
find("Land");
|
||||
find("Artifact");
|
||||
find("Legendary");
|
||||
}
|
||||
|
||||
int Subtypes::find(string value, bool forceAdd){
|
||||
|
||||
@@ -191,7 +191,7 @@ TargetChooser * TargetChooserFactory::createTargetChooser(string s, MTGCardInsta
|
||||
}else{
|
||||
int attributefound = 0;
|
||||
//Colors
|
||||
for (int cid = 0; cid < Constants::MTG_NB_COLORS; cid++){
|
||||
for (int cid = 1; cid < Constants::MTG_NB_COLORS - 1; cid++){ //remove Artifact and Land from the loop
|
||||
if (attribute.find(Constants::MTGColorStrings[cid]) != string::npos){
|
||||
attributefound = 1;
|
||||
if (minus){
|
||||
|
||||
Reference in New Issue
Block a user