more work on cascade, I think I figured out what was causing a weird crash.
This commit is contained in:
@@ -6208,6 +6208,7 @@ class AACascade: public ActivatedAbility
|
||||
{
|
||||
public:
|
||||
string nbcardsStr;
|
||||
MTGCardInstance * castingThis;
|
||||
vector<MTGCardInstance*>selectedCards;
|
||||
vector<MTGCardInstance *>oldOrder;
|
||||
vector<MTGCardInstance *>newOrder;
|
||||
|
||||
@@ -133,6 +133,7 @@ class GameObserver{
|
||||
int isInPlay(MTGCardInstance * card);
|
||||
int isInGrave(MTGCardInstance * card);
|
||||
int isInExile(MTGCardInstance * card);
|
||||
int isInHand(MTGCardInstance * card);
|
||||
virtual void Update(float dt);
|
||||
void Render();
|
||||
void ButtonPressed(PlayGuiObject*);
|
||||
|
||||
@@ -92,6 +92,7 @@ public:
|
||||
bool isPhased;
|
||||
bool isCascaded;
|
||||
int phasedTurn;
|
||||
bool handEffects;
|
||||
bool graveEffects;
|
||||
bool exileEffects;
|
||||
bool suspended;
|
||||
|
||||
@@ -1143,6 +1143,7 @@ AACascade::AACascade(GameObserver* observer, int _id, MTGCardInstance * _source,
|
||||
selectedCards.clear();
|
||||
oldOrder.clear();
|
||||
newOrder.clear();
|
||||
castingThis = NULL;
|
||||
}
|
||||
int AACascade::resolve()
|
||||
{
|
||||
@@ -1171,10 +1172,9 @@ int AACascade::resolve()
|
||||
{
|
||||
if (!viable->isLand() && (viable->getManaCost()->getConvertedCost() < source->getManaCost()->getConvertedCost()))
|
||||
{
|
||||
|
||||
toCastCard(viable);
|
||||
viable = player->game->putInZone(viable, library, exile);
|
||||
viable->isCascaded = true;
|
||||
castingThis = viable;
|
||||
found = true;
|
||||
}
|
||||
else
|
||||
@@ -1193,7 +1193,7 @@ int AACascade::resolve()
|
||||
{
|
||||
if (exile->cards[j]->isCascaded)
|
||||
{
|
||||
MTGCardInstance * CardToPutBack = exile->cards[j];//player->game->putInZone(exile->cards[j], exile, library);
|
||||
MTGCardInstance * CardToPutBack = exile->cards[j];;
|
||||
CardToPutBack->isCascaded = false;
|
||||
selectedCards.push_back(CardToPutBack);
|
||||
}
|
||||
@@ -1213,6 +1213,13 @@ int AACascade::resolve()
|
||||
selectedCards.pop_back();
|
||||
}
|
||||
} while (selectedCards.size());
|
||||
|
||||
if (castingThis)
|
||||
{
|
||||
while (castingThis->next)
|
||||
castingThis = castingThis->next;
|
||||
toCastCard(castingThis);
|
||||
}
|
||||
}
|
||||
//////////////////////////////////////
|
||||
return 1;
|
||||
|
||||
@@ -1568,7 +1568,17 @@ int GameObserver::isInExile(MTGCardInstance * card)
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
int GameObserver::isInHand(MTGCardInstance * card)
|
||||
{
|
||||
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
MTGGameZone * hand = players[i]->game->hand;
|
||||
if (players[i]->game->isInZone(card, hand))
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
void GameObserver::cleanupPhase()
|
||||
{
|
||||
currentPlayer->cleanupPhase();
|
||||
|
||||
@@ -3982,13 +3982,14 @@ int AbilityFactory::getAbilities(vector<MTGAbility *> * v, Spell * spell, MTGCar
|
||||
{
|
||||
card->graveEffects = false;
|
||||
card->exileEffects = false;
|
||||
|
||||
card->handEffects = false;
|
||||
for (int i = 0; i < 2; ++i)
|
||||
{
|
||||
MTGPlayerCards * zones = observer->players[i]->game;
|
||||
if (dest == zones->hand)
|
||||
{
|
||||
magicText = card->magicTexts["hand"];
|
||||
card->handEffects = true;
|
||||
break;
|
||||
}
|
||||
if (dest == zones->graveyard)
|
||||
@@ -4891,6 +4892,8 @@ int MTGAbility::testDestroy()
|
||||
return 1;
|
||||
if (forceDestroy == -1)
|
||||
return 0;
|
||||
if (source->handEffects && game->isInHand(source))
|
||||
return 0;
|
||||
if(source->graveEffects && game->isInGrave(source))
|
||||
return 0;
|
||||
if(source->exileEffects && game->isInExile(source))
|
||||
@@ -5934,13 +5937,26 @@ int AManaProducer::isReactingToClick(MTGCardInstance * _card, ManaCost * mana)
|
||||
int result = 0;
|
||||
if (!mana)
|
||||
mana = game->currentlyActing()->getManaPool();
|
||||
if (_card == source && (!tap || !source->isTapped()) && game->currentlyActing()->game->inPlay->hasCard(source)
|
||||
&& (source->hasType(Subtypes::TYPE_LAND) || !tap || !source->hasSummoningSickness()) && !source->isPhased)
|
||||
//please do not condense the following, I broke it apart for readability, it was far to difficult to tell what exactly happened before with it all in a single line.
|
||||
//and far to prone to bugs.
|
||||
if (_card == source)
|
||||
{
|
||||
ManaCost * cost = getCost();
|
||||
if (!cost || (mana->canAfford(cost) && (!cost->extraCosts || cost->extraCosts->canPay())))/*counter cost bypass react to click*/
|
||||
if (!tap || (tap && !source->isTapped()))
|
||||
{
|
||||
result = 1;
|
||||
if (!source->hasSummoningSickness())
|
||||
{
|
||||
if (game->currentlyActing()->game->inPlay->hasCard(source) && source->hasType(Subtypes::TYPE_LAND))
|
||||
{
|
||||
if (!source->isPhased)
|
||||
{
|
||||
ManaCost * cost = getCost();
|
||||
if (!cost || (mana->canAfford(cost) && (!cost->extraCosts || cost->extraCosts->canPay())))/*counter cost bypass react to click*/
|
||||
{
|
||||
result = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
||||
Reference in New Issue
Block a user