Merge pull request #929 from kevlahnota/master

Some Bug Fixes
This commit is contained in:
Anthony Calosa
2017-02-06 22:25:59 +08:00
committed by GitHub
7 changed files with 49 additions and 25 deletions
+1 -1
View File
@@ -48,7 +48,6 @@ public:
vector<MTGCardInstance*>parentCards; vector<MTGCardInstance*>parentCards;
vector<MTGCardInstance*>childrenCards; vector<MTGCardInstance*>childrenCards;
vector<MTGAbility *>cardsAbilities; vector<MTGAbility *>cardsAbilities;
//vector<MTGAbility *>cardsAbilitiesFilter;
int setAttacker(int value); int setAttacker(int value);
int setDefenser(MTGCardInstance * c); int setDefenser(MTGCardInstance * c);
@@ -263,6 +262,7 @@ public:
bool bypassTC; bool bypassTC;
bool discarded; bool discarded;
int copiedID; int copiedID;
int copiedSetID;
bool StackIsEmptyandSorcerySpeed(); bool StackIsEmptyandSorcerySpeed();
bool isTargetted(); bool isTargetted();
int cardistargetted; int cardistargetted;
+6 -1
View File
@@ -593,7 +593,12 @@ int ActionStack::addAbility(MTGAbility * ability)
int result = addAction(stackAbility); int result = addAction(stackAbility);
if (!observer->players[0]->isAI() && ability->source->controller() == observer->players[0] && 0 if (!observer->players[0]->isAI() && ability->source->controller() == observer->players[0] && 0
== options[Options::INTERRUPTMYABILITIES].number) == options[Options::INTERRUPTMYABILITIES].number)
interruptDecision[0] = DONT_INTERRUPT; {
if(observer->gameType() == GAME_TYPE_MOMIR && ability->aType == MTGAbility::FORCED_TOKEN_CREATOR)
interruptDecision[0] = NOT_DECIDED;
else
interruptDecision[0] = DONT_INTERRUPT;
}
if (observer->OpenedDisplay && observer->players[0]->game->reveal->cards.size()) if (observer->OpenedDisplay && observer->players[0]->game->reveal->cards.size())
{ {
interruptDecision[0] = DONT_INTERRUPT; interruptDecision[0] = DONT_INTERRUPT;
+12
View File
@@ -1799,6 +1799,18 @@ AACounter::AACounter(GameObserver* observer, int id, MTGCardInstance * source, M
while (_target->next) while (_target->next)
_target = _target->next; _target = _target->next;
if(_target->getCurrentZone() != _target->controller()->game->battlefield ||
_target->getCurrentZone() != _target->controller()->opponent()->game->battlefield)
{
if(power||toughness)
{
if(_target->previousZone == _target->controller()->game->battlefield ||
_target->previousZone == _target->controller()->opponent()->game->battlefield)
return 0;
}
}
Counter * targetCounter = NULL; Counter * targetCounter = NULL;
int currentAmount = 0; int currentAmount = 0;
if (_target->counters && _target->counters->hasCounter(name.c_str(), power, toughness)) if (_target->counters && _target->counters->hasCounter(name.c_str(), power, toughness))
+12 -1
View File
@@ -3638,7 +3638,18 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
a->oneShot = 1; a->oneShot = 1;
a->canBeInterrupted = false; a->canBeInterrupted = false;
a->named = newName; a->named = newName;
if(card->getAICustomCode().size() && card->controller()->isAI()) /***********do nothing***********/
if((card->controller()->isAI() &&
card->controller()->opponent()->isAI())||
!card->getAICustomCode().size())
{
MTGAbility * a2 = parseMagicLine("activate donothing", id, spell, card);
a2->oneShot = 1;
a2->canBeInterrupted = false;
return a2;
}
/*******************************/
else if(card->getAICustomCode().size() && card->controller()->isAI())
{ {
MTGAbility * a3 = parseMagicLine(card->getAICustomCode(), id, spell, card); MTGAbility * a3 = parseMagicLine(card->getAICustomCode(), id, spell, card);
a3->oneShot = 1; a3->oneShot = 1;
+4 -18
View File
@@ -64,6 +64,7 @@ MTGCardInstance::MTGCardInstance(MTGCard * card, MTGPlayerCards * arg_belongs_to
bypassTC = false; bypassTC = false;
discarded = false; discarded = false;
copiedID = getId(); copiedID = getId();
copiedSetID = 0;
LKIpower = power; LKIpower = power;
LKItoughness = toughness; LKItoughness = toughness;
cardistargetted = 0; cardistargetted = 0;
@@ -143,6 +144,7 @@ void MTGCardInstance::copy(MTGCardInstance * card)
spellTargetType = data->spellTargetType; spellTargetType = data->spellTargetType;
alias = data->alias; alias = data->alias;
copiedID = card->copiedID; copiedID = card->copiedID;
copiedSetID = card->setId;
doubleFaced = data->doubleFaced; doubleFaced = data->doubleFaced;
AICustomCode = data->AICustomCode; AICustomCode = data->AICustomCode;
CrewAbility = data->CrewAbility; CrewAbility = data->CrewAbility;
@@ -156,25 +158,9 @@ void MTGCardInstance::copy(MTGCardInstance * card)
int castMethodBackUP = this->castMethod; int castMethodBackUP = this->castMethod;
mtgid = source->getId(); mtgid = source->getId();
MTGCardInstance * oldStored = this->storedSourceCard; MTGCardInstance * oldStored = this->storedSourceCard;
//test copy filtered
/*cardsAbilitiesFilter.clear();
for(unsigned int i = 0;i < card->cardsAbilities.size();i++)
{
MTGAbility * a = dynamic_cast<MTGAbility *>(card->cardsAbilities[i]);
if(a && a->source == card)
{
cardsAbilitiesFilter.push_back(a);
}
}*/
if(observer->players[1]->playMode == Player::MODE_TEST_SUITE) mtgid = backupid; // found a way :)
mtgid = backupid; // there must be a way to get the token id...
else
{
mtgid = card->getMTGId(); ///////////////////////////////////////////////////
setId = card->setId; // Copier/Cloner cards produces the same token...//
rarity = card->getRarity(); ///////////////////////////////////////////////////
}
castMethod = castMethodBackUP; castMethod = castMethodBackUP;
backupTargets = this->backupTargets; backupTargets = this->backupTargets;
storedCard = oldStored; storedCard = oldStored;
+4 -2
View File
@@ -3262,7 +3262,8 @@ int MTGLegendRule::added(MTGCardInstance * card)
{ {
MTGCardInstance * comparison = (*it).first; MTGCardInstance * comparison = (*it).first;
if (comparison != card && comparison->controller() == card->controller() && !(comparison->getName().compare(card->getName()))) if (comparison != card && comparison->controller() == card->controller() && !(comparison->getName().compare(card->getName())))
destroy = 1; if (!(game->getCurrentTargetChooser() || game->mLayers->actionLayer()->isWaitingForAnswer()))
destroy = 1;
} }
if(destroy) if(destroy)
{ {
@@ -3340,7 +3341,8 @@ int MTGPlaneWalkerRule::added(MTGCardInstance * card)
{ {
MTGCardInstance * comparison = (*it).first; MTGCardInstance * comparison = (*it).first;
if (comparison != card && comparison->types == card->types && comparison->controller() == card->controller()) if (comparison != card && comparison->types == card->types && comparison->controller() == card->controller())
destroy = 1; if (!(game->getCurrentTargetChooser() || game->mLayers->actionLayer()->isWaitingForAnswer()))
destroy = 1;
} }
if (destroy) if (destroy)
{ {
+10 -2
View File
@@ -18,8 +18,16 @@ Token::Token(string _name, MTGCardInstance * source, int _power, int _toughness)
rarity = Constants::RARITY_T; rarity = Constants::RARITY_T;
name = _name; name = _name;
if (name.size() && name[0] >= 97 && name[0] <= 122) name[0] -= 32; //Poor man's camelcase. We assume strings we get are either Camelcased or lowercase if (name.size() && name[0] >= 97 && name[0] <= 122) name[0] -= 32; //Poor man's camelcase. We assume strings we get are either Camelcased or lowercase
setMTGId(-source->getMTGId()); if(source->isACopier && source->copiedSetID)
setId = source->setId; {
setMTGId(-source->copiedID);
setId = source->copiedSetID;
}
else
{
setMTGId(-source->getMTGId());
setId = source->setId;
}
model = this; model = this;
data = this; data = this;
owner = source->owner; owner = source->owner;