- Moved Cast Restriction variables "out" of CardPrimitives (replaced with a pointer). This frees 64bytes off of CardPrimitives on Windows, I assume something similar on the PSP, which gives a result of more than 500kB freed
- fix for issue 716 (text not rendered in some cases) Test suite passes
This commit is contained in:
@@ -49,12 +49,12 @@ CardPrimitive::CardPrimitive(CardPrimitive * source)
|
||||
manaCost.alternative->alternativeName = source->getManaCost()->alternative->alternativeName;
|
||||
|
||||
text = source->text;
|
||||
formattedText = source->formattedText;
|
||||
setName(source->name);
|
||||
|
||||
power = source->power;
|
||||
toughness = source->toughness;
|
||||
restriction = source->restriction;
|
||||
otherrestriction = source->otherrestriction;
|
||||
restrictions = source->restrictions ? source->restrictions->clone() : NULL;
|
||||
suspendedTime = source->suspendedTime;
|
||||
|
||||
magicText = source->magicText;
|
||||
@@ -66,6 +66,7 @@ CardPrimitive::CardPrimitive(CardPrimitive * source)
|
||||
|
||||
CardPrimitive::~CardPrimitive()
|
||||
{
|
||||
SAFE_DELETE(restrictions);
|
||||
}
|
||||
|
||||
int CardPrimitive::init()
|
||||
@@ -78,7 +79,7 @@ int CardPrimitive::init()
|
||||
magicTexts.clear();
|
||||
spellTargetType = "";
|
||||
alias = 0;
|
||||
hasRestriction = false;
|
||||
restrictions = NULL;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -99,22 +100,34 @@ bool CardPrimitive::isSpell()
|
||||
|
||||
void CardPrimitive::setRestrictions(string _restriction)
|
||||
{
|
||||
restriction = _restriction;
|
||||
if (!restrictions)
|
||||
restrictions = NEW CastRestrictions();
|
||||
|
||||
restrictions->restriction = _restriction;
|
||||
}
|
||||
|
||||
void CardPrimitive::getRestrictions()
|
||||
const string CardPrimitive::getRestrictions()
|
||||
{
|
||||
restriction;
|
||||
if (!restrictions)
|
||||
return "";
|
||||
|
||||
return restrictions->restriction;
|
||||
}
|
||||
|
||||
void CardPrimitive::setOtherRestrictions(string _restriction)
|
||||
{
|
||||
otherrestriction = _restriction;
|
||||
if (!restrictions)
|
||||
restrictions = NEW CastRestrictions();
|
||||
|
||||
restrictions->otherrestriction = _restriction;
|
||||
}
|
||||
|
||||
void CardPrimitive::getOtherRestrictions()
|
||||
const string CardPrimitive::getOtherRestrictions()
|
||||
{
|
||||
otherrestriction;
|
||||
if (!restrictions)
|
||||
return "";
|
||||
|
||||
return restrictions->otherrestriction;
|
||||
}
|
||||
|
||||
void CardPrimitive::setColor(const string& _color, int removeAllOthers)
|
||||
|
||||
@@ -67,12 +67,12 @@ int MTGAbility::parseCastRestrictions(MTGCardInstance * card,Player * player,str
|
||||
|
||||
int MTGAbility::allowedToCast(MTGCardInstance * card,Player * player)
|
||||
{
|
||||
return parseCastRestrictions(card,player,card->restriction,"");
|
||||
return parseCastRestrictions(card,player,card->getRestrictions(),"");
|
||||
}
|
||||
|
||||
int MTGAbility::allowedToAltCast(MTGCardInstance * card,Player * player)
|
||||
{
|
||||
return parseCastRestrictions(card,player,"",card->otherrestriction);
|
||||
return parseCastRestrictions(card,player,"",card->getOtherRestrictions());
|
||||
}
|
||||
|
||||
int AbilityFactory::parseCastRestrictions(MTGCardInstance * card,Player * player,string restrictions,string otherRestrictions)
|
||||
|
||||
@@ -94,6 +94,16 @@ int MTGAllCards::processConfLine(string &s, MTGCard *card, CardPrimitive * primi
|
||||
}
|
||||
break;
|
||||
|
||||
case 'b': //buyback
|
||||
if (!primitive) primitive = NEW CardPrimitive();
|
||||
if (ManaCost * cost = primitive->getManaCost())
|
||||
{
|
||||
string value = val;
|
||||
std::transform(value.begin(), value.end(), value.begin(), ::tolower);
|
||||
cost->BuyBack = ManaCost::parseManaCost(value);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'c': //color
|
||||
if (!primitive) primitive = NEW CardPrimitive();
|
||||
{
|
||||
@@ -109,10 +119,36 @@ int MTGAllCards::processConfLine(string &s, MTGCard *card, CardPrimitive * primi
|
||||
}
|
||||
break;
|
||||
|
||||
case 'f': //flashback//morph
|
||||
{
|
||||
if (!primitive) primitive = NEW CardPrimitive();
|
||||
if(ManaCost * cost = primitive->getManaCost())
|
||||
{
|
||||
if( s.find("facedown") != string::npos)//morph
|
||||
{
|
||||
string value = val;
|
||||
std::transform(value.begin(), value.end(), value.begin(), ::tolower);
|
||||
cost->morph = ManaCost::parseManaCost(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
string value = val;
|
||||
std::transform(value.begin(), value.end(), value.begin(), ::tolower);
|
||||
cost->FlashBack = ManaCost::parseManaCost(value);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case 'g': //grade
|
||||
if (s.size() - i - 1 > 2) currentGrade = getGrade(val[2]);
|
||||
break;
|
||||
|
||||
case 'i': //id
|
||||
if (!card) card = NEW MTGCard();
|
||||
card->setMTGId(atoi(val));
|
||||
break;
|
||||
|
||||
case 'k': //kicker
|
||||
if (!primitive) primitive = NEW CardPrimitive();
|
||||
if (ManaCost * cost = primitive->getManaCost())
|
||||
@@ -123,7 +159,21 @@ int MTGAllCards::processConfLine(string &s, MTGCard *card, CardPrimitive * primi
|
||||
}
|
||||
break;
|
||||
|
||||
case 'o': //othercost
|
||||
case 'm': //mana
|
||||
if (!primitive) primitive = NEW CardPrimitive();
|
||||
{
|
||||
string value = val;
|
||||
std::transform(value.begin(), value.end(), value.begin(), ::tolower);
|
||||
primitive->setManaCost(value);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'n': //name
|
||||
if (!primitive) primitive = NEW CardPrimitive();
|
||||
primitive->setName(val);
|
||||
break;
|
||||
|
||||
case 'o': //othercost/otherrestriction
|
||||
if (!primitive) primitive = NEW CardPrimitive();
|
||||
if(key[5] == 'r')//otherrestrictions
|
||||
{
|
||||
@@ -151,54 +201,6 @@ int MTGAllCards::processConfLine(string &s, MTGCard *card, CardPrimitive * primi
|
||||
}
|
||||
break;
|
||||
|
||||
case 'b': //buyback
|
||||
if (!primitive) primitive = NEW CardPrimitive();
|
||||
if (ManaCost * cost = primitive->getManaCost())
|
||||
{
|
||||
string value = val;
|
||||
std::transform(value.begin(), value.end(), value.begin(), ::tolower);
|
||||
cost->BuyBack = ManaCost::parseManaCost(value);
|
||||
}
|
||||
break;
|
||||
case 'f': //flashback//morph
|
||||
{
|
||||
if (!primitive) primitive = NEW CardPrimitive();
|
||||
if(ManaCost * cost = primitive->getManaCost())
|
||||
{
|
||||
if( s.find("facedown") != string::npos)//morph
|
||||
{
|
||||
string value = val;
|
||||
std::transform(value.begin(), value.end(), value.begin(), ::tolower);
|
||||
cost->morph = ManaCost::parseManaCost(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
string value = val;
|
||||
std::transform(value.begin(), value.end(), value.begin(), ::tolower);
|
||||
cost->FlashBack = ManaCost::parseManaCost(value);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'i': //id
|
||||
if (!card) card = NEW MTGCard();
|
||||
card->setMTGId(atoi(val));
|
||||
break;
|
||||
|
||||
case 'm': //mana
|
||||
if (!primitive) primitive = NEW CardPrimitive();
|
||||
{
|
||||
string value = val;
|
||||
std::transform(value.begin(), value.end(), value.begin(), ::tolower);
|
||||
primitive->setManaCost(value);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'n': //name
|
||||
if (!primitive) primitive = NEW CardPrimitive();
|
||||
primitive->setName(val);
|
||||
break;
|
||||
|
||||
case 'p':
|
||||
if ('r' == key[1])
|
||||
{ // primitive
|
||||
@@ -213,13 +215,12 @@ int MTGAllCards::processConfLine(string &s, MTGCard *card, CardPrimitive * primi
|
||||
}
|
||||
break;
|
||||
|
||||
case 'r': //retrace/rarity
|
||||
case 'r': //retrace/rarity//restrictions
|
||||
if('s' == key[2] && 't' == key[3])//restrictions
|
||||
{
|
||||
if (!primitive) primitive = NEW CardPrimitive();
|
||||
string value = val;
|
||||
primitive->setRestrictions(value);
|
||||
primitive->hasRestriction = true;
|
||||
}
|
||||
else if ('e' == key[1] && 't' == key[2])
|
||||
{ //retrace
|
||||
@@ -237,6 +238,7 @@ int MTGAllCards::processConfLine(string &s, MTGCard *card, CardPrimitive * primi
|
||||
card->setRarity(val[0]);
|
||||
}
|
||||
break;
|
||||
|
||||
case 's': //subtype, suspend
|
||||
{
|
||||
if (s.find("suspend") != string::npos)
|
||||
@@ -263,6 +265,7 @@ int MTGAllCards::processConfLine(string &s, MTGCard *card, CardPrimitive * primi
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case 't':
|
||||
if (!primitive) primitive = NEW CardPrimitive();
|
||||
if (0 == strcmp("target", key))
|
||||
@@ -1068,8 +1071,8 @@ void MTGDeck::printDetailedDeckText(std::ofstream& file )
|
||||
currentCard << card->data->getPower() << "/" << card->data->getToughness() << ", ";
|
||||
|
||||
|
||||
if ( card->data->hasRestriction )
|
||||
currentCard << ", " << card->data->otherrestriction;
|
||||
if ( card->data->getOtherRestrictions().size() )
|
||||
currentCard << ", " << card->data->getOtherRestrictions();
|
||||
|
||||
for (size_t x = 0; x < card->data->basicAbilities.size(); ++x)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user