add restriction for checking what alternative cost was paid. combined with if/ifnot ability becomes a very powerful tool.
paid(blah)
auto=if paid(alternative) then damage:3 target(creature)
auto=if paid(alternative) then life:10 target(player)
auto=ifnot paid(alternative) then damage:3 controller
auto=ifnot paid(alternative) then life:4 opponent
it can be used any place a restriction can be used.
rearranged the constants for the payment type keywords to match the order we int the alternatePayment array on a card, added keywords for the remaining payment types,
"notpaid",
"paidmana",
the 2 above pretain to paying the real manacost of a card
it checks the mana={1} cost line and is not joined to the other types.
"kicker",
"alternative",
"buyback",
"flashback",
"retrace",
"facedown",
"suspended"
note: all test pass in this revision.
This commit is contained in:
@@ -55,7 +55,7 @@ public:
|
|||||||
Pos* view;
|
Pos* view;
|
||||||
int X;
|
int X;
|
||||||
int castX;
|
int castX;
|
||||||
int alternateCostPaid[ManaCost::MANA_PAID_WITH_RETRACE + 1];
|
int alternateCostPaid[ManaCost::MANA_PAID_WITH_SUSPEND + 1];
|
||||||
int paymenttype;
|
int paymenttype;
|
||||||
int castMethod; /* Tells if the card reached its current zone by being cast or not (brought into the zone by an effect). non 0 == cast, 0 == not cast */
|
int castMethod; /* Tells if the card reached its current zone by being cast or not (brought into the zone by an effect). non 0 == cast, 0 == not cast */
|
||||||
int frozen;
|
int frozen;
|
||||||
|
|||||||
@@ -260,6 +260,12 @@ bool Spell::FullfilledAlternateCost(const int &costType)
|
|||||||
|
|
||||||
switch (costType)
|
switch (costType)
|
||||||
{
|
{
|
||||||
|
case ManaCost::MANA_UNPAID:
|
||||||
|
hasFullfilledAlternateCost = (payResult == ManaCost::MANA_UNPAID);
|
||||||
|
break;
|
||||||
|
case ManaCost::MANA_PAID:
|
||||||
|
hasFullfilledAlternateCost = (payResult == ManaCost::MANA_PAID);
|
||||||
|
break;
|
||||||
case ManaCost::MANA_PAID_WITH_KICKER:
|
case ManaCost::MANA_PAID_WITH_KICKER:
|
||||||
hasFullfilledAlternateCost = (payResult == ManaCost::MANA_PAID_WITH_KICKER);
|
hasFullfilledAlternateCost = (payResult == ManaCost::MANA_PAID_WITH_KICKER);
|
||||||
break;
|
break;
|
||||||
@@ -275,6 +281,9 @@ bool Spell::FullfilledAlternateCost(const int &costType)
|
|||||||
case ManaCost::MANA_PAID_WITH_RETRACE:
|
case ManaCost::MANA_PAID_WITH_RETRACE:
|
||||||
hasFullfilledAlternateCost = (payResult == ManaCost::MANA_PAID_WITH_RETRACE);
|
hasFullfilledAlternateCost = (payResult == ManaCost::MANA_PAID_WITH_RETRACE);
|
||||||
break;
|
break;
|
||||||
|
case ManaCost::MANA_PAID_WITH_SUSPEND:
|
||||||
|
hasFullfilledAlternateCost = (payResult == ManaCost::MANA_PAID_WITH_RETRACE);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return hasFullfilledAlternateCost;
|
return hasFullfilledAlternateCost;
|
||||||
|
|||||||
@@ -29,10 +29,29 @@ const int kMaxCastZones[] = { MTGGameZone::BATTLEFIELD, MTGGameZone::STACK};
|
|||||||
const size_t kMaxCastKeywordsCount = 2;
|
const size_t kMaxCastKeywordsCount = 2;
|
||||||
|
|
||||||
//Used for alternate Costs parsing
|
//Used for alternate Costs parsing
|
||||||
const string kAlternateCostKeywords[] = { "kicker", "retrace", "alternative", "buyback", "flashback", "facedown"};
|
const string kAlternateCostKeywords[] =
|
||||||
const int kAlternateCostIds[] = {
|
{
|
||||||
ManaCost::MANA_PAID_WITH_KICKER, ManaCost::MANA_PAID_WITH_RETRACE, ManaCost::MANA_PAID_WITH_ALTERNATIVE,
|
"notpaid",
|
||||||
ManaCost::MANA_PAID_WITH_BUYBACK, ManaCost::MANA_PAID_WITH_FLASHBACK, ManaCost::MANA_PAID_WITH_MORPH
|
"paidmana",
|
||||||
|
"kicker",
|
||||||
|
"alternative",
|
||||||
|
"buyback",
|
||||||
|
"flashback",
|
||||||
|
"retrace",
|
||||||
|
"facedown",
|
||||||
|
"suspended"
|
||||||
|
};
|
||||||
|
const int kAlternateCostIds[] =
|
||||||
|
{
|
||||||
|
ManaCost::MANA_UNPAID,
|
||||||
|
ManaCost::MANA_PAID,
|
||||||
|
ManaCost::MANA_PAID_WITH_KICKER,
|
||||||
|
ManaCost::MANA_PAID_WITH_ALTERNATIVE,
|
||||||
|
ManaCost::MANA_PAID_WITH_BUYBACK,
|
||||||
|
ManaCost::MANA_PAID_WITH_FLASHBACK,
|
||||||
|
ManaCost::MANA_PAID_WITH_RETRACE,
|
||||||
|
ManaCost::MANA_PAID_WITH_MORPH,
|
||||||
|
ManaCost::MANA_PAID_WITH_SUSPEND
|
||||||
};
|
};
|
||||||
|
|
||||||
//Used for "dynamic ability" parsing
|
//Used for "dynamic ability" parsing
|
||||||
@@ -353,6 +372,26 @@ int AbilityFactory::parseCastRestrictions(MTGCardInstance * card, Player * playe
|
|||||||
{
|
{
|
||||||
restriction.push_back("type(creature|mybattlefield)~lessthan~type(creature|opponentbattlefield)");
|
restriction.push_back("type(creature|mybattlefield)~lessthan~type(creature|opponentbattlefield)");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
check = restriction[i].find("paid(");
|
||||||
|
if(check != string::npos)
|
||||||
|
{
|
||||||
|
vector<string>getPaid = parseBetween(restriction[i].c_str(),"paid(",")");
|
||||||
|
string paid = getPaid[1];
|
||||||
|
|
||||||
|
for (size_t j = 0; j < sizeof(kAlternateCostIds)/sizeof(kAlternateCostIds[0]); ++j)
|
||||||
|
{
|
||||||
|
string keyword = kAlternateCostKeywords[j];
|
||||||
|
if (paid.find(keyword) != string::npos)
|
||||||
|
{
|
||||||
|
if (!(card->alternateCostPaid[j] > 0 ))
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -171,7 +171,7 @@ void MTGCardInstance::initMTGCI()
|
|||||||
storedSourceCard = NULL;
|
storedSourceCard = NULL;
|
||||||
myPair = NULL;
|
myPair = NULL;
|
||||||
|
|
||||||
for (int i = 0; i < ManaCost::MANA_PAID_WITH_RETRACE +1; i++)
|
for (int i = 0; i < ManaCost::MANA_PAID_WITH_SUSPEND +1; i++)
|
||||||
alternateCostPaid[i] = 0;
|
alternateCostPaid[i] = 0;
|
||||||
|
|
||||||
paymenttype = MTGAbility::PUT_INTO_PLAY;
|
paymenttype = MTGAbility::PUT_INTO_PLAY;
|
||||||
|
|||||||
@@ -476,6 +476,8 @@ MTGCardInstance * MTGGameZone::removeCard(MTGCardInstance * card, int createCopy
|
|||||||
copy->kicked = card->kicked;
|
copy->kicked = card->kicked;
|
||||||
copy->storedCard = card->storedCard;
|
copy->storedCard = card->storedCard;
|
||||||
copy->storedSourceCard = card->storedSourceCard;
|
copy->storedSourceCard = card->storedSourceCard;
|
||||||
|
for (int i = 0; i < ManaCost::MANA_PAID_WITH_SUSPEND +1; i++)
|
||||||
|
copy->alternateCostPaid[i] = card->alternateCostPaid[i];
|
||||||
|
|
||||||
//stupid bug with tokens...
|
//stupid bug with tokens...
|
||||||
if (card->model == card)
|
if (card->model == card)
|
||||||
|
|||||||
Reference in New Issue
Block a user