Merge branch 'master' into iOS-build

This commit is contained in:
xawotihs
2015-09-04 00:04:59 +02:00
22 changed files with 2938 additions and 204 deletions
+75 -27
View File
@@ -1359,6 +1359,13 @@ int AAFizzler::resolve()
sCard = sTarget->source;
if (!sCard || !sTarget || sCard->has(Constants::NOFIZZLE))
return 0;
if (source->alias == 111057 && sTarget)//Draining Whelk
{
for (int j = sTarget->cost->getConvertedCost(); j > 0; j--)
{
source->counters->addCounter(1,1);
}
}
stack->Fizzle(sTarget, fizzleMode);
return 1;
}
@@ -2482,35 +2489,49 @@ int AACloner::resolve()
Player * targetPlayer = who == 1 ? source->controller()->opponent() : source->controller();
MTGCardInstance * myClone = NEW MTGCardInstance(clone, targetPlayer->game);
targetPlayer->game->temp->addCard(myClone);
int tokenize = 1;//tokenizer support for cloning
if (targetPlayer->game->battlefield->hasAbility(Constants::TOKENIZER))
{
int nbcards = targetPlayer->game->battlefield->nb_cards;
for (int j = 0; j < nbcards; j++)
{
if (targetPlayer->game->battlefield->cards[j]->has(Constants::TOKENIZER))
tokenize *= 2;
}
}
for (int i = 0; i < tokenize; ++i)
{
MTGCardInstance * myClone = NEW MTGCardInstance(clone, targetPlayer->game);
targetPlayer->game->temp->addCard(myClone);
Spell * spell = NEW Spell(game, myClone);
spell->source->isToken = 1;
spell->resolve();
spell->source->fresh = 1;
spell->source->model = spell->source;
spell->source->model->data = spell->source;
if(_target->isToken)
{
spell->source->power = _target->origpower;
spell->source->toughness = _target->origtoughness;
spell->source->life = _target->origtoughness;
Spell * spell = NEW Spell(game, myClone);
spell->source->isToken = 1;
spell->resolve();
spell->source->fresh = 1;
spell->source->model = spell->source;
spell->source->model->data = spell->source;
if(_target->isToken)
{
spell->source->power = _target->origpower;
spell->source->toughness = _target->origtoughness;
spell->source->life = _target->origtoughness;
}
list<int>::iterator it;
for (it = awith.begin(); it != awith.end(); it++)
{
spell->source->basicAbilities[*it] = 1;
}
for (it = colors.begin(); it != colors.end(); it++)
{
spell->source->setColor(*it);
}
for (it = typesToAdd.begin(); it != typesToAdd.end(); it++)
{
spell->source->addType(*it);
}
delete spell;
}
list<int>::iterator it;
for (it = awith.begin(); it != awith.end(); it++)
{
spell->source->basicAbilities[*it] = 1;
}
for (it = colors.begin(); it != colors.end(); it++)
{
spell->source->setColor(*it);
}
for (it = typesToAdd.begin(); it != typesToAdd.end(); it++)
{
spell->source->addType(*it);
}
delete spell;
return 1;
}
@@ -2941,6 +2962,32 @@ AAShuffle * AAShuffle::clone() const
return NEW AAShuffle(*this);
}
// Mulligan
AAMulligan::AAMulligan(GameObserver* observer, int _id, MTGCardInstance * card, Targetable * _target, ManaCost * _cost, int who) :
ActivatedAbilityTP(observer, _id, card, _target, _cost, who)
{
}
int AAMulligan::resolve()
{
Player * player = getPlayerFromTarget(getTarget());
if (player)
{
player->serumMulligan();
}
return 1;
}
const string AAMulligan::getMenuText()
{
return "Mulligan";
}
AAMulligan * AAMulligan::clone() const
{
return NEW AAMulligan(*this);
}
// Remove Mana From ManaPool
AARemoveMana::AARemoveMana(GameObserver* observer, int _id, MTGCardInstance * card, Targetable * _target, string manaDesc, int who) :
ActivatedAbilityTP(observer, _id, card, _target, NULL, who)
@@ -4316,6 +4363,7 @@ int PTInstant::resolve()
APowerToughnessModifier * a = ability->clone();
GenericInstantAbility * wrapper = NEW GenericInstantAbility(game, 1, source, (Damageable *) (this->target), a);
wrapper->addToGame();
((Damageable *) (this->target))->afterDamage();//additional check the negative pt after resolving..
return 1;
}
const string PTInstant::getMenuText()
+3
View File
@@ -1242,6 +1242,9 @@ bool CardGui::FilterCard(MTGCard * _card,string filter)
if (minus)
{
cd.setisMultiColored(-1);
cd.SetExclusionColor(0);//not multicolored is monocolored not colorless, use iscolorless attribute
cd.SetExclusionColor(6);//restriction... green, red, blue, black or white colored only
cd.mode = CardDescriptor::CD_OR;
}
else
{
+8 -28
View File
@@ -727,34 +727,7 @@ void GameObserver::gameStateBasedEffects()
///////////////////////////////////////////////////////////
//life checks/poison checks also checks cant win or lose.//
///////////////////////////////////////////////////////////
if (players[i]->life <= 0 || players[i]->poisonCount >= 10)
{
int cantlosers = 0;
MTGGameZone * z = players[i]->game->inPlay;
int nbcards = z->nb_cards;
for (int j = 0; j < nbcards; ++j)
{
MTGCardInstance * c = z->cards[j];
if (c->has(Constants::CANTLOSE) || (c->has(Constants::CANTLIFELOSE) && players[i]->poisonCount < 10))
{
cantlosers++;
}
}
MTGGameZone * k = players[i]->opponent()->game->inPlay;
int onbcards = k->nb_cards;
for (int m = 0; m < onbcards; ++m)
{
MTGCardInstance * e = k->cards[m];
if (e->has(Constants::CANTWIN))
{
cantlosers++;
}
}
if (cantlosers < 1)
{
setLoser(players[i]);
}
}
players[i]->DeadLifeState();//refactored
}
//////////////////////////////////////////////////////
//-------------card based states effects------------//
@@ -1839,6 +1812,13 @@ void GameObserver::Mulligan(Player* player)
player->takeMulligan();
}
void GameObserver::serumMulligan(Player* player)
{
if(!player) player = currentPlayer;
logAction(player, "mulligan serum powder");
player->serumMulligan();
}
Player* GameObserver::createPlayer(const string& playerMode
#ifdef TESTSUITE
, TestSuiteGame* testgame
+43
View File
@@ -2532,6 +2532,16 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
return a;
}
//Serum Powder
found = s.find("serumpowder");
if (found != string::npos)
{
Targetable * t = spell? spell->getNextTarget() : NULL;
MTGAbility * a = NEW AAMulligan(observer, id, card, t, NULL, who);
a->oneShot = 1;
return a;
}
//Remove Mana from ManaPool
vector<string> splitRemove = parseBetween(s, "removemana(", ")");
if (splitRemove.size())
@@ -4942,6 +4952,39 @@ int TriggeredAbility::receiveEvent(WEvent * e)
resolve();
return 1;
}
if(dynamic_cast<WEventCardSacrifice*>(e))
{
//sacrificed event
//thraximundar vs bloodfore collosus, thraximundar
//must be able to survive a sacrificed bloodfire collosus,
//same with mortician beetle vs phyrexian denouncer test
resolve();
return 1;
}
if(dynamic_cast<WEventLife*>(e))
{
//check life state on life triger
WEventLife * lifecheck = dynamic_cast<WEventLife*>(e);
if (lifecheck->player->DeadLifeState())
{
return 0;
}
fireAbility();
return 1;
}
if(dynamic_cast<WEventDamage*>(e))
{
//check life state on damage trigger
WEventDamage * lifecheck = dynamic_cast<WEventDamage*>(e);
if (lifecheck->damage->target->type_as_damageable == Damageable::DAMAGEABLE_PLAYER)
{
Player * triggerPlayer = (Player *) lifecheck->damage->target;
if(triggerPlayer->DeadLifeState())
return 0;
}
fireAbility();
return 1;
}
WEventZoneChange * stackCheck = dynamic_cast<WEventZoneChange*>(e);
if(stackCheck && (stackCheck->to == game->currentPlayer->game->stack||stackCheck->to == game->currentPlayer->opponent()->game->stack))
{
+2 -1
View File
@@ -132,7 +132,8 @@ const char* Constants::MTGBasicAbilities[] = {
"soulbond",
"lure",
"nolegend",
"canplayfromgraveyard"
"canplayfromgraveyard",
"tokenizer"//parallel lives
};
map<string,int> Constants::MTGBasicAbilitiesMap;
+50
View File
@@ -217,6 +217,56 @@ void Player::takeMulligan()
//Draw hand with 1 less card penalty //almhum
}
void Player::serumMulligan()
{
MTGPlayerCards * currentPlayerZones = game;
int cardsinhand = currentPlayerZones->hand->nb_cards;
for (int i = 0; i < cardsinhand; i++) //Exile
currentPlayerZones->putInZone(currentPlayerZones->hand->cards[0],
currentPlayerZones->hand,
currentPlayerZones->exile);
currentPlayerZones->library->shuffle(); //Shuffle
for (int i = 0; i < (cardsinhand); i++)
game->drawFromLibrary();
//Draw hand no penalty
}
bool Player::DeadLifeState()
{
if ((life <= 0)||(poisonCount >= 10))
{
int cantlosers = 0;
MTGGameZone * z = game->inPlay;
int nbcards = z->nb_cards;
for (int j = 0; j < nbcards; ++j)
{
MTGCardInstance * c = z->cards[j];
if (c->has(Constants::CANTLOSE) || (c->has(Constants::CANTLIFELOSE) && poisonCount < 10))
{
cantlosers++;
}
}
MTGGameZone * k = opponent()->game->inPlay;
int onbcards = k->nb_cards;
for (int m = 0; m < onbcards; ++m)
{
MTGCardInstance * e = k->cards[m];
if (e->has(Constants::CANTWIN))
{
cantlosers++;
}
}
if (cantlosers < 1)
{
getObserver()->setLoser(this);
return true;
}
}
return false;
}
//Cleanup phase at the end of a turn
void Player::cleanupPhase()
{
+3
View File
@@ -503,6 +503,9 @@ TargetChooser * TargetChooserFactory::createTargetChooser(string s, MTGCardInsta
if (minus)
{
cd->setisMultiColored(-1);
cd->SetExclusionColor(0);//not multicolored is monocolored not colorless, use iscolorless attribute
cd->SetExclusionColor(6);//restriction... green, red, blue, black or white colored only
cd->mode = CardDescriptor::CD_OR;
}
else
{