-fix for issue 604 (Land play limitation should not apply in all cases)
-- this adds a "castMehod" variable to MTGCardInstance. IF this variable is 0, the card was not "cast" (or for lands, "put into play" as part of the lands rule), but "added" to the battlefield with some other effect. On the other hand, if this variable is set, it means the card was cast 
-- as we discussed, I did not touch the "alternateCostPaid" variable, as I'm still not really sure these two concepts are actually the same
This commit is contained in:
wagic.the.homebrew@gmail.com
2011-03-02 13:41:24 +00:00
parent 8f9b1d5b8d
commit b021417324
12 changed files with 95 additions and 15 deletions
+23
View File
@@ -201,11 +201,14 @@ Interruptible(0)
cost = NEW ManaCost();
tc = NULL;
from = _source->getCurrentZone();
payResult = ManaCost::MANA_UNPAID;
source->castMethod = Constants::NOT_CAST;
}
Spell::Spell(int id, MTGCardInstance * _source, TargetChooser * tc, ManaCost * _cost, int payResult) :
Interruptible(id), tc(tc), cost(_cost), payResult(payResult)
{
if (!cost) cost = NEW ManaCost();
source = _source;
mHeight = 40;
type = ACTION_SPELL;
@@ -215,6 +218,20 @@ Interruptible(id), tc(tc), cost(_cost), payResult(payResult)
if(tc && tc->targets[i] != NULL)
_source->backupTargets[i] = tc->targets[i];
}
// fill information on how the card came into this zone. Right now the quickest way is to do it here, based on how the mana was paid...
switch(payResult) {
case ManaCost::MANA_UNPAID:
source->castMethod = Constants::NOT_CAST;
break;
case ManaCost::MANA_PAID:
case ManaCost::MANA_PAID_WITH_KICKER:
source->castMethod = Constants::CAST_NORMALLY;
break;
default:
source->castMethod = Constants::CAST_ALTERNATE;
break;
}
}
int Spell::computeX(MTGCardInstance * card)
@@ -275,7 +292,13 @@ int Spell::resolve()
if (!source->hasType("instant") && !source->hasType("sorcery"))
{
Player * p = source->controller();
int castMethod = source->castMethod;
source = p->game->putInZone(source, from, p->game->battlefield);
// We need to get the information about the cast method on both the card in the stack AND the card in play,
//so we copy it from the previous card (in the stack) to the new one (in play).
source->castMethod = castMethod;
from = p->game->battlefield;
}
+1 -1
View File
@@ -65,7 +65,7 @@ int MTGAbility::allowedToCast(MTGCardInstance * card,Player * player)
return 0;
break;
case CASTED_A_SPELL:
if(player->game->stack->seenThisTurn("*") < 1)
if(player->game->stack->seenThisTurn("*", Constants::CAST_ALL) < 1)
return 0;
break;
case ONE_OF_AKIND:
+14 -1
View File
@@ -43,6 +43,7 @@ MTGCardInstance::MTGCardInstance(MTGCard * card, MTGPlayerCards * arg_belongs_to
life = toughness;
preventable = 0;
flanked = 0;
castMethod = Constants::NOT_CAST;
}
void MTGCardInstance::copy(MTGCardInstance * card)
@@ -146,6 +147,8 @@ void MTGCardInstance::initMTGCI()
damageToController = false;
wasDealtDamage = false;
suspended = false;
castMethod = Constants::NOT_CAST;
for (int i = 0; i < ManaCost::MANA_PAID_WITH_RETRACE +1; i++)
alternateCostPaid[i] = 0;
@@ -883,7 +886,7 @@ int MTGCardInstance::toggleDefenser(MTGCardInstance * opponent)
{
if(opponent->view != NULL)
{
//todo: qoute wololo "change this into a cool blinking effects when opposing creature has cursor focus."
//todo: quote wololo "change this into a cool blinking effects when opposing creature has cursor focus."
opponent->view->actZ += .8f;
opponent->view->actT -= .2f;
}
@@ -896,6 +899,16 @@ int MTGCardInstance::toggleDefenser(MTGCardInstance * opponent)
return 0;
}
bool MTGCardInstance::matchesCastFilter(int castFilter) {
if(castFilter == Constants::CAST_DONT_CARE)
return true; //everything
if(castFilter == Constants::CAST_ALL)
return (castMethod != Constants::NOT_CAST); //everything except "not cast"
if (castFilter == Constants::CAST_ALTERNATE && castMethod > Constants::CAST_NORMALLY)
return true; //all alternate casts
return (castFilter == castMethod);
};
int MTGCardInstance::addProtection(TargetChooser * tc)
{
tc->targetter = NULL;
+5 -4
View File
@@ -608,7 +608,7 @@ int MTGGameZone::hasAbility(int ability)
return 0;
}
int MTGGameZone::seenThisTurn(TargetChooser * tc)
int MTGGameZone::seenThisTurn(TargetChooser * tc, int castMethod)
{
//The following 2 lines modify the passed TargetChooser. Call this function with care :/
tc->setAllZones(); // This is to allow targetting cards without caring about the actual zone
@@ -617,17 +617,18 @@ int MTGGameZone::seenThisTurn(TargetChooser * tc)
int count = 0;
for (vector<MTGCardInstance *>::iterator iter = cardsSeenThisTurn.begin(); iter != cardsSeenThisTurn.end(); ++iter)
{
if (tc->canTarget(*iter))
MTGCardInstance * c = (*iter);
if (c->matchesCastFilter(castMethod) && tc->canTarget(c))
count++;
}
return count;
}
int MTGGameZone::seenThisTurn(string targetChooserDefinition)
int MTGGameZone::seenThisTurn(string targetChooserDefinition, int castMethod)
{
TargetChooserFactory tcf;
TargetChooser *tc = tcf.createTargetChooser(targetChooserDefinition, NULL);
int result = seenThisTurn(tc);
int result = seenThisTurn(tc, castMethod);
delete(tc);
return result;
}
+4 -4
View File
@@ -130,7 +130,7 @@ int MTGPutInPlayRule::reactToClick(MTGCardInstance * card)
if (card->hasType("land"))
{
MTGCardInstance * copy = player->game->putInZone(card, player->game->hand, player->game->temp);
Spell * spell = NEW Spell(copy);
Spell * spell = NEW Spell(0,copy,NULL,NULL, payResult);
spell->resolve();
delete spellCost;
delete spell;
@@ -151,7 +151,7 @@ int MTGPutInPlayRule::reactToClick(MTGCardInstance * card)
if (card->has(Constants::STORM))
{
int storm = player->game->stack->seenThisTurn("*") + player->opponent()->game->stack->seenThisTurn("*");
int storm = player->game->stack->seenThisTurn("*", Constants::CAST_ALL) + player->opponent()->game->stack->seenThisTurn("*", Constants::CAST_ALL);
ManaCost * spellCost = player->getManaPool();
for (int i = storm; i > 1; i--)
{
@@ -298,7 +298,7 @@ int MTGAlternativeCostRule::reactToClick(MTGCardInstance * card, ManaCost *alter
if (card->hasType("land"))
{
MTGCardInstance * copy = player->game->putInZone(card, card->currentZone, player->game->temp);
Spell * spell = NEW Spell(copy);
Spell * spell = NEW Spell(0,copy,NULL,NULL, alternateCostType);
copy->alternateCostPaid[alternateCostType] = 1;
spell->resolve();
SAFE_DELETE(spell);
@@ -316,7 +316,7 @@ int MTGAlternativeCostRule::reactToClick(MTGCardInstance * card, ManaCost *alter
if (card->has(Constants::STORM))
{
int storm = player->game->stack->seenThisTurn("*") + player->opponent()->game->stack->seenThisTurn("*");
int storm = player->game->stack->seenThisTurn("*", Constants::CAST_ALL) + player->opponent()->game->stack->seenThisTurn("*", Constants::CAST_ALL);
for (int i = storm; i > 1; i--)
{
game->mLayers->stackLayer()->addSpell(copy, NULL, playerMana, alternateCostType, 1);
+1 -1
View File
@@ -31,7 +31,7 @@ int MaxPerTurnRestriction::canPutIntoZone(MTGCardInstance * card, MTGGameZone *
if (maxPerTurn == NO_MAX) return PlayRestriction::CAN_PLAY;
if (zone->seenThisTurn(tc) >= maxPerTurn)
if (zone->seenThisTurn(tc, Constants::CAST_ALL) >= maxPerTurn)
return PlayRestriction::CANT_PLAY;
return PlayRestriction::CAN_PLAY;