taught ai how to use ability fizzlers such as Glen Elendra Archmage...reworked fizzle to cover both cases of ai trying to target a card on the stack.

This commit is contained in:
omegablast2002@yahoo.com
2011-05-17 13:58:28 +00:00
parent 9b63553c3e
commit 4793ba76bb
4 changed files with 36 additions and 18 deletions

View File

@@ -200,6 +200,7 @@ public:
SUSPEND_COST = 29,
COUNTERS = 30,
PUT_INTO_PLAY_WITH_KICKER = 31,
STANDARD_FIZZLER = 32,
};

View File

@@ -701,6 +701,17 @@ int AIAction::getEfficiency()
}
break;
}
case MTGAbility::STANDARD_FIZZLER:
{
Interruptible * action = g->mLayers->stackLayer()->getAt(-1);
Spell * spell = (Spell *) action;
Player * lastStackActionController = NULL;
if(spell && spell->type == ACTION_SPELL)
lastStackActionController = spell->source->controller();
if(p != target->controller() && lastStackActionController && lastStackActionController != p)
efficiency = 60;//we want ai to fizzle at higher than "unknown" ability %.
break;
}
default:
if (target)
{
@@ -757,8 +768,8 @@ int AIPlayer::createAbilityTargets(MTGAbility * a, MTGCardInstance * c, RankingC
for (int i = 0; i < 2; i++)
{
Player * p = g->players[i];
MTGGameZone * playerZones[] = { p->game->graveyard, p->game->library, p->game->hand, p->game->inPlay };
for (int j = 0; j < 4; j++)
MTGGameZone * playerZones[] = { p->game->graveyard, p->game->library, p->game->hand, p->game->inPlay,p->game->stack };
for (int j = 0; j < 5; j++)
{
MTGGameZone * zone = playerZones[j];
for (int k = 0; k < zone->nb_cards; k++)
@@ -819,7 +830,7 @@ int AIPlayer::selectAbility()
// Try Deck hints first
if (selectHintAbility())
if (selectHintAbility())
{
findingAbility = false;//ok to start looking again.
return 1;

View File

@@ -754,6 +754,8 @@ int ActionStack::count(int type, int state, int display)
int ActionStack::getActionElementFromCard(MTGCardInstance * card)
{
if(!card)
return NULL;
for (int i = 0; i < mCount; i++)
{
Interruptible * current = (Interruptible *) mObjects[i];

View File

@@ -493,26 +493,30 @@ AAResetDamage * AAResetDamage::clone() const
AAFizzler::AAFizzler(int _id, MTGCardInstance * card, Spell * _target, ManaCost * _cost) :
ActivatedAbility(_id, card, _cost, 0)
{
aType = MTGAbility::STANDARD_FIZZLER;
target = _target;
}
int AAFizzler::resolve()
{
Spell * _target = (Spell *) target;
if(!target && !_target)
{
//if we hit this condiational its because Ai was targetting.
Interruptible * targetCard = game->mLayers->stackLayer()->getAt(game->mLayers->stackLayer()->getActionElementFromCard(source->target));
if (source->target && source->target->has(Constants::NOFIZZLE))
return 0;
_target = (Spell *) targetCard;
game->mLayers->stackLayer()->Fizzle(_target);
return 1;
}
if (target && _target->source->has(Constants::NOFIZZLE))
return 0;
game->mLayers->stackLayer()->Fizzle(_target);
return 1;
ActionStack * stack = game->mLayers->stackLayer();
//the next section helps Ai correctly recieve its targets for this effect
if(!target)
{
//ai is casting a spell from it's hand to fizzle.
target = stack->getAt(stack->getActionElementFromCard(source->target));
}
else if(target->typeAsTarget() == TARGET_CARD)
{
//ai targeted using an ability on a card to fizzle.
target = stack->getAt(stack->getActionElementFromCard((MTGCardInstance*)target));
}
Spell * sTarget = (Spell *) target;
MTGCardInstance* sCard = (MTGCardInstance*)sTarget->source;
if(!sCard || !sTarget || sCard->has(Constants::NOFIZZLE))
return 0;
game->mLayers->stackLayer()->Fizzle(sTarget);
return 1;
}
const char * AAFizzler::getMenuText()