Changed the owner of ManaCost in LifeorManaCost to itself

This commit is contained in:
pankdm
2013-10-18 06:37:31 +00:00
parent f7eded7417
commit 5c3eb2c405
3 changed files with 11 additions and 13 deletions

View File

@@ -95,6 +95,7 @@ class LifeorManaCost : public ExtraCost
{
private:
string manaType;
ManaCost manaCost;
public:
LifeorManaCost(TargetChooser *_tc = NULL, string manaType = "");

View File

@@ -162,22 +162,23 @@ LifeorManaCost * LifeorManaCost::clone() const
ManaCost * LifeorManaCost::getManaCost()
{
string buildType ="{";
buildType.append(manaType);
buildType.append("}");
return ManaCost::parseManaCost(buildType);
return &manaCost;
}
LifeorManaCost::LifeorManaCost(TargetChooser *_tc, string manaType)
: ExtraCost("Phyrexian Mana", _tc), manaType(manaType)
{
string buildType ="{";
buildType.append(manaType);
buildType.append("}");
boost::scoped_ptr<ManaCost> cost(ManaCost::parseManaCost(buildType));
manaCost.copy(cost.get());
}
int LifeorManaCost::canPay()
{
MTGCardInstance * _target = (MTGCardInstance *) target;
boost::scoped_ptr<ManaCost> manaCost(getManaCost());
if (_target->controller()->getManaPool()->canAfford(manaCost.get()) || _target->controller()->life > 1)
if (_target->controller()->getManaPool()->canAfford(getManaCost()) || _target->controller()->life > 1)
{
return 1;
}
@@ -190,16 +191,14 @@ int LifeorManaCost::doPay()
return 0;
MTGCardInstance * _target = (MTGCardInstance *) target;
ManaCost * manaCost = getManaCost();
if (_target->controller()->getManaPool()->canAfford(manaCost))
if (_target->controller()->getManaPool()->canAfford(&manaCost))
{
_target->controller()->getManaPool()->pay(manaCost);
_target->controller()->getManaPool()->pay(&manaCost);
}
else
{
_target->controller()->loseLife(2);
}
SAFE_DELETE(manaCost);
target = NULL;
if (tc)
tc->initTargets();

View File

@@ -8,7 +8,6 @@
#include "WEvent.h"
#include "MTGAbility.h"
#include "iterator"
#include <boost/scoped_ptr.hpp>
SUPPORT_OBJECT_ANALYTICS(ManaCost)
@@ -594,8 +593,7 @@ int ManaCost::getManaSymbols(int color)
LifeorManaCost * phyrexianMana = dynamic_cast<LifeorManaCost*>(extraCosts->costs[i]);
if (phyrexianMana)
{
boost::scoped_ptr<ManaCost> manaCost(phyrexianMana->getManaCost());
result += manaCost->getManaSymbols(color);
result += phyrexianMana->getManaCost()->getManaSymbols(color);
}
}
}