Merge branch 'master' into cmake
This commit is contained in:
@@ -714,6 +714,9 @@ bool AIPlayerBaka::payTheManaCost(ManaCost * cost, MTGCardInstance * target,vect
|
||||
|
||||
if(!cost->getConvertedCost())
|
||||
{
|
||||
DebugTrace("AIPlayerBaka: Card was a land and ai cant play any more lands this turn. ");
|
||||
if (target && target->isLand() && game->playRestrictions->canPutIntoZone(target, game->battlefield) == PlayRestriction::CANT_PLAY)
|
||||
return false;
|
||||
DebugTrace("AIPlayerBaka: Card or Ability was free to play. ");
|
||||
if(!cost->hasX())//don't return true if it contains {x} but no cost, locks ai in a loop. ie oorchi hatchery cost {x}{x} to play.
|
||||
return true;
|
||||
|
||||
@@ -264,12 +264,10 @@ AADamager * AADamager::clone() const
|
||||
AADepleter::AADepleter(GameObserver* observer, int _id, MTGCardInstance * card, Targetable * _target,string nbcardsStr, ManaCost * _cost, int who, bool toexile) :
|
||||
ActivatedAbilityTP(observer, _id, card, _target, _cost, who),nbcardsStr(nbcardsStr),toexile(toexile)
|
||||
{
|
||||
|
||||
}
|
||||
int AADepleter::resolve()
|
||||
{
|
||||
Player * player = getPlayerFromTarget(getTarget());
|
||||
|
||||
if (player)
|
||||
{
|
||||
WParsedInt numCards(nbcardsStr, NULL, source);
|
||||
@@ -300,6 +298,93 @@ AADepleter * AADepleter::clone() const
|
||||
return NEW AADepleter(*this);
|
||||
}
|
||||
|
||||
//AACascade
|
||||
AACascade::AACascade(GameObserver* observer, int _id, MTGCardInstance * card, Targetable * _target,string nbcardsStr, ManaCost * _cost, int who) :
|
||||
ActivatedAbilityTP(observer, _id, card, _target, _cost, who),nbcardsStr(nbcardsStr)
|
||||
{
|
||||
}
|
||||
int AACascade::resolve()
|
||||
{
|
||||
Player * player = getPlayerFromTarget(getTarget());
|
||||
if (player)
|
||||
{
|
||||
WParsedInt numCards(nbcardsStr, NULL, source);
|
||||
MTGLibrary * library = player->game->library;
|
||||
MTGRemovedFromGame * exile = player->game->exile;
|
||||
MTGCardInstance * viable = NULL;
|
||||
int counter = 0;
|
||||
for (int i = 0; i < numCards.getValue(); i++)
|
||||
{
|
||||
if (library->nb_cards)
|
||||
{
|
||||
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++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
void AACascade::toCastCard(MTGCardInstance * thisCard)
|
||||
{
|
||||
MTGAbility *ac = NEW AACastCard(game, game->mLayers->actionLayer()->getMaxId(), thisCard, thisCard,false,false,true,"","",false,false);
|
||||
MayAbility *ma1 = NEW MayAbility(game, game->mLayers->actionLayer()->getMaxId(), ac, thisCard->clone(),true);
|
||||
MTGAbility *ga1 = NEW GenericAddToGame(game, game->mLayers->actionLayer()->getMaxId(), thisCard,NULL,ma1);
|
||||
ga1->resolve();
|
||||
return;
|
||||
}
|
||||
|
||||
const string AACascade::getMenuText()
|
||||
{
|
||||
return "Cascade";
|
||||
}
|
||||
|
||||
AACascade * AACascade::clone() const
|
||||
{
|
||||
return NEW AACascade(*this);
|
||||
}
|
||||
|
||||
//take extra turns or skip turns, values in the negitive will make you skip.
|
||||
AAModTurn::AAModTurn(GameObserver* observer, int _id, MTGCardInstance * card, Targetable * _target,string nbTurnStr, ManaCost * _cost, int who) :
|
||||
ActivatedAbilityTP(observer, _id, card, _target, _cost, who),nbTurnStr(nbTurnStr)
|
||||
@@ -394,7 +479,7 @@ int AACopier::resolve()
|
||||
MTGCardInstance * myClone = NEW MTGCardInstance(clone, source->controller()->game);
|
||||
source->copy(myClone);
|
||||
source->isACopier = true;
|
||||
source->copiedID = _target->copiedID;
|
||||
source->copiedID = _target->getMTGId();
|
||||
source->modifiedbAbi = _target->modifiedbAbi;
|
||||
source->origbasicAbilities = _target->origbasicAbilities;
|
||||
if(_target->isMorphed)
|
||||
@@ -1220,25 +1305,15 @@ int GenericPaidAbility::resolve()
|
||||
{
|
||||
must = true;
|
||||
//cost increase - reduce + trinisphere effect ability todo...
|
||||
if(((MTGCardInstance *)target)->getIncreasedManaCost()->getConvertedCost())
|
||||
optionalCost->add(((MTGCardInstance *)target)->getIncreasedManaCost());
|
||||
if(((MTGCardInstance *)target)->getReducedManaCost()->getConvertedCost())
|
||||
optionalCost->remove(((MTGCardInstance *)target)->getReducedManaCost());
|
||||
//trinisphere effect must be hardcoded...here..
|
||||
/*if(((MTGCardInstance *)target)->has(Constants::TRINISPHERE))
|
||||
optionalCost = ((MTGCardInstance *)target)->computeNewCost(((MTGCardInstance *)target),optionalCost,optionalCost);
|
||||
if(optionalCost->extraCosts)
|
||||
{
|
||||
if(optionalCost->getConvertedCost() == 2)
|
||||
optionalCost->add(Constants::MTG_COLOR_ARTIFACT, 1);
|
||||
else if(optionalCost->getConvertedCost() == 1)
|
||||
optionalCost->add(Constants::MTG_COLOR_ARTIFACT, 2);
|
||||
else if(optionalCost->getConvertedCost() < 1)
|
||||
optionalCost->add(Constants::MTG_COLOR_ARTIFACT, 3);
|
||||
}*/
|
||||
for(unsigned int i = 0; i < optionalCost->extraCosts->costs.size();i++)
|
||||
optionalCost->extraCosts->costs[i]->setSource(((MTGCardInstance *)target));
|
||||
}
|
||||
}
|
||||
if(asAlternate && nomenu && optionalCost->getConvertedCost() < 1)
|
||||
{
|
||||
nomenuAbility->resolve();
|
||||
}
|
||||
else
|
||||
{
|
||||
MenuAbility * a1 = NEW MenuAbility(game, this->GetId(), target, source, must, selection, NULL, newName);
|
||||
@@ -1386,15 +1461,18 @@ AAFakeAbility * AAFakeAbility::clone() const
|
||||
}
|
||||
|
||||
//EPIC
|
||||
AAEPIC::AAEPIC(GameObserver* observer, int id, MTGCardInstance * source, MTGCardInstance * _target, string _named,ManaCost * cost):
|
||||
ActivatedAbility(observer, id, source, cost, 0),named(_named)
|
||||
AAEPIC::AAEPIC(GameObserver* observer, int id, MTGCardInstance * source, MTGCardInstance * _target, string _named,ManaCost * cost, bool _ffield):
|
||||
ActivatedAbility(observer, id, source, cost, 0),named(_named),FField(_ffield)
|
||||
{
|
||||
this->target = _target;
|
||||
}
|
||||
int AAEPIC::resolve()
|
||||
{
|
||||
MTGCardInstance * _target = (MTGCardInstance *)target;
|
||||
_target->controller()->epic = 1;
|
||||
if(FField)
|
||||
_target->controller()->forcefield = 1;
|
||||
else
|
||||
_target->controller()->epic = 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -4081,19 +4159,8 @@ int AAlterCost::destroy()
|
||||
|
||||
int AAlterCost::testDestroy()
|
||||
{
|
||||
MTGCardInstance * _target = (MTGCardInstance *)target;
|
||||
if(!this->manaReducer->isInPlay(game))
|
||||
{
|
||||
if (amount > 0)
|
||||
{
|
||||
_target->getIncreasedManaCost()->remove(type,amount);
|
||||
refreshCost(_target);//special case for 0 cost.
|
||||
}
|
||||
else
|
||||
{
|
||||
_target->getReducedManaCost()->remove(type,abs(amount));
|
||||
refreshCost(_target);//special case for 0 cost.
|
||||
}
|
||||
return MTGAbility::testDestroy();
|
||||
}
|
||||
return 0;
|
||||
@@ -4102,8 +4169,10 @@ void AAlterCost::refreshCost(MTGCardInstance * card)
|
||||
{
|
||||
ManaCost * original = NEW ManaCost();
|
||||
original->copy(card->model->data->getManaCost());
|
||||
original->add(card->getIncreasedManaCost());
|
||||
original->remove(card->getReducedManaCost());
|
||||
if(card->getIncreasedManaCost()->getConvertedCost())
|
||||
original->add(card->getIncreasedManaCost());
|
||||
if(card->getReducedManaCost()->getConvertedCost())
|
||||
original->remove(card->getReducedManaCost());
|
||||
card->getManaCost()->copy(original);
|
||||
delete original;
|
||||
return;
|
||||
@@ -4115,14 +4184,6 @@ void AAlterCost::increaseTheCost(MTGCardInstance * card)
|
||||
for(int k = Constants::MTG_COLOR_ARTIFACT; k < Constants::NB_Colors;k++)
|
||||
{
|
||||
card->getManaCost()->add(k,card->getIncreasedManaCost()->getCost(k));
|
||||
if (card->getManaCost()->getAlternative())
|
||||
{
|
||||
card->getManaCost()->getAlternative()->add(k,card->getIncreasedManaCost()->getCost(k));
|
||||
}
|
||||
if (card->getManaCost()->getBuyback())
|
||||
{
|
||||
card->getManaCost()->getBuyback()->add(k,card->getIncreasedManaCost()->getCost(k));
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
@@ -4135,14 +4196,6 @@ void AAlterCost::decreaseTheCost(MTGCardInstance * card)
|
||||
for(int k = Constants::MTG_COLOR_ARTIFACT; k < Constants::NB_Colors;k++)
|
||||
{
|
||||
card->getManaCost()->remove(k,card->getReducedManaCost()->getCost(k));
|
||||
if (card->getManaCost()->getAlternative())
|
||||
{
|
||||
card->getManaCost()->getAlternative()->remove(k,card->getReducedManaCost()->getCost(k));
|
||||
}
|
||||
if (card->getManaCost()->getBuyback())
|
||||
{
|
||||
card->getManaCost()->getBuyback()->remove(k,card->getReducedManaCost()->getCost(k));
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
@@ -4620,6 +4673,8 @@ int AAExchangeLife::resolve()
|
||||
Damageable * _target = (Damageable *) getTarget();
|
||||
if (_target)
|
||||
{
|
||||
if(_target->type_as_damageable == Damageable::DAMAGEABLE_PLAYER && ((Player*)_target)->inPlay()->hasAbility(Constants::CANTCHANGELIFE))
|
||||
return 0;
|
||||
Player *player = source->controller();
|
||||
int oldlife = player->getLife();
|
||||
int targetOldLife = _target->getLife();
|
||||
|
||||
@@ -244,7 +244,10 @@ void CardGui::Render()
|
||||
highlightborder = game? game->getResourceManager()->GetQuad("white"):WResourceManager::Instance()->GetQuad("white");
|
||||
if(fakeborder)
|
||||
{
|
||||
fakeborder->SetColor(ARGB((int)(actA),15,15,15));
|
||||
if(card->has(Constants::CANPLAYFROMGRAVEYARD)||card->has(Constants::CANPLAYFROMEXILE)||card->has(Constants::PAYZERO))
|
||||
fakeborder->SetColor(ARGB((int)(actA),7,235,7));//green border
|
||||
else
|
||||
fakeborder->SetColor(ARGB((int)(actA),15,15,15));
|
||||
renderer->RenderQuad(fakeborder.get(), actX, actY, actT, (29 * actZ + 1) / 16, 42 * actZ / 16);
|
||||
}
|
||||
//draw border for highlighting
|
||||
@@ -365,8 +368,8 @@ void CardGui::Render()
|
||||
buff = "CT";
|
||||
if(!card->isToken && card->isACopier)
|
||||
buff = "C";
|
||||
if(card->has(Constants::PAYZERO))
|
||||
buff += "Z";
|
||||
//if(card->has(Constants::PAYZERO))
|
||||
//buff += "Z";
|
||||
if(card->alias == 1000)
|
||||
{
|
||||
if(card->chooseacolor == 1)
|
||||
|
||||
+35
-10
@@ -71,6 +71,9 @@ int Damage::resolve()
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
//Ajani Steadfast ---
|
||||
if(target->type_as_damageable == Damageable::DAMAGEABLE_MTGCARDINSTANCE && ((MTGCardInstance*)target)->hasType("planeswalker") && ((MTGCardInstance*)target)->controller()->forcefield)
|
||||
damage = 1;
|
||||
if (target->type_as_damageable == Damageable::DAMAGEABLE_MTGCARDINSTANCE)
|
||||
{
|
||||
MTGCardInstance * _target = (MTGCardInstance *) target;
|
||||
@@ -127,7 +130,9 @@ int Damage::resolve()
|
||||
_target->doDamageTest = 1;
|
||||
}
|
||||
if (target->type_as_damageable == Damageable::DAMAGEABLE_PLAYER)
|
||||
{
|
||||
{//Ajani Steadfast
|
||||
if(((Player*)target)->forcefield)
|
||||
damage = 1;
|
||||
if(source->has(Constants::LIBRARYEATER) && typeOfDamage == 1)
|
||||
{
|
||||
for (int j = damage; j > 0; j--)
|
||||
@@ -191,7 +196,8 @@ int Damage::resolve()
|
||||
{
|
||||
//Damage + 1, 2, or 3 poison counters on player
|
||||
Player * _target = (Player *) target;
|
||||
a = target->dealDamage(damage);
|
||||
if(!_target->inPlay()->hasAbility(Constants::CANTCHANGELIFE))
|
||||
a = target->dealDamage(damage);
|
||||
target->damageCount += damage;
|
||||
if ( typeOfDamage == 1 && target == source->controller()->opponent() )//add vector prowledtypes.
|
||||
{
|
||||
@@ -223,7 +229,10 @@ int Damage::resolve()
|
||||
{
|
||||
// "Normal" case,
|
||||
//return the left over amount after effects have been applied to them.
|
||||
a = target->dealDamage(damage);
|
||||
if (target->type_as_damageable == Damageable::DAMAGEABLE_PLAYER && ((Player *)target)->inPlay()->hasAbility(Constants::CANTCHANGELIFE))
|
||||
;//do nothing
|
||||
else
|
||||
a = target->dealDamage(damage);
|
||||
target->damageCount += damage;//the amount must be the actual damage so i changed this from 1 to damage, this fixes pdcount and odcount
|
||||
if (target->type_as_damageable == Damageable::DAMAGEABLE_MTGCARDINSTANCE){
|
||||
((MTGCardInstance*)target)->wasDealtDamage = true;
|
||||
@@ -265,28 +274,44 @@ void Damage::Render()
|
||||
mFont->SetScale(DEFAULT_MAIN_FONT_SCALE);
|
||||
char buffer[200];
|
||||
sprintf(buffer, _("Deals %i damage to").c_str(), damage);
|
||||
mFont->DrawString(buffer, x + 20, y, JGETEXT_LEFT);
|
||||
//mFont->DrawString(buffer, x + 20, y, JGETEXT_LEFT);
|
||||
mFont->DrawString(buffer, x + 32, y + GetVerticalTextOffset(), JGETEXT_LEFT);
|
||||
JRenderer * renderer = JRenderer::GetInstance();
|
||||
JQuadPtr quad = WResourceManager::Instance()->RetrieveCard(source, CACHE_THUMB);
|
||||
if (quad.get())
|
||||
{
|
||||
float scale = 30 / quad->mHeight;
|
||||
renderer->RenderQuad(quad.get(), x, y, 0, scale, scale);
|
||||
//float scale = 30 / quad->mHeight;
|
||||
//renderer->RenderQuad(quad.get(), x, y, 0, scale, scale);
|
||||
quad->SetColor(ARGB(255,255,255,255));
|
||||
float scale = mHeight / quad->mHeight;
|
||||
renderer->RenderQuad(quad.get(), x + (quad->mWidth * scale / 2), y + (quad->mHeight * scale / 2), 0, scale, scale);
|
||||
}
|
||||
else
|
||||
{
|
||||
mFont->DrawString(_(source->getName()).c_str(), x, y - 15);
|
||||
//mFont->DrawString(_(source->getName()).c_str(), x, y - 15);
|
||||
mFont->DrawString(_(source->getName()).c_str(), x, y + GetVerticalTextOffset() - 15);
|
||||
}
|
||||
quad = target->getIcon();
|
||||
if (quad.get())
|
||||
{
|
||||
float scale = 30 / quad->mHeight;
|
||||
renderer->RenderQuad(quad.get(), x + 150, y, 0, scale, scale);
|
||||
//float scale = 30 / quad->mHeight;
|
||||
//renderer->RenderQuad(quad.get(), x + 150, y, 0, scale, scale);
|
||||
float backupX = quad->mHotSpotX;
|
||||
float backupY = quad->mHotSpotY;
|
||||
quad->SetColor(ARGB(255,255,255,255));
|
||||
quad->SetHotSpot(quad->mWidth / 2, quad->mHeight / 2);
|
||||
float scale = mHeight / quad->mHeight;
|
||||
renderer->RenderQuad(quad.get(), x + 130, y - 0.5f + ((mHeight - quad->mHeight) / 2) + quad->mHotSpotY, 0, scale, scale);
|
||||
quad->SetHotSpot(backupX, backupY);
|
||||
}
|
||||
else
|
||||
{
|
||||
//if (target->type_as_damageable == Damageable::DAMAGEABLE_MTGCARDINSTANCE)
|
||||
//mFont->DrawString(_(((MTGCardInstance *) target)->getName()).c_str(), x + 120, y);
|
||||
if (target->type_as_damageable == Damageable::DAMAGEABLE_MTGCARDINSTANCE)
|
||||
mFont->DrawString(_(((MTGCardInstance *) target)->getName()).c_str(), x + 120, y);
|
||||
mFont->DrawString(_(((MTGCardInstance *) target)->getName()).c_str(), x + 35, y+15 + GetVerticalTextOffset());
|
||||
else if(target->type_as_damageable == Damageable::DAMAGEABLE_PLAYER)
|
||||
mFont->DrawString(_(((Player *) target)->getDisplayName()).c_str(), x + 35, y+15 + GetVerticalTextOffset());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -125,7 +125,7 @@ void DeckMenu::RenderDeckManaColors()
|
||||
if (deckManaColors.size() == 6)
|
||||
{
|
||||
// due to space constraints don't display icons for colorless mana.
|
||||
for( int colorIdx = Constants::MTG_COLOR_GREEN; colorIdx < Constants::MTG_COLOR_LAND; ++colorIdx )
|
||||
for( int colorIdx = Constants::MTG_COLOR_GREEN; colorIdx < Constants::MTG_COLOR_WASTE; ++colorIdx )
|
||||
{
|
||||
if ( (deckManaColors.at(colorIdx) == '1') != 0)
|
||||
{
|
||||
|
||||
@@ -394,6 +394,7 @@ void StatsWrapper::updateStats(string filename, MTGAllCards *collection)
|
||||
|
||||
void StatsWrapper::updateStats(DeckDataWrapper *myDeck)
|
||||
{
|
||||
if(!this) return;
|
||||
if (!this->needUpdate || !myDeck) return;
|
||||
|
||||
this->needUpdate = false;
|
||||
|
||||
@@ -130,6 +130,107 @@ int ExtraManaCost::doPay()
|
||||
return 1;
|
||||
}
|
||||
|
||||
//Snow cost
|
||||
SnowCost * SnowCost::clone() const
|
||||
{
|
||||
SnowCost * ec = NEW SnowCost(*this);
|
||||
return ec;
|
||||
}
|
||||
|
||||
SnowCost::SnowCost() :
|
||||
ExtraCost("Snow Mana")
|
||||
{
|
||||
}
|
||||
|
||||
int SnowCost::isPaymentSet()
|
||||
{
|
||||
if (source->controller()->getManaPool()->getConvertedCost())
|
||||
{
|
||||
int result = 0;
|
||||
result += source->controller()->snowManaG;
|
||||
result += source->controller()->snowManaU;
|
||||
result += source->controller()->snowManaR;
|
||||
result += source->controller()->snowManaB;
|
||||
result += source->controller()->snowManaW;
|
||||
result += source->controller()->snowManaC;
|
||||
if (result)
|
||||
{
|
||||
if ((source->controller()->snowManaC && source->controller()->getManaPool()->canAfford(ManaCost::parseManaCost("{1}",NULL,source))) ||
|
||||
(source->controller()->snowManaG && source->controller()->getManaPool()->canAfford(ManaCost::parseManaCost("{g}",NULL,source))) ||
|
||||
(source->controller()->snowManaU && source->controller()->getManaPool()->canAfford(ManaCost::parseManaCost("{u}",NULL,source))) ||
|
||||
(source->controller()->snowManaR && source->controller()->getManaPool()->canAfford(ManaCost::parseManaCost("{r}",NULL,source))) ||
|
||||
(source->controller()->snowManaB && source->controller()->getManaPool()->canAfford(ManaCost::parseManaCost("{b}",NULL,source))) ||
|
||||
(source->controller()->snowManaW && source->controller()->getManaPool()->canAfford(ManaCost::parseManaCost("{w}",NULL,source))) ||
|
||||
(source->controller()->snowManaC && source->controller()->getManaPool()->canAfford(ManaCost::parseManaCost("{c}",NULL,source))))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SnowCost::canPay()
|
||||
{
|
||||
return isPaymentSet();
|
||||
}
|
||||
|
||||
int SnowCost::doPay()
|
||||
{
|
||||
if (source->controller()->getManaPool()->getConvertedCost())
|
||||
{
|
||||
int result = 0;
|
||||
result += source->controller()->snowManaG;
|
||||
result += source->controller()->snowManaU;
|
||||
result += source->controller()->snowManaR;
|
||||
result += source->controller()->snowManaB;
|
||||
result += source->controller()->snowManaW;
|
||||
result += source->controller()->snowManaC;
|
||||
if (result)
|
||||
{
|
||||
if (source->controller()->snowManaC && source->controller()->getManaPool()->canAfford(ManaCost::parseManaCost("{1}",NULL,source)))
|
||||
{
|
||||
source->controller()->getManaPool()->pay(ManaCost::parseManaCost("{1}",NULL,source));
|
||||
source->controller()->snowManaC -= 1;
|
||||
}
|
||||
else if (source->controller()->snowManaG && source->controller()->getManaPool()->canAfford(ManaCost::parseManaCost("{g}",NULL,source)))
|
||||
{
|
||||
source->controller()->getManaPool()->pay(ManaCost::parseManaCost("{g}",NULL,source));
|
||||
source->controller()->snowManaG -= 1;
|
||||
}
|
||||
else if (source->controller()->snowManaU && source->controller()->getManaPool()->canAfford(ManaCost::parseManaCost("{u}",NULL,source)))
|
||||
{
|
||||
source->controller()->getManaPool()->pay(ManaCost::parseManaCost("{u}",NULL,source));
|
||||
source->controller()->snowManaU -= 1;
|
||||
}
|
||||
else if (source->controller()->snowManaR && source->controller()->getManaPool()->canAfford(ManaCost::parseManaCost("{r}",NULL,source)))
|
||||
{
|
||||
source->controller()->getManaPool()->pay(ManaCost::parseManaCost("{r}",NULL,source));
|
||||
source->controller()->snowManaR -= 1;
|
||||
}
|
||||
else if (source->controller()->snowManaB && source->controller()->getManaPool()->canAfford(ManaCost::parseManaCost("{b}",NULL,source)))
|
||||
{
|
||||
source->controller()->getManaPool()->pay(ManaCost::parseManaCost("{b}",NULL,source));
|
||||
source->controller()->snowManaB -= 1;
|
||||
}
|
||||
else if (source->controller()->snowManaW && source->controller()->getManaPool()->canAfford(ManaCost::parseManaCost("{w}",NULL,source)))
|
||||
{
|
||||
source->controller()->getManaPool()->pay(ManaCost::parseManaCost("{w}",NULL,source));
|
||||
source->controller()->snowManaW -= 1;
|
||||
}
|
||||
else if (source->controller()->snowManaC && source->controller()->getManaPool()->canAfford(ManaCost::parseManaCost("{c}",NULL,source)))
|
||||
{
|
||||
source->controller()->getManaPool()->pay(ManaCost::parseManaCost("{c}",NULL,source));
|
||||
source->controller()->snowManaC -= 1;
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
//life cost
|
||||
LifeCost * LifeCost::clone() const
|
||||
{
|
||||
@@ -147,7 +248,7 @@ LifeCost::LifeCost(TargetChooser *_tc)
|
||||
int LifeCost::canPay()
|
||||
{
|
||||
MTGCardInstance * _target = (MTGCardInstance *) target;
|
||||
if(_target->controller()->life <= 0)
|
||||
if(_target->controller()->life <= 0 || _target->controller()->inPlay()->hasAbility(Constants::CANTCHANGELIFE))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -185,7 +286,7 @@ SpecificLifeCost::SpecificLifeCost(TargetChooser *_tc, int slc)
|
||||
int SpecificLifeCost::canPay()
|
||||
{
|
||||
MTGCardInstance * _target = (MTGCardInstance *) target;
|
||||
if(_target->controller()->life >= slc)
|
||||
if(_target->controller()->life >= slc && !_target->controller()->inPlay()->hasAbility(Constants::CANTCHANGELIFE))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
@@ -394,6 +495,35 @@ int ToLibraryCost::doPay()
|
||||
return 0;
|
||||
}
|
||||
|
||||
//to graveyard cost
|
||||
ToGraveCost * ToGraveCost::clone() const
|
||||
{
|
||||
ToGraveCost * ec = NEW ToGraveCost(*this);
|
||||
if (tc)
|
||||
ec->tc = tc->clone();
|
||||
return ec;
|
||||
}
|
||||
|
||||
ToGraveCost::ToGraveCost(TargetChooser *_tc)
|
||||
: ExtraCost("Move a card to Graveyard", _tc)
|
||||
{
|
||||
}
|
||||
|
||||
int ToGraveCost::doPay()
|
||||
{
|
||||
MTGCardInstance * _target = (MTGCardInstance *) target;
|
||||
if (target)
|
||||
{
|
||||
source->storedCard = target->createSnapShot();
|
||||
_target->controller()->game->putInGraveyard(target);
|
||||
target = NULL;
|
||||
if (tc)
|
||||
tc->initTargets();
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
//Mill yourself as a cost
|
||||
MillCost * MillCost::clone() const
|
||||
{
|
||||
|
||||
@@ -600,6 +600,32 @@ void GameObserver::gameStateBasedEffects()
|
||||
/////////////////////////////////////
|
||||
for (int d = 0; d < 2; d++)
|
||||
{
|
||||
////check snow count
|
||||
if (players[d]->snowManaC > players[d]->getManaPool()->getCost(0) + players[d]->getManaPool()->getCost(6))
|
||||
players[d]->snowManaC = players[d]->getManaPool()->getCost(0) + players[d]->getManaPool()->getCost(6);
|
||||
if (players[d]->snowManaC < 0)
|
||||
players[d]->snowManaC = 0;
|
||||
if (players[d]->snowManaG > players[d]->getManaPool()->getCost(1))
|
||||
players[d]->snowManaG = players[d]->getManaPool()->getCost(1);
|
||||
if (players[d]->snowManaG < 0)
|
||||
players[d]->snowManaG = 0;
|
||||
if (players[d]->snowManaU > players[d]->getManaPool()->getCost(2))
|
||||
players[d]->snowManaU = players[d]->getManaPool()->getCost(2);
|
||||
if (players[d]->snowManaU < 0)
|
||||
players[d]->snowManaU = 0;
|
||||
if (players[d]->snowManaR > players[d]->getManaPool()->getCost(3))
|
||||
players[d]->snowManaR = players[d]->getManaPool()->getCost(3);
|
||||
if (players[d]->snowManaR < 0)
|
||||
players[d]->snowManaR = 0;
|
||||
if (players[d]->snowManaB > players[d]->getManaPool()->getCost(4))
|
||||
players[d]->snowManaB = players[d]->getManaPool()->getCost(4);
|
||||
if (players[d]->snowManaB < 0)
|
||||
players[d]->snowManaB = 0;
|
||||
if (players[d]->snowManaW > players[d]->getManaPool()->getCost(5))
|
||||
players[d]->snowManaW = players[d]->getManaPool()->getCost(5);
|
||||
if (players[d]->snowManaW < 0)
|
||||
players[d]->snowManaW = 0;
|
||||
|
||||
MTGGameZone * dzones[] = { players[d]->game->inPlay, players[d]->game->graveyard, players[d]->game->hand, players[d]->game->library, players[d]->game->exile };
|
||||
for (int k = 0; k < 5; k++)
|
||||
{
|
||||
@@ -612,6 +638,21 @@ void GameObserver::gameStateBasedEffects()
|
||||
zone->cards[c]->cardistargetter = 0;
|
||||
}
|
||||
}
|
||||
|
||||
///while checking all these zones, lets also strip devoid cards of thier colors
|
||||
for (int w = 0; w < zone->nb_cards; w++)
|
||||
{
|
||||
MTGCardInstance * card = zone->cards[w];
|
||||
for (int i = Constants::MTG_COLOR_GREEN; i <= Constants::MTG_COLOR_WHITE; ++i)
|
||||
{
|
||||
if (card->has(Constants::DEVOID))
|
||||
{
|
||||
card->removeColor(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}//check for losers if its GAMEOVER clear the stack to allow gamestateeffects to continue
|
||||
players[d]->DeadLifeState();
|
||||
}
|
||||
@@ -912,13 +953,12 @@ void GameObserver::gameStateBasedEffects()
|
||||
//Auto skip Phases
|
||||
int skipLevel = (currentPlayer->playMode == Player::MODE_TEST_SUITE || mLoading) ? Constants::ASKIP_NONE
|
||||
: options[Options::ASPHASES].number;
|
||||
int nrCreatures = currentPlayer->game->inPlay->hasType("creature")?1:0;
|
||||
|
||||
if (skipLevel == Constants::ASKIP_SAFE || skipLevel == Constants::ASKIP_FULL)
|
||||
{
|
||||
if ((opponent()->isAI() && !(isInterrupting)) && ((mCurrentGamePhase == MTG_PHASE_UNTAP)
|
||||
|| (mCurrentGamePhase == MTG_PHASE_DRAW) || (mCurrentGamePhase == MTG_PHASE_COMBATBEGIN)
|
||||
|| ((mCurrentGamePhase == MTG_PHASE_COMBATATTACKERS) && (nrCreatures == 0))
|
||||
|| ((mCurrentGamePhase == MTG_PHASE_COMBATATTACKERS) && (currentPlayer->noPossibleAttackers()))
|
||||
|| mCurrentGamePhase == MTG_PHASE_COMBATEND || mCurrentGamePhase == MTG_PHASE_ENDOFTURN
|
||||
|| ((mCurrentGamePhase == MTG_PHASE_CLEANUP) && (currentPlayer->game->hand->nb_cards < 8))))
|
||||
userRequestNextGamePhase();
|
||||
@@ -975,74 +1015,15 @@ void GameObserver::Affinity()
|
||||
string type = "";
|
||||
//only do any of the following if a card with the stated ability is in your hand.
|
||||
ManaCost * original = NEW ManaCost();
|
||||
ManaCost * alternate = NEW ManaCost();
|
||||
ManaCost * buyback = NEW ManaCost();
|
||||
ManaCost * flashback = NEW ManaCost();
|
||||
ManaCost * retrace = NEW ManaCost();
|
||||
original->copy(card->model->data->getManaCost());
|
||||
alternate->copy(card->model->data->getManaCost()->getAlternative());
|
||||
buyback->copy(card->model->data->getManaCost()->getBuyback());
|
||||
flashback->copy(card->model->data->getManaCost()->getFlashback());
|
||||
retrace->copy(card->model->data->getManaCost()->getRetrace());
|
||||
//have to run alter cost before affinity or the 2 cancel each other out.
|
||||
if(card->getIncreasedManaCost()->getConvertedCost()||card->getReducedManaCost()->getConvertedCost())
|
||||
{
|
||||
{//start1
|
||||
if(card->getIncreasedManaCost()->getConvertedCost())
|
||||
{
|
||||
original->add(card->getIncreasedManaCost());
|
||||
for(int kc = Constants::MTG_COLOR_ARTIFACT; kc < Constants::NB_Colors;kc++)
|
||||
{
|
||||
if (card->getManaCost()->getAlternative())
|
||||
{
|
||||
alternate->add(kc,card->getIncreasedManaCost()->getCost(kc));
|
||||
}
|
||||
if (card->getManaCost()->getBuyback())
|
||||
{
|
||||
buyback->add(kc,card->getIncreasedManaCost()->getCost(kc));
|
||||
}
|
||||
if (card->getManaCost()->getFlashback())
|
||||
{
|
||||
flashback->add(kc,card->getIncreasedManaCost()->getCost(kc));
|
||||
}
|
||||
if (card->getManaCost()->getRetrace())
|
||||
{
|
||||
retrace->add(kc,card->getIncreasedManaCost()->getCost(kc));
|
||||
}
|
||||
}
|
||||
}
|
||||
if(card->getReducedManaCost()->getConvertedCost())
|
||||
{
|
||||
original->remove(card->getReducedManaCost());
|
||||
for(int kc = Constants::MTG_COLOR_ARTIFACT; kc < Constants::NB_Colors;kc++)
|
||||
{
|
||||
if (card->getManaCost()->getAlternative())
|
||||
{
|
||||
alternate->remove(kc,card->getReducedManaCost()->getCost(kc));
|
||||
}
|
||||
if (card->getManaCost()->getBuyback())
|
||||
{
|
||||
buyback->remove(kc,card->getIncreasedManaCost()->getCost(kc));
|
||||
}
|
||||
if (card->getManaCost()->getFlashback())
|
||||
{
|
||||
flashback->remove(kc,card->getIncreasedManaCost()->getCost(kc));
|
||||
}
|
||||
if (card->getManaCost()->getRetrace())
|
||||
{
|
||||
retrace->remove(kc,card->getIncreasedManaCost()->getCost(kc));
|
||||
}
|
||||
}
|
||||
}
|
||||
if(card->getManaCost())
|
||||
card->getManaCost()->copy(original);
|
||||
if(card->getManaCost()->getAlternative())
|
||||
card->getManaCost()->setAlternative(alternate);
|
||||
if(card->getManaCost()->getBuyback())
|
||||
card->getManaCost()->setBuyback(buyback);
|
||||
if(card->getManaCost()->getFlashback())
|
||||
card->getManaCost()->setFlashback(flashback);
|
||||
if(card->getManaCost()->getRetrace())
|
||||
card->getManaCost()->setRetrace(retrace);
|
||||
if(card->getManaCost()->extraCosts)
|
||||
{
|
||||
for(unsigned int i = 0; i < card->getManaCost()->extraCosts->costs.size();i++)
|
||||
@@ -1050,11 +1031,11 @@ void GameObserver::Affinity()
|
||||
card->getManaCost()->extraCosts->costs[i]->setSource(card);
|
||||
}
|
||||
}
|
||||
}
|
||||
}//end1
|
||||
int reducem = 0;
|
||||
bool resetCost = false;
|
||||
for(unsigned int na = 0; na < card->cardsAbilities.size();na++)
|
||||
{
|
||||
{//start2
|
||||
ANewAffinity * newAff = dynamic_cast<ANewAffinity*>(card->cardsAbilities[na]);
|
||||
if(newAff)
|
||||
{
|
||||
@@ -1092,7 +1073,7 @@ void GameObserver::Affinity()
|
||||
card->getManaCost()->remove(removingCost);
|
||||
SAFE_DELETE(removingCost);
|
||||
}
|
||||
}
|
||||
}//end2
|
||||
if(card->has(Constants::AFFINITYARTIFACTS)||
|
||||
card->has(Constants::AFFINITYFOREST)||
|
||||
card->has(Constants::AFFINITYGREENCREATURES)||
|
||||
@@ -1100,7 +1081,7 @@ void GameObserver::Affinity()
|
||||
card->has(Constants::AFFINITYMOUNTAIN)||
|
||||
card->has(Constants::AFFINITYPLAINS)||
|
||||
card->has(Constants::AFFINITYSWAMP))
|
||||
{
|
||||
{//start3
|
||||
if (card->has(Constants::AFFINITYARTIFACTS))
|
||||
{
|
||||
type = "artifact";
|
||||
@@ -1155,13 +1136,27 @@ void GameObserver::Affinity()
|
||||
if(card->getManaCost()->getCost(color) > 0)
|
||||
card->getManaCost()->remove(color,1);
|
||||
}
|
||||
}//end3
|
||||
//trinisphere... now how to implement kicker recomputation
|
||||
|
||||
if(card->has(Constants::TRINISPHERE))
|
||||
{
|
||||
for(int jj = card->getManaCost()->getConvertedCost(); jj < 3; jj++)
|
||||
{
|
||||
card->getManaCost()->add(Constants::MTG_COLOR_ARTIFACT, 1);
|
||||
card->countTrini++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(card->countTrini)
|
||||
{
|
||||
card->getManaCost()->remove(Constants::MTG_COLOR_ARTIFACT, card->countTrini);
|
||||
card->countTrini=0;
|
||||
}
|
||||
}
|
||||
|
||||
SAFE_DELETE(original);
|
||||
|
||||
SAFE_DELETE(alternate);
|
||||
SAFE_DELETE(buyback);
|
||||
SAFE_DELETE(flashback);
|
||||
SAFE_DELETE(retrace);
|
||||
}//end
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2561,6 +2561,16 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
|
||||
return a;
|
||||
}
|
||||
|
||||
//Forcefield
|
||||
found = s.find("forcefield");
|
||||
if (found != string::npos)
|
||||
{
|
||||
|
||||
MTGAbility * a = NEW AAEPIC(observer, id, card, target,"Forcefield",NULL,true);
|
||||
a->oneShot = 1;
|
||||
return a;
|
||||
}
|
||||
|
||||
//Damage
|
||||
vector<string> splitDamage = parseBetween(s, "damage:", " ", false);
|
||||
if (splitDamage.size())
|
||||
@@ -2674,6 +2684,16 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
|
||||
return a;
|
||||
}
|
||||
|
||||
//Cascade
|
||||
vector<string> splitCascade = parseBetween(s, "cascade:", " ", false);
|
||||
if (splitCascade.size())
|
||||
{
|
||||
Targetable * t = spell ? spell->getNextTarget() : NULL;
|
||||
MTGAbility * a = NEW AACascade(observer, id, card, t , splitCascade[1], NULL, who);
|
||||
a->oneShot = 1;
|
||||
return a;
|
||||
}
|
||||
|
||||
//modify turns
|
||||
vector<string> splitModTurn = parseBetween(s, "turns:", " ", false);
|
||||
if (splitModTurn.size())
|
||||
@@ -4379,8 +4399,11 @@ void AbilityFactory::addAbilities(int _id, Spell * spell)
|
||||
case 130553:// Beacon of Immortality
|
||||
{
|
||||
Player * player = spell->getNextPlayerTarget();
|
||||
if (player->life < (INT_MAX / 4))
|
||||
player->life += player->life;
|
||||
if (!player->inPlay()->hasAbility(Constants::CANTCHANGELIFE))
|
||||
{
|
||||
if (player->life < (INT_MAX / 4))
|
||||
player->life += player->life;
|
||||
}
|
||||
zones->putInZone(card, spell->from, zones->library);
|
||||
zones->library->shuffle();
|
||||
break;
|
||||
@@ -5752,7 +5775,7 @@ const string AManaProducer::getMenuText()
|
||||
menutext = _("Add ");
|
||||
char buffer[128];
|
||||
int alreadyHasOne = 0;
|
||||
for (int i = 0; i < 6; i++)
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
int value = output->getCost(i);
|
||||
if (value)
|
||||
@@ -5761,8 +5784,11 @@ const string AManaProducer::getMenuText()
|
||||
menutext.append(",");
|
||||
sprintf(buffer, "%i ", value);
|
||||
menutext.append(buffer);
|
||||
if (i >= Constants::MTG_COLOR_GREEN && i <= Constants::MTG_COLOR_WHITE)
|
||||
if (i == Constants::MTG_COLOR_WASTE)
|
||||
menutext.append(_(" colorless"));
|
||||
else if (i >= Constants::MTG_COLOR_GREEN && i <= Constants::MTG_COLOR_WASTE)
|
||||
menutext.append(_(Constants::MTGColorStrings[i]));
|
||||
|
||||
alreadyHasOne = 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,9 @@
|
||||
#include "Counters.h"
|
||||
#include "Subtypes.h"
|
||||
|
||||
|
||||
#include "AIPlayerBaka.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
SUPPORT_OBJECT_ANALYTICS(MTGCardInstance)
|
||||
@@ -115,7 +118,14 @@ void MTGCardInstance::copy(MTGCardInstance * card)
|
||||
AbilityFactory af(observer);
|
||||
af.addAbilities(observer->mLayers->actionLayer()->getMaxId(), spell);
|
||||
delete spell;
|
||||
mtgid = backupid;
|
||||
if(observer->players[1]->playMode == Player::MODE_TEST_SUITE)
|
||||
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;
|
||||
backupTargets = this->backupTargets;
|
||||
storedCard = oldStored;
|
||||
@@ -168,6 +178,7 @@ void MTGCardInstance::initMTGCI()
|
||||
isMorphed = false;
|
||||
isFlipped = false;
|
||||
isPhased = false;
|
||||
isCascaded = false;
|
||||
phasedTurn = -1;
|
||||
didattacked = 0;
|
||||
didblocked = 0;
|
||||
@@ -194,6 +205,7 @@ void MTGCardInstance::initMTGCI()
|
||||
storedSourceCard = NULL;
|
||||
myPair = NULL;
|
||||
miracle = false;
|
||||
countTrini = 0;
|
||||
|
||||
for (int i = 0; i < ManaCost::MANA_PAID_WITH_SUSPEND +1; i++)
|
||||
alternateCostPaid[i] = 0;
|
||||
@@ -918,23 +930,119 @@ JQuadPtr MTGCardInstance::getIcon()
|
||||
return WResourceManager::Instance()->RetrieveCard(this, CACHE_THUMB);
|
||||
}
|
||||
|
||||
ManaCost * MTGCardInstance::computeNewCost(MTGCardInstance * card,ManaCost * oldCost)
|
||||
ManaCost * MTGCardInstance::computeNewCost(MTGCardInstance * card,ManaCost * newCost, ManaCost * refCost, bool noTrinisphere)
|
||||
{
|
||||
if(card->isLand())
|
||||
return oldCost;
|
||||
|
||||
if(!card)
|
||||
return oldCost;
|
||||
//use forcedalive//
|
||||
//pay zero costs//
|
||||
//kicker???...//
|
||||
//morph cost todo//
|
||||
//trinisphere must be here below//
|
||||
if(card->has(Constants::TRINISPHERE))
|
||||
for(int jj = oldCost->getConvertedCost(); jj < 3; jj++)
|
||||
oldCost->add(Constants::MTG_COLOR_ARTIFACT, 1);
|
||||
return NULL;
|
||||
|
||||
if(card->getIncreasedManaCost()->getConvertedCost())
|
||||
newCost->add(card->getIncreasedManaCost());
|
||||
if(card->getReducedManaCost()->getConvertedCost())
|
||||
newCost->remove(card->getReducedManaCost());
|
||||
if(refCost->extraCosts)
|
||||
newCost->extraCosts = refCost->extraCosts;
|
||||
//affinity
|
||||
int color = 0;
|
||||
string type = "";
|
||||
ManaCost * original = NEW ManaCost();
|
||||
original->copy(newCost);
|
||||
int reducem = 0;
|
||||
bool resetCost = false;
|
||||
for(unsigned int na = 0; na < card->cardsAbilities.size();na++)
|
||||
{//start2
|
||||
ANewAffinity * newAff = dynamic_cast<ANewAffinity*>(card->cardsAbilities[na]);
|
||||
if(newAff)
|
||||
{
|
||||
if(!resetCost)
|
||||
{
|
||||
resetCost = true;
|
||||
newCost->copy(original);
|
||||
}
|
||||
TargetChooserFactory tf(observer);
|
||||
TargetChooser * tcn = tf.createTargetChooser(newAff->tcString,card,NULL);
|
||||
|
||||
return oldCost;
|
||||
for (int w = 0; w < 2; ++w)
|
||||
{
|
||||
Player *p = observer->players[w];
|
||||
MTGGameZone * zones[] = { p->game->inPlay, p->game->graveyard, p->game->hand, p->game->library, p->game->stack, p->game->exile };
|
||||
for (int k = 0; k < 6; k++)
|
||||
{
|
||||
MTGGameZone * z = zones[k];
|
||||
if (tcn->targetsZone(z))
|
||||
reducem += z->countByCanTarget(tcn);
|
||||
}
|
||||
}
|
||||
SAFE_DELETE(tcn);
|
||||
ManaCost * removingCost = ManaCost::parseManaCost(newAff->manaString);
|
||||
for(int j = 0; j < reducem; j++)
|
||||
newCost->remove(removingCost);
|
||||
SAFE_DELETE(removingCost);
|
||||
}
|
||||
}//end2
|
||||
if(card->has(Constants::AFFINITYARTIFACTS)||
|
||||
card->has(Constants::AFFINITYFOREST)||
|
||||
card->has(Constants::AFFINITYGREENCREATURES)||
|
||||
card->has(Constants::AFFINITYISLAND)||
|
||||
card->has(Constants::AFFINITYMOUNTAIN)||
|
||||
card->has(Constants::AFFINITYPLAINS)||
|
||||
card->has(Constants::AFFINITYSWAMP))
|
||||
{//start3
|
||||
if (card->has(Constants::AFFINITYARTIFACTS))
|
||||
type = "artifact";
|
||||
else if (card->has(Constants::AFFINITYSWAMP))
|
||||
type = "swamp";
|
||||
else if (card->has(Constants::AFFINITYMOUNTAIN))
|
||||
type = "mountain";
|
||||
else if (card->has(Constants::AFFINITYPLAINS))
|
||||
type = "plains";
|
||||
else if (card->has(Constants::AFFINITYISLAND))
|
||||
type = "island";
|
||||
else if (card->has(Constants::AFFINITYFOREST))
|
||||
type = "forest";
|
||||
else if (card->has(Constants::AFFINITYGREENCREATURES))
|
||||
{
|
||||
color = 1;
|
||||
type = "creature";
|
||||
}
|
||||
newCost->copy(original);
|
||||
int reduce = 0;
|
||||
if(card->has(Constants::AFFINITYGREENCREATURES))
|
||||
{
|
||||
TargetChooserFactory tf(observer);
|
||||
TargetChooser * tc = tf.createTargetChooser("creature[green]",NULL);
|
||||
reduce = card->controller()->game->battlefield->countByCanTarget(tc);
|
||||
SAFE_DELETE(tc);
|
||||
}
|
||||
else
|
||||
reduce = card->controller()->game->battlefield->countByType(type);
|
||||
for(int i = 0; i < reduce;i++)
|
||||
if(newCost->getCost(color) > 0)
|
||||
newCost->remove(color,1);
|
||||
}//end3
|
||||
SAFE_DELETE(original);
|
||||
|
||||
if(!noTrinisphere)
|
||||
{
|
||||
//trinisphere... now how to implement kicker recomputation
|
||||
if(card->has(Constants::TRINISPHERE))
|
||||
{
|
||||
for(int jj = newCost->getConvertedCost(); jj < 3; jj++)
|
||||
{
|
||||
newCost->add(Constants::MTG_COLOR_ARTIFACT, 1);
|
||||
card->countTrini++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(card->countTrini)
|
||||
{
|
||||
newCost->remove(Constants::MTG_COLOR_ARTIFACT, card->countTrini);
|
||||
card->countTrini=0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return newCost;
|
||||
}
|
||||
|
||||
MTGCardInstance * MTGCardInstance::getNextPartner()
|
||||
|
||||
@@ -4,7 +4,7 @@ using std::string;
|
||||
|
||||
#include "MTGDefinitions.h"
|
||||
|
||||
char Constants::MTGColorChars[] = {'x','g','u','r','b','w','l'};
|
||||
char Constants::MTGColorChars[] = {'x','g','u','r','b','w','c','l'};
|
||||
vector <const char*> Constants::MTGColorStrings;
|
||||
|
||||
const string Constants::kManaColorless = "colorless";
|
||||
@@ -13,6 +13,7 @@ const string Constants::kManaBlue = "blue";
|
||||
const string Constants::kManaRed = "red";
|
||||
const string Constants::kManaBlack = "black";
|
||||
const string Constants::kManaWhite = "white";
|
||||
const string Constants::kManaWaste = "waste";
|
||||
|
||||
int Constants::_r[7] = {75,20,20,200,50,255,128};
|
||||
int Constants::_g[7] = {30,140,30,15,50,255,128};
|
||||
@@ -151,7 +152,9 @@ const char* Constants::MTGBasicAbilities[] = {
|
||||
"zerocast",
|
||||
"trinisphere",
|
||||
"canplayfromexile",
|
||||
"libraryeater"
|
||||
"libraryeater",
|
||||
"devoid",
|
||||
"cantchangelife"
|
||||
};
|
||||
|
||||
map<string,int> Constants::MTGBasicAbilitiesMap;
|
||||
|
||||
@@ -375,6 +375,12 @@ MTGCardInstance * MTGPlayerCards::putInZone(MTGCardInstance * card, MTGGameZone
|
||||
{
|
||||
copy->miracle = true;
|
||||
}
|
||||
if(from == g->players[0]->game->battlefield || from == g->players[1]->game->battlefield)
|
||||
if(to != g->players[0]->game->battlefield || to != g->players[1]->game->battlefield)
|
||||
{
|
||||
card->kicked = 0;
|
||||
copy->kicked = 0;//kicked reset everflowing chalice...
|
||||
}
|
||||
if (card->discarded)
|
||||
{//set discarded for madness...
|
||||
if(from == g->players[0]->game->hand || from == g->players[1]->game->hand)
|
||||
|
||||
+172
-97
@@ -481,84 +481,86 @@ int MTGKickerRule::isReactingToClick(MTGCardInstance * card, ManaCost *)
|
||||
return 0;
|
||||
if ((player->game->graveyard->hasCard(card) && !card->has(Constants::CANPLAYFROMGRAVEYARD)) || (player->game->exile->hasCard(card) && !card->has(Constants::CANPLAYFROMEXILE)))
|
||||
return 0;
|
||||
ManaCost * kicker = card->getManaCost()->getKicker();
|
||||
if(!kicker)
|
||||
{
|
||||
SAFE_DELETE(kicker);
|
||||
if(!allowedToCast(card,player))
|
||||
return 0;
|
||||
}
|
||||
ManaCost * playerMana = player->getManaPool();
|
||||
ManaCost * withKickerCost= NEW ManaCost(card->model->data->getManaCost());
|
||||
if(card->getIncreasedManaCost()->getConvertedCost())
|
||||
withKickerCost->add(card->getIncreasedManaCost());
|
||||
if(card->getReducedManaCost()->getConvertedCost())
|
||||
withKickerCost->remove(card->getReducedManaCost());
|
||||
withKickerCost->add(card->model->data->getManaCost()->getKicker());
|
||||
if(!playerMana->canAfford(withKickerCost))
|
||||
{
|
||||
delete withKickerCost;
|
||||
if(!card->getManaCost()->getKicker())
|
||||
return 0;
|
||||
|
||||
if ((card->hasType(Subtypes::TYPE_INSTANT)) || card->has(Constants::FLASH) || (card->StackIsEmptyandSorcerySpeed()))
|
||||
{
|
||||
if(card->controller()->epic)
|
||||
return 0;
|
||||
|
||||
if (card->controller()->game->playRestrictions->canPutIntoZone(card, game->currentActionPlayer->game->stack) == PlayRestriction::CANT_PLAY)
|
||||
return 0;
|
||||
ManaCost * playerMana = player->getManaPool();
|
||||
ManaCost * withKickerCost= NEW ManaCost(card->getManaCost());
|
||||
withKickerCost->add(card->getManaCost()->getKicker());
|
||||
//cost reduction/recalculation must be here or outside somehow...
|
||||
#ifdef WIN32
|
||||
withKickerCost->Dump();
|
||||
#endif
|
||||
if (playerMana->canAfford(withKickerCost))
|
||||
return 1;
|
||||
}
|
||||
delete withKickerCost;
|
||||
|
||||
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int MTGKickerRule::reactToClick(MTGCardInstance * card)
|
||||
{
|
||||
if(!isReactingToClick(card, NULL))
|
||||
if (!isReactingToClick(card))
|
||||
return 0;
|
||||
|
||||
Player * player = game->currentlyActing();
|
||||
ManaCost * withKickerCost= NEW ManaCost(card->model->data->getManaCost());//using pointers here alters the real cost of the card.
|
||||
if(card->getIncreasedManaCost()->getConvertedCost())
|
||||
withKickerCost->add(card->getIncreasedManaCost());
|
||||
if(card->getReducedManaCost()->getConvertedCost())
|
||||
withKickerCost->remove(card->getReducedManaCost());
|
||||
if (card->model->data->getManaCost()->getKicker()->isMulti)
|
||||
{
|
||||
while(player->getManaPool()->canAfford(withKickerCost))
|
||||
{
|
||||
withKickerCost->add(card->model->data->getManaCost()->getKicker());
|
||||
card->kicked += 1;
|
||||
}
|
||||
card->kicked -= 1;
|
||||
//for(int i = 0;i < card->kicked;i++)
|
||||
//player->getManaPool()->pay(card->getManaCost()->kicker);
|
||||
card->paymenttype = MTGAbility::PUT_INTO_PLAY_WITH_KICKER;
|
||||
}
|
||||
else
|
||||
{
|
||||
withKickerCost->add(card->model->data->getManaCost()->getKicker());
|
||||
card->paymenttype = MTGAbility::PUT_INTO_PLAY_WITH_KICKER;
|
||||
}
|
||||
if (withKickerCost->isExtraPaymentSet())
|
||||
ManaCost * cost = card->getManaCost();
|
||||
|
||||
//this handles extra cost payments at the moment a card is played.
|
||||
|
||||
if (cost->isExtraPaymentSet())
|
||||
{
|
||||
if (!game->targetListIsSet(card))
|
||||
{
|
||||
delete withKickerCost;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
withKickerCost->setExtraCostsAction(this, card);
|
||||
game->mExtraPayment = withKickerCost->extraCosts;
|
||||
delete withKickerCost;
|
||||
cost->setExtraCostsAction(this, card);
|
||||
game->mExtraPayment = cost->extraCosts;
|
||||
return 0;
|
||||
}
|
||||
|
||||
ManaCost * previousManaPool = NEW ManaCost(player->getManaPool());
|
||||
player->getManaPool()->pay(withKickerCost);
|
||||
withKickerCost->doPayExtra();
|
||||
int payResult = player->getManaPool()->pay(card->getManaCost());
|
||||
if (card->getManaCost()->getKicker())
|
||||
{ //cost reduction/recalculation must be here or outside somehow...
|
||||
ManaCost * withKickerCost= NEW ManaCost(card->getManaCost());
|
||||
withKickerCost->add(withKickerCost->getKicker());
|
||||
if (card->getManaCost()->getKicker()->isMulti)
|
||||
{
|
||||
while(previousManaPool->canAfford(withKickerCost))
|
||||
{
|
||||
withKickerCost->add(withKickerCost->getKicker());
|
||||
card->kicked += 1;
|
||||
}
|
||||
for(int i = 0;i < card->kicked;i++)
|
||||
player->getManaPool()->pay(card->getManaCost()->getKicker());
|
||||
payResult = ManaCost::MANA_PAID_WITH_KICKER;
|
||||
}
|
||||
else if (previousManaPool->canAfford(withKickerCost))
|
||||
{
|
||||
player->getManaPool()->pay(card->getManaCost()->getKicker());
|
||||
payResult = ManaCost::MANA_PAID_WITH_KICKER;
|
||||
}
|
||||
delete withKickerCost;
|
||||
}
|
||||
card->getManaCost()->doPayExtra();
|
||||
ManaCost * spellCost = previousManaPool->Diff(player->getManaPool());
|
||||
delete withKickerCost;
|
||||
|
||||
delete previousManaPool;
|
||||
if (card->isLand())
|
||||
{
|
||||
MTGCardInstance * copy = player->game->putInZone(card, card->currentZone, player->game->temp);
|
||||
Spell * spell = NEW Spell(game, 0,copy,NULL,NULL, ManaCost::MANA_PAID_WITH_KICKER);
|
||||
Spell * spell = NEW Spell(game, 0,copy,NULL,NULL, payResult);
|
||||
spell->resolve();
|
||||
delete spellCost;
|
||||
delete spell;
|
||||
@@ -569,21 +571,21 @@ int MTGKickerRule::reactToClick(MTGCardInstance * card)
|
||||
MTGCardInstance * copy = player->game->putInZone(card, card->currentZone, player->game->stack);
|
||||
if (game->targetChooser)
|
||||
{
|
||||
spell = game->mLayers->stackLayer()->addSpell(copy, game->targetChooser, spellCost, ManaCost::MANA_PAID_WITH_KICKER, 0);
|
||||
spell = game->mLayers->stackLayer()->addSpell(copy, game->targetChooser, spellCost, payResult, 0);
|
||||
game->targetChooser = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
spell = game->mLayers->stackLayer()->addSpell(copy, NULL, spellCost, ManaCost::MANA_PAID_WITH_KICKER, 0);
|
||||
spell = game->mLayers->stackLayer()->addSpell(copy, NULL, spellCost, payResult, 0);
|
||||
}
|
||||
|
||||
if (card->has(Constants::STORM))
|
||||
{
|
||||
int storm = player->game->stack->seenThisTurn("*", Constants::CAST_ALL) + player->opponent()->game->stack->seenThisTurn("*", Constants::CAST_ALL);
|
||||
ManaCost * stormSpellCost = player->getManaPool();
|
||||
ManaCost * spellCost = player->getManaPool();
|
||||
for (int i = storm; i > 1; i--)
|
||||
{
|
||||
spell = game->mLayers->stackLayer()->addSpell(copy, NULL, stormSpellCost, ManaCost::MANA_PAID_WITH_KICKER, 1);
|
||||
spell = game->mLayers->stackLayer()->addSpell(copy, NULL, spellCost, payResult, 1);
|
||||
|
||||
}
|
||||
}//end of storm
|
||||
@@ -629,7 +631,14 @@ int MTGAlternativeCostRule::isReactingToClick(MTGCardInstance * card, ManaCost *
|
||||
{
|
||||
if (card->alias == 11000)
|
||||
return 0;//overload has its own rule
|
||||
ManaCost * alternateCost = card->getManaCost()->getAlternative();
|
||||
if(!card->getManaCost()->getAlternative())
|
||||
return 0;
|
||||
ManaCost * alternateCost = card->computeNewCost(card,NEW ManaCost(card->model->data->getManaCost()->getAlternative()),card->getManaCost()->getAlternative());
|
||||
if(alternateCost->extraCosts)
|
||||
for(unsigned int i = 0; i < alternateCost->extraCosts->costs.size();i++)
|
||||
{
|
||||
alternateCost->extraCosts->costs[i]->setSource(card);
|
||||
}
|
||||
if (!game->currentlyActing()->game->hand->hasCard(card) && !game->currentlyActing()->game->graveyard->hasCard(card) && !game->currentlyActing()->game->exile->hasCard(card))
|
||||
return 0;
|
||||
if ((game->currentlyActing()->game->graveyard->hasCard(card) && !card->has(Constants::CANPLAYFROMGRAVEYARD)) || (game->currentlyActing()->game->exile->hasCard(card) && !card->has(Constants::CANPLAYFROMEXILE)))
|
||||
@@ -689,9 +698,13 @@ int MTGAlternativeCostRule::reactToClick(MTGCardInstance * card)
|
||||
if ( !isReactingToClick(card))
|
||||
return 0;
|
||||
|
||||
ManaCost *alternateCost = card->getManaCost()->getAlternative();
|
||||
ManaCost * alternateCost = card->computeNewCost(card,NEW ManaCost(card->model->data->getManaCost()->getAlternative()),card->getManaCost()->getAlternative());
|
||||
card->paymenttype = MTGAbility::ALTERNATIVE_COST;
|
||||
|
||||
if(alternateCost->extraCosts)
|
||||
for(unsigned int i = 0; i < alternateCost->extraCosts->costs.size();i++)
|
||||
{
|
||||
alternateCost->extraCosts->costs[i]->setSource(card);
|
||||
}
|
||||
return reactToClick(card, alternateCost, ManaCost::MANA_PAID_WITH_ALTERNATIVE);
|
||||
}
|
||||
|
||||
@@ -795,7 +808,15 @@ int MTGBuyBackRule::isReactingToClick(MTGCardInstance * card, ManaCost * mana)
|
||||
return 0;
|
||||
if(!allowedToCast(card,player))
|
||||
return 0;
|
||||
return MTGAlternativeCostRule::isReactingToClick( card, mana, card->getManaCost()->getBuyback() );
|
||||
if(!card->getManaCost()->getBuyback())
|
||||
return 0;
|
||||
ManaCost * buybackCost = card->computeNewCost(card,NEW ManaCost(card->model->data->getManaCost()->getBuyback()),card->getManaCost()->getBuyback());
|
||||
if(buybackCost->extraCosts)
|
||||
for(unsigned int i = 0; i < buybackCost->extraCosts->costs.size();i++)
|
||||
{
|
||||
buybackCost->extraCosts->costs[i]->setSource(card);
|
||||
}
|
||||
return MTGAlternativeCostRule::isReactingToClick( card, mana, buybackCost );
|
||||
}
|
||||
|
||||
int MTGBuyBackRule::reactToClick(MTGCardInstance * card)
|
||||
@@ -803,11 +824,15 @@ int MTGBuyBackRule::reactToClick(MTGCardInstance * card)
|
||||
if (!isReactingToClick(card))
|
||||
return 0;
|
||||
|
||||
ManaCost * alternateCost = card->getManaCost()->getBuyback();
|
||||
|
||||
ManaCost * buybackCost = card->computeNewCost(card,NEW ManaCost(card->model->data->getManaCost()->getBuyback()),card->getManaCost()->getBuyback());
|
||||
if(buybackCost->extraCosts)
|
||||
for(unsigned int i = 0; i < buybackCost->extraCosts->costs.size();i++)
|
||||
{
|
||||
buybackCost->extraCosts->costs[i]->setSource(card);
|
||||
}
|
||||
card->paymenttype = MTGAbility::BUYBACK_COST;
|
||||
|
||||
return MTGAlternativeCostRule::reactToClick(card, alternateCost, ManaCost::MANA_PAID_WITH_BUYBACK);
|
||||
return MTGAlternativeCostRule::reactToClick(card, buybackCost, ManaCost::MANA_PAID_WITH_BUYBACK);
|
||||
|
||||
}
|
||||
|
||||
@@ -837,19 +862,31 @@ int MTGFlashBackRule::isReactingToClick(MTGCardInstance * card, ManaCost * mana)
|
||||
Player * player = game->currentlyActing();
|
||||
if (!player->game->graveyard->hasCard(card))
|
||||
return 0;
|
||||
return MTGAlternativeCostRule::isReactingToClick(card, mana, card->getManaCost()->getFlashback() );
|
||||
if(!card->getManaCost()->getFlashback())
|
||||
return 0;
|
||||
ManaCost * flashbackCost = card->computeNewCost(card,NEW ManaCost(card->model->data->getManaCost()->getFlashback()),card->getManaCost()->getFlashback());
|
||||
if(flashbackCost->extraCosts)
|
||||
for(unsigned int i = 0; i < flashbackCost->extraCosts->costs.size();i++)
|
||||
{
|
||||
flashbackCost->extraCosts->costs[i]->setSource(card);
|
||||
}
|
||||
return MTGAlternativeCostRule::isReactingToClick(card, mana, flashbackCost );
|
||||
}
|
||||
|
||||
int MTGFlashBackRule::reactToClick(MTGCardInstance * card)
|
||||
{
|
||||
ManaCost * alternateCost = card->getManaCost()->getFlashback();
|
||||
|
||||
ManaCost * flashbackCost = card->computeNewCost(card,NEW ManaCost(card->model->data->getManaCost()->getFlashback()),card->getManaCost()->getFlashback());
|
||||
if(flashbackCost->extraCosts)
|
||||
for(unsigned int i = 0; i < flashbackCost->extraCosts->costs.size();i++)
|
||||
{
|
||||
flashbackCost->extraCosts->costs[i]->setSource(card);
|
||||
}
|
||||
if (!isReactingToClick(card))
|
||||
return 0;
|
||||
|
||||
card->paymenttype = MTGAbility::FLASHBACK_COST;
|
||||
|
||||
return MTGAlternativeCostRule::reactToClick(card, alternateCost, ManaCost::MANA_PAID_WITH_FLASHBACK);
|
||||
return MTGAlternativeCostRule::reactToClick(card, flashbackCost, ManaCost::MANA_PAID_WITH_FLASHBACK);
|
||||
|
||||
}
|
||||
|
||||
@@ -878,12 +915,19 @@ MTGAlternativeCostRule(observer, _id)
|
||||
int MTGRetraceRule::isReactingToClick(MTGCardInstance * card, ManaCost * mana)
|
||||
{
|
||||
Player * player = game->currentlyActing();
|
||||
ManaCost * alternateManaCost = card->getManaCost()->getRetrace();
|
||||
if(!card->getManaCost()->getRetrace())
|
||||
return 0;
|
||||
ManaCost * retraceCost = card->computeNewCost(card,NEW ManaCost(card->model->data->getManaCost()->getRetrace()),card->getManaCost()->getRetrace());
|
||||
if(retraceCost->extraCosts)
|
||||
for(unsigned int i = 0; i < retraceCost->extraCosts->costs.size();i++)
|
||||
{
|
||||
retraceCost->extraCosts->costs[i]->setSource(card);
|
||||
}
|
||||
|
||||
if (!player->game->graveyard->hasCard(card))
|
||||
return 0;
|
||||
|
||||
return MTGAlternativeCostRule::isReactingToClick( card, mana, alternateManaCost );
|
||||
return MTGAlternativeCostRule::isReactingToClick( card, mana, retraceCost );
|
||||
}
|
||||
|
||||
|
||||
@@ -891,12 +935,17 @@ int MTGRetraceRule::reactToClick(MTGCardInstance * card)
|
||||
{
|
||||
if (!isReactingToClick(card))
|
||||
return 0;
|
||||
|
||||
ManaCost * alternateCost = card->getManaCost()->getRetrace();
|
||||
|
||||
ManaCost * retraceCost = card->computeNewCost(card,NEW ManaCost(card->model->data->getManaCost()->getRetrace()),card->getManaCost()->getRetrace());
|
||||
if(retraceCost->extraCosts)
|
||||
for(unsigned int i = 0; i < retraceCost->extraCosts->costs.size();i++)
|
||||
{
|
||||
retraceCost->extraCosts->costs[i]->setSource(card);
|
||||
}
|
||||
|
||||
card->paymenttype = MTGAbility::RETRACE_COST;
|
||||
|
||||
return MTGAlternativeCostRule::reactToClick(card, alternateCost, ManaCost::MANA_PAID_WITH_RETRACE);
|
||||
return MTGAlternativeCostRule::reactToClick(card, retraceCost, ManaCost::MANA_PAID_WITH_RETRACE);
|
||||
}
|
||||
|
||||
ostream& MTGRetraceRule::toString(ostream& out) const
|
||||
@@ -1048,7 +1097,9 @@ int MTGMorphCostRule::isReactingToClick(MTGCardInstance * card, ManaCost *)
|
||||
|
||||
Player * player = game->currentlyActing();
|
||||
//Player * currentPlayer = game->currentPlayer;
|
||||
if (!player->game->hand->hasCard(card))
|
||||
if (!player->game->graveyard->hasCard(card) && !player->game->exile->hasCard(card) && !player->game->hand->hasCard(card))
|
||||
return 0;
|
||||
if ((!card->has(Constants::CANPLAYFROMGRAVEYARD) && player->game->graveyard->hasCard(card))||(!card->has(Constants::CANPLAYFROMEXILE) && player->game->exile->hasCard(card)))
|
||||
return 0;
|
||||
if (!card->getManaCost()->getMorph())
|
||||
return 0;
|
||||
@@ -1062,7 +1113,12 @@ int MTGMorphCostRule::isReactingToClick(MTGCardInstance * card, ManaCost *)
|
||||
if (card->controller()->game->playRestrictions->canPutIntoZone(card, card->controller()->game->stack) == PlayRestriction::CANT_PLAY)
|
||||
return 0;
|
||||
ManaCost * playerMana = player->getManaPool();
|
||||
ManaCost * morph = card->getManaCost()->getMorph();
|
||||
ManaCost * morph = card->computeNewCost(card,NEW ManaCost(card->model->data->getManaCost()->getMorph()),card->getManaCost()->getMorph());
|
||||
if(morph->extraCosts)
|
||||
for(unsigned int i = 0; i < morph->extraCosts->costs.size();i++)
|
||||
{
|
||||
morph->extraCosts->costs[i]->setSource(card);
|
||||
}
|
||||
|
||||
#ifdef WIN32
|
||||
ManaCost * cost = card->getManaCost();
|
||||
@@ -1070,7 +1126,7 @@ int MTGMorphCostRule::isReactingToClick(MTGCardInstance * card, ManaCost *)
|
||||
#endif
|
||||
|
||||
//cost of card.
|
||||
if (morph && playerMana->canAfford(morph))
|
||||
if (playerMana->canAfford(morph))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
@@ -1085,8 +1141,13 @@ int MTGMorphCostRule::reactToClick(MTGCardInstance * card)
|
||||
return 0;
|
||||
Player * player = game->currentlyActing();
|
||||
ManaCost * cost = card->getManaCost();
|
||||
ManaCost * morph = card->getManaCost()->getMorph();
|
||||
ManaCost * playerMana = player->getManaPool();
|
||||
ManaCost * morph = card->computeNewCost(card,NEW ManaCost(card->model->data->getManaCost()->getMorph()),card->getManaCost()->getMorph());
|
||||
if(morph->extraCosts)
|
||||
for(unsigned int i = 0; i < morph->extraCosts->costs.size();i++)
|
||||
{
|
||||
morph->extraCosts->costs[i]->setSource(card);
|
||||
}
|
||||
//this handles extra cost payments at the moment a card is played.
|
||||
if (playerMana->canAfford(morph))
|
||||
{
|
||||
@@ -1108,7 +1169,7 @@ int MTGMorphCostRule::reactToClick(MTGCardInstance * card)
|
||||
}
|
||||
//------------------------------------------------------------------------
|
||||
ManaCost * previousManaPool = NEW ManaCost(player->getManaPool());
|
||||
player->getManaPool()->pay(card->getManaCost()->getMorph());
|
||||
player->getManaPool()->pay(morph);
|
||||
card->getManaCost()->getMorph()->doPayExtra();
|
||||
int payResult = ManaCost::MANA_PAID_WITH_MORPH;
|
||||
//if morph has a extra payment thats set, this code pays it.the if statement is 100% needed as it would cause a crash on cards that dont have the morph cost.
|
||||
@@ -1122,6 +1183,12 @@ int MTGMorphCostRule::reactToClick(MTGCardInstance * card)
|
||||
card->morphed = true;
|
||||
card->isMorphed = true;
|
||||
MTGCardInstance * copy = player->game->putInZone(card, card->currentZone, player->game->stack);
|
||||
copy->getManaCost()->resetCosts();//Morph has no ManaCost on stack
|
||||
copy->setColor(0,1);
|
||||
copy->types.clear();
|
||||
string cre = "Creature";
|
||||
copy->setType(cre.c_str());
|
||||
copy->basicAbilities.reset();
|
||||
Spell * spell = NULL;
|
||||
spell = game->mLayers->stackLayer()->addSpell(copy, NULL, spellCost, payResult, 0);
|
||||
spell->source->morphed = true;
|
||||
@@ -1169,10 +1236,12 @@ int MTGPayZeroRule::isReactingToClick(MTGCardInstance * card, ManaCost * mana)
|
||||
return 0;
|
||||
Player * player = game->currentlyActing();
|
||||
ManaCost * cost = NEW ManaCost(ManaCost::parseManaCost("{0}",NULL,NULL));
|
||||
if(card->getIncreasedManaCost()->getConvertedCost())
|
||||
cost->add(card->getIncreasedManaCost());
|
||||
if(card->getReducedManaCost()->getConvertedCost())
|
||||
cost->remove(card->getReducedManaCost());
|
||||
ManaCost * newCost = card->computeNewCost(card,cost,cost);
|
||||
if(newCost->extraCosts)
|
||||
for(unsigned int i = 0; i < newCost->extraCosts->costs.size();i++)
|
||||
{
|
||||
newCost->extraCosts->costs[i]->setSource(card);
|
||||
}
|
||||
|
||||
if(card->isLand())
|
||||
return 0;
|
||||
@@ -1187,7 +1256,7 @@ int MTGPayZeroRule::isReactingToClick(MTGCardInstance * card, ManaCost * mana)
|
||||
else
|
||||
CustomName = "Zero Cast From Anywhere";
|
||||
|
||||
return MTGAlternativeCostRule::isReactingToClick(card, mana, cost);
|
||||
return MTGAlternativeCostRule::isReactingToClick(card, mana, newCost);
|
||||
}
|
||||
|
||||
int MTGPayZeroRule::reactToClick(MTGCardInstance * card)
|
||||
@@ -1196,14 +1265,16 @@ int MTGPayZeroRule::reactToClick(MTGCardInstance * card)
|
||||
return 0;
|
||||
|
||||
ManaCost * cost = NEW ManaCost(ManaCost::parseManaCost("{0}",NULL,NULL));
|
||||
if(card->getIncreasedManaCost()->getConvertedCost())
|
||||
cost->add(card->getIncreasedManaCost());
|
||||
if(card->getReducedManaCost()->getConvertedCost())
|
||||
cost->remove(card->getReducedManaCost());
|
||||
ManaCost * newCost = card->computeNewCost(card,cost,cost);
|
||||
if(newCost->extraCosts)
|
||||
for(unsigned int i = 0; i < newCost->extraCosts->costs.size();i++)
|
||||
{
|
||||
newCost->extraCosts->costs[i]->setSource(card);
|
||||
}
|
||||
|
||||
card->paymenttype = MTGAbility::PAYZERO_COST;
|
||||
|
||||
return MTGAlternativeCostRule::reactToClick(card, cost, ManaCost::MANA_PAID);
|
||||
return MTGAlternativeCostRule::reactToClick(card, newCost, ManaCost::MANA_PAID);
|
||||
}
|
||||
|
||||
ostream& MTGPayZeroRule::toString(ostream& out) const
|
||||
@@ -1229,10 +1300,12 @@ int MTGOverloadRule::isReactingToClick(MTGCardInstance * card, ManaCost * mana)
|
||||
return 0;
|
||||
Player * player = game->currentlyActing();
|
||||
ManaCost * cost = NEW ManaCost(card->model->data->getManaCost()->getAlternative());
|
||||
if(card->getIncreasedManaCost()->getConvertedCost())
|
||||
cost->add(card->getIncreasedManaCost());
|
||||
if(card->getReducedManaCost()->getConvertedCost())
|
||||
cost->remove(card->getReducedManaCost());
|
||||
ManaCost * newCost = card->computeNewCost(card,cost,cost);
|
||||
if(newCost->extraCosts)
|
||||
for(unsigned int i = 0; i < newCost->extraCosts->costs.size();i++)
|
||||
{
|
||||
newCost->extraCosts->costs[i]->setSource(card);
|
||||
}
|
||||
|
||||
if (card->isLand())
|
||||
return 0;
|
||||
@@ -1241,7 +1314,7 @@ int MTGOverloadRule::isReactingToClick(MTGCardInstance * card, ManaCost * mana)
|
||||
if ((!card->has(Constants::CANPLAYFROMGRAVEYARD) && player->game->graveyard->hasCard(card))||(!card->has(Constants::CANPLAYFROMEXILE) && player->game->exile->hasCard(card)))
|
||||
return 0;
|
||||
|
||||
return MTGAlternativeCostRule::isReactingToClick(card, mana, cost);
|
||||
return MTGAlternativeCostRule::isReactingToClick(card, mana, newCost);
|
||||
}
|
||||
|
||||
int MTGOverloadRule::reactToClick(MTGCardInstance * card)
|
||||
@@ -1250,14 +1323,16 @@ int MTGOverloadRule::reactToClick(MTGCardInstance * card)
|
||||
return 0;
|
||||
|
||||
ManaCost * cost = NEW ManaCost(card->model->data->getManaCost()->getAlternative());
|
||||
if(card->getIncreasedManaCost()->getConvertedCost())
|
||||
cost->add(card->getIncreasedManaCost());
|
||||
if(card->getReducedManaCost()->getConvertedCost())
|
||||
cost->remove(card->getReducedManaCost());
|
||||
ManaCost * newCost = card->computeNewCost(card,cost,cost);
|
||||
if(newCost->extraCosts)
|
||||
for(unsigned int i = 0; i < newCost->extraCosts->costs.size();i++)
|
||||
{
|
||||
newCost->extraCosts->costs[i]->setSource(card);
|
||||
}
|
||||
|
||||
card->paymenttype = MTGAbility::OVERLOAD_COST;
|
||||
|
||||
return MTGAlternativeCostRule::reactToClick(card, cost, ManaCost::MANA_PAID_WITH_OVERLOAD, true);
|
||||
return MTGAlternativeCostRule::reactToClick(card, newCost, ManaCost::MANA_PAID_WITH_OVERLOAD, true);
|
||||
}
|
||||
|
||||
ostream& MTGOverloadRule::toString(ostream& out) const
|
||||
|
||||
@@ -139,10 +139,14 @@ ManaCost * ManaCost::parseManaCost(string s, ManaCost * _manaCost, MTGCardInstan
|
||||
}
|
||||
break;
|
||||
case 's':
|
||||
if (value == "s2l")
|
||||
if (value.find("s2l") != string::npos)
|
||||
{ //Send To Library Cost (move from anywhere to Library)
|
||||
manaCost->addExtraCost(NEW ToLibraryCost(tc));
|
||||
}
|
||||
else if (value.find("s2g") != string::npos)
|
||||
{ //Send to Graveyard Cost (move from anywhere to Graveyard)
|
||||
manaCost->addExtraCost(NEW ToGraveCost(tc));
|
||||
}
|
||||
else
|
||||
{ //Sacrifice
|
||||
manaCost->addExtraCost(NEW SacrificeCost(tc));
|
||||
@@ -229,6 +233,13 @@ ManaCost * ManaCost::parseManaCost(string s, ManaCost * _manaCost, MTGCardInstan
|
||||
manaCost->addExtraCost(NEW LifeorManaCost(NULL,manaType));
|
||||
break;
|
||||
}
|
||||
case 'i' :
|
||||
{
|
||||
SAFE_DELETE(tc);
|
||||
manaCost->add(0,1);
|
||||
manaCost->addExtraCost(NEW SnowCost);
|
||||
break;
|
||||
}
|
||||
case 'q':
|
||||
if(value == "q")
|
||||
{
|
||||
@@ -250,7 +261,7 @@ ManaCost * ManaCost::parseManaCost(string s, ManaCost * _manaCost, MTGCardInstan
|
||||
{
|
||||
manaCost->addExtraCost(NEW CycleCost(tc));
|
||||
}
|
||||
else
|
||||
else if(value.find("(") != string::npos)
|
||||
{
|
||||
size_t counter_start = value.find("(");
|
||||
size_t counter_end = value.find(")", counter_start);
|
||||
@@ -276,9 +287,15 @@ ManaCost * ManaCost::parseManaCost(string s, ManaCost * _manaCost, MTGCardInstan
|
||||
tc = tcf.createTargetChooser(target, c);
|
||||
}
|
||||
manaCost->addExtraCost(NEW CounterCost(counter, tc));
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
else if(value == "c")
|
||||
{
|
||||
manaCost->add(Constants::MTG_COLOR_WASTE, 1);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: //uncolored cost and hybrid costs and special cost
|
||||
{
|
||||
if(value == "unattach")
|
||||
@@ -742,6 +759,10 @@ int ManaCost::getConvertedCost()
|
||||
ExtraCost * pMana = dynamic_cast<LifeorManaCost*>(extraCosts->costs[i]);
|
||||
if (pMana)
|
||||
result++;
|
||||
//snow cost???
|
||||
ExtraCost * sMana = dynamic_cast<SnowCost*>(extraCosts->costs[i]);
|
||||
if (sMana)
|
||||
result++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1092,6 +1113,8 @@ int ManaPool::remove(int color, int value)
|
||||
|
||||
int ManaPool::add(int color, int value, MTGCardInstance * source)
|
||||
{
|
||||
if (color == Constants::MTG_COLOR_ARTIFACT)
|
||||
color = Constants::MTG_COLOR_WASTE;
|
||||
int result = ManaCost::add(color, value);
|
||||
for (int i = 0; i < value; ++i)
|
||||
{
|
||||
@@ -1105,6 +1128,15 @@ int ManaPool::add(ManaCost * _cost, MTGCardInstance * source)
|
||||
{
|
||||
if (!_cost)
|
||||
return 0;
|
||||
//while colorless is still exactly the same, there are now cards that require
|
||||
//true colorless mana, ei:eldrazi. so whenever we add mana, we now replace it with the
|
||||
//new type. keeping the old type intact for payment methods {1}{c} ....
|
||||
int replaceArtifact = _cost->getCost(Constants::MTG_COLOR_ARTIFACT);
|
||||
if (replaceArtifact)
|
||||
{
|
||||
_cost->add(Constants::MTG_COLOR_WASTE, replaceArtifact);
|
||||
_cost->remove(Constants::MTG_COLOR_ARTIFACT, replaceArtifact);
|
||||
}
|
||||
int result = ManaCost::add(_cost);
|
||||
for (int i = 0; i < Constants::NB_Colors; i++)
|
||||
{
|
||||
|
||||
@@ -34,8 +34,15 @@ Player::Player(GameObserver *observer, string file, string fileSmall, MTGDeck *
|
||||
extraTurn = 0;
|
||||
drawCounter = 0;
|
||||
epic = 0;
|
||||
forcefield = 0;
|
||||
raidcount = 0;
|
||||
handmodifier = 0;
|
||||
snowManaG = 0;
|
||||
snowManaR = 0;
|
||||
snowManaB = 0;
|
||||
snowManaU = 0;
|
||||
snowManaW = 0;
|
||||
snowManaC = 0;
|
||||
prowledTypes.clear();
|
||||
doesntEmpty = NEW ManaCost();
|
||||
poolDoesntEmpty = NEW ManaCost();
|
||||
@@ -155,7 +162,8 @@ int Player::gainOrLoseLife(int value)
|
||||
thatmuch = abs(value); //the value that much is a variable to be used with triggered abilities.
|
||||
//ie:when ever you gain life, draw that many cards. when used in a trigger draw:thatmuch, will return the value
|
||||
//that the triggered event stored in the card for "that much".
|
||||
life+=value;
|
||||
if (!inPlay()->hasAbility(Constants::CANTCHANGELIFE))
|
||||
life+=value;
|
||||
if (value<0)
|
||||
lifeLostThisTurn += abs(value);
|
||||
|
||||
@@ -238,6 +246,24 @@ void Player::serumMulligan()
|
||||
//Draw hand no penalty
|
||||
}
|
||||
|
||||
bool Player::hasPossibleAttackers()
|
||||
{
|
||||
MTGGameZone * z = game->inPlay;
|
||||
int nbcards = z->nb_cards;
|
||||
for (int j = 0; j < nbcards; ++j)
|
||||
{
|
||||
MTGCardInstance * c = z->cards[j];
|
||||
if (c->canAttack())
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Player::noPossibleAttackers()
|
||||
{
|
||||
return !hasPossibleAttackers();
|
||||
}
|
||||
|
||||
bool Player::DeadLifeState(bool check)
|
||||
{
|
||||
if ((life <= 0)||(poisonCount >= 10))
|
||||
|
||||
@@ -149,7 +149,32 @@ WEventCreatureBlockerRank::WEventCreatureBlockerRank(MTGCardInstance * card, MTG
|
||||
|
||||
WEventEngageMana::WEventEngageMana(int color, MTGCardInstance* card, ManaPool * destination) :
|
||||
WEvent(), color(color), card(card), destination(destination)
|
||||
{
|
||||
{//controller snow
|
||||
if(color == 1 && card->controller()->getManaPool() == destination && card->hasType("snow"))
|
||||
card->controller()->snowManaG += 1;
|
||||
if(color == 2 && card->controller()->getManaPool() == destination && card->hasType("snow"))
|
||||
card->controller()->snowManaU += 1;
|
||||
if(color == 3 && card->controller()->getManaPool() == destination && card->hasType("snow"))
|
||||
card->controller()->snowManaR += 1;
|
||||
if(color == 4 && card->controller()->getManaPool() == destination && card->hasType("snow"))
|
||||
card->controller()->snowManaB += 1;
|
||||
if(color == 5 && card->controller()->getManaPool() == destination && card->hasType("snow"))
|
||||
card->controller()->snowManaW += 1;
|
||||
if((color == 0 || color == 6) && card->controller()->getManaPool() == destination && card->hasType("snow"))
|
||||
card->controller()->snowManaC += 1;
|
||||
//opponent snow
|
||||
if(color == 1 && card->controller()->opponent()->getManaPool() == destination && card->hasType("snow"))
|
||||
card->controller()->opponent()->snowManaG += 1;
|
||||
if(color == 2 && card->controller()->opponent()->getManaPool() == destination && card->hasType("snow"))
|
||||
card->controller()->opponent()->snowManaU += 1;
|
||||
if(color == 3 && card->controller()->opponent()->getManaPool() == destination && card->hasType("snow"))
|
||||
card->controller()->opponent()->snowManaR += 1;
|
||||
if(color == 4 && card->controller()->opponent()->getManaPool() == destination && card->hasType("snow"))
|
||||
card->controller()->opponent()->snowManaB += 1;
|
||||
if(color == 5 && card->controller()->opponent()->getManaPool() == destination && card->hasType("snow"))
|
||||
card->controller()->opponent()->snowManaW += 1;
|
||||
if((color == 0 || color == 6) && card->controller()->opponent()->getManaPool() == destination && card->hasType("snow"))
|
||||
card->controller()->opponent()->snowManaC += 1;
|
||||
}
|
||||
WEventConsumeMana::WEventConsumeMana(int color, ManaPool * source) :
|
||||
WEvent(), color(color), source(source)
|
||||
|
||||
Reference in New Issue
Block a user