this was accidental, i was just about to toy with a may pay( ability.
This commit is contained in:
@@ -1077,33 +1077,6 @@ public:
|
||||
~IfThenAbility();
|
||||
};
|
||||
|
||||
//MayPayAbility: May do ...
|
||||
class MayPayAbility: public MTGAbility, public NestedAbility
|
||||
{
|
||||
public:
|
||||
int triggered;
|
||||
bool must;
|
||||
string Cond;
|
||||
Player * previousInterrupter;
|
||||
MTGAbility * mClone;
|
||||
ManaCost * optionalCost;
|
||||
|
||||
MayPayAbility(GameObserver* observer, int _id, MTGAbility * _ability, MTGCardInstance * _source, bool must = false, string restriction = "");
|
||||
|
||||
void Update(float dt);
|
||||
|
||||
const char * getMenuText();
|
||||
int testDestroy();
|
||||
|
||||
int isReactingToTargetClick(Targetable * card);
|
||||
|
||||
int reactToTargetClick(Targetable * object);
|
||||
|
||||
MayPayAbility * clone() const;
|
||||
~MayPayAbility();
|
||||
|
||||
};
|
||||
|
||||
//MayAbility: May do ...
|
||||
class MayAbility: public MTGAbility, public NestedAbility
|
||||
{
|
||||
|
||||
@@ -3095,101 +3095,6 @@ IfThenAbility::~IfThenAbility()
|
||||
SAFE_DELETE(delayedElseAbility);
|
||||
}
|
||||
//
|
||||
//May Abilities
|
||||
MayPayAbility::MayPayAbility(GameObserver* observer, int _id, MTGAbility * _ability, MTGCardInstance * _source, bool must,string _cond) :
|
||||
MTGAbility(observer, _id, _source), NestedAbility(_ability), must(must), Cond(_cond)
|
||||
{
|
||||
triggered = 0;
|
||||
mClone = NULL;
|
||||
optionalCost = NULL;
|
||||
}
|
||||
|
||||
void MayPayAbility::Update(float dt)
|
||||
{
|
||||
MTGAbility::Update(dt);
|
||||
if (!triggered && !game->getCurrentTargetChooser() && (!game->mLayers->actionLayer()->menuObject||game->mLayers->actionLayer()->menuObject == source))
|
||||
{
|
||||
triggered = 1;
|
||||
if(optionalCost && !source->controller()->getManaPool()->canAfford(optionalCost))
|
||||
return;
|
||||
if(Cond.size())
|
||||
{
|
||||
AbilityFactory af(game);
|
||||
int checkCond = af.parseCastRestrictions(source,source->controller(),Cond);
|
||||
if(!checkCond)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (TargetAbility * ta = dynamic_cast<TargetAbility *>(ability))
|
||||
{
|
||||
if (!ta->getActionTc()->validTargetsExist())
|
||||
return;
|
||||
}
|
||||
game->mLayers->actionLayer()->setMenuObject(source, must);
|
||||
previousInterrupter = game->isInterrupting;
|
||||
game->mLayers->stackLayer()->setIsInterrupting(source->controller(), false);
|
||||
}
|
||||
}
|
||||
|
||||
const char * MayPayAbility::getMenuText()
|
||||
{
|
||||
return ability->getMenuText();
|
||||
}
|
||||
|
||||
int MayPayAbility::testDestroy()
|
||||
{
|
||||
if (!triggered)
|
||||
return 0;
|
||||
if (game->mLayers->actionLayer()->menuObject)
|
||||
return 0;
|
||||
if (game->mLayers->actionLayer()->getIndexOf(mClone) != -1)
|
||||
return 0;
|
||||
if(game->currentPlayer == source->controller() && game->isInterrupting == source->controller() && dynamic_cast<AManaProducer*>(AbilityFactory::getCoreAbility(ability)))
|
||||
//if its my turn, and im interrupting myself(why?) then set interrupting to previous interrupter if the ability was a manaability
|
||||
//special case since they don't use the stack.
|
||||
game->mLayers->stackLayer()->setIsInterrupting(previousInterrupter, false);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int MayPayAbility::isReactingToTargetClick(Targetable * card)
|
||||
{
|
||||
if (card == source)
|
||||
{
|
||||
if(!optionalCost || source->controller()->getManaPool()->canAfford(optionalCost))
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int MayPayAbility::reactToTargetClick(Targetable * object)
|
||||
{
|
||||
mClone = ability->clone();
|
||||
if(optionalCost)
|
||||
{
|
||||
source->controller()->getManaPool()->pay(optionalCost);
|
||||
optionalCost->setExtraCostsAction(this, source);
|
||||
optionalCost->doPayExtra();
|
||||
}
|
||||
mClone->addToGame();
|
||||
mClone->forceDestroy = 1;
|
||||
return mClone->reactToTargetClick(object);
|
||||
}
|
||||
|
||||
MayPayAbility * MayPayAbility::clone() const
|
||||
{
|
||||
MayPayAbility * a = NEW MayPayAbility(*this);
|
||||
a->ability = ability->clone();
|
||||
a->optionalCost = this->optionalCost;
|
||||
return a;
|
||||
}
|
||||
|
||||
MayPayAbility::~MayPayAbility()
|
||||
{
|
||||
SAFE_DELETE(ability);
|
||||
SAFE_DELETE(optionalCost);
|
||||
}
|
||||
|
||||
//May Abilities
|
||||
MayAbility::MayAbility(GameObserver* observer, int _id, MTGAbility * _ability, MTGCardInstance * _source, bool must,string _cond) :
|
||||
MTGAbility(observer, _id, _source), NestedAbility(_ability), must(must), Cond(_cond)
|
||||
|
||||
Reference in New Issue
Block a user