TrcardDrawn, TrDamaged, TrLifeGained

Added trigger restriction for "@trigger(player)
restriction{opponenttrigger/controllertrigger}"

Restriction for:
@drawn
@damaged(combat and noncombat)
@lifed/lifeloss

Why?

When using @drawn trigger like Underworld Dreams
auto=@drawn(opponent):life:-1 opponent

If you take control of Underworld Dreams from an opponent, the
targetchooser for "opponent" is not updated and you are still the
opponent of Underworld Dreams even you take control of it(It is right if
you are the chosen opponent from cards like Black Vise, The Rack, etc...
The chosen opponent never changes. But cards that don't define a chosen
player an "opponent" like Underworld Dreams when an exchanged control
happens, the opponent of the card is the opponent of the one who
controls the card). :P

The new correct code for Underworld Dreams:
auto=@drawn(player) restriction{opponenttrigger}:life:-1 opponent
This commit is contained in:
Anthony Calosa
2015-10-18 22:38:41 +08:00
parent 8c4fabb89a
commit c7535e38dc
5 changed files with 55 additions and 8 deletions

View File

@@ -1207,7 +1207,10 @@ public:
WEventcardDraw * e = dynamic_cast<WEventcardDraw *> (event);
if (!e) return 0;
if (!tc->canTarget(e->player)) return 0;
if(source->controller() == e->player)
source->controllerTrigger = 1;
else
source->opponentTrigger = 1;
return 1;
}
@@ -1315,6 +1318,18 @@ public:
if (type == 2 && e->damage->typeOfDamage == Damage::DAMAGE_COMBAT) return 0;
e->damage->target->thatmuch = e->damage->damage;
e->damage->source->thatmuch = e->damage->damage;
if (e->damage->target->type_as_damageable == Damageable::DAMAGEABLE_PLAYER)
{
Player * p = (Player *) e->damage->target;
if(p && p == source->controller()->opponent())
{
source->opponentTrigger = 1;
}
else
{
source->controllerTrigger = 1;
}
}
this->source->thatmuch = e->damage->damage;
triggeredTurn = game->turn;
@@ -1354,6 +1369,10 @@ public:
if (type == 1 && (e->amount > 0)) return 0;
if (type == 0 && (e->amount < 0)) return 0;
e->player->thatmuch = abs(e->amount);
if(source->controller() == e->player)
source->controllerTrigger = 1;
else
source->opponentTrigger = 1;
this->source->thatmuch = abs(e->amount);
return 1;

View File

@@ -253,6 +253,8 @@ public:
int cardistargetted;
bool isTargetter();
int cardistargetter;
int opponentTrigger;
int controllerTrigger;
void eventattacked();
void eventattackedAlone();

View File

@@ -593,15 +593,25 @@ void GameObserver::gameStateBasedEffects()
/////////////////////////////////////
for (int d = 0; d < 2; d++)
{
MTGGameZone * zone = players[d]->game->inPlay;
if (mLayers->stackLayer()->count(0, NOT_RESOLVED) == 0)
{
for (int c = zone->nb_cards - 1; c >= 0; c--)
MTGGameZone * dzones[] = { players[d]->game->inPlay, players[d]->game->graveyard, players[d]->game->hand, players[d]->game->library };
for (int k = 0; k < 4; k++)
{
MTGGameZone * zone = dzones[k];
if (mLayers->stackLayer()->count(0, NOT_RESOLVED) == 0)
{
zone->cards[c]->cardistargetted = 0;
zone->cards[c]->cardistargetter = 0;
for (int c = zone->nb_cards - 1; c >= 0; c--)
{
zone->cards[c]->cardistargetted = 0;
zone->cards[c]->cardistargetter = 0;
}
}
}
//clear trigger
for (int b = zone->nb_cards - 1; b >= 0; b--)
{
zone->cards[b]->controllerTrigger = 0;
zone->cards[b]->opponentTrigger = 0;
}
}//check for losers if its gameover call the statebased action
players[d]->DeadLifeState();
}
////////////////////////////////////

View File

@@ -411,6 +411,20 @@ int AbilityFactory::parseCastRestrictions(MTGCardInstance * card, Player * playe
}
}
check = restriction[i].find("opponenttrigger");
if(check != string::npos)
{
if(!card->opponentTrigger)
return 0;
}
check = restriction[i].find("controllertrigger");
if(check != string::npos)
{
if(!card->controllerTrigger)
return 0;
}
check = restriction[i].find("discarded");
if(check != string::npos)
{

View File

@@ -65,6 +65,8 @@ MTGCardInstance::MTGCardInstance(MTGCard * card, MTGPlayerCards * arg_belongs_to
LKItoughness = toughness;
cardistargetted = 0;
cardistargetter = 0;
opponentTrigger = 0;
controllerTrigger = 0;
}
MTGCardInstance * MTGCardInstance::createSnapShot()