From 18ff503bd93a2301e1ba4ce54cd2e98f217e66e3 Mon Sep 17 00:00:00 2001 From: "omegablast2002@yahoo.com" Date: Thu, 21 Oct 2010 15:52:04 +0000 Subject: [PATCH] fixed Ai not using regenerate during combat, taught Ai a little about prevent:number, changed "removepoison" mtgability to "alterpoison" as it made more sense. --- projects/mtg/include/AllAbilities.h | 15 ++++++++------- projects/mtg/include/MTGAbility.h | 3 ++- projects/mtg/src/AIPlayer.cpp | 20 ++++++++++++++++++-- projects/mtg/src/AIStats.cpp | 4 ++-- projects/mtg/src/MTGAbility.cpp | 5 ++--- 5 files changed, 32 insertions(+), 15 deletions(-) diff --git a/projects/mtg/include/AllAbilities.h b/projects/mtg/include/AllAbilities.h index 892da7efe..3973fb2ee 100644 --- a/projects/mtg/include/AllAbilities.h +++ b/projects/mtg/include/AllAbilities.h @@ -2784,6 +2784,7 @@ class AADamagePrevent:public ActivatedAbilityTP{ public: int preventing; AADamagePrevent(int _id, MTGCardInstance * _source, Targetable * _target,int preventing, ManaCost * _cost=NULL, int doTap = 0, int who = TargetChooser::UNSET):ActivatedAbilityTP(_id,_source,_target,_cost,doTap,who),preventing(preventing){ + aType = MTGAbility::STANDARD_PREVENT; } int resolve(){ @@ -2810,31 +2811,31 @@ public: }; //poison removel -class AARemovePoison:public ActivatedAbilityTP{ +class AAAlterPoison:public ActivatedAbilityTP{ public: int poison; - AARemovePoison(int _id, MTGCardInstance * _source, Targetable * _target,int poison, ManaCost * _cost=NULL, int doTap = 0, int who = TargetChooser::UNSET):ActivatedAbilityTP(_id,_source,_target,_cost,doTap,who),poison(poison){ + AAAlterPoison(int _id, MTGCardInstance * _source, Targetable * _target,int poison, ManaCost * _cost=NULL, int doTap = 0, int who = TargetChooser::UNSET):ActivatedAbilityTP(_id,_source,_target,_cost,doTap,who),poison(poison){ } int resolve(){ Damageable * _target = (Damageable *) getTarget(); if(_target){ - _target->poisonCount -= poison; + _target->poisonCount += poison; } return 0; } const char * getMenuText(){ - return "Remove Poison"; + return "Poison"; } - AARemovePoison * clone() const{ - AARemovePoison * a = NEW AARemovePoison(*this); + AAAlterPoison * clone() const{ + AAAlterPoison * a = NEW AAAlterPoison(*this); a->isClone = 1; return a; } - ~AARemovePoison(){ + ~AAAlterPoison(){ } diff --git a/projects/mtg/include/MTGAbility.h b/projects/mtg/include/MTGAbility.h index 473e8dcd9..0b50f4430 100644 --- a/projects/mtg/include/MTGAbility.h +++ b/projects/mtg/include/MTGAbility.h @@ -89,7 +89,8 @@ class MTGAbility: public ActionElement{ BUYBACK_COST = 9, FLASHBACK_COST = 10, RETRACE_COST = 11, - MTG_COMBATTRIGGERS_RULE = 13, + MTG_COMBATTRIGGERS_RULE = 12, + STANDARD_PREVENT = 13, }; diff --git a/projects/mtg/src/AIPlayer.cpp b/projects/mtg/src/AIPlayer.cpp index 814d8a04a..cc741b993 100644 --- a/projects/mtg/src/AIPlayer.cpp +++ b/projects/mtg/src/AIPlayer.cpp @@ -189,9 +189,24 @@ int AIAction::getEfficiency(){ { MTGCardInstance * _target = (MTGCardInstance *)(a->target); efficiency = 0; - if (!_target->regenerateTokens && g->getCurrentGamePhase()< Constants::MTG_PHASE_COMBATDAMAGE && (_target->defenser || _target->blockers.size())){ + if (!_target->regenerateTokens && g->getCurrentGamePhase() == Constants::MTG_PHASE_COMBATBLOCKERS && (_target->defenser || _target->blockers.size())){ efficiency = 95; } + + //TODO If the card is the target of a damage spell + break; + } + case MTGAbility::STANDARD_PREVENT: + { + MTGCardInstance * _target = (MTGCardInstance *)(a->target); + efficiency = 10;//starts out low to avoid spamming it when its not needed. + if (!_target->regenerateTokens && g->getCurrentGamePhase() == Constants::MTG_PHASE_COMBATBLOCKERS && (_target->defenser || _target->blockers.size()) && _target->preventable < 2 || (_target->canBlock()||_target->canAttack()) && _target->preventable < 2){ + efficiency = 95;//increase this chance to be used in combat. + } + if (_target->preventable > 2){ + efficiency -= 10; //lower the chance to be used if the creature already has over 3 prevent points. + } + //basically a rip off of regen, if it is not regenerating, its combat blockers, it is being blocked or blocking, and has less then 3 prevents, the effeincy is increased. //TODO If the card is the target of a damage spell break; } @@ -454,6 +469,7 @@ int AIPlayer::canFirstStrikeKill(MTGCardInstance * card, MTGCardInstance *ennemy if (ennemy->has(Constants::FIRSTSTRIKE) || ennemy->has(Constants::DOUBLESTRIKE)) return 0; if (!(card->has(Constants::FIRSTSTRIKE) || card->has(Constants::DOUBLESTRIKE))) return 0; if (!(card->power >= ennemy->toughness)) return 0; + if (!(card->power >= ennemy->toughness + 1) && ennemy->has(Constants::FLANKING)) return 0; return 1; } @@ -514,7 +530,7 @@ int AIPlayer::chooseBlockers(){ MTGCardInstance * attacker = card->defenser; if (opponentsToughness[attacker] <= 0 || (card->toughness <= attacker->power && opponentForce*2 nbOpponents()>1){ + attacker->nbOpponents()>1){ g->mLayers->actionLayer()->reactToClick(a,card); }else{ set = 1; diff --git a/projects/mtg/src/AIStats.cpp b/projects/mtg/src/AIStats.cpp index 951c26205..91d720216 100644 --- a/projects/mtg/src/AIStats.cpp +++ b/projects/mtg/src/AIStats.cpp @@ -5,7 +5,7 @@ #include "../include/MTGCardInstance.h" #include "../include/WEvent.h" #include "../include/AllAbilities.h" - +//TODO:better comments this is too cryptic to work on by anyone but original coder. bool compare_aistats(AIStat * first, AIStat * second){ float damage1 = first->value / first->occurences; float damage2 = second->value/ second->occurences; @@ -81,7 +81,7 @@ int AIStats::receiveEvent(WEvent * event){ stats.sort(compare_aistats); //this could be slow, if it is, let's run it only at the end of the turn return 1; //is this meant to return 0 or 1? } - +//TODO:what does this do? bool AIStats::isInTop(MTGCardInstance * card, unsigned int max, bool tooSmallCountsForTrue ){ if (stats.size()getNextPlayerTarget(); - MTGAbility * a = NEW AARemovePoison (id, card, t,poison,NULL,0,who); + MTGAbility * a = NEW AAAlterPoison (id, card, t,poison,NULL,0,who); a->oneShot = 1; return a; } @@ -1658,7 +1658,6 @@ int AbilityFactory::abilityEfficiency(MTGAbility * a, Player * p, int mode, Targ if (dynamic_cast(a)) return BAKA_EFFECT_GOOD; if (dynamic_cast(a)) return BAKA_EFFECT_BAD; if (dynamic_cast(a)) return BAKA_EFFECT_GOOD; - if (dynamic_cast(a)) return BAKA_EFFECT_BAD; if (AALifer * abi = dynamic_cast(a)) return abi->life > 0 ? BAKA_EFFECT_GOOD : BAKA_EFFECT_BAD; if (dynamic_cast(a)) return BAKA_EFFECT_BAD; if (dynamic_cast(a)) return BAKA_EFFECT_GOOD;