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
+1
View File
@@ -200,6 +200,7 @@ public:
SUSPEND_COST = 29, SUSPEND_COST = 29,
COUNTERS = 30, COUNTERS = 30,
PUT_INTO_PLAY_WITH_KICKER = 31, PUT_INTO_PLAY_WITH_KICKER = 31,
STANDARD_FIZZLER = 32,
}; };
+14 -3
View File
@@ -701,6 +701,17 @@ int AIAction::getEfficiency()
} }
break; 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: default:
if (target) if (target)
{ {
@@ -757,8 +768,8 @@ int AIPlayer::createAbilityTargets(MTGAbility * a, MTGCardInstance * c, RankingC
for (int i = 0; i < 2; i++) for (int i = 0; i < 2; i++)
{ {
Player * p = g->players[i]; Player * p = g->players[i];
MTGGameZone * playerZones[] = { p->game->graveyard, p->game->library, p->game->hand, p->game->inPlay }; MTGGameZone * playerZones[] = { p->game->graveyard, p->game->library, p->game->hand, p->game->inPlay,p->game->stack };
for (int j = 0; j < 4; j++) for (int j = 0; j < 5; j++)
{ {
MTGGameZone * zone = playerZones[j]; MTGGameZone * zone = playerZones[j];
for (int k = 0; k < zone->nb_cards; k++) for (int k = 0; k < zone->nb_cards; k++)
@@ -819,7 +830,7 @@ int AIPlayer::selectAbility()
// Try Deck hints first // Try Deck hints first
if (selectHintAbility()) if (selectHintAbility())
{ {
findingAbility = false;//ok to start looking again. findingAbility = false;//ok to start looking again.
return 1; return 1;
+2
View File
@@ -754,6 +754,8 @@ int ActionStack::count(int type, int state, int display)
int ActionStack::getActionElementFromCard(MTGCardInstance * card) int ActionStack::getActionElementFromCard(MTGCardInstance * card)
{ {
if(!card)
return NULL;
for (int i = 0; i < mCount; i++) for (int i = 0; i < mCount; i++)
{ {
Interruptible * current = (Interruptible *) mObjects[i]; Interruptible * current = (Interruptible *) mObjects[i];
+19 -15
View File
@@ -493,26 +493,30 @@ AAResetDamage * AAResetDamage::clone() const
AAFizzler::AAFizzler(int _id, MTGCardInstance * card, Spell * _target, ManaCost * _cost) : AAFizzler::AAFizzler(int _id, MTGCardInstance * card, Spell * _target, ManaCost * _cost) :
ActivatedAbility(_id, card, _cost, 0) ActivatedAbility(_id, card, _cost, 0)
{ {
aType = MTGAbility::STANDARD_FIZZLER;
target = _target; target = _target;
} }
int AAFizzler::resolve() int AAFizzler::resolve()
{ {
Spell * _target = (Spell *) target; ActionStack * stack = game->mLayers->stackLayer();
if(!target && !_target) //the next section helps Ai correctly recieve its targets for this effect
{ if(!target)
//if we hit this condiational its because Ai was targetting. {
Interruptible * targetCard = game->mLayers->stackLayer()->getAt(game->mLayers->stackLayer()->getActionElementFromCard(source->target)); //ai is casting a spell from it's hand to fizzle.
if (source->target && source->target->has(Constants::NOFIZZLE)) target = stack->getAt(stack->getActionElementFromCard(source->target));
return 0; }
_target = (Spell *) targetCard; else if(target->typeAsTarget() == TARGET_CARD)
game->mLayers->stackLayer()->Fizzle(_target); {
return 1; //ai targeted using an ability on a card to fizzle.
} target = stack->getAt(stack->getActionElementFromCard((MTGCardInstance*)target));
if (target && _target->source->has(Constants::NOFIZZLE)) }
return 0; Spell * sTarget = (Spell *) target;
game->mLayers->stackLayer()->Fizzle(_target); MTGCardInstance* sCard = (MTGCardInstance*)sTarget->source;
return 1; if(!sCard || !sTarget || sCard->has(Constants::NOFIZZLE))
return 0;
game->mLayers->stackLayer()->Fizzle(sTarget);
return 1;
} }
const char * AAFizzler::getMenuText() const char * AAFizzler::getMenuText()