added abilities=lure

"all creatures able to block blah must do so."
This commit is contained in:
omegablast2002@yahoo.com
2013-01-05 05:01:31 +00:00
parent 4960969640
commit 972e2b1ec2
6 changed files with 58 additions and 6 deletions

View File

@@ -219,8 +219,8 @@ class Constants
ONLYMANA = 98,
POISONDAMAGER = 99,
soulbond = 100,
NB_BASIC_ABILITIES = 101,
LURE = 101,
NB_BASIC_ABILITIES = 102,
RARITY_S = 'S', //Special Rarity

View File

@@ -164,6 +164,7 @@ class MTGInPlay: public MTGGameZone {
public:
void untapAll();
MTGCardInstance * getNextAttacker(MTGCardInstance * previous);
MTGCardInstance * getNextLurer(MTGCardInstance * previous);
virtual ostream& toString(ostream&) const;
const char * getName(){return "battlefield";}
};

View File

@@ -129,7 +129,8 @@ const char* Constants::MTGBasicAbilities[] = {
"nomanaability",
"onlymanaability",
"poisondamager",//deals damage to players as poison counters.
"soulbond"
"soulbond",
"lure"
};
map<string,int> Constants::MTGBasicAbilitiesMap;

View File

@@ -761,6 +761,28 @@ MTGCardInstance * MTGInPlay::getNextAttacker(MTGCardInstance * previous)
return NULL;
}
MTGCardInstance * MTGInPlay::getNextLurer(MTGCardInstance * previous)
{
int foundprevious = 0;
if (previous == NULL)
{
foundprevious = 1;
}
for (int i = 0; i < nb_cards; i++)
{
MTGCardInstance * current = cards[i];
if (current == previous)
{
foundprevious = 1;
}
else if (foundprevious && current->isAttacker() && current->has(Constants::LURE))
{
return current;
}
}
return NULL;
}
void MTGInPlay::untapAll()
{
int i;

View File

@@ -1547,17 +1547,33 @@ int MTGBlockRule::reactToClick(MTGCardInstance * card)
card->toggleDefenser(NULL);
}
else
{
bool lured = false;
int lureFound = 0;
MTGCardInstance * lurers = NULL;
while(!lureFound)
{
lurers = game->currentPlayer->game->inPlay->getNextLurer(lurers);
lureFound = (lurers == NULL || lurers->attacker);
if(lurers)
lured = true;
}
while (!result)
{
currentOpponent = game->currentPlayer->game->inPlay->getNextAttacker(currentOpponent);
canDefend = card->toggleDefenser(currentOpponent);
if(lured && currentOpponent && !currentOpponent->has(Constants::LURE))
currentOpponent = game->currentPlayer->game->inPlay->getNextAttacker(currentOpponent);
canDefend = card->toggleDefenser(currentOpponent);
DebugTrace("Defenser Toggle: " << card->getName() << endl
<< "- canDefend: " << (canDefend == 0) << endl
<< "- currentOpponent: " << currentOpponent);
result = (canDefend || currentOpponent == NULL);
result = (currentOpponent == NULL || canDefend);
}
return 1;
lured = false;
}
return 1;
}
const char * MTGBlockRule::getMenuText()

View File

@@ -1534,6 +1534,18 @@ bool BlockableChooser::canTarget(Targetable * target,bool withoutProtections)
{
if(!card->isAttacker() || !source->canBlock(card))
return false;
bool lured = false;
int lureFound = 0;
MTGCardInstance * lurers = NULL;
while(!lureFound)
{
lurers = card->controller()->game->inPlay->getNextLurer(lurers);
lureFound = (lurers == NULL || lurers->attacker);
if(lurers)
lured = true;
}
if(lured && card->controller()->inPlay()->hasAbility(Constants::LURE) && !card->has(Constants::LURE))
return false;
return true;
}
return TypeTargetChooser::canTarget(target,withoutProtections);