Phase out Event & Trigger
This commit is contained in:
@@ -1332,6 +1332,28 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
class TrCardPhasesOut: public Trigger
|
||||
{
|
||||
public:
|
||||
TrCardPhasesOut(GameObserver* observer, int id, MTGCardInstance * source, TargetChooser * tc, bool once = false) :
|
||||
Trigger(observer, id, source, once, tc)
|
||||
{
|
||||
}
|
||||
|
||||
int triggerOnEventImpl(WEvent * event)
|
||||
{
|
||||
WEventCardPhasesOut * e = dynamic_cast<WEventCardPhasesOut *> (event);
|
||||
if (!e) return 0;
|
||||
if (!tc->canTarget(e->card)) return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
TrCardPhasesOut * clone() const
|
||||
{
|
||||
return NEW TrCardPhasesOut(*this);
|
||||
}
|
||||
};
|
||||
|
||||
class TrCardPhasesIn: public Trigger
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -305,7 +305,13 @@ struct WEventCardControllerChange : public WEventCardUpdate {
|
||||
virtual Targetable * getTarget(int target);
|
||||
};
|
||||
|
||||
//event when card with phases in
|
||||
//event when card phases out
|
||||
struct WEventCardPhasesOut : public WEventCardUpdate {
|
||||
WEventCardPhasesOut(MTGCardInstance * card);
|
||||
virtual Targetable * getTarget(int target);
|
||||
};
|
||||
|
||||
//event when card phases in
|
||||
struct WEventCardPhasesIn : public WEventCardUpdate {
|
||||
WEventCardPhasesIn(MTGCardInstance * card);
|
||||
virtual Targetable * getTarget(int target);
|
||||
|
||||
@@ -1708,6 +1708,9 @@ int AAPhaseOut::resolve()
|
||||
if(_target->view)
|
||||
_target->view->alpha = 50;
|
||||
_target->initAttackersDefensers();
|
||||
//add event phases out here
|
||||
WEvent * e = NEW WEventCardPhasesOut(_target);
|
||||
game->receiveEvent(e);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
|
||||
@@ -852,6 +852,9 @@ void GameObserver::gameStateBasedEffects()
|
||||
if(card->view)
|
||||
card->view->alpha = 50;
|
||||
card->initAttackersDefensers();
|
||||
//add event phases out here
|
||||
WEvent * evphaseout = NEW WEventCardPhasesOut(card);
|
||||
receiveEvent(evphaseout);
|
||||
}
|
||||
else if((card->has(Constants::PHASING) || card->isPhased)&& mCurrentGamePhase == MTG_PHASE_UNTAP && currentPlayer == card->controller() && card->phasedTurn != turn)
|
||||
{
|
||||
|
||||
@@ -1044,6 +1044,10 @@ TriggeredAbility * AbilityFactory::parseTrigger(string s, string, int id, Spell
|
||||
if (TargetChooser *tc = parseSimpleTC(s,"phasedin", card))
|
||||
return NEW TrCardPhasesIn(observer, id, card, tc,once);
|
||||
|
||||
//Card Phases Out
|
||||
if (TargetChooser *tc = parseSimpleTC(s,"phasedout", card))
|
||||
return NEW TrCardPhasesOut(observer, id, card, tc,once);
|
||||
|
||||
//CombatTrigger
|
||||
//Card card attacked and is blocked
|
||||
found = s.find("combat(");
|
||||
|
||||
@@ -236,6 +236,11 @@ WEventCardControllerChange::WEventCardControllerChange(MTGCardInstance * card) :
|
||||
{
|
||||
}
|
||||
|
||||
WEventCardPhasesOut::WEventCardPhasesOut(MTGCardInstance * card) :
|
||||
WEventCardUpdate(card)
|
||||
{
|
||||
}
|
||||
|
||||
WEventCardPhasesIn::WEventCardPhasesIn(MTGCardInstance * card) :
|
||||
WEventCardUpdate(card)
|
||||
{
|
||||
@@ -427,6 +432,12 @@ Targetable * WEventCardControllerChange::getTarget(int target)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Targetable * WEventCardPhasesOut::getTarget(int target)
|
||||
{
|
||||
if (target) return card;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Targetable * WEventCardPhasesIn::getTarget(int target)
|
||||
{
|
||||
if (target) return card;
|
||||
|
||||
Reference in New Issue
Block a user