- Fix a memory leak in AI "payTheManaCost"

- Minor fixes in AI code
- Attempt at preventing the AI from interrupting itself while it's selecting targets. I don't know why this happens, and my fix didn't work. I believe it shouldn't be possible to interrupt when there is an active targetChooser, please let me know if this is an incorrect assumption.
This commit is contained in:
wagic.the.homebrew
2011-09-21 03:54:47 +00:00
parent 206f3b4d3f
commit e9ce574bca
5 changed files with 748 additions and 113 deletions

View File

@@ -12,10 +12,10 @@ class AIHints;
class OrderedAIAction: public AIAction
{
protected:
int efficiency;
public:
int efficiency;
OrderedAIAction(MTGAbility * a, MTGCardInstance * c, MTGCardInstance * t = NULL)
: AIAction(a, c, t), efficiency(-1)
@@ -61,29 +61,28 @@ typedef std::map<OrderedAIAction, int, CmpAbilities> RankingContainer;
class AIPlayerBaka: public AIPlayer{
private:
int orderBlockers();
int combatDamages();
int interruptIfICan();
int chooseAttackers();
int chooseBlockers();
int canFirstStrikeKill(MTGCardInstance * card, MTGCardInstance *ennemy);
int effectBadOrGood(MTGCardInstance * card, int mode = MODE_PUTINTOPLAY, TargetChooser * tc = NULL);
virtual int orderBlockers();
virtual int combatDamages();
virtual int interruptIfICan();
virtual int chooseAttackers();
virtual int chooseBlockers();
virtual int canFirstStrikeKill(MTGCardInstance * card, MTGCardInstance *ennemy);
virtual int effectBadOrGood(MTGCardInstance * card, int mode = MODE_PUTINTOPLAY, TargetChooser * tc = NULL);
// returns 1 if the AI algorithm supports a given cost (ex:simple mana cost), 0 otherwise (ex: cost involves Sacrificing a target)
int CanHandleCost(ManaCost * cost);
virtual int CanHandleCost(ManaCost * cost);
//Tries to play an ability recommended by the deck creator
int selectHintAbility();
virtual int selectHintAbility();
vector<MTGAbility*> canPayMana(MTGCardInstance * card = NULL,ManaCost * mCost = NULL);
vector<MTGAbility*> canPaySunBurst(ManaCost * mCost = NULL);
virtual vector<MTGAbility*> canPayMana(MTGCardInstance * card = NULL,ManaCost * mCost = NULL);
virtual vector<MTGAbility*> canPaySunBurst(ManaCost * mCost = NULL);
MTGCardInstance * chooseCard(TargetChooser * tc, MTGCardInstance * source, int random = 0);
int selectMenuOption();
int useAbility();
virtual MTGCardInstance * chooseCard(TargetChooser * tc, MTGCardInstance * source, int random = 0);
virtual int selectMenuOption();
AIStats * getStats();
virtual AIStats * getStats();
protected:
MTGCardInstance * nextCardToPlay;
@@ -91,13 +90,13 @@ private:
AIStats * stats;
int oldGamePhase;
float timer;
MTGCardInstance * FindCardToPlay(ManaCost * potentialMana, const char * type);
virtual MTGCardInstance * FindCardToPlay(ManaCost * potentialMana, const char * type);
//used by MomirPlayer, hence protected instead of private
virtual int getEfficiency(OrderedAIAction * action);
bool payTheManaCost(ManaCost * cost, MTGCardInstance * card = NULL,vector<MTGAbility*> gotPayment = vector<MTGAbility*>());
int getCreaturesInfo(Player * player, int neededInfo = INFO_NBCREATURES , int untapMode = 0, int canAttack = 0);
ManaCost * getPotentialMana(MTGCardInstance * card = NULL);
virtual bool payTheManaCost(ManaCost * cost, MTGCardInstance * card = NULL,vector<MTGAbility*> gotPayment = vector<MTGAbility*>());
virtual int getCreaturesInfo(Player * player, int neededInfo = INFO_NBCREATURES , int untapMode = 0, int canAttack = 0);
virtual ManaCost * getPotentialMana(MTGCardInstance * card = NULL);
int selectAbility();
public:
@@ -118,12 +117,12 @@ private:
virtual void Render();
virtual int receiveEvent(WEvent * event);
virtual ~AIPlayerBaka();
int affectCombatDamages(CombatStep step);
int canHandleCost(MTGAbility * ability);
int chooseTarget(TargetChooser * tc = NULL, Player * forceTarget = NULL,MTGCardInstance * Chosencard = NULL,bool checkonly = false);
virtual int affectCombatDamages(CombatStep step);
virtual int canHandleCost(MTGAbility * ability);
virtual int chooseTarget(TargetChooser * tc = NULL, Player * forceTarget = NULL,MTGCardInstance * Chosencard = NULL,bool checkonly = false);
//used by AIHInts, therefore public instead of private :/
int createAbilityTargets(MTGAbility * a, MTGCardInstance * c, RankingContainer& ranking);
virtual int createAbilityTargets(MTGAbility * a, MTGCardInstance * c, RankingContainer& ranking);
};
#endif