Improved Die Roll event and trigger, added Flip Coin trigger management, added/fixed almost all primitives with "roll a die ability", fixed some tab chars in source files.
This commit is contained in:
@@ -2731,6 +2731,9 @@ int AASetCoin::resolve()
|
||||
_target->coinSide = side;
|
||||
|
||||
int flip = game->getRandomGenerator()->random() % 2;
|
||||
_target->lastFlipResult = flip;
|
||||
WEvent * e = NEW WEventCardFlipCoin(_target, source->controller()->getDisplayName());
|
||||
game->receiveEvent(e);
|
||||
vector<string>Win = parseBetween(abilityToAlter,"winability "," winabilityend");
|
||||
if(Win.size())
|
||||
{
|
||||
@@ -2881,7 +2884,7 @@ int AASetDie::resolve()
|
||||
|
||||
int roll = 1 + game->getRandomGenerator()->random() % 6;
|
||||
_target->lastRollResult = roll;
|
||||
WEvent * e = NEW WEventCardRollDie(_target);
|
||||
WEvent * e = NEW WEventCardRollDie(_target, source->controller()->getDisplayName());
|
||||
game->receiveEvent(e);
|
||||
vector<string>Win = parseBetween(abilityToAlter,"winability "," winabilityend");
|
||||
if(Win.size())
|
||||
@@ -2894,6 +2897,7 @@ int AASetDie::resolve()
|
||||
abilityLose = Lose[1];
|
||||
}
|
||||
|
||||
std::stringstream msg;
|
||||
if(abilityWin.size() && roll == side)
|
||||
{
|
||||
AbilityFactory af(game);
|
||||
@@ -2908,13 +2912,15 @@ int AASetDie::resolve()
|
||||
{
|
||||
abilityAltered->addToGame();
|
||||
}
|
||||
MTGAbility * message = NEW MTGEventText(game,this->GetId(), source, "You Won The Die Roll");
|
||||
msg << "Result is: " << roll << ". You Won The Die Roll";
|
||||
MTGAbility * message = NEW MTGEventText(game,this->GetId(), source, msg.str());
|
||||
message->oneShot = true;
|
||||
message->addToGame();
|
||||
}
|
||||
else if(abilityWin.size() && !abilityLose.size())
|
||||
{
|
||||
MTGAbility * message = NEW MTGEventText(game,this->GetId(), source, "You Lost The Die Roll");
|
||||
msg << "Result is: " << roll << ". You Lost The Die Roll";
|
||||
MTGAbility * message = NEW MTGEventText(game,this->GetId(), source, msg.str());
|
||||
message->oneShot = true;
|
||||
message->addToGame();
|
||||
}
|
||||
@@ -2932,13 +2938,15 @@ int AASetDie::resolve()
|
||||
{
|
||||
abilityAltered->addToGame();
|
||||
}
|
||||
MTGAbility * message = NEW MTGEventText(game,this->GetId(), source, "You Lost The Die Roll");
|
||||
msg << "Result is: " << roll << ". You Lost The Die Roll";
|
||||
MTGAbility * message = NEW MTGEventText(game,this->GetId(), source, msg.str());
|
||||
message->oneShot = true;
|
||||
message->addToGame();
|
||||
}
|
||||
else if(abilityLose.size())
|
||||
{
|
||||
MTGAbility * message = NEW MTGEventText(game,this->GetId(), source, "You Won The Die Roll");
|
||||
msg << "Result is: " << roll << ". You Won The Die Roll";
|
||||
MTGAbility * message = NEW MTGEventText(game,this->GetId(), source, msg.str());
|
||||
message->oneShot = true;
|
||||
message->addToGame();
|
||||
}
|
||||
@@ -2948,17 +2956,9 @@ int AASetDie::resolve()
|
||||
|
||||
const string AASetDie::getMenuText()
|
||||
{
|
||||
if(side == 1)
|
||||
return "Your choice is 1";
|
||||
if(side == 2)
|
||||
return "Your choice is 2";
|
||||
if(side == 3)
|
||||
return "Your choice is 3";
|
||||
if(side == 4)
|
||||
return "Your choice is 4";
|
||||
if(side == 5)
|
||||
return "Your choice is 5";
|
||||
return "Your choice is 6";
|
||||
std::stringstream msg;
|
||||
msg << "Your choice is: " << side;
|
||||
return msg.str();
|
||||
}
|
||||
|
||||
AASetDie * AASetDie::clone() const
|
||||
|
||||
@@ -1030,17 +1030,35 @@ void GameObserver::gameStateBasedEffects()
|
||||
c->Provoker = NULL;
|
||||
}
|
||||
|
||||
MTGGameZone * f = p->game->graveyard;
|
||||
for (int k = 0; k < f->nb_cards; k++)
|
||||
MTGGameZone * fg = p->game->graveyard;
|
||||
for (int k = 0; k < fg->nb_cards; k++)
|
||||
{
|
||||
MTGCardInstance * card = f->cards[k];
|
||||
card->fresh = 0;
|
||||
MTGCardInstance * card = fg->cards[k];
|
||||
card->fresh = 0; // Remove fresh attribute to cards put in graveyard last turn
|
||||
}
|
||||
MTGGameZone * fe = p->game->exile;
|
||||
for (int k = 0; k < fe->nb_cards; k++)
|
||||
{
|
||||
MTGCardInstance * card = fe->cards[k]; // Remove fresh attribute to previous exiled cards
|
||||
card->fresh = 0;
|
||||
MTGCardInstance * card = fe->cards[k];
|
||||
card->fresh = 0; // Remove fresh attribute to cards put in exile last turn
|
||||
}
|
||||
MTGGameZone * fh = p->game->hand;
|
||||
for (int k = 0; k < fh->nb_cards; k++)
|
||||
{
|
||||
MTGCardInstance * card = fh->cards[k];
|
||||
card->fresh = 0; // Remove fresh attribute to cards put in hand last turn
|
||||
}
|
||||
MTGGameZone * fc = p->game->commandzone;
|
||||
for (int k = 0; k < fc->nb_cards; k++)
|
||||
{
|
||||
MTGCardInstance * card = fc->cards[k];
|
||||
card->fresh = 0; // Remove fresh attribute to cards put in commandzone last turn
|
||||
}
|
||||
MTGGameZone * fl = p->game->commandzone;
|
||||
for (int k = 0; k < fl->nb_cards; k++)
|
||||
{
|
||||
MTGCardInstance * card = fl->cards[k];
|
||||
card->fresh = 0; // Remove fresh attribute to cards put in library last turn
|
||||
}
|
||||
}
|
||||
if (z->nb_cards == 0)
|
||||
|
||||
@@ -1229,7 +1229,33 @@ TriggeredAbility * AbilityFactory::parseTrigger(string s, string, int id, Spell
|
||||
if(res.size()){
|
||||
rollresult = atoi(res[1].c_str());
|
||||
}
|
||||
return NEW TrCardRolledDie(observer, id, card, tc, once, limitOnceATurn, rollresult);
|
||||
string playerName = "";
|
||||
vector<string>from = parseBetween(s, "from(",")");
|
||||
if(from.size() && from[1] == "opponent"){
|
||||
playerName = card->controller()->opponent()->getDisplayName();
|
||||
} else if(from.size() && from[1] == "controller"){
|
||||
playerName = card->controller()->getDisplayName();
|
||||
}
|
||||
return NEW TrCardRolledDie(observer, id, card, tc, once, limitOnceATurn, rollresult, playerName);
|
||||
}
|
||||
|
||||
//Fip coin has been performed from a card
|
||||
if (TargetChooser * tc = parseSimpleTC(s, "coinflipped", card)){
|
||||
int flipresult = -1;
|
||||
vector<string>res = parseBetween(s, "result(",")");
|
||||
if(res.size() && res[1] == "head"){
|
||||
flipresult = 0;
|
||||
} else if(res.size() && (res[1] == "tails" || res[1] == "tail")){
|
||||
flipresult = 1;
|
||||
}
|
||||
string playerName = "";
|
||||
vector<string>from = parseBetween(s, "from(",")");
|
||||
if(from.size() && from[1] == "opponent"){
|
||||
playerName = card->controller()->opponent()->getDisplayName();
|
||||
} else if(from.size() && from[1] == "controller"){
|
||||
playerName = card->controller()->getDisplayName();
|
||||
}
|
||||
return NEW TrCardFlippedCoin(observer, id, card, tc, once, limitOnceATurn, flipresult, playerName);
|
||||
}
|
||||
|
||||
//Token has been created
|
||||
|
||||
@@ -262,6 +262,7 @@ void MTGCardInstance::initMTGCI()
|
||||
chooseacolor = -1;
|
||||
chooseasubtype = "";
|
||||
coinSide = -1;
|
||||
lastFlipResult = -1;
|
||||
dieSide = 0;
|
||||
lastRollResult = 0;
|
||||
isAttacking = NULL;
|
||||
|
||||
@@ -3311,6 +3311,10 @@ int MTGUnearthRule::receiveEvent(WEvent * event)
|
||||
{
|
||||
e->card->fresh = 1;
|
||||
}
|
||||
if (e->from == e->card->controller()->game->stack && e->to == e->card->controller()->game->graveyard) // Apply fresh attribute for new casted spells
|
||||
{
|
||||
e->card->fresh = 1;
|
||||
}
|
||||
if (e->to == e->card->controller()->game->battlefield)
|
||||
{
|
||||
e->card->fresh = 1;
|
||||
@@ -3320,6 +3324,18 @@ int MTGUnearthRule::receiveEvent(WEvent * event)
|
||||
{
|
||||
e->card->fresh = 1;
|
||||
}
|
||||
if (e->to == e->card->controller()->game->hand) // Apply fresh attribute for cards just put in hand
|
||||
{
|
||||
e->card->fresh = 1;
|
||||
}
|
||||
if (e->to == e->card->controller()->game->commandzone) // Apply fresh attribute for cards just put in commandzone
|
||||
{
|
||||
e->card->fresh = 1;
|
||||
}
|
||||
if (e->to == e->card->controller()->game->library) // Apply fresh attribute for cards just put in library
|
||||
{
|
||||
e->card->fresh = 1;
|
||||
}
|
||||
|
||||
if (card && card->basicAbilities[(int)Constants::UNEARTH])
|
||||
{
|
||||
|
||||
@@ -297,8 +297,13 @@ WEventCardSurveiled::WEventCardSurveiled(MTGCardInstance * card) :
|
||||
{
|
||||
}
|
||||
|
||||
WEventCardRollDie::WEventCardRollDie(MTGCardInstance * card) :
|
||||
WEventCardUpdate(card)
|
||||
WEventCardRollDie::WEventCardRollDie(MTGCardInstance * card, string playerName) :
|
||||
WEventCardUpdate(card), playerName(playerName)
|
||||
{
|
||||
}
|
||||
|
||||
WEventCardFlipCoin::WEventCardFlipCoin(MTGCardInstance * card, string playerName) :
|
||||
WEventCardUpdate(card), playerName(playerName)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -527,6 +532,12 @@ Targetable * WEventCardRollDie::getTarget(int target)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Targetable * WEventCardFlipCoin::getTarget(int target)
|
||||
{
|
||||
if (target) return card;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Targetable * WEventTokenCreated::getTarget(int target)
|
||||
{
|
||||
if (target) return card;
|
||||
|
||||
Reference in New Issue
Block a user