force a lure block when the players decide they want to skip the action, a lurer MUST be blocked if the defending creature can block it. this action can not be skipped.
This commit is contained in:
@@ -165,6 +165,7 @@ public:
|
|||||||
void untapAll();
|
void untapAll();
|
||||||
MTGCardInstance * getNextAttacker(MTGCardInstance * previous);
|
MTGCardInstance * getNextAttacker(MTGCardInstance * previous);
|
||||||
MTGCardInstance * getNextLurer(MTGCardInstance * previous);
|
MTGCardInstance * getNextLurer(MTGCardInstance * previous);
|
||||||
|
MTGCardInstance * findALurer();
|
||||||
virtual ostream& toString(ostream&) const;
|
virtual ostream& toString(ostream&) const;
|
||||||
const char * getName(){return "battlefield";}
|
const char * getName(){return "battlefield";}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -247,6 +247,7 @@ public:
|
|||||||
TargetChooser * tcb;
|
TargetChooser * tcb;
|
||||||
MTGAbility * blocker;
|
MTGAbility * blocker;
|
||||||
MTGAbility * blockAbility;
|
MTGAbility * blockAbility;
|
||||||
|
int receiveEvent(WEvent * event);
|
||||||
int isReactingToClick(MTGCardInstance * card, ManaCost * mana = NULL);
|
int isReactingToClick(MTGCardInstance * card, ManaCost * mana = NULL);
|
||||||
int reactToClick(MTGCardInstance * card);
|
int reactToClick(MTGCardInstance * card);
|
||||||
virtual ostream& toString(ostream& out) const;
|
virtual ostream& toString(ostream& out) const;
|
||||||
|
|||||||
@@ -785,6 +785,19 @@ MTGCardInstance * MTGInPlay::getNextLurer(MTGCardInstance * previous)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MTGCardInstance * MTGInPlay::findALurer()
|
||||||
|
{
|
||||||
|
for (int i = 0; i < nb_cards; i++)
|
||||||
|
{
|
||||||
|
MTGCardInstance * current = cards[i];
|
||||||
|
if (current->isAttacker() && current->has(Constants::LURE))
|
||||||
|
{
|
||||||
|
return current;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
void MTGInPlay::untapAll()
|
void MTGInPlay::untapAll()
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|||||||
@@ -1499,6 +1499,33 @@ PermanentAbility(observer, _id)
|
|||||||
blockAbility = NULL;
|
blockAbility = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int MTGBlockRule::receiveEvent(WEvent *e)
|
||||||
|
{
|
||||||
|
if (WEventCombatStepChange * event = dynamic_cast<WEventCombatStepChange*>(e))
|
||||||
|
{
|
||||||
|
if (TRIGGERS == event->step)
|
||||||
|
{
|
||||||
|
Player * p = game->currentPlayer;
|
||||||
|
MTGCardInstance * lurer = p->game->inPlay->findALurer();
|
||||||
|
if(lurer)
|
||||||
|
{
|
||||||
|
MTGGameZone * z = p->opponent()->game->inPlay;
|
||||||
|
for (int i = 0; i < z->nb_cards; i++)
|
||||||
|
{
|
||||||
|
MTGCardInstance * card = z->cards[i];
|
||||||
|
if ((card->defenser && !card->defenser->has(Constants::LURE))||!card->defenser)
|
||||||
|
if(card->canBlock(lurer))
|
||||||
|
card->setDefenser(lurer);
|
||||||
|
//force a block on a lurer, the player has a chance to set his own choice on multiple lures
|
||||||
|
//but this action can not be ignored.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int MTGBlockRule::isReactingToClick(MTGCardInstance * card, ManaCost * mana)
|
int MTGBlockRule::isReactingToClick(MTGCardInstance * card, ManaCost * mana)
|
||||||
{
|
{
|
||||||
if (currentPhase == MTG_PHASE_COMBATBLOCKERS && !game->isInterrupting
|
if (currentPhase == MTG_PHASE_COMBATBLOCKERS && !game->isInterrupting
|
||||||
@@ -1549,14 +1576,10 @@ int MTGBlockRule::reactToClick(MTGCardInstance * card)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
bool lured = false;
|
bool lured = false;
|
||||||
int lureFound = 0;
|
MTGCardInstance * lurers = game->currentPlayer->game->inPlay->findALurer();
|
||||||
MTGCardInstance * lurers = NULL;
|
if(lurers)
|
||||||
while(!lureFound)
|
|
||||||
{
|
{
|
||||||
lurers = game->currentPlayer->game->inPlay->getNextLurer(lurers);
|
lured = true;
|
||||||
lureFound = (lurers == NULL || lurers->attacker);
|
|
||||||
if(lurers)
|
|
||||||
lured = true;
|
|
||||||
}
|
}
|
||||||
while (!result)
|
while (!result)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1543,14 +1543,10 @@ bool BlockableChooser::canTarget(Targetable * target,bool withoutProtections)
|
|||||||
if(!card->isAttacker() || !source->canBlock(card))
|
if(!card->isAttacker() || !source->canBlock(card))
|
||||||
return false;
|
return false;
|
||||||
bool lured = false;
|
bool lured = false;
|
||||||
int lureFound = 0;
|
MTGCardInstance * lurers = observer->currentPlayer->game->inPlay->findALurer();
|
||||||
MTGCardInstance * lurers = NULL;
|
if(lurers)
|
||||||
while(!lureFound)
|
|
||||||
{
|
{
|
||||||
lurers = card->controller()->game->inPlay->getNextLurer(lurers);
|
lured = true;
|
||||||
lureFound = (lurers == NULL || lurers->attacker);
|
|
||||||
if(lurers)
|
|
||||||
lured = true;
|
|
||||||
}
|
}
|
||||||
if(lured && card->controller()->inPlay()->hasAbility(Constants::LURE) && !card->has(Constants::LURE))
|
if(lured && card->controller()->inPlay()->hasAbility(Constants::LURE) && !card->has(Constants::LURE))
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user