|
|
|
@@ -44,9 +44,6 @@ int cardsinhand = game->players[0]->game->hand->nb_cards;
|
|
|
|
|
if(player->castrestrictedcreature > 0 && card->hasType("creature")){return 0;}
|
|
|
|
|
|
|
|
|
|
//cost of card.
|
|
|
|
|
if(alternative && playerMana->canAfford(alternative)){
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
if (playerMana->canAfford(cost)){
|
|
|
|
|
return 1;//play if you can afford too.
|
|
|
|
|
}
|
|
|
|
@@ -57,23 +54,9 @@ int MTGPutInPlayRule::reactToClick(MTGCardInstance * card){
|
|
|
|
|
if (!isReactingToClick(card)) return 0;
|
|
|
|
|
Player * player = game->currentlyActing();
|
|
|
|
|
ManaCost * cost = card->getManaCost();
|
|
|
|
|
ManaCost * alternative = card->getManaCost()->alternative;
|
|
|
|
|
ManaCost * playerMana = player->getManaPool();
|
|
|
|
|
//this handles extra cost payments at the moment a card is played.
|
|
|
|
|
|
|
|
|
|
//as long as you dont have enough mana to pay the real cost, and the alternative contains extra cost, add extras
|
|
|
|
|
if(!playerMana->canAfford(cost) && playerMana->canAfford(alternative)){
|
|
|
|
|
if (cost->alternative->isExtraPaymentSet()){
|
|
|
|
|
if (!game->targetListIsSet(card)){
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
cost->alternative->setExtraCostsAction(this, card);
|
|
|
|
|
game->waitForExtraPayment = cost->alternative->extraCosts;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
if (cost->isExtraPaymentSet()){
|
|
|
|
|
if (!game->targetListIsSet(card)){
|
|
|
|
|
return 0;
|
|
|
|
@@ -88,13 +71,6 @@ int MTGPutInPlayRule::reactToClick(MTGCardInstance * card){
|
|
|
|
|
int payResult = player->getManaPool()->pay(card->getManaCost());
|
|
|
|
|
card->getManaCost()->doPayExtra();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//if alternative 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 alternative cost.
|
|
|
|
|
if(alternative){
|
|
|
|
|
card->getManaCost()->alternative->doPayExtra();}
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ManaCost * spellCost = previousManaPool->Diff(player->getManaPool());
|
|
|
|
|
|
|
|
|
|
delete previousManaPool;
|
|
|
|
@@ -153,6 +129,143 @@ ostream& MTGPutInPlayRule::toString(ostream& out) const
|
|
|
|
|
//cast from anywhere possible with this??
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Alternative cost rules
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
MTGAlternativeCostRule::MTGAlternativeCostRule(int _id):MTGAbility(_id, NULL){
|
|
|
|
|
aType=MTGAbility::ALTERNATIVE_COST;
|
|
|
|
|
}
|
|
|
|
|
int MTGAlternativeCostRule::isReactingToClick(MTGCardInstance * card, ManaCost * mana){
|
|
|
|
|
int cardsinhand = game->players[0]->game->hand->nb_cards;
|
|
|
|
|
Player * player = game->currentlyActing();
|
|
|
|
|
Player * currentPlayer = game->currentPlayer;
|
|
|
|
|
if (!player->game->hand->hasCard(card)) return 0;
|
|
|
|
|
if (!card->getManaCost()->alternative) return 0;
|
|
|
|
|
if (card->hasType("land")){
|
|
|
|
|
if (player == currentPlayer && currentPlayer->canPutLandsIntoPlay && (game->currentGamePhase == Constants::MTG_PHASE_FIRSTMAIN || game->currentGamePhase == Constants::MTG_PHASE_SECONDMAIN)){
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
}else if ((card->hasType("instant")) || card->has(Constants::FLASH) || (player == currentPlayer && !game->isInterrupting && (game->currentGamePhase == Constants::MTG_PHASE_FIRSTMAIN || game->currentGamePhase == Constants::MTG_PHASE_SECONDMAIN))){
|
|
|
|
|
ManaCost * playerMana = player->getManaPool();
|
|
|
|
|
ManaCost * cost = card->getManaCost();
|
|
|
|
|
ManaCost * alternative = card->getManaCost()->alternative;
|
|
|
|
|
|
|
|
|
|
#ifdef WIN32
|
|
|
|
|
cost->Dump();
|
|
|
|
|
#endif
|
|
|
|
|
if(player->castrestrictedspell > 0 && !card->hasType("land")){ return 0;}
|
|
|
|
|
if(player->onlyonecast > 0 && player->castcount >= 1){return 0;}
|
|
|
|
|
if(player->nospellinstant > 0){return 0;}
|
|
|
|
|
if(player->onlyoneinstant > 0){ if(player->castcount >= 1){return 0;}}
|
|
|
|
|
if(player->nocreatureinstant > 0 && card->hasType("creature")){return 0;}
|
|
|
|
|
if(player->castrestrictedcreature > 0 && card->hasType("creature")){return 0;}
|
|
|
|
|
//cost of card.
|
|
|
|
|
if(alternative && playerMana->canAfford(alternative)){
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return 0;//dont play if you cant afford it.
|
|
|
|
|
}
|
|
|
|
|
int MTGAlternativeCostRule::reactToClick(MTGCardInstance * card){
|
|
|
|
|
if (!isReactingToClick(card)) return 0;
|
|
|
|
|
Player * player = game->currentlyActing();
|
|
|
|
|
ManaCost * cost = card->getManaCost();
|
|
|
|
|
ManaCost * alternative = card->getManaCost()->alternative;
|
|
|
|
|
ManaCost * playerMana = player->getManaPool();
|
|
|
|
|
//this handles extra cost payments at the moment a card is played.
|
|
|
|
|
if(playerMana->canAfford(alternative)){
|
|
|
|
|
if (cost->alternative->isExtraPaymentSet()){
|
|
|
|
|
if (!game->targetListIsSet(card)){
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
cost->alternative->setExtraCostsAction(this, card);
|
|
|
|
|
game->waitForExtraPayment = cost->alternative->extraCosts;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
ManaCost * previousManaPool = NEW ManaCost(player->getManaPool());
|
|
|
|
|
int payResult = player->getManaPool()->pay(card->getManaCost()->alternative);
|
|
|
|
|
card->getManaCost()->doPayExtra();
|
|
|
|
|
payResult = ManaCost::MANA_PAID_WITH_ALTERNATIVE;
|
|
|
|
|
//if alternative 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 alternative cost.
|
|
|
|
|
if(alternative){
|
|
|
|
|
card->getManaCost()->alternative->doPayExtra();
|
|
|
|
|
}
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
ManaCost * spellCost = previousManaPool->Diff(player->getManaPool());
|
|
|
|
|
delete previousManaPool;
|
|
|
|
|
if (card->hasType("land")){
|
|
|
|
|
MTGCardInstance * copy = player->game->putInZone(card, player->game->hand, player->game->temp);
|
|
|
|
|
Spell * spell = NEW Spell(copy);
|
|
|
|
|
spell->resolve();
|
|
|
|
|
delete spellCost;
|
|
|
|
|
delete spell;
|
|
|
|
|
player->canPutLandsIntoPlay--;
|
|
|
|
|
payResult = ManaCost::MANA_PAID_WITH_ALTERNATIVE;
|
|
|
|
|
spell = game->mLayers->stackLayer()->addSpell(copy,NULL, spellCost, payResult,1);
|
|
|
|
|
}else{
|
|
|
|
|
Spell * spell = NULL;
|
|
|
|
|
MTGCardInstance * copy = player->game->putInZone(card, player->game->hand, player->game->stack);
|
|
|
|
|
if (game->targetChooser){
|
|
|
|
|
spell = game->mLayers->stackLayer()->addSpell(copy,game->targetChooser, spellCost,payResult,0);
|
|
|
|
|
game->targetChooser = NULL;
|
|
|
|
|
player->castedspellsthisturn += 1;
|
|
|
|
|
if(player->onlyonecast > 0 || player->onlyoneinstant > 0){player->castcount += 1;}
|
|
|
|
|
}else{
|
|
|
|
|
spell = game->mLayers->stackLayer()->addSpell(copy,NULL, spellCost, payResult,0);
|
|
|
|
|
player->castedspellsthisturn += 1;
|
|
|
|
|
if(player->onlyonecast > 0 || player->onlyoneinstant > 0){player->castcount += 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(card->has(Constants::STORM)){
|
|
|
|
|
int storm = player->castedspellsthisturn;
|
|
|
|
|
ManaCost * spellCost = player->getManaPool();
|
|
|
|
|
for(int i = storm; i > 1; i--){
|
|
|
|
|
spell = game->mLayers->stackLayer()->addSpell(copy,NULL, spellCost, payResult,1);
|
|
|
|
|
}
|
|
|
|
|
}//end of storm
|
|
|
|
|
if(!card->has(Constants::STORM)){
|
|
|
|
|
copy->X = spell->computeX(copy);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//The Put into play rule is never destroyed
|
|
|
|
|
int MTGAlternativeCostRule::testDestroy(){
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ostream& MTGAlternativeCostRule::toString(ostream& out) const
|
|
|
|
|
{
|
|
|
|
|
out << "MTGAlternativeCostRule ::: (";
|
|
|
|
|
return MTGAbility::toString(out) << ")";
|
|
|
|
|
}
|
|
|
|
|
MTGAlternativeCostRule * MTGAlternativeCostRule::clone() const{
|
|
|
|
|
MTGAlternativeCostRule * a = NEW MTGAlternativeCostRule(*this);
|
|
|
|
|
a->isClone = 1;
|
|
|
|
|
return a;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool MTGAttackRule::select(Target* t)
|
|
|
|
|
{
|
|
|
|
|
if (CardView* c = dynamic_cast<CardView*>(t)) {
|
|
|
|
|