Changed the owner of ManaCost in LifeorManaCost to itself
This commit is contained in:
@@ -95,6 +95,7 @@ class LifeorManaCost : public ExtraCost
|
|||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
string manaType;
|
string manaType;
|
||||||
|
ManaCost manaCost;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
LifeorManaCost(TargetChooser *_tc = NULL, string manaType = "");
|
LifeorManaCost(TargetChooser *_tc = NULL, string manaType = "");
|
||||||
|
|||||||
@@ -162,22 +162,23 @@ LifeorManaCost * LifeorManaCost::clone() const
|
|||||||
|
|
||||||
ManaCost * LifeorManaCost::getManaCost()
|
ManaCost * LifeorManaCost::getManaCost()
|
||||||
{
|
{
|
||||||
string buildType ="{";
|
return &manaCost;
|
||||||
buildType.append(manaType);
|
|
||||||
buildType.append("}");
|
|
||||||
return ManaCost::parseManaCost(buildType);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LifeorManaCost::LifeorManaCost(TargetChooser *_tc, string manaType)
|
LifeorManaCost::LifeorManaCost(TargetChooser *_tc, string manaType)
|
||||||
: ExtraCost("Phyrexian Mana", _tc), manaType(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()
|
int LifeorManaCost::canPay()
|
||||||
{
|
{
|
||||||
MTGCardInstance * _target = (MTGCardInstance *) target;
|
MTGCardInstance * _target = (MTGCardInstance *) target;
|
||||||
boost::scoped_ptr<ManaCost> manaCost(getManaCost());
|
if (_target->controller()->getManaPool()->canAfford(getManaCost()) || _target->controller()->life > 1)
|
||||||
if (_target->controller()->getManaPool()->canAfford(manaCost.get()) || _target->controller()->life > 1)
|
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -190,16 +191,14 @@ int LifeorManaCost::doPay()
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
MTGCardInstance * _target = (MTGCardInstance *) target;
|
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
|
else
|
||||||
{
|
{
|
||||||
_target->controller()->loseLife(2);
|
_target->controller()->loseLife(2);
|
||||||
}
|
}
|
||||||
SAFE_DELETE(manaCost);
|
|
||||||
target = NULL;
|
target = NULL;
|
||||||
if (tc)
|
if (tc)
|
||||||
tc->initTargets();
|
tc->initTargets();
|
||||||
|
|||||||
@@ -8,7 +8,6 @@
|
|||||||
#include "WEvent.h"
|
#include "WEvent.h"
|
||||||
#include "MTGAbility.h"
|
#include "MTGAbility.h"
|
||||||
#include "iterator"
|
#include "iterator"
|
||||||
#include <boost/scoped_ptr.hpp>
|
|
||||||
|
|
||||||
SUPPORT_OBJECT_ANALYTICS(ManaCost)
|
SUPPORT_OBJECT_ANALYTICS(ManaCost)
|
||||||
|
|
||||||
@@ -594,8 +593,7 @@ int ManaCost::getManaSymbols(int color)
|
|||||||
LifeorManaCost * phyrexianMana = dynamic_cast<LifeorManaCost*>(extraCosts->costs[i]);
|
LifeorManaCost * phyrexianMana = dynamic_cast<LifeorManaCost*>(extraCosts->costs[i]);
|
||||||
if (phyrexianMana)
|
if (phyrexianMana)
|
||||||
{
|
{
|
||||||
boost::scoped_ptr<ManaCost> manaCost(phyrexianMana->getManaCost());
|
result += phyrexianMana->getManaCost()->getManaSymbols(color);
|
||||||
result += manaCost->getManaSymbols(color);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user