Merge pull request #672 from kevlahnota/master

Cascade
This commit is contained in:
Anthony Calosa
2016-06-02 21:11:53 +08:00
5 changed files with 95 additions and 7 deletions

View File

@@ -584,6 +584,18 @@ private:
if (target->controller()->life >= target->controller()->initLife) if (target->controller()->life >= target->controller()->initLife)
intValue = 1; intValue = 1;
} }
else if (s == "plibrarycount")
{
intValue = 0;
if (target->controller()->game->library->nb_cards)
intValue = target->controller()->game->library->nb_cards;
}
else if (s == "olibrarycount")
{
intValue = 0;
if (target->controller()->opponent()->game->library->nb_cards)
intValue = target->controller()->opponent()->game->library->nb_cards;
}
else if (s == "highestlifetotal") else if (s == "highestlifetotal")
{ {
intValue = target->controller()->life <= target->controller()->opponent()->life? target->controller()->opponent()->life:target->controller()->life; intValue = target->controller()->life <= target->controller()->opponent()->life? target->controller()->opponent()->life:target->controller()->life;
@@ -6064,9 +6076,12 @@ class AADepleter: public ActivatedAbilityTP
public: public:
string nbcardsStr; string nbcardsStr;
bool toexile; bool toexile;
bool cascade;
AADepleter(GameObserver* observer, int _id, MTGCardInstance * card, Targetable * _target,string nbcardsStr, ManaCost * _cost = NULL, AADepleter(GameObserver* observer, int _id, MTGCardInstance * card, Targetable * _target,string nbcardsStr, ManaCost * _cost = NULL,
int who = TargetChooser::UNSET, bool toexile = false); int who = TargetChooser::UNSET, bool toexile = false, bool cascade = false);
int resolve(); int resolve();
string Cascade;
void toCastCard(MTGCardInstance * card);
const string getMenuText(); const string getMenuText();
AADepleter * clone() const; AADepleter * clone() const;
}; };

View File

@@ -89,6 +89,7 @@ public:
bool isMorphed; bool isMorphed;
bool isFlipped; bool isFlipped;
bool isPhased; bool isPhased;
bool isCascaded;
int phasedTurn; int phasedTurn;
bool graveEffects; bool graveEffects;
bool exileEffects; bool exileEffects;

View File

@@ -261,24 +261,72 @@ AADamager * AADamager::clone() const
//AADepleter //AADepleter
AADepleter::AADepleter(GameObserver* observer, int _id, MTGCardInstance * card, Targetable * _target,string nbcardsStr, ManaCost * _cost, int who, bool toexile) : AADepleter::AADepleter(GameObserver* observer, int _id, MTGCardInstance * card, Targetable * _target,string nbcardsStr, ManaCost * _cost, int who, bool toexile, bool cascade) :
ActivatedAbilityTP(observer, _id, card, _target, _cost, who),nbcardsStr(nbcardsStr),toexile(toexile) ActivatedAbilityTP(observer, _id, card, _target, _cost, who),nbcardsStr(nbcardsStr),toexile(toexile),cascade(cascade)
{ {
Cascade = "Cascade";
} }
int AADepleter::resolve() int AADepleter::resolve()
{ {
Player * player = getPlayerFromTarget(getTarget()); Player * player = getPlayerFromTarget(getTarget());
if (player) if (player)
{ {
WParsedInt numCards(nbcardsStr, NULL, source); WParsedInt numCards(nbcardsStr, NULL, source);
MTGLibrary * library = player->game->library; MTGLibrary * library = player->game->library;
MTGRemovedFromGame * exile = player->game->exile;
MTGCardInstance * viable = NULL;
int counter = 0;
for (int i = 0; i < numCards.getValue(); i++) for (int i = 0; i < numCards.getValue(); i++)
{ {
if (library->nb_cards) if (library->nb_cards)
{ {
if(toexile) if(cascade)
{
for(int z = library->nb_cards; z >= 0; z--)
{
if(!library->cards[z]->isLand() && (library->cards[z]->getManaCost()->getConvertedCost() < source->getManaCost()->getConvertedCost()))
{
viable = library->cards[z];
player->game->putInZone(viable, library, exile);
{
vector<MTGCardInstance*>selectedCards;
for(int j=0; j < library->nb_cards; j++)
{
if(library->cards[j]->isCascaded)
{
library->cards[j]->isCascaded = false;
selectedCards.push_back(library->cards[j]);
}
}
if(selectedCards.size())
{
std::random_shuffle ( selectedCards.begin(), selectedCards.end() );
for(unsigned int i = 0; i < selectedCards.size();++i)
{
vector<MTGCardInstance *>oldOrder = library->cards;
vector<MTGCardInstance *>newOrder;
newOrder.push_back(selectedCards[i]);
for(unsigned int k = 0;k < oldOrder.size();++k)
{
MTGCardInstance * rearranged = oldOrder[k];
if(rearranged != selectedCards[i])
newOrder.push_back(rearranged);
}
library->cards = newOrder;
}
}
}
toCastCard(viable->next);
return 1;
}
else
{
library->cards[library->nb_cards - 1]->isCascaded=true;
counter++;
}
}
}
else if(toexile)
player->game->putInZone(library->cards[library->nb_cards - 1], library, player->game->exile); player->game->putInZone(library->cards[library->nb_cards - 1], library, player->game->exile);
else else
player->game->putInZone(library->cards[library->nb_cards - 1], library, player->game->graveyard); player->game->putInZone(library->cards[library->nb_cards - 1], library, player->game->graveyard);
@@ -288,9 +336,22 @@ AADepleter::AADepleter(GameObserver* observer, int _id, MTGCardInstance * card,
return 1; return 1;
} }
void AADepleter::toCastCard(MTGCardInstance * thisCard)
{
MTGAbility *ac = NEW AACastCard(game, game->mLayers->actionLayer()->getMaxId(), thisCard, thisCard,false,false,true,"","",false,false);
//ac->oneShot=true;
//ac->addToGame();
MayAbility *ma1 = NEW MayAbility(game, game->mLayers->actionLayer()->getMaxId(), ac, thisCard,true);
MTGAbility *ga1 = NEW GenericAddToGame(game, game->mLayers->actionLayer()->getMaxId(), thisCard,NULL,ma1);
ga1->resolve();
return;
}
const string AADepleter::getMenuText() const string AADepleter::getMenuText()
{ {
if(toexile) if(cascade)
return Cascade;
else if(toexile)
return "Ingest"; return "Ingest";
return "Deplete"; return "Deplete";
} }

View File

@@ -2684,6 +2684,16 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
return a; return a;
} }
//Cascade
vector<string> splitCascade = parseBetween(s, "cascade:", " ", false);
if (splitCascade.size())
{
Targetable * t = spell ? spell->getNextTarget() : NULL;
MTGAbility * a = NEW AADepleter(observer, id, card, t , splitCascade[1], NULL, who, false,true);
a->oneShot = 1;
return a;
}
//modify turns //modify turns
vector<string> splitModTurn = parseBetween(s, "turns:", " ", false); vector<string> splitModTurn = parseBetween(s, "turns:", " ", false);
if (splitModTurn.size()) if (splitModTurn.size())

View File

@@ -168,6 +168,7 @@ void MTGCardInstance::initMTGCI()
isMorphed = false; isMorphed = false;
isFlipped = false; isFlipped = false;
isPhased = false; isPhased = false;
isCascaded = false;
phasedTurn = -1; phasedTurn = -1;
didattacked = 0; didattacked = 0;
didblocked = 0; didblocked = 0;