Added / fixed primitives from ONE set, fixed Treasure name in all sets and primitives, updated missing cards by sets list, improved token creator ability by trying to retrieve the token id from the same set of source card (e.g. Urza's Saga), improved toxic ability adding a new target chooser "hastoxic" and adding a new keyword "toxicity" to retrieve the toxic amount of card.
This commit is contained in:
@@ -32,8 +32,9 @@ CardDescriptor::CardDescriptor()
|
||||
hasBackSide = 0;
|
||||
hasPartner = 0;
|
||||
modified = 0;
|
||||
toxicity = 0;
|
||||
hasXCost = 0;
|
||||
compareName ="";
|
||||
compareName = "";
|
||||
nameComparisonMode = COMPARISON_NONE;
|
||||
colorComparisonMode = COMPARISON_NONE;
|
||||
CDopponentDamaged = 0;
|
||||
@@ -95,6 +96,11 @@ void CardDescriptor::unsecureSetModified(int k)
|
||||
modified = k;
|
||||
}
|
||||
|
||||
void CardDescriptor::unsecureSetHasToxic(int k)
|
||||
{
|
||||
toxicity = k;
|
||||
}
|
||||
|
||||
void CardDescriptor::unsecureSetHasPartner(int k)
|
||||
{
|
||||
hasPartner = k;
|
||||
@@ -367,6 +373,11 @@ MTGCardInstance * CardDescriptor::match(MTGCardInstance * card)
|
||||
match = NULL;
|
||||
}
|
||||
|
||||
if ((toxicity == -1 && card->getToxicity() > 0) || (toxicity == 1 && card->getToxicity() == 0))
|
||||
{
|
||||
match = NULL;
|
||||
}
|
||||
|
||||
if ((hasPartner == -1 && card->partner != "") || (hasPartner == 1 && card->partner == ""))
|
||||
{
|
||||
match = NULL;
|
||||
|
||||
@@ -1568,6 +1568,18 @@ bool CardGui::FilterCard(MTGCard * _card,string filter)
|
||||
cd.unsecureSetModified(1);
|
||||
}
|
||||
}
|
||||
//Has toxic
|
||||
else if (attribute.find("hastoxic") != string::npos)
|
||||
{
|
||||
if (minus)
|
||||
{
|
||||
cd.unsecureSetHasToxic(-1);
|
||||
}
|
||||
else
|
||||
{
|
||||
cd.unsecureSetHasToxic(1);
|
||||
}
|
||||
}
|
||||
//Has partner
|
||||
else if (attribute.find("haspartner") != string::npos)
|
||||
{
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "Translate.h"
|
||||
#include "WResourceManager.h"
|
||||
#include "GameObserver.h"
|
||||
#include "WParsedInt.h"
|
||||
|
||||
Damage::Damage(GameObserver* observer, MTGCardInstance * source, Damageable * target)
|
||||
: Interruptible(observer)
|
||||
@@ -213,10 +214,9 @@ int Damage::resolve()
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (target->type_as_damageable == Damageable::DAMAGEABLE_PLAYER && (source->has(Constants::POISONTOXIC) ||
|
||||
source->has(Constants::POISONTWOTOXIC) || source->has(Constants::POISONTHREETOXIC)))
|
||||
else if ((target->type_as_damageable == Damageable::DAMAGEABLE_PLAYER) && (source->getToxicity() > 0))
|
||||
{
|
||||
//Damage + 1, 2, or 3 poison counters on player
|
||||
//Damage + poison counters on player
|
||||
Player * _target = (Player *) target;
|
||||
if(!_target->inPlay()->hasAbility(Constants::CANTCHANGELIFE))
|
||||
a = target->dealDamage(damage);
|
||||
@@ -234,20 +234,7 @@ int Damage::resolve()
|
||||
}
|
||||
if(!_target->inPlay()->hasAbility(Constants::POISONSHROUD))
|
||||
{
|
||||
int poison = 0;
|
||||
if (source->has(Constants::POISONTOXIC))
|
||||
{
|
||||
poison = 1;
|
||||
}
|
||||
else if (source->has(Constants::POISONTWOTOXIC))
|
||||
{
|
||||
poison = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
poison = 3;
|
||||
}
|
||||
_target->poisonCount += poison;
|
||||
_target->poisonCount += source->getToxicity();
|
||||
WEvent * e = NEW WEventplayerPoisoned(_target, damage); // Added an event when player receives any poison counter.
|
||||
_target->getObserver()->receiveEvent(e);
|
||||
}
|
||||
|
||||
@@ -583,6 +583,33 @@ int MTGCardInstance::has(int basicAbility)
|
||||
return basicAbilities[basicAbility];
|
||||
}
|
||||
|
||||
//Return the toxicity of card
|
||||
int MTGCardInstance::getToxicity()
|
||||
{
|
||||
int toxicity = 0;
|
||||
if(has(Constants::POISONTOXIC))
|
||||
toxicity = 1;
|
||||
else if(has(Constants::POISONTWOTOXIC))
|
||||
toxicity = 2;
|
||||
else if(has(Constants::POISONTHREETOXIC))
|
||||
toxicity = 3;
|
||||
else if(has(Constants::POISONFOURTOXIC))
|
||||
toxicity = 4;
|
||||
else if(has(Constants::POISONFIVETOXIC))
|
||||
toxicity = 5;
|
||||
else if(has(Constants::POISONSIXTOXIC))
|
||||
toxicity = 6;
|
||||
else if(has(Constants::POISONSEVENTOXIC))
|
||||
toxicity = 7;
|
||||
else if(has(Constants::POISONEIGHTTOXIC))
|
||||
toxicity = 8;
|
||||
else if(has(Constants::POISONNINETOXIC))
|
||||
toxicity = 9;
|
||||
else if(has(Constants::POISONTENTOXIC))
|
||||
toxicity = 10;
|
||||
return toxicity;
|
||||
}
|
||||
|
||||
ManaCost* MTGCardInstance::getReducedManaCost()
|
||||
{
|
||||
return &reducedCost;
|
||||
|
||||
@@ -822,7 +822,7 @@ void MTGAllCards::prefetchCardNameCache()
|
||||
}
|
||||
#endif
|
||||
|
||||
MTGCard * MTGAllCards::getCardByName(string nameDescriptor)
|
||||
MTGCard * MTGAllCards::getCardByName(string nameDescriptor, int forcedSetId)
|
||||
{
|
||||
boost::mutex::scoped_lock lock(instance->mMutex);
|
||||
if (!nameDescriptor.size()) return NULL;
|
||||
@@ -832,7 +832,7 @@ MTGCard * MTGAllCards::getCardByName(string nameDescriptor)
|
||||
|
||||
map<string, MTGCard * >::iterator cached = mtgCardByNameCache.find(nameDescriptor);
|
||||
|
||||
if (cached!= mtgCardByNameCache.end())
|
||||
if ((forcedSetId < 0) && (cached!= mtgCardByNameCache.end()))
|
||||
{
|
||||
return cached->second;
|
||||
}
|
||||
@@ -845,6 +845,21 @@ MTGCard * MTGAllCards::getCardByName(string nameDescriptor)
|
||||
return result;
|
||||
}
|
||||
|
||||
map<int, MTGCard *>::iterator it;
|
||||
if(forcedSetId != -1){
|
||||
for (it = collection.begin(); it != collection.end(); it++)
|
||||
{
|
||||
MTGCard * c = it->second;
|
||||
if (forcedSetId != c->setId) continue;
|
||||
string cardName = c->data->name;
|
||||
std::transform(cardName.begin(), cardName.end(), cardName.begin(), ::tolower);
|
||||
if (cardName.compare(nameDescriptor) == 0) {
|
||||
mtgCardByNameCache[nameDescriptor] = c;
|
||||
return c;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int setId = -1;
|
||||
size_t found = nameDescriptor.find(" (");
|
||||
string name = nameDescriptor;
|
||||
@@ -859,9 +874,8 @@ MTGCard * MTGAllCards::getCardByName(string nameDescriptor)
|
||||
|
||||
//Reconstruct a clean string "name (set)" for cache consistency
|
||||
nameDescriptor = name + " (" + setName + ")";
|
||||
|
||||
}
|
||||
map<int, MTGCard *>::iterator it;
|
||||
|
||||
for (it = collection.begin(); it != collection.end(); it++)
|
||||
{
|
||||
MTGCard * c = it->second;
|
||||
@@ -872,8 +886,8 @@ MTGCard * MTGAllCards::getCardByName(string nameDescriptor)
|
||||
mtgCardByNameCache[nameDescriptor] = c;
|
||||
return c;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
mtgCardByNameCache[nameDescriptor] = NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -80,9 +80,9 @@ const char* Constants::MTGBasicAbilities[] = {
|
||||
"cantregen",
|
||||
"oneblocker",
|
||||
"infect",
|
||||
"poisontoxic",
|
||||
"poisontwotoxic",
|
||||
"poisonthreetoxic",
|
||||
"poisontoxic", // Card has toxic 1
|
||||
"poisontwotoxic", // Card has toxic 2
|
||||
"poisonthreetoxic", // Card has toxic 3
|
||||
"phantom",//prevents damage and remove 1 +1/+1 counter
|
||||
"wilting",//source takes damage in the form of -1/-1 counters.
|
||||
"vigor",//instead of taking damage the source gains +1/+1 counters
|
||||
@@ -260,7 +260,14 @@ const char* Constants::MTGBasicAbilities[] = {
|
||||
"affinitygravecreatures", //Cost 1 less for each creature in your graveyard.
|
||||
"affinityattackingcreatures", //Cost 1 less for each attacking creature in your battlefield.
|
||||
"affinitygraveinstsorc", //Cost 1 less for each instant or sorcery in your graveyard.
|
||||
"canloyaltytwice" //Planeswalker can activate its loyalty abilities twice in a turn (e.g. "Urza, Planeswalker").
|
||||
"canloyaltytwice", //Planeswalker can activate its loyalty abilities twice in a turn (e.g. "Urza, Planeswalker").
|
||||
"poisonfourtoxic", // Card has toxic 4
|
||||
"poisonfivetoxic", // Card has toxic 5
|
||||
"poisonsixtoxic", // Card has toxic 6
|
||||
"poisonseventoxic", // Card has toxic 7
|
||||
"poisoneighttoxic", // Card has toxic 8
|
||||
"poisonninetoxic", // Card has toxic 9
|
||||
"poisontentoxic" // Card has toxic 10
|
||||
};
|
||||
|
||||
map<string,int> Constants::MTGBasicAbilitiesMap;
|
||||
|
||||
@@ -3063,7 +3063,7 @@ int MTGSoulbondRule::receiveEvent(WEvent * event)
|
||||
MTGCardInstance * card = e->card;
|
||||
if (!card || !card->isCreature()) return 0;
|
||||
int ok = 0;
|
||||
if(card->has(Constants::soulbond) || soulbonders.size())
|
||||
if(card->has(Constants::SOULBOND) || soulbonders.size())
|
||||
{
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
@@ -3071,7 +3071,7 @@ int MTGSoulbondRule::receiveEvent(WEvent * event)
|
||||
if (e->to == p->game->inPlay)
|
||||
{
|
||||
ok = 1;
|
||||
if(card->basicAbilities[(int)Constants::soulbond])
|
||||
if(card->basicAbilities[(int)Constants::SOULBOND])
|
||||
soulbonders.push_back(e->card);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -663,6 +663,18 @@ TargetChooser * TargetChooserFactory::createTargetChooser(string s, MTGCardInsta
|
||||
cd->unsecureSetModified(1);
|
||||
}
|
||||
}
|
||||
//Has toxic
|
||||
else if (attribute.find("hastoxic") != string::npos)
|
||||
{
|
||||
if (minus)
|
||||
{
|
||||
cd->unsecureSetHasToxic(-1);
|
||||
}
|
||||
else
|
||||
{
|
||||
cd->unsecureSetHasToxic(1);
|
||||
}
|
||||
}
|
||||
//Has partner
|
||||
else if (attribute.find("haspartner") != string::npos)
|
||||
{
|
||||
@@ -2237,7 +2249,7 @@ bool pairableChooser::canTarget(Targetable * target,bool)
|
||||
return false;
|
||||
if(card->controller() != source->controller())
|
||||
return false;
|
||||
if(!card->has(Constants::soulbond) && !source->has(Constants::soulbond))
|
||||
if(!card->has(Constants::SOULBOND) && !source->has(Constants::SOULBOND))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1619,6 +1619,29 @@ void WParsedInt::extendedParse(string s, Spell * spell, MTGCardInstance * card)
|
||||
intValue = card->getManaCost()->getManaUsedToCast()->getConvertedCost();
|
||||
}
|
||||
}
|
||||
else if(s.find("toxicity") != string::npos){ //Return the toxicity of card.
|
||||
intValue = card->getToxicity();
|
||||
}
|
||||
else if (s.find("ninelands") != string::npos) //Count the number of lands with different names among the Basic, Sphere, and Locus lands you control.
|
||||
{
|
||||
intValue = 0;
|
||||
vector<string> list;
|
||||
for (int j = card->controller()->game->inPlay->nb_cards - 1; j >= 0; --j)
|
||||
{
|
||||
if (card->controller()->game->inPlay->cards[j]->isLand() &&
|
||||
(card->controller()->game->inPlay->cards[j]->hasType("basic") || card->controller()->game->inPlay->cards[j]->hasType("sphere") || card->controller()->game->inPlay->cards[j]->hasType("locus"))){
|
||||
bool name_found = false;
|
||||
for(unsigned int i = 0; i < list.size() && !name_found; i++){
|
||||
if(list[i] == card->controller()->game->inPlay->cards[j]->name)
|
||||
name_found = true;
|
||||
}
|
||||
if(!name_found){
|
||||
list.push_back(card->controller()->game->inPlay->cards[j]->name);
|
||||
intValue += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(!intValue)//found nothing, try parsing a atoi
|
||||
{
|
||||
intValue = atoi(s.c_str());
|
||||
|
||||
Reference in New Issue
Block a user