Altercost

Altercost alter cards to be cast...
Removed Trinisphere temporarily...
This commit is contained in:
Anthony Calosa
2015-10-30 07:11:16 +08:00
parent 40db1180df
commit 8793feb9ba
12 changed files with 297 additions and 149 deletions
+1 -10
View File
@@ -104963,15 +104963,6 @@ mana={5}
type=Artifact type=Artifact
[/card] [/card]
[card] [card]
name=Trinisphere
auto=this(untapped) lord(*[manacost=0]|hand) altercost(colorless, +3)
auto=this(untapped) lord(*[manacost=1]|hand) altercost(colorless, +2)
auto=this(untapped) lord(*[manacost=2]|hand) altercost(colorless, +1)
text=As long as Trinisphere is untapped, each spell that would cost less than three mana to cast costs three mana to cast. (Additional mana in the cost may be paid with any color of mana or colorless mana. For example, a spell that would cost {1}{B} to cast costs {2}{B} to cast instead.)
mana={3}
type=Artifact
[/card]
[card]
name=Trinket Mage name=Trinket Mage
auto=may moveTo(myhand) target(artifact[manacost<=1]|mylibrary) auto=may moveTo(myhand) target(artifact[manacost<=1]|mylibrary)
text=When Trinket Mage enters the battlefield, you may search your library for an artifact card with converted mana cost 1 or less, reveal that card, and put it into your hand. If you do, shuffle your library. text=When Trinket Mage enters the battlefield, you may search your library for an artifact card with converted mana cost 1 or less, reveal that card, and put it into your hand. If you do, shuffle your library.
@@ -111696,7 +111687,7 @@ toughness=2
[card] [card]
name=Warden of Evos Isle name=Warden of Evos Isle
abilities=flying abilities=flying
auto=lord(creature[flying]|myhand) altercost(colorless, -1) auto=lord(creature[flying]|myhand,mylibrary,mygraveyard,myexile) altercost(colorless, -1)
text=Flying. -- Creature spells with flying you cast cost 1 less to cast. text=Flying. -- Creature spells with flying you cast cost 1 less to cast.
mana={2}{U} mana={2}{U}
type=Creature type=Creature
@@ -17156,6 +17156,15 @@ mana={U}
type=Instant type=Instant
[/card] [/card]
[card] [card]
name=Trinisphere
auto=this(untapped) lord(*[manacost=0]|hand) altercost(colorless, +3)
auto=this(untapped) lord(*[manacost=1]|hand) altercost(colorless, +2)
auto=this(untapped) lord(*[manacost=2]|hand) altercost(colorless, +1)
text=As long as Trinisphere is untapped, each spell that would cost less than three mana to cast costs three mana to cast. (Additional mana in the cost may be paid with any color of mana or colorless mana. For example, a spell that would cost {1}{B} to cast costs {2}{B} to cast instead.)
mana={3}
type=Artifact
[/card]
[card]
name=Trumpeting Armodon name=Trumpeting Armodon
text={1}{G}: Target creature blocks Trumpeting Armodon this turn if able. text={1}{G}: Target creature blocks Trumpeting Armodon this turn if able.
mana={3}{G} mana={3}{G}
+4 -3
View File
@@ -195,10 +195,11 @@ private:
} }
else if (s == "manacost") else if (s == "manacost")
{ {
int convertedvalue = card->currentZone == card->controller()->game->battlefield ? card->getManaCost()->getConvertedCost():card->model->data->getManaCost()->getConvertedCost();
if (target->currentZone == target->controller()->game->stack)//X is 0 except if it's on the stack if (target->currentZone == target->controller()->game->stack)//X is 0 except if it's on the stack
intValue = target->getManaCost()->getConvertedCost() + target->castX; intValue = target->getManaCost()->getConvertedCost() + target->castX;
else else
intValue = target->getManaCost()->getConvertedCost(); intValue = convertedvalue;
} }
else if (s == "azorius")//devotion blue white else if (s == "azorius")//devotion blue white
{ {
@@ -6360,13 +6361,13 @@ class GenericPaidAbility: public ActivatedAbility
public: public:
MTGAbility * baseAbility; MTGAbility * baseAbility;
ManaCost * optionalCost; ManaCost * optionalCost;
bool asAlternate;
string newName; string newName;
string restrictions; string restrictions;
string baseCost; string baseCost;
string baseAbilityStr; string baseAbilityStr;
GenericPaidAbility(GameObserver* observer, int id, MTGCardInstance * source, Targetable * target,string _newName,string _castRestriction,string _mayCost, string toAdd, ManaCost * cost = NULL); GenericPaidAbility(GameObserver* observer, int id, MTGCardInstance * source, Targetable * target,string _newName,string _castRestriction,string _mayCost, string toAdd, bool asAlternate = false, ManaCost * cost = NULL);
int resolve(); int resolve();
const string getMenuText(); const string getMenuText();
GenericPaidAbility * clone() const; GenericPaidAbility * clone() const;
+2
View File
@@ -253,6 +253,8 @@ public:
int cardistargetted; int cardistargetted;
bool isTargetter(); bool isTargetter();
int cardistargetter; int cardistargetter;
int tmodifier;
int tmodifierb;
void eventattacked(); void eventattacked();
void eventattackedAlone(); void eventattackedAlone();
+2 -1
View File
@@ -235,7 +235,8 @@ class Constants
MYGCREATUREEXILER = 117, MYGCREATUREEXILER = 117,
OPPGCREATUREEXILER = 118, OPPGCREATUREEXILER = 118,
PAYZERO = 119, PAYZERO = 119,
NB_BASIC_ABILITIES = 120, TRINISPHERE = 120,
NB_BASIC_ABILITIES = 121,
RARITY_S = 'S', //Special Rarity RARITY_S = 'S', //Special Rarity
+37 -6
View File
@@ -1146,9 +1146,9 @@ AASetCoin::~AASetCoin()
//paying for an ability as an effect but as a cost //paying for an ability as an effect but as a cost
GenericPaidAbility::GenericPaidAbility(GameObserver* observer, int id, MTGCardInstance * source, GenericPaidAbility::GenericPaidAbility(GameObserver* observer, int id, MTGCardInstance * source,
Targetable * target, string _newName, string _castRestriction, string mayCost, string _toAdd, ManaCost * cost) : Targetable * target, string _newName, string _castRestriction, string mayCost, string _toAdd, bool asAlternate, ManaCost * cost) :
ActivatedAbility(observer, id, source, cost, 0), ActivatedAbility(observer, id, source, cost, 0),
newName(_newName), restrictions(_castRestriction), baseCost(mayCost), baseAbilityStr(_toAdd) newName(_newName), restrictions(_castRestriction), baseCost(mayCost), baseAbilityStr(_toAdd), asAlternate(asAlternate)
{ {
this->GetId(); this->GetId();
baseAbility = NULL; baseAbility = NULL;
@@ -1172,6 +1172,8 @@ int GenericPaidAbility::resolve()
AbilityFactory Af(game); AbilityFactory Af(game);
vector<string> baseAbilityStrSplit = split(baseAbilityStr,'?'); vector<string> baseAbilityStrSplit = split(baseAbilityStr,'?');
vector<MTGAbility*> selection; vector<MTGAbility*> selection;
MTGAbility * nomenuAbility = NULL;
bool nomenu = false;
if (baseAbilityStrSplit.size() > 1) if (baseAbilityStrSplit.size() > 1)
{ {
baseAbility = Af.parseMagicLine(baseAbilityStrSplit[0], this->GetId(), NULL, source); baseAbility = Af.parseMagicLine(baseAbilityStrSplit[0], this->GetId(), NULL, source);
@@ -1200,10 +1202,12 @@ int GenericPaidAbility::resolve()
} }
else else
{ {
nomenu = true;
baseAbility = Af.parseMagicLine(baseAbilityStrSplit[0], this->GetId(), NULL, source); baseAbility = Af.parseMagicLine(baseAbilityStrSplit[0], this->GetId(), NULL, source);
baseAbility->target = target; baseAbility->target = target;
optionalCost = ManaCost::parseManaCost(baseCost, NULL, source); optionalCost = ManaCost::parseManaCost(baseCost, NULL, source);
MTGAbility * set = baseAbility->clone(); MTGAbility * set = baseAbility->clone();
nomenuAbility = baseAbility->clone();
set->oneShot = true; set->oneShot = true;
selection.push_back(set); selection.push_back(set);
} }
@@ -1211,10 +1215,37 @@ int GenericPaidAbility::resolve()
if (selection.size()) if (selection.size())
{ {
bool must = baseAbilityStrSplit.size() > 1 ? true : false; bool must = baseAbilityStrSplit.size() > 1 ? true : false;
MenuAbility * a1 = NEW MenuAbility(game, this->GetId(), target, source, must, selection, NULL, newName); //todo get increased - reduced cost if asAlternate cost to cast using castcard
a1->optionalCosts.push_back(NEW ManaCost(optionalCost)); if(asAlternate)
game->mLayers->actionLayer()->currentActionCard = (MTGCardInstance *)target; {
a1->resolve(); must = true;
//cost increase - reduce + trinisphere effect ability todo...
if(((MTGCardInstance *)target)->getIncreasedManaCost()->getConvertedCost())
optionalCost->add(((MTGCardInstance *)target)->getIncreasedManaCost());
if(((MTGCardInstance *)target)->getReducedManaCost()->getConvertedCost())
optionalCost->remove(((MTGCardInstance *)target)->getReducedManaCost());
//trinisphere effect must be hardcoded...here..
/*if(((MTGCardInstance *)target)->has(Constants::TRINISPHERE))
{
if(optionalCost->getConvertedCost() == 2)
optionalCost->add(Constants::MTG_COLOR_ARTIFACT, 1);
else if(optionalCost->getConvertedCost() == 1)
optionalCost->add(Constants::MTG_COLOR_ARTIFACT, 2);
else if(optionalCost->getConvertedCost() < 1)
optionalCost->add(Constants::MTG_COLOR_ARTIFACT, 3);
}*/
}
if(nomenu && optionalCost->getConvertedCost() < 1)
{
nomenuAbility->resolve();
}
else
{
MenuAbility * a1 = NEW MenuAbility(game, this->GetId(), target, source, must, selection, NULL, newName);
a1->optionalCosts.push_back(NEW ManaCost(optionalCost));
game->mLayers->actionLayer()->currentActionCard = (MTGCardInstance *)target;
a1->resolve();
}
} }
return 1; return 1;
} }
+4 -3
View File
@@ -125,11 +125,12 @@ MTGCardInstance * CardDescriptor::match_or(MTGCardInstance * card)
} }
// Quantified restrictions are always AND-ed: // Quantified restrictions are always AND-ed:
int convertedvalue = card->currentZone == card->controller()->game->battlefield ? card->getManaCost()->getConvertedCost():card->model->data->getManaCost()->getConvertedCost();
if (powerComparisonMode && !valueInRange(powerComparisonMode, card->getPower(), power)) if (powerComparisonMode && !valueInRange(powerComparisonMode, card->getPower(), power))
return NULL; return NULL;
if (toughnessComparisonMode && !valueInRange(toughnessComparisonMode, card->getToughness(), toughness)) if (toughnessComparisonMode && !valueInRange(toughnessComparisonMode, card->getToughness(), toughness))
return NULL; return NULL;
if (manacostComparisonMode && !valueInRange(manacostComparisonMode, card->getManaCost()->getConvertedCost(), convertedManacost)) if (manacostComparisonMode && !valueInRange(manacostComparisonMode, convertedvalue, convertedManacost))
return NULL; return NULL;
if (nameComparisonMode && compareName != card->name) if (nameComparisonMode && compareName != card->name)
return NULL; return NULL;
@@ -165,12 +166,12 @@ MTGCardInstance * CardDescriptor::match_and(MTGCardInstance * card)
if ((mColorExclusions & card->colors) != 0) if ((mColorExclusions & card->colors) != 0)
match = NULL; match = NULL;
} }
int convertedvalue = card->currentZone == card->controller()->game->battlefield ? card->getManaCost()->getConvertedCost():card->model->data->getManaCost()->getConvertedCost();
if (powerComparisonMode && !valueInRange(powerComparisonMode, card->getPower(), power)) if (powerComparisonMode && !valueInRange(powerComparisonMode, card->getPower(), power))
match = NULL; match = NULL;
if (toughnessComparisonMode && !valueInRange(toughnessComparisonMode, card->getToughness(), toughness)) if (toughnessComparisonMode && !valueInRange(toughnessComparisonMode, card->getToughness(), toughness))
match = NULL; match = NULL;
if (manacostComparisonMode && !valueInRange(manacostComparisonMode, card->getManaCost()->getConvertedCost(), convertedManacost)) if (manacostComparisonMode && !valueInRange(manacostComparisonMode, convertedvalue, convertedManacost))
match = NULL; match = NULL;
if(nameComparisonMode && compareName != card->name) if(nameComparisonMode && compareName != card->name)
match = NULL; match = NULL;
+227 -118
View File
@@ -604,8 +604,8 @@ void GameObserver::gameStateBasedEffects()
{ {
for (int c = zone->nb_cards - 1; c >= 0; c--) for (int c = zone->nb_cards - 1; c >= 0; c--)
{ {
zone->cards[c]->cardistargetted = 0; zone->cards[c]->cardistargetted = 0;
zone->cards[c]->cardistargetter = 0; zone->cards[c]->cardistargetter = 0;
} }
} }
}//check for losers if its GAMEOVER clear the stack to allow gamestateeffects to continue }//check for losers if its GAMEOVER clear the stack to allow gamestateeffects to continue
@@ -878,8 +878,90 @@ void GameObserver::gameStateBasedEffects()
enchantmentStatus(); enchantmentStatus();
///////////////////////////// /////////////////////////////
// Check affinity on a card// // Check affinity on a card//
// plus modify costs //
///////////////////////////// /////////////////////////////
Affinity(); Affinity();
//trinisphere?
/*for (int td = 0; td < 2; td++)
{
MTGGameZone * dzones[] = { players[td]->game->graveyard, players[td]->game->hand, players[td]->game->library, players[td]->game->exile };
for (int tk = 0; tk < 4; tk++)
{
MTGGameZone * zone = dzones[tk];
for (int ct = zone->nb_cards - 1; ct >= 0; ct--)
{
if(zone->cards[ct]->has(Constants::TRINISPHERE))
{
if(zone->cards[ct]->getManaCost()->getConvertedCost() == 2)
{
zone->cards[ct]->getManaCost()->add(Constants::MTG_COLOR_ARTIFACT, 1);
zone->cards[ct]->tmodifier = 1;
}
else if(zone->cards[ct]->getManaCost()->getConvertedCost() == 1)
{
zone->cards[ct]->getManaCost()->add(Constants::MTG_COLOR_ARTIFACT, 2);
zone->cards[ct]->tmodifier = 2;
}
else if(zone->cards[ct]->getManaCost()->getConvertedCost() < 1)
{
zone->cards[ct]->getManaCost()->add(Constants::MTG_COLOR_ARTIFACT, 3);
zone->cards[ct]->tmodifier = 3;
}
//alternate
if(zone->cards[ct]->getManaCost()->getAlternative() && zone->cards[ct]->getManaCost()->getAlternative()->getConvertedCost() == 2)
{
zone->cards[ct]->getManaCost()->getAlternative()->add(Constants::MTG_COLOR_ARTIFACT, 1);
zone->cards[ct]->tmodifierb = 1;
}
else if(zone->cards[ct]->getManaCost()->getAlternative() && zone->cards[ct]->getManaCost()->getAlternative()->getConvertedCost() == 1)
{
zone->cards[ct]->getManaCost()->getAlternative()->add(Constants::MTG_COLOR_ARTIFACT, 2);
zone->cards[ct]->tmodifierb = 2;
}
else if(zone->cards[ct]->getManaCost()->getAlternative() && zone->cards[ct]->getManaCost()->getAlternative()->getConvertedCost() < 1)
{
zone->cards[ct]->getManaCost()->getAlternative()->add(Constants::MTG_COLOR_ARTIFACT, 3);
zone->cards[ct]->tmodifierb = 3;
}
}
else
{
if(zone->cards[ct]->tmodifier == 1)
{
zone->cards[ct]->getManaCost()->remove(Constants::MTG_COLOR_ARTIFACT, 1);
zone->cards[ct]->tmodifier = 0;
}
else if(zone->cards[ct]->tmodifier == 2)
{
zone->cards[ct]->getManaCost()->remove(Constants::MTG_COLOR_ARTIFACT, 2);
zone->cards[ct]->tmodifier = 0;
}
else if(zone->cards[ct]->tmodifier == 3)
{
zone->cards[ct]->getManaCost()->remove(Constants::MTG_COLOR_ARTIFACT, 3);
zone->cards[ct]->tmodifier = 0;
}
//alternate
if(zone->cards[ct]->tmodifierb == 1)
{
zone->cards[ct]->getManaCost()->getAlternative()->remove(Constants::MTG_COLOR_ARTIFACT, 1);
zone->cards[ct]->tmodifierb = 0;
}
else if(zone->cards[ct]->tmodifierb == 2)
{
zone->cards[ct]->getManaCost()->getAlternative()->remove(Constants::MTG_COLOR_ARTIFACT, 2);
zone->cards[ct]->tmodifierb = 0;
}
else if(zone->cards[ct]->tmodifierb == 3)
{
zone->cards[ct]->getManaCost()->getAlternative()->remove(Constants::MTG_COLOR_ARTIFACT, 3);
zone->cards[ct]->tmodifierb = 0;
}
}
}
}
}*/
//end trinisphere
///////////////////////////////////// /////////////////////////////////////
// Check colored statuses on cards // // Check colored statuses on cards //
///////////////////////////////////// /////////////////////////////////////
@@ -954,46 +1036,140 @@ void GameObserver::enchantmentStatus()
void GameObserver::Affinity() void GameObserver::Affinity()
{ {
for (int i = 0; i < 2; i++) for (int dd = 0; dd < 2; dd++)
{ {
MTGGameZone * zone = players[i]->game->hand; MTGGameZone * dzones[] = { players[dd]->game->graveyard, players[dd]->game->hand, players[dd]->game->library, players[dd]->game->exile };
for (int k = zone->nb_cards - 1; k >= 0; k--) for (int kk = 0; kk < 4; kk++)
{ {
MTGCardInstance * card = zone->cards[k]; MTGGameZone * zone = dzones[kk];
if (!card) for (int cc = zone->nb_cards - 1; cc >= 0; cc--)
continue; {//start
MTGCardInstance * card = zone->cards[cc];
if (!card)
continue;
int color = 0; int color = 0;
string type = ""; string type = "";
//only do any of the following if a card with the stated ability is in your hand. //only do any of the following if a card with the stated ability is in your hand.
ManaCost * original = NEW ManaCost(); ManaCost * original = NEW ManaCost();
original->copy(card->model->data->getManaCost()); ManaCost * alternate = NEW ManaCost();
//have to run alter cost before affinity or the 2 cancel each other out. original->copy(card->model->data->getManaCost());
if(card->getIncreasedManaCost()->getConvertedCost()||card->getReducedManaCost()->getConvertedCost()) alternate->copy(card->model->data->getManaCost()->getAlternative());
{ if (card->has(Constants::PAYZERO))
if(card->getIncreasedManaCost()->getConvertedCost()) original = ManaCost::parseManaCost("{0}",NULL,card);//can't figure out 2 or more alternative...
original->add(card->getIncreasedManaCost()); //have to run alter cost before affinity or the 2 cancel each other out.
if(card->getReducedManaCost()->getConvertedCost()) if(card->getIncreasedManaCost()->getConvertedCost()||card->getReducedManaCost()->getConvertedCost())
original->remove(card->getReducedManaCost());
card->getManaCost()->copy(original);
if(card->getManaCost()->extraCosts)
{ {
for(unsigned int i = 0; i < card->getManaCost()->extraCosts->costs.size();i++) if(card->getIncreasedManaCost()->getConvertedCost())
{ {
card->getManaCost()->extraCosts->costs[i]->setSource(card); original->add(card->getIncreasedManaCost());
for(int kc = Constants::MTG_COLOR_ARTIFACT; kc < Constants::NB_Colors;kc++)
{
if (card->getManaCost()->getAlternative())
{
alternate->add(kc,card->getIncreasedManaCost()->getCost(kc));
}
}
}
if(card->getReducedManaCost()->getConvertedCost())
{
original->remove(card->getReducedManaCost());
for(int kc = Constants::MTG_COLOR_ARTIFACT; kc < Constants::NB_Colors;kc++)
{
if (card->getManaCost()->getAlternative())
{
alternate->remove(kc,card->getReducedManaCost()->getCost(kc));
}
}
}
card->getManaCost()->copy(original);
card->getManaCost()->setAlternative(alternate);
if(card->getManaCost()->extraCosts)
{
for(unsigned int i = 0; i < card->getManaCost()->extraCosts->costs.size();i++)
{
card->getManaCost()->extraCosts->costs[i]->setSource(card);
}
} }
} }
} int reducem = 0;
int reducem = 0; bool resetCost = false;
bool resetCost = false; for(unsigned int na = 0; na < card->cardsAbilities.size();na++)
for(unsigned int na = 0; na < card->cardsAbilities.size();na++)
{
ANewAffinity * newAff = dynamic_cast<ANewAffinity*>(card->cardsAbilities[na]);
if(newAff)
{ {
if(!resetCost) ANewAffinity * newAff = dynamic_cast<ANewAffinity*>(card->cardsAbilities[na]);
if(newAff)
{ {
resetCost = true; if(!resetCost)
{
resetCost = true;
card->getManaCost()->copy(original);
if(card->getManaCost()->extraCosts)
{
for(unsigned int i = 0; i < card->getManaCost()->extraCosts->costs.size();i++)
{
card->getManaCost()->extraCosts->costs[i]->setSource(card);
}
}
}
TargetChooserFactory tf(this);
TargetChooser * tcn = tf.createTargetChooser(newAff->tcString,card,NULL);
for (int w = 0; w < 2; ++w)
{
Player *p = this->players[w];
MTGGameZone * zones[] = { p->game->inPlay, p->game->graveyard, p->game->hand, p->game->library, p->game->stack, p->game->exile };
for (int k = 0; k < 6; k++)
{
MTGGameZone * z = zones[k];
if (tcn->targetsZone(z))
{
reducem += z->countByCanTarget(tcn);
}
}
}
SAFE_DELETE(tcn);
ManaCost * removingCost = ManaCost::parseManaCost(newAff->manaString);
for(int j = 0; j < reducem; j++)
card->getManaCost()->remove(removingCost);
SAFE_DELETE(removingCost);
}
}
if(card->has(Constants::AFFINITYARTIFACTS)||
card->has(Constants::AFFINITYFOREST)||
card->has(Constants::AFFINITYGREENCREATURES)||
card->has(Constants::AFFINITYISLAND)||
card->has(Constants::AFFINITYMOUNTAIN)||
card->has(Constants::AFFINITYPLAINS)||
card->has(Constants::AFFINITYSWAMP)){
if (card->has(Constants::AFFINITYARTIFACTS))
{
type = "artifact";
}
else if (card->has(Constants::AFFINITYSWAMP))
{
type = "swamp";
}
else if (card->has(Constants::AFFINITYMOUNTAIN))
{
type = "mountain";
}
else if (card->has(Constants::AFFINITYPLAINS))
{
type = "plains";
}
else if (card->has(Constants::AFFINITYISLAND))
{
type = "island";
}
else if (card->has(Constants::AFFINITYFOREST))
{
type = "forest";
}
else if (card->has(Constants::AFFINITYGREENCREATURES))
{
color = 1;
type = "creature";
}
card->getManaCost()->copy(original); card->getManaCost()->copy(original);
if(card->getManaCost()->extraCosts) if(card->getManaCost()->extraCosts)
{ {
@@ -1002,94 +1178,27 @@ void GameObserver::Affinity()
card->getManaCost()->extraCosts->costs[i]->setSource(card); card->getManaCost()->extraCosts->costs[i]->setSource(card);
} }
} }
} int reduce = 0;
TargetChooserFactory tf(this); if(card->has(Constants::AFFINITYGREENCREATURES))
TargetChooser * tcn = tf.createTargetChooser(newAff->tcString,card,NULL);
for (int w = 0; w < 2; ++w)
{
Player *p = this->players[w];
MTGGameZone * zones[] = { p->game->inPlay, p->game->graveyard, p->game->hand, p->game->library, p->game->stack, p->game->exile };
for (int k = 0; k < 6; k++)
{ {
MTGGameZone * z = zones[k]; TargetChooserFactory tf(this);
if (tcn->targetsZone(z)) TargetChooser * tc = tf.createTargetChooser("creature[green]",NULL);
{ reduce = card->controller()->game->battlefield->countByCanTarget(tc);
reducem += z->countByCanTarget(tcn); SAFE_DELETE(tc);
}
} }
} else
SAFE_DELETE(tcn); {
ManaCost * removingCost = ManaCost::parseManaCost(newAff->manaString); reduce = card->controller()->game->battlefield->countByType(type);
for(int j = 0; j < reducem; j++) }
card->getManaCost()->remove(removingCost); for(int i = 0; i < reduce;i++)
SAFE_DELETE(removingCost); {
if(card->getManaCost()->getCost(color) > 0)
card->getManaCost()->remove(color,1);
}
} }
} SAFE_DELETE(original);
if(card->has(Constants::AFFINITYARTIFACTS)|| }//end
card->has(Constants::AFFINITYFOREST)||
card->has(Constants::AFFINITYGREENCREATURES)||
card->has(Constants::AFFINITYISLAND)||
card->has(Constants::AFFINITYMOUNTAIN)||
card->has(Constants::AFFINITYPLAINS)||
card->has(Constants::AFFINITYSWAMP)){
if (card->has(Constants::AFFINITYARTIFACTS))
{
type = "artifact";
}
else if (card->has(Constants::AFFINITYSWAMP))
{
type = "swamp";
}
else if (card->has(Constants::AFFINITYMOUNTAIN))
{
type = "mountain";
}
else if (card->has(Constants::AFFINITYPLAINS))
{
type = "plains";
}
else if (card->has(Constants::AFFINITYISLAND))
{
type = "island";
}
else if (card->has(Constants::AFFINITYFOREST))
{
type = "forest";
}
else if (card->has(Constants::AFFINITYGREENCREATURES))
{
color = 1;
type = "creature";
}
card->getManaCost()->copy(original);
if(card->getManaCost()->extraCosts)
{
for(unsigned int i = 0; i < card->getManaCost()->extraCosts->costs.size();i++)
{
card->getManaCost()->extraCosts->costs[i]->setSource(card);
}
}
int reduce = 0;
if(card->has(Constants::AFFINITYGREENCREATURES))
{
TargetChooserFactory tf(this);
TargetChooser * tc = tf.createTargetChooser("creature[green]",NULL);
reduce = card->controller()->game->battlefield->countByCanTarget(tc);
SAFE_DELETE(tc);
}
else
{
reduce = card->controller()->game->battlefield->countByType(type);
}
for(int i = 0; i < reduce;i++)
{
if(card->getManaCost()->getCost(color) > 0)
card->getManaCost()->remove(color,1);
}
}
SAFE_DELETE(original);
} }
} }
} }
+6 -3
View File
@@ -1079,6 +1079,7 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
MTGGameZone * dest) MTGGameZone * dest)
{ {
size_t found; size_t found;
bool asAlternate = false;
trim(s); trim(s);
//TODO This block redundant with calling function //TODO This block redundant with calling function
if (!card && spell) if (!card && spell)
@@ -1088,7 +1089,9 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
MTGCardInstance * target = card->target; MTGCardInstance * target = card->target;
if (!target) if (!target)
target = card; target = card;
//pay and castcard?
if(s.find("pay(") != string::npos || s.find("pay[[") != string::npos && s.find("castcard(restricted") != string::npos)
asAlternate = true;
//MTG Specific rules //MTG Specific rules
//adds the bonus credit system //adds the bonus credit system
found = s.find("bonusrule"); found = s.find("bonusrule");
@@ -1586,7 +1589,7 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
vector<string> splitMayPay = parseBetween(s, "pay(", ")", true); vector<string> splitMayPay = parseBetween(s, "pay(", ")", true);
if(splitMayPay.size()) if(splitMayPay.size())
{ {
GenericPaidAbility * a = NEW GenericPaidAbility(observer, id, card, target,newName,castRestriction,splitMayPay[1],storedPayString); GenericPaidAbility * a = NEW GenericPaidAbility(observer, id, card, target,newName,castRestriction,splitMayPay[1],storedPayString,asAlternate);
a->oneShot = 1; a->oneShot = 1;
a->canBeInterrupted = false; a->canBeInterrupted = false;
return a; return a;
@@ -2091,7 +2094,7 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
vector<string> splitMayPaysub = parseBetween(s, "pay[[","]]", true); vector<string> splitMayPaysub = parseBetween(s, "pay[[","]]", true);
if (splitMayPaysub.size()) if (splitMayPaysub.size())
{ {
GenericPaidAbility * a = NEW GenericPaidAbility(observer, id, card, target,newName,castRestriction,splitMayPaysub[1],storedPayString); GenericPaidAbility * a = NEW GenericPaidAbility(observer, id, card, target,newName,castRestriction,splitMayPaysub[1],storedPayString,asAlternate);
a->oneShot = 1; a->oneShot = 1;
a->canBeInterrupted = false; a->canBeInterrupted = false;
return a; return a;
+2
View File
@@ -65,6 +65,8 @@ MTGCardInstance::MTGCardInstance(MTGCard * card, MTGPlayerCards * arg_belongs_to
LKItoughness = toughness; LKItoughness = toughness;
cardistargetted = 0; cardistargetted = 0;
cardistargetter = 0; cardistargetter = 0;
tmodifier = 0;
tmodifierb = 0;
} }
MTGCardInstance * MTGCardInstance::createSnapShot() MTGCardInstance * MTGCardInstance::createSnapShot()
+2 -1
View File
@@ -148,7 +148,8 @@ const char* Constants::MTGBasicAbilities[] = {
"protectionfromcoloredspells", "protectionfromcoloredspells",
"mygcreatureexiler", "mygcreatureexiler",
"oppgcreatureexiler", "oppgcreatureexiler",
"payzero" "payzero",
"trinisphere"
}; };
map<string,int> Constants::MTGBasicAbilitiesMap; map<string,int> Constants::MTGBasicAbilitiesMap;
+1 -4
View File
@@ -1139,8 +1139,6 @@ int MTGPlayFromGraveyardRule::isReactingToClick(MTGCardInstance * card, ManaCost
{ {
Player * player = game->currentlyActing(); Player * player = game->currentlyActing();
ManaCost * cost = card->getManaCost(); ManaCost * cost = card->getManaCost();
if (card->has(Constants::PAYZERO))
cost = ManaCost::parseManaCost("{0}",NULL,NULL);
if (!player->game->graveyard->hasCard(card)) if (!player->game->graveyard->hasCard(card))
return 0; return 0;
@@ -1156,8 +1154,7 @@ int MTGPlayFromGraveyardRule::reactToClick(MTGCardInstance * card)
return 0; return 0;
ManaCost * cost = card->getManaCost(); ManaCost * cost = card->getManaCost();
if (card->has(Constants::PAYZERO))
cost = ManaCost::parseManaCost("{0}",NULL,NULL);
card->paymenttype = MTGAbility::PUT_INTO_PLAY; card->paymenttype = MTGAbility::PUT_INTO_PLAY;
return MTGAlternativeCostRule::reactToClick(card, cost, ManaCost::MANA_PAID); return MTGAlternativeCostRule::reactToClick(card, cost, ManaCost::MANA_PAID);