altercost should affect retrace, flashback, buyback costs

This commit is contained in:
Anthony Calosa
2015-11-04 06:41:59 +08:00
parent 58b032627e
commit 60ba4e3eeb
11 changed files with 73 additions and 96 deletions

View File

@@ -122,8 +122,6 @@ class GameObserver{
void gameStateBasedEffects();
void enchantmentStatus();
void Affinity();
void ComputeTrinisphere();
void RemoveTrinisphere(MTGCardInstance * card);
void addObserver(MTGAbility * observer);
bool removeObserver(ActionElement * observer);
void startGame(GameType, Rules * rules);

View File

@@ -213,6 +213,7 @@ public:
COUNTERS = 30,
PUT_INTO_PLAY_WITH_KICKER = 31,
STANDARD_FIZZLER = 32,
CASTINGRAVEYARD_COST = 33,
};
};

View File

@@ -253,9 +253,25 @@ public:
int cardistargetted;
bool isTargetter();
int cardistargetter;
int tmodifier;
int tmodifierb;
int myconvertedcost;
ManaCost * computeNewCost(MTGCardInstance * card,ManaCost * oldCost)
{
if(card->isLand())
return oldCost;
if(!card)
return NULL;
//i don't know why this method doesn't affect cards in hand, but is working on other zones....//
//pay zero costs//
//kicker???...//
//morph cost todo//
//trinisphere must be here below//
if(card->has(Constants::TRINISPHERE))
for(int jj = oldCost->getConvertedCost(); jj < 3; jj++)
oldCost->add(Constants::MTG_COLOR_ARTIFACT, 1);
return oldCost;
};
void eventattacked();
void eventattackedAlone();

View File

@@ -236,7 +236,8 @@ class Constants
OPPGCREATUREEXILER = 118,
PAYZERO = 119,
TRINISPHERE = 120,
NB_BASIC_ABILITIES = 121,
CANPLAYFROMEXILE = 121,
NB_BASIC_ABILITIES = 122,
RARITY_S = 'S', //Special Rarity

View File

@@ -76,6 +76,8 @@ public:
MTGPutInPlayRule(GameObserver* observer, int _id);
const string getMenuText()
{
if(game && game->gameType() == GAME_TYPE_MOMIR)
return "Play Land";
return "Cast Card Normally";
}
virtual MTGPutInPlayRule * clone() const;

View File

@@ -47,7 +47,8 @@ public:
MANA_PAID_WITH_FLASHBACK = 5,
MANA_PAID_WITH_RETRACE = 6,
MANA_PAID_WITH_MORPH = 7,
MANA_PAID_WITH_SUSPEND = 8
MANA_PAID_WITH_SUSPEND = 8,
MANA_PAID_WITH_OTHERCOST = 9
};
ExtraCosts * extraCosts;

View File

@@ -301,7 +301,7 @@ bool Spell::FullfilledAlternateCost(const int &costType)
hasFullfilledAlternateCost = (payResult == ManaCost::MANA_PAID_WITH_RETRACE);
break;
case ManaCost::MANA_PAID_WITH_SUSPEND:
hasFullfilledAlternateCost = (payResult == ManaCost::MANA_PAID_WITH_RETRACE);
hasFullfilledAlternateCost = (payResult == ManaCost::MANA_PAID_WITH_SUSPEND);
break;
}

View File

@@ -885,9 +885,6 @@ void GameObserver::gameStateBasedEffects()
// plus modify costs //
/////////////////////////////
Affinity();
//trinisphere? buggy...
//ComputeTrinisphere();
//end trinisphere
/////////////////////////////////////
// Check colored statuses on cards //
/////////////////////////////////////
@@ -979,10 +976,14 @@ void GameObserver::Affinity()
//only do any of the following if a card with the stated ability is in your hand.
ManaCost * original = NEW ManaCost();
ManaCost * alternate = NEW ManaCost();
ManaCost * buyback = NEW ManaCost();
ManaCost * flashback = NEW ManaCost();
ManaCost * retrace = NEW ManaCost();
original->copy(card->model->data->getManaCost());
alternate->copy(card->model->data->getManaCost()->getAlternative());
if (card->has(Constants::PAYZERO))
original = ManaCost::parseManaCost("{0}",NULL,card);//can't figure out 2 or more alternative...
buyback->copy(card->model->data->getManaCost()->getBuyback());
flashback->copy(card->model->data->getManaCost()->getFlashback());
retrace->copy(card->model->data->getManaCost()->getRetrace());
//have to run alter cost before affinity or the 2 cancel each other out.
if(card->getIncreasedManaCost()->getConvertedCost()||card->getReducedManaCost()->getConvertedCost())
{
@@ -995,10 +996,22 @@ void GameObserver::Affinity()
{
alternate->add(kc,card->getIncreasedManaCost()->getCost(kc));
}
if (card->getManaCost()->getBuyback())
{
buyback->add(kc,card->getIncreasedManaCost()->getCost(kc));
}
if (card->getManaCost()->getFlashback())
{
flashback->add(kc,card->getIncreasedManaCost()->getCost(kc));
}
if (card->getManaCost()->getRetrace())
{
retrace->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++)
{
@@ -1006,12 +1019,30 @@ void GameObserver::Affinity()
{
alternate->remove(kc,card->getReducedManaCost()->getCost(kc));
}
if (card->getManaCost()->getBuyback())
{
buyback->remove(kc,card->getIncreasedManaCost()->getCost(kc));
}
if (card->getManaCost()->getFlashback())
{
flashback->remove(kc,card->getIncreasedManaCost()->getCost(kc));
}
if (card->getManaCost()->getRetrace())
{
retrace->remove(kc,card->getIncreasedManaCost()->getCost(kc));
}
}
}
if(card->getManaCost())
card->getManaCost()->copy(original);
if(card->getManaCost()->getAlternative())
card->getManaCost()->setAlternative(alternate);
card->getManaCost()->setAlternative(alternate);
if(card->getManaCost()->getBuyback())
card->getManaCost()->setBuyback(buyback);
if(card->getManaCost()->getFlashback())
card->getManaCost()->setFlashback(flashback);
if(card->getManaCost()->getRetrace())
card->getManaCost()->setRetrace(retrace);
if(card->getManaCost()->extraCosts)
{
for(unsigned int i = 0; i < card->getManaCost()->extraCosts->costs.size();i++)
@@ -1068,7 +1099,8 @@ void GameObserver::Affinity()
card->has(Constants::AFFINITYISLAND)||
card->has(Constants::AFFINITYMOUNTAIN)||
card->has(Constants::AFFINITYPLAINS)||
card->has(Constants::AFFINITYSWAMP)){
card->has(Constants::AFFINITYSWAMP))
{
if (card->has(Constants::AFFINITYARTIFACTS))
{
type = "artifact";
@@ -1123,86 +1155,13 @@ void GameObserver::Affinity()
if(card->getManaCost()->getCost(color) > 0)
card->getManaCost()->remove(color,1);
}
}
SAFE_DELETE(original);
}
//SAFE_DELETE(original);
}//end
}
}
}
void GameObserver::ComputeTrinisphere()
{
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;
}
if(zone->cards[ct]->getManaCost()->getAlternative())
{
ManaCost * currentAlternate = NEW ManaCost();
currentAlternate->copy(zone->cards[ct]->getManaCost()->getAlternative());
if(zone->cards[ct]->getManaCost()->getAlternative()->getConvertedCost() == 2)
zone->cards[ct]->tmodifierb = 1;
else if(zone->cards[ct]->getManaCost()->getAlternative()->getConvertedCost() == 1)
zone->cards[ct]->tmodifierb = 2;
else if(zone->cards[ct]->getManaCost()->getAlternative()->getConvertedCost() < 1)
zone->cards[ct]->tmodifierb = 3;
currentAlternate->add(Constants::MTG_COLOR_ARTIFACT, zone->cards[ct]->tmodifierb);
zone->cards[ct]->getManaCost()->setAlternative(currentAlternate);
}
}
else
RemoveTrinisphere(zone->cards[ct]);
if(zone->cards[ct]->getManaCost()->extraCosts)
{
for(unsigned int i = 0; i < zone->cards[ct]->getManaCost()->extraCosts->costs.size();i++)
{
zone->cards[ct]->getManaCost()->extraCosts->costs[i]->setSource(zone->cards[ct]);
}
}
}
}
}
}
void GameObserver::RemoveTrinisphere(MTGCardInstance * card)
{
if(card->has(Constants::TRINISPHERE))
return;
if(card->tmodifier)
{
card->getManaCost()->remove(Constants::MTG_COLOR_ARTIFACT, card->tmodifier);
card->tmodifier = 0;
}
if(card->getManaCost()->getAlternative() && card->tmodifierb)
{
ManaCost * newalternate = NEW ManaCost();
newalternate->copy(card->getManaCost()->getAlternative());
newalternate->remove(Constants::MTG_COLOR_ARTIFACT, card->tmodifierb);
card->getManaCost()->setAlternative(newalternate);
card->tmodifierb = 0;
}
}
void GameObserver::Render()
{
if(mLayers)

View File

@@ -65,8 +65,6 @@ MTGCardInstance::MTGCardInstance(MTGCard * card, MTGPlayerCards * arg_belongs_to
LKItoughness = toughness;
cardistargetted = 0;
cardistargetter = 0;
tmodifier = 0;
tmodifierb = 0;
myconvertedcost = getManaCost()->getConvertedCost();
}

View File

@@ -149,7 +149,8 @@ const char* Constants::MTGBasicAbilities[] = {
"mygcreatureexiler",
"oppgcreatureexiler",
"payzero",
"trinisphere"
"trinisphere",
"canplayfromexile"
};
map<string,int> Constants::MTGBasicAbilitiesMap;

View File

@@ -1132,7 +1132,7 @@ MTGMorphCostRule * MTGMorphCostRule::clone() const
MTGPlayFromGraveyardRule::MTGPlayFromGraveyardRule(GameObserver* observer, int _id) :
MTGAlternativeCostRule(observer, _id)
{
aType = MTGAbility::PUT_INTO_PLAY;
aType = MTGAbility::CASTINGRAVEYARD_COST;
}
int MTGPlayFromGraveyardRule::isReactingToClick(MTGCardInstance * card, ManaCost * mana)
@@ -1155,9 +1155,9 @@ int MTGPlayFromGraveyardRule::reactToClick(MTGCardInstance * card)
ManaCost * cost = card->getManaCost();
card->paymenttype = MTGAbility::PUT_INTO_PLAY;
card->paymenttype = MTGAbility::CASTINGRAVEYARD_COST;
return MTGAlternativeCostRule::reactToClick(card, cost, ManaCost::MANA_PAID);
return MTGAlternativeCostRule::reactToClick(card, cost, ManaCost::MANA_PAID_WITH_OTHERCOST);
}
ostream& MTGPlayFromGraveyardRule::toString(ostream& out) const