fixed an issue with dredge, where dredge is offered even though theres only one dredger on cards that draw multiple.
This commit is contained in:
@@ -2775,8 +2775,12 @@ WEvent * MTGDredgeRule::replace(WEvent * event)
|
|||||||
if (e->player == p)
|
if (e->player == p)
|
||||||
{
|
{
|
||||||
int Dredgers = 0;
|
int Dredgers = 0;
|
||||||
|
vector<MTGAbility*>menusOfferedWithDredge;
|
||||||
for(int draw = 0;draw < e->nb_cards;draw++)
|
for(int draw = 0;draw < e->nb_cards;draw++)
|
||||||
{
|
{
|
||||||
|
tcb = tf.createTargetChooser("dredgeable", card);
|
||||||
|
int toDredge = tcb->countValidTargets();
|
||||||
|
SAFE_DELETE(tcb);
|
||||||
vector<MTGAbility*>selection;
|
vector<MTGAbility*>selection;
|
||||||
//look for other draw replacement effects
|
//look for other draw replacement effects
|
||||||
list<ReplacementEffect *>::iterator it;
|
list<ReplacementEffect *>::iterator it;
|
||||||
@@ -2800,17 +2804,16 @@ WEvent * MTGDredgeRule::replace(WEvent * event)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Choices = int(selection.size());
|
||||||
//there is a memleak here that i have no idea what causes it. got it reduced to just 4 bytes but its still bothering me.
|
//there is a memleak here that i have no idea what causes it. got it reduced to just 4 bytes but its still bothering me.
|
||||||
if (Dredgers < e->nb_cards)
|
if (int(menusOfferedWithDredge.size()) < toDredge)
|
||||||
{
|
{
|
||||||
tcb = tf.createTargetChooser("dredgeable", card);
|
tcb = tf.createTargetChooser("dredgeable", card);
|
||||||
tcb->targetter = NULL;
|
tcb->targetter = NULL;
|
||||||
|
|
||||||
dredgeAbility = NEW dredgeCard(game, game->mLayers->actionLayer()->getMaxId(), card, NULL);
|
dredgeAbility = NEW dredgeCard(game, game->mLayers->actionLayer()->getMaxId(), card, NULL);
|
||||||
dredgeAbility->oneShot = true;
|
dredgeAbility->oneShot = true;
|
||||||
dredgeAbility->canBeInterrupted = false;
|
dredgeAbility->canBeInterrupted = false;
|
||||||
targetAbility = NEW GenericTargetAbility(game, "Dredge A Card", "", game->mLayers->actionLayer()->getMaxId(), card, tcb->clone(), dredgeAbility->clone());
|
targetAbility = NEW GenericTargetAbility(game, "Dredge A Card", "", game->mLayers->actionLayer()->getMaxId(), card, tcb, dredgeAbility->clone());
|
||||||
SAFE_DELETE(tcb);
|
|
||||||
SAFE_DELETE(dredgeAbility);
|
SAFE_DELETE(dredgeAbility);
|
||||||
targetAbility->oneShot = true;
|
targetAbility->oneShot = true;
|
||||||
targetAbility->canBeInterrupted = false;
|
targetAbility->canBeInterrupted = false;
|
||||||
@@ -2820,16 +2823,19 @@ WEvent * MTGDredgeRule::replace(WEvent * event)
|
|||||||
MTGAbility * setDredge = targetAbilityAdder->clone();
|
MTGAbility * setDredge = targetAbilityAdder->clone();
|
||||||
SAFE_DELETE(targetAbilityAdder);
|
SAFE_DELETE(targetAbilityAdder);
|
||||||
setDredge->oneShot = true;
|
setDredge->oneShot = true;
|
||||||
|
|
||||||
selection.push_back(setDredge);
|
selection.push_back(setDredge);
|
||||||
|
}
|
||||||
targetAbility1 = NEW AADrawer(game, this->GetId(), card, card, NULL, "1", TargetChooser::CONTROLLER, true);
|
targetAbility1 = NEW AADrawer(game, this->GetId(), card, card, NULL, "1", TargetChooser::CONTROLLER, true);
|
||||||
targetAbility1->canBeInterrupted = false;
|
targetAbility1->canBeInterrupted = false;
|
||||||
selection.push_back(targetAbility1);
|
selection.push_back(targetAbility1);
|
||||||
MTGAbility * menuChoice = NEW MenuAbility(game, this->GetId(), card, card, true, selection, card->controller(), "Dredge or Draw");
|
MTGAbility * menuChoice = NEW MenuAbility(game, this->GetId(), card, card, true, selection, card->controller(), "Dredge or Draw");
|
||||||
|
menusOfferedWithDredge.push_back(menuChoice);
|
||||||
menuChoice->addToGame();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
while (menusOfferedWithDredge.size())
|
||||||
|
{
|
||||||
|
menusOfferedWithDredge[0]->addToGame();
|
||||||
|
menusOfferedWithDredge.erase(menusOfferedWithDredge.begin());
|
||||||
}
|
}
|
||||||
|
|
||||||
SAFE_DELETE(event);
|
SAFE_DELETE(event);
|
||||||
|
|||||||
Reference in New Issue
Block a user