removed calls to ManaCost::init() as all but two are actually necessary.
moved init() from ManaCost to a private call changed ManaPool method init() to Empty() to better represent what it does. renamed ManaCost::reinit to resetCosts() as reinit sounds like your are returning the ManaCost object back to initial state which is not what happens. Only the cost related members are reset, the bool isMulti is left alone
This commit is contained in:
@@ -21,11 +21,12 @@ class ManaCost
|
|||||||
friend std::ostream& operator<<(std::ostream& out, ManaCost& m);
|
friend std::ostream& operator<<(std::ostream& out, ManaCost& m);
|
||||||
friend std::ostream& operator<<(std::ostream& out, ManaCost* m);
|
friend std::ostream& operator<<(std::ostream& out, ManaCost* m);
|
||||||
friend std::ostream& operator<<(std::ostream& out, ManaCost m);
|
friend std::ostream& operator<<(std::ostream& out, ManaCost m);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::vector<int8_t> cost;
|
std::vector<int8_t> cost;
|
||||||
std::vector<ManaCostHybrid> hybrids;
|
std::vector<ManaCostHybrid> hybrids;
|
||||||
|
|
||||||
|
virtual void init();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum
|
enum
|
||||||
@@ -52,8 +53,7 @@ public:
|
|||||||
string alternativeName;
|
string alternativeName;
|
||||||
bool isMulti;
|
bool isMulti;
|
||||||
static ManaCost * parseManaCost(string value, ManaCost * _manacost = NULL, MTGCardInstance * c = NULL);
|
static ManaCost * parseManaCost(string value, ManaCost * _manacost = NULL, MTGCardInstance * c = NULL);
|
||||||
virtual void init();
|
virtual void resetCosts();
|
||||||
virtual void reinit();
|
|
||||||
void x();
|
void x();
|
||||||
int hasX();
|
int hasX();
|
||||||
int hasAnotherCost();
|
int hasAnotherCost();
|
||||||
@@ -108,7 +108,7 @@ class ManaPool:public ManaCost{
|
|||||||
protected:
|
protected:
|
||||||
Player * player;
|
Player * player;
|
||||||
public:
|
public:
|
||||||
void init();
|
void Empty();
|
||||||
ManaPool(Player * player);
|
ManaPool(Player * player);
|
||||||
ManaPool(ManaCost * _manaCost, Player * player);
|
ManaPool(ManaCost * _manaCost, Player * player);
|
||||||
int remove (int color, int value);
|
int remove (int color, int value);
|
||||||
|
|||||||
@@ -70,7 +70,6 @@ AIHint * AIHints::getByCondition (string condition)
|
|||||||
|
|
||||||
bool AIHints::HintSaysDontAttack(GameObserver* observer,MTGCardInstance * card)
|
bool AIHints::HintSaysDontAttack(GameObserver* observer,MTGCardInstance * card)
|
||||||
{
|
{
|
||||||
int count = 0;
|
|
||||||
TargetChooserFactory tfc(observer);
|
TargetChooserFactory tfc(observer);
|
||||||
TargetChooser * hintTc = NULL;
|
TargetChooser * hintTc = NULL;
|
||||||
for(unsigned int i = 0; i < hints.size();i++)
|
for(unsigned int i = 0; i < hints.size();i++)
|
||||||
|
|||||||
@@ -603,7 +603,7 @@ int OrderedAIAction::getEfficiency()
|
|||||||
//Decrease chance of using ability if there is an extra cost to use the ability, ignore tap
|
//Decrease chance of using ability if there is an extra cost to use the ability, ignore tap
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (MTGPutInPlayRule * pip = dynamic_cast<MTGPutInPlayRule *>(a))
|
if (dynamic_cast<MTGPutInPlayRule *>(a))
|
||||||
{
|
{
|
||||||
efficiency += 65;
|
efficiency += 65;
|
||||||
}
|
}
|
||||||
@@ -931,10 +931,8 @@ vector<MTGAbility*> AIPlayerBaka::canPayMana(MTGCardInstance * target,ManaCost *
|
|||||||
if (!used[card] && amp->isReactingToClick(card) && amp->output->getConvertedCost() >= 1)
|
if (!used[card] && amp->isReactingToClick(card) && amp->output->getConvertedCost() >= 1)
|
||||||
{
|
{
|
||||||
ManaCost * check = NEW ManaCost();
|
ManaCost * check = NEW ManaCost();
|
||||||
check->init();
|
|
||||||
check->add(k,cost->getCost(k));
|
check->add(k,cost->getCost(k));
|
||||||
ManaCost * checkResult = NEW ManaCost();
|
ManaCost * checkResult = NEW ManaCost();
|
||||||
checkResult->init();
|
|
||||||
checkResult->add(k,result->getCost(k));
|
checkResult->add(k,result->getCost(k));
|
||||||
if(!(checkResult->canAfford(check)))
|
if(!(checkResult->canAfford(check)))
|
||||||
{
|
{
|
||||||
@@ -979,10 +977,8 @@ vector<MTGAbility*> AIPlayerBaka::canPayMana(MTGCardInstance * target,ManaCost *
|
|||||||
if (!used[card] && amp->isReactingToClick(card) && amp->output->getConvertedCost() >= 1)
|
if (!used[card] && amp->isReactingToClick(card) && amp->output->getConvertedCost() >= 1)
|
||||||
{
|
{
|
||||||
ManaCost * check = NEW ManaCost();
|
ManaCost * check = NEW ManaCost();
|
||||||
check->init();
|
|
||||||
check->add(foundColor1?hybridCost->color1:hybridCost->color2,foundColor1?hybridCost->value1:hybridCost->value2);
|
check->add(foundColor1?hybridCost->color1:hybridCost->color2,foundColor1?hybridCost->value1:hybridCost->value2);
|
||||||
ManaCost * checkResult = NEW ManaCost();
|
ManaCost * checkResult = NEW ManaCost();
|
||||||
checkResult->init();
|
|
||||||
checkResult->add(foundColor1?hybridCost->color1:hybridCost->color2,result->getCost(foundColor1?hybridCost->color1:hybridCost->color2));
|
checkResult->add(foundColor1?hybridCost->color1:hybridCost->color2,result->getCost(foundColor1?hybridCost->color1:hybridCost->color2));
|
||||||
if(((foundColor1 && !foundColor2)||(!foundColor1 && foundColor2)) &&!(checkResult->canAfford(check)))
|
if(((foundColor1 && !foundColor2)||(!foundColor1 && foundColor2)) &&!(checkResult->canAfford(check)))
|
||||||
{
|
{
|
||||||
@@ -1004,8 +1000,6 @@ vector<MTGAbility*> AIPlayerBaka::canPayMana(MTGCardInstance * target,ManaCost *
|
|||||||
{
|
{
|
||||||
ManaCost * check = NEW ManaCost();
|
ManaCost * check = NEW ManaCost();
|
||||||
ManaCost * checkResult = NEW ManaCost();
|
ManaCost * checkResult = NEW ManaCost();
|
||||||
check->init();
|
|
||||||
checkResult->init();
|
|
||||||
for (int k = 1; k < Constants::NB_Colors; k++)
|
for (int k = 1; k < Constants::NB_Colors; k++)
|
||||||
{
|
{
|
||||||
check->add(k,cost->getCost(k));
|
check->add(k,cost->getCost(k));
|
||||||
@@ -1104,10 +1098,8 @@ vector<MTGAbility*> AIPlayerBaka::canPaySunBurst(ManaCost * cost)
|
|||||||
if (!used[card] && amp->isReactingToClick(card) && amp->output->getConvertedCost() >= 1)
|
if (!used[card] && amp->isReactingToClick(card) && amp->output->getConvertedCost() >= 1)
|
||||||
{
|
{
|
||||||
ManaCost * check = NEW ManaCost();
|
ManaCost * check = NEW ManaCost();
|
||||||
check->init();
|
|
||||||
check->add(k,1);
|
check->add(k,1);
|
||||||
ManaCost * checkResult = NEW ManaCost();
|
ManaCost * checkResult = NEW ManaCost();
|
||||||
checkResult->init();
|
|
||||||
checkResult->add(k,result->getCost(k));
|
checkResult->add(k,result->getCost(k));
|
||||||
if(!(checkResult->canAfford(check)))
|
if(!(checkResult->canAfford(check)))
|
||||||
{
|
{
|
||||||
@@ -1340,7 +1332,6 @@ int AIPlayerBaka::selectAbility()
|
|||||||
if (abilityPayment.size())
|
if (abilityPayment.size())
|
||||||
{
|
{
|
||||||
fullPayment = NEW ManaCost();
|
fullPayment = NEW ManaCost();
|
||||||
fullPayment->init();
|
|
||||||
for(int ch = 0; ch < int(abilityPayment.size());ch++)
|
for(int ch = 0; ch < int(abilityPayment.size());ch++)
|
||||||
{
|
{
|
||||||
AManaProducer * ampp = dynamic_cast<AManaProducer*> (abilityPayment[ch]);
|
AManaProducer * ampp = dynamic_cast<AManaProducer*> (abilityPayment[ch]);
|
||||||
|
|||||||
@@ -1064,7 +1064,7 @@ int AAFlip::resolve()
|
|||||||
_target->types = myFlip->types;
|
_target->types = myFlip->types;
|
||||||
_target->text = myFlip->text;
|
_target->text = myFlip->text;
|
||||||
_target->formattedText = myFlip->formattedText;
|
_target->formattedText = myFlip->formattedText;
|
||||||
ActionLayer * al = game->mLayers->actionLayer();
|
|
||||||
for(unsigned int i = 0;i < _target->cardsAbilities.size();i++)
|
for(unsigned int i = 0;i < _target->cardsAbilities.size();i++)
|
||||||
{
|
{
|
||||||
MTGAbility * a = dynamic_cast<MTGAbility *>(_target->cardsAbilities[i]);
|
MTGAbility * a = dynamic_cast<MTGAbility *>(_target->cardsAbilities[i]);
|
||||||
@@ -2123,7 +2123,7 @@ int AARemoveMana::resolve()
|
|||||||
}
|
}
|
||||||
else //Remove all mana
|
else //Remove all mana
|
||||||
{
|
{
|
||||||
manaPool->init();
|
manaPool->Empty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else //remove a "standard" mana Description
|
else //remove a "standard" mana Description
|
||||||
|
|||||||
@@ -2854,7 +2854,7 @@ int AbilityFactory::getAbilities(vector<MTGAbility *> * v, Spell * spell, MTGCar
|
|||||||
string cre = "Creature";
|
string cre = "Creature";
|
||||||
card->setType(cre.c_str());
|
card->setType(cre.c_str());
|
||||||
card->basicAbilities.reset();
|
card->basicAbilities.reset();
|
||||||
card->getManaCost()->reinit();
|
card->getManaCost()->resetCosts();
|
||||||
}
|
}
|
||||||
else if(card && !card->morphed && card->turningOver)
|
else if(card && !card->morphed && card->turningOver)
|
||||||
{
|
{
|
||||||
@@ -3315,7 +3315,7 @@ void AbilityFactory::addAbilities(int _id, Spell * spell)
|
|||||||
if (current->hasType(Subtypes::TYPE_LAND))
|
if (current->hasType(Subtypes::TYPE_LAND))
|
||||||
current->tap();
|
current->tap();
|
||||||
}
|
}
|
||||||
player->getManaPool()->init();
|
player->getManaPool()->Empty();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -388,11 +388,14 @@ int ManaCost::hasAnotherCost()
|
|||||||
void ManaCost::init()
|
void ManaCost::init()
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
cost.erase(cost.begin(),cost.end());
|
|
||||||
|
cost.erase(cost.begin() ,cost.end());
|
||||||
|
|
||||||
for (i = 0; i <= Constants::NB_Colors; i++)
|
for (i = 0; i <= Constants::NB_Colors; i++)
|
||||||
{
|
{
|
||||||
cost.push_back(0);
|
cost.push_back(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
extraCosts = NULL;
|
extraCosts = NULL;
|
||||||
kicker = NULL;
|
kicker = NULL;
|
||||||
alternative = NULL;
|
alternative = NULL;
|
||||||
@@ -404,7 +407,7 @@ void ManaCost::init()
|
|||||||
isMulti = false;
|
isMulti = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ManaCost::reinit()
|
void ManaCost::resetCosts()
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@@ -414,6 +417,7 @@ void ManaCost::reinit()
|
|||||||
{
|
{
|
||||||
cost.push_back(0);
|
cost.push_back(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
SAFE_DELETE(extraCosts);
|
SAFE_DELETE(extraCosts);
|
||||||
SAFE_DELETE(kicker);
|
SAFE_DELETE(kicker);
|
||||||
SAFE_DELETE(alternative);
|
SAFE_DELETE(alternative);
|
||||||
@@ -841,9 +845,9 @@ ostream& operator<<(ostream& out, ManaCost m)
|
|||||||
return out << m.toString();
|
return out << m.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ManaPool::init()
|
void ManaPool::Empty()
|
||||||
{
|
{
|
||||||
ManaCost::init();
|
init();
|
||||||
WEvent * e = NEW WEventEmptyManaPool(this);
|
WEvent * e = NEW WEventEmptyManaPool(this);
|
||||||
player->getObserver()->receiveEvent(e);
|
player->getObserver()->receiveEvent(e);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user