added poolsave(COLOR) its an ability that works only on permanents in play.

opponentpoolsave(
mypoolsave(
ex:Upwelling


added a tag for mana, doesntempty
add{g}{g}{g} doesntempty
what this does is make THAT mana remain in the pool until end of turn.
ex:
Sakura-Tribe Springcaller
This commit is contained in:
omegablast2002@yahoo.com
2013-02-09 06:48:16 +00:00
parent 2b4c3a51aa
commit 3c15357c38
8 changed files with 110 additions and 11 deletions

View File

@@ -4378,6 +4378,18 @@ public:
};
class AManaPoolSaver: public MTGAbility
{
public:
string Color;
bool OtherPlayer;
AManaPoolSaver(GameObserver* observer, int id, MTGCardInstance * source,string Color = "",bool otherPlayer = false);
int addToGame();
int destroy();
AManaPoolSaver * clone() const;
~AManaPoolSaver();
};
class ADrawReplacer: public MTGAbility
{
public:

View File

@@ -519,7 +519,8 @@ public:
ManaCost * output;
int tap;
string Producing;
AManaProducer(GameObserver* observer, int id, MTGCardInstance * card, Targetable * t, ManaCost * _output, ManaCost * _cost = NULL, int who = TargetChooser::UNSET,string producing = "");
bool DoesntEmpty;
AManaProducer(GameObserver* observer, int id, MTGCardInstance * card, Targetable * t, ManaCost * _output, ManaCost * _cost = NULL, int who = TargetChooser::UNSET,string producing = "",bool doesntEmpty = false);
int isReactingToClick(MTGCardInstance * _card, ManaCost * mana = NULL);
int resolve();
int reactToClick(MTGCardInstance* _card);

View File

@@ -66,7 +66,8 @@ public:
MTGInPlay * inPlay();
ManaPool * getManaPool();
void takeMulligan();
ManaCost * doesntEmpty;
ManaCost * poolDoesntEmpty;
void cleanupPhase();
virtual int Act(float dt)
{

View File

@@ -1112,6 +1112,35 @@ AASetCoin::~AASetCoin()
{
}
//saves a listed mana type until end of turn.
AManaPoolSaver::AManaPoolSaver(GameObserver* observer, int id, MTGCardInstance * source,string color, bool otherPlayer) :
MTGAbility(observer, id, source),Color(color),OtherPlayer(otherPlayer)
{
}
int AManaPoolSaver::addToGame()
{
int colorInt = Constants::GetColorStringIndex(Color.c_str());
source->controller()->poolDoesntEmpty->add(colorInt,1);
return 1;
}
int AManaPoolSaver::destroy()
{
int colorInt = Constants::GetColorStringIndex(Color.c_str());
source->controller()->poolDoesntEmpty->remove(colorInt,1);
return 1;
}
AManaPoolSaver * AManaPoolSaver::clone() const
{
AManaPoolSaver * a = NEW AManaPoolSaver(*this);
return a;
}
AManaPoolSaver::~AManaPoolSaver()
{
}
//replace drawing a card with activation of an ability
ADrawReplacer::ADrawReplacer(GameObserver* observer, int id, MTGCardInstance * source, MTGAbility * replace, bool otherPlayer) :
@@ -2817,15 +2846,54 @@ int AARemoveMana::resolve()
{
if (mManaDesc) // Remove all mana Matching a description
{
for (int i = 0; i < Constants::NB_Colors; i++)
{
if (mManaDesc->hasColor(i))
manaPool->removeAll(i);
}
for (int i = 0; i < Constants::NB_Colors; i++)
{
if (mManaDesc->hasColor(i))
manaPool->removeAll(i);
}
}
else //Remove all mana
{
manaPool->Empty();
if(game->getCurrentGamePhase() != MTG_PHASE_ENDOFTURN)
{
if (player->doesntEmpty->getConvertedCost() && !player->poolDoesntEmpty->getConvertedCost())
{
ManaCost * toRemove = manaPool->Diff(player->doesntEmpty);
player->getManaPool()->pay(manaPool->Diff(player->doesntEmpty));
}
else if(!player->doesntEmpty->getConvertedCost() && player->poolDoesntEmpty->getConvertedCost())
{
ManaCost * toSave = NEW ManaCost();
for(int k = Constants::MTG_COLOR_ARTIFACT; k < Constants::NB_Colors;k++)
{
if(player->poolDoesntEmpty->getCost(k))
toSave->add(k,manaPool->getCost(k));
}
player->getManaPool()->pay(manaPool->Diff(toSave));
delete(toSave);
}
else if(player->doesntEmpty->getConvertedCost() && player->poolDoesntEmpty->getConvertedCost())
{
ManaCost * toSave = NEW ManaCost();
for(int k = Constants::MTG_COLOR_ARTIFACT; k < Constants::NB_Colors;k++)
{
if(player->poolDoesntEmpty->getCost(k))
{
toSave->add(k,manaPool->getCost(k));//save the whole amount of k;
}
else if(player->doesntEmpty->getCost(k))
{
toSave->add(k,player->doesntEmpty->getCost(k));//save the amount of doesnt empty
}
}
player->getManaPool()->pay(manaPool->Diff(toSave));//remove the manacost equal to the difference of toSave and the manapool.
delete(toSave);
}
}
else
manaPool->Empty();
}
}
else //remove a "standard" mana Description

View File

@@ -230,6 +230,8 @@ void GameObserver::nextGamePhase()
mLayers->actionLayer()->Update(0);
currentPlayer->lifeLostThisTurn = 0;
currentPlayer->opponent()->lifeLostThisTurn = 0;
currentPlayer->doesntEmpty->remove(currentPlayer->doesntEmpty);
currentPlayer->opponent()->doesntEmpty->remove(currentPlayer->opponent()->doesntEmpty);
nextPlayer();
return nextGamePhase();
}

View File

@@ -1725,6 +1725,13 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
return NULL;
}
//mana of the listed type doesnt get emptied from the pools.
vector<string>colorType = parseBetween(s,"poolsave(",")",false);
if (colorType.size())
{
return NEW AManaPoolSaver(observer,id, card,colorType[1],s.find("opponentpool")!=string::npos);
}
//opponent replace draw with
found = s.find("opponentreplacedraw ");
if (found != string::npos)
@@ -2710,9 +2717,10 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
found = s.find("add");
if (found != string::npos)
{
bool doesntEmptyTilueot = s.find("doesntempty") != string::npos;
ManaCost * output = ManaCost::parseManaCost(s.substr(found),NULL,card);
Targetable * t = spell ? spell->getNextTarget() : NULL;
MTGAbility * a = NEW AManaProducer(observer, id, card, t, output, NULL, who,s.substr(found));
MTGAbility * a = NEW AManaProducer(observer, id, card, t, output, NULL, who,s.substr(found),doesntEmptyTilueot);
a->oneShot = 1;
if(newName.size())
((AManaProducer*)a)->menutext = newName;
@@ -5232,7 +5240,7 @@ GenericTriggeredAbility* GenericTriggeredAbility::clone() const
*/
AManaProducer::AManaProducer(GameObserver* observer, int id, MTGCardInstance * card, Targetable * t, ManaCost * _output, ManaCost * _cost,
int who,string producing) :
int who,string producing,bool doesntEmpty) :
ActivatedAbilityTP(observer, id, card, t, _cost, who)
{
@@ -5241,6 +5249,7 @@ AManaProducer::AManaProducer(GameObserver* observer, int id, MTGCardInstance * c
output = _output;
Producing = producing;
menutext = "";
DoesntEmpty = doesntEmpty;
}
int AManaProducer::isReactingToClick(MTGCardInstance * _card, ManaCost * mana)
@@ -5268,6 +5277,8 @@ int AManaProducer::resolve()
return 0;
player->getManaPool()->add(output, source);
if(DoesntEmpty)
player->doesntEmpty->add(output);
return 1;
}

View File

@@ -155,7 +155,7 @@ int Constants::GetColorStringIndex(string mtgColor)
{
for (int idx = 0; idx < Constants::NB_Colors; ++idx)
{
if (Constants::MTGColorStrings[idx])
if (Constants::MTGColorStrings[idx] == mtgColor)
return idx;
}

View File

@@ -32,6 +32,8 @@ Player::Player(GameObserver *observer, string file, string fileSmall, MTGDeck *
playMode = MODE_HUMAN;
skippingTurn = 0;
extraTurn = 0;
doesntEmpty = NEW ManaCost();
poolDoesntEmpty = NEW ManaCost();
if (deck != NULL)
{
game = NEW MTGPlayerCards(deck);
@@ -63,6 +65,8 @@ void Player::End()
Player::~Player()
{
SAFE_DELETE(manaPool);
SAFE_DELETE(doesntEmpty);
SAFE_DELETE(poolDoesntEmpty);
SAFE_DELETE(game);
if(mAvatarTex && observer->getResourceManager())
observer->getResourceManager()->Release(mAvatarTex);