Draft of the "fizzle to zone"

(credit goes to excessum)
This commit is contained in:
pankdm
2013-10-08 23:17:43 +00:00
parent da7c336dc2
commit 17fdedb648
6 changed files with 131 additions and 0 deletions
+28
View File
@@ -1165,6 +1165,34 @@ void ActionStack::Fizzle(Interruptible * action)
action->state = RESOLVED_NOK;
}
void ActionStack::Fizzle(Interruptible * action,int targetZone)
{
if (!action)
{
DebugTrace("ACTIONSTACK ==ERROR==: action is NULL in ActionStack::Fizzle");
return;
}
if (action->type == ACTION_SPELL)
{
Spell * spell = (Spell *) action;
switch ( targetZone ) {
case 0:
spell->source->controller()->game->putInGraveyard(spell->source);
break;
case 1:
spell->source->controller()->game->putInHand(spell->source);
break;
case 2:
spell->source->controller()->game->putInExile(spell->source);
break;
case 3:
spell->source->controller()->game->putInLibrary(spell->source);
break;
}
}
action->state = RESOLVED_NOK;
}
void ActionStack::Render()
{
//This is a hack to avoid rendering the stack above the tuto messages
+36
View File
@@ -1349,6 +1349,42 @@ AAFizzler* AAFizzler::clone() const
{
return NEW AAFizzler(*this);
}
AAOFizzler::AAOFizzler( GameObserver* observer, int _id, MTGCardInstance * card, Spell * _target, int tgtZone, ManaCost * _cost ) :
AAFizzler( observer, _id, card, _target, _cost )
{
targetZone = tgtZone;
}
int AAOFizzler::resolve()
{
ActionStack * stack = game->mLayers->stackLayer();
//the next section helps Ai correctly recieve its targets for this effect
if(!target && source->target)
{
//ai is casting a spell from its hand to fizzle.
target = stack->getActionElementFromCard(source->target);
}
else if(MTGCardInstance * cTarget = dynamic_cast<MTGCardInstance *>(target))
{
//ai targeted using an ability on a card to fizzle.
target = stack->getActionElementFromCard(cTarget);
}
Spell * sTarget = (Spell *) target;
MTGCardInstance* sCard = NULL;
if(sTarget)
sCard = sTarget->source;
if(!sCard || !sTarget || sCard->has(Constants::NOFIZZLE))
return 0;
stack->Fizzle(sTarget, targetZone);
return 1;
}
AAOFizzler* AAOFizzler::clone() const
{
return NEW AAOFizzler(*this);
}
// BanishCard implementations
// Bury
+32
View File
@@ -2026,6 +2026,38 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
a->oneShot = 1;
return a;
}
found = s.find("fizhand");
if (found != string::npos)
{
Spell * starget = NULL;
if (spell)
starget = spell->getNextSpellTarget();
MTGAbility * a = NEW AAOFizzler( observer, id, card, starget, 1, NULL );
a->oneShot = 1;
return a;
}
//Fizzle to exile
found = s.find("fizexile");
if (found != string::npos)
{
Spell * starget = NULL;
if (spell)
starget = spell->getNextSpellTarget();
MTGAbility * a = NEW AAOFizzler( observer, id, card, starget, 2, NULL );
a->oneShot = 1;
return a;
}
//Fizzle to top of library
found = s.find("fizlibrary");
if (found != string::npos)
{
Spell * starget = NULL;
if (spell)
starget = spell->getNextSpellTarget();
MTGAbility * a = NEW AAOFizzler( observer, id, card, starget, 3, NULL );
a->oneShot = 1;
return a;
}
//Describes a player target in many abilities
int who = TargetChooser::UNSET;