Merge pull request #873 from kevlahnota/master
Fix granted flashback, add flashback indicator
This commit is contained in:
@@ -2021,6 +2021,7 @@ public:
|
||||
list<int> awith;
|
||||
list<int> colors;
|
||||
list<int> typesToAdd;
|
||||
MTGAbility * andAbility;
|
||||
|
||||
AACloner(GameObserver* observer, int _id, MTGCardInstance * _source, MTGCardInstance * _target = NULL, ManaCost * _cost = NULL, int who = 0,
|
||||
string abilitiesStringList = "",string typeslist = "");
|
||||
|
||||
@@ -3939,7 +3939,7 @@ AACloner::AACloner(GameObserver* observer, int _id, MTGCardInstance * _source, M
|
||||
{
|
||||
PopulateSubtypesIndexVector(typesToAdd,TypesList);
|
||||
}
|
||||
|
||||
andAbility = NULL;
|
||||
}
|
||||
|
||||
int AACloner::resolve()
|
||||
@@ -4012,9 +4012,23 @@ int AACloner::resolve()
|
||||
}
|
||||
if(_target->TokenAndAbility)
|
||||
{//the source copied a token with andAbility
|
||||
MTGAbility * andAbilityClone = _target->TokenAndAbility->clone();
|
||||
andAbilityClone->target = spell->source;
|
||||
MTGAbility * TokenandAbilityClone = _target->TokenAndAbility->clone();
|
||||
TokenandAbilityClone->target = spell->source;
|
||||
if(_target->TokenAndAbility->oneShot)
|
||||
{
|
||||
TokenandAbilityClone->resolve();
|
||||
SAFE_DELETE(TokenandAbilityClone);
|
||||
}
|
||||
else
|
||||
{
|
||||
TokenandAbilityClone->addToGame();
|
||||
}
|
||||
}
|
||||
if(andAbility)
|
||||
{
|
||||
MTGAbility * andAbilityClone = andAbility->clone();
|
||||
andAbilityClone->target = spell->source;
|
||||
if(andAbility->oneShot)
|
||||
{
|
||||
andAbilityClone->resolve();
|
||||
SAFE_DELETE(andAbilityClone);
|
||||
|
||||
@@ -249,7 +249,8 @@ void CardGui::Render()
|
||||
highlightborder = game? game->getResourceManager()->GetQuad("white"):WResourceManager::Instance()->GetQuad("white");
|
||||
if(fakeborder)
|
||||
{
|
||||
if(card->has(Constants::CANPLAYFROMGRAVEYARD)||card->has(Constants::CANPLAYFROMEXILE)||card->has(Constants::PAYZERO))
|
||||
if(card->has(Constants::CANPLAYFROMGRAVEYARD)||card->has(Constants::CANPLAYFROMEXILE)||card->has(Constants::PAYZERO)
|
||||
||((card->has(Constants::TEMPFLASHBACK) || card->getManaCost()->getFlashback()) && game->isInGrave(card)))
|
||||
fakeborder->SetColor(ARGB((int)(actA),7,235,7));//green border
|
||||
else
|
||||
fakeborder->SetColor(ARGB((int)(actA),15,15,15));
|
||||
@@ -1172,7 +1173,7 @@ void CardGui::RenderBig(MTGCard* card, const Pos& pos, bool thumb, bool noborder
|
||||
if(alphabeta.get())
|
||||
{
|
||||
alphabeta->SetHotSpot(static_cast<float> (alphabeta->mWidth / 2), static_cast<float> (alphabeta->mHeight / 2));
|
||||
float myscale = pos.actZ * 254 / alphabeta->mHeight;
|
||||
float myscale = pos.actZ * 255 / alphabeta->mHeight;
|
||||
alphabeta->SetColor(ARGB((int)pos.actA,255,255,255));
|
||||
renderer->RenderQuad(alphabeta.get(), x, pos.actY+0.2f, pos.actT, myscale, myscale);
|
||||
}
|
||||
|
||||
@@ -2483,6 +2483,110 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
|
||||
return tok;
|
||||
}
|
||||
|
||||
//Alternative Token creator. Name, type, p/t, abilities - uses ":" as delimeter
|
||||
vector<string> makeToken = parseBetween(s, "makecardt(", ")");
|
||||
if (makeToken.size())
|
||||
{
|
||||
WParsedInt * multiplier = NULL;
|
||||
size_t myMultiplier = s.find("*");
|
||||
string myMultiplierfound = "";
|
||||
if (myMultiplier != string::npos)
|
||||
{
|
||||
myMultiplierfound = s.substr(myMultiplier + 1);
|
||||
size_t myMultiplierEnd= myMultiplierfound.find_first_of(" ");
|
||||
myMultiplierfound = myMultiplierfound.substr(0,myMultiplierEnd);
|
||||
multiplier = NEW WParsedInt(myMultiplierfound, spell, card);
|
||||
}
|
||||
|
||||
int mytokenId = atoi(makeToken[1].c_str());
|
||||
if (mytokenId)
|
||||
{
|
||||
MTGCard * mysafetycard = MTGCollection()->getCardById(mytokenId);
|
||||
if (!mysafetycard) //Error, card not foudn in DB
|
||||
return NEW ATokenCreator(observer, id, card, target, NULL, "ID NOT FOUND", "ERROR ID",0, 0, "","", NULL,0);
|
||||
|
||||
ATokenCreator * mtok = NEW ATokenCreator(observer, id, card,target, NULL, mytokenId, myMultiplierfound, multiplier, who);
|
||||
mtok->oneShot = 1;
|
||||
//andability
|
||||
if(storedAndAbility.size())
|
||||
{
|
||||
string stored = storedAndAbility;
|
||||
storedAndAbility.clear();
|
||||
((ATokenCreator*)mtok)->andAbility = parseMagicLine(stored, id, spell, card);
|
||||
}
|
||||
return mtok;
|
||||
}
|
||||
|
||||
string tokenDesc = makeToken[1];
|
||||
vector<string> tokenParameters = split(tokenDesc, ':');
|
||||
//lets try finding a token by card name.
|
||||
if (makeToken[1].size() && tokenParameters.size() ==1)
|
||||
{
|
||||
string cardName = makeToken[1];
|
||||
MTGCard * mysafetycard = MTGCollection()->getCardByName(cardName);
|
||||
if (mysafetycard) //lets try constructing it then,we didnt find it by name
|
||||
{
|
||||
ATokenCreator * mtok = NEW ATokenCreator(observer, id, card, target, NULL, cardName, myMultiplierfound, multiplier, who);
|
||||
mtok->oneShot = 1;
|
||||
//andability
|
||||
if(storedAndAbility.size())
|
||||
{
|
||||
string stored = storedAndAbility;
|
||||
storedAndAbility.clear();
|
||||
((ATokenCreator*)mtok)->andAbility = parseMagicLine(stored, id, spell, card);
|
||||
}
|
||||
return mtok;
|
||||
}
|
||||
}
|
||||
if (tokenParameters.size() < 3)
|
||||
{
|
||||
DebugTrace("incorrect Parameters for Token" << tokenDesc);
|
||||
return NULL;
|
||||
}
|
||||
string sname = tokenParameters[0];
|
||||
string stypes = tokenParameters[1];
|
||||
string spt = tokenParameters[2];
|
||||
string cID = "";
|
||||
//reconstructing string abilities from the split version,
|
||||
// then we re-split it again in the token constructor,
|
||||
// this needs to be improved
|
||||
string sabilities = (tokenParameters.size() > 3)? tokenParameters[3] : "";
|
||||
for (size_t i = 4; i < tokenParameters.size(); ++i)
|
||||
{
|
||||
sabilities.append(",");
|
||||
sabilities.append(tokenParameters[i]);
|
||||
}
|
||||
if(sabilities.find(",tnum:") != string::npos)
|
||||
{
|
||||
size_t begins = sabilities.find(",tnum:");
|
||||
cID = sabilities.substr(begins+6);
|
||||
sabilities = cReplaceString(sabilities,",tnum:"+cID,"");
|
||||
}
|
||||
int value = 0;
|
||||
if (spt.find("xx/xx") != string::npos)
|
||||
value = card->X / 2;
|
||||
else if (spt.find("x/x") != string::npos)
|
||||
value = card->X;
|
||||
|
||||
int power, toughness;
|
||||
parsePowerToughness(spt, &power, &toughness);
|
||||
|
||||
ATokenCreator * mtok = NEW ATokenCreator(
|
||||
observer, id, card,target, NULL, sname, stypes, power + value, toughness + value,
|
||||
sabilities, myMultiplierfound, multiplier, who, aLivingWeapon, spt, cID);
|
||||
mtok->oneShot = 1;
|
||||
if(aLivingWeapon)
|
||||
mtok->forceDestroy = 1;
|
||||
//andability
|
||||
if(storedAndAbility.size())
|
||||
{
|
||||
string stored = storedAndAbility;
|
||||
storedAndAbility.clear();
|
||||
((ATokenCreator*)mtok)->andAbility = parseMagicLine(stored, id, spell, card);
|
||||
}
|
||||
return mtok;
|
||||
}
|
||||
|
||||
//Equipment
|
||||
found = s.find("equip");
|
||||
if (found != string::npos)
|
||||
@@ -2596,6 +2700,12 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
|
||||
}
|
||||
MTGAbility * a = NEW AACloner(observer, id, card, target, 0, who, with,types);
|
||||
a->oneShot = 1;
|
||||
if(storedAndAbility.size())
|
||||
{
|
||||
string stored = storedAndAbility;
|
||||
storedAndAbility.clear();
|
||||
((AACloner*)a)->andAbility = parseMagicLine(stored, id, spell, card);
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
|
||||
@@ -1111,7 +1111,7 @@ int MTGTempFlashBackRule::reactToClick(MTGCardInstance * card)
|
||||
if (!isReactingToClick(card))
|
||||
return 0;
|
||||
|
||||
card->paymenttype = MTGAbility::FLASHBACK_COST;
|
||||
card->paymenttype = MTGAbility::GRANTEDFLASHBACK_COST;
|
||||
|
||||
return MTGAlternativeCostRule::reactToClick(card, flashbackCost, ManaCost::MANA_PAID_WITH_FLASHBACK);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user